AdrienWehrle / diuca

GNU Lesser General Public License v2.1
0 stars 1 forks source link

Segmentation fault on `icestream` FV with `FVSedimentMaterialSI` #27

Closed AdrienWehrle closed 6 months ago

AdrienWehrle commented 6 months ago

Every time I've been using FVSedimentMaterialSI (variable viscosity) e.g. in https://github.com/AdrienWehrle/diuca/blob/PR_sedimentbase/problems/icestream_fv_3d_SI_ru_sediment.i I've been getting a segmentation fault that I find very hard to debug. I thought it could come from the viscosity evaluated at time t-1 but getting rid of it doesn't fix the segmentation fault.

Framework Information:
MOOSE Version:           git commit 778cc52c3e on 2024-03-02
LibMesh Version:         
PETSc Version:           3.20.3
SLEPc Version:           3.20.1
Current Time:            Fri Mar 22 18:35:02 2024
Executable Timestamp:    Fri Mar 22 18:16:20 2024

Parallelism:
  Num Processors:          1
  Num Threads:             15

Mesh: 
  Parallel Type:           replicated
  Mesh Dimension:          3
  Spatial Dimension:       3
  Nodes:                   2618
  Elems:                   2016
  Num Subdomains:          3

Nonlinear System:
  Num DOFs:                8064
  Num Local DOFs:          8064
  Variables:               { "vel_x" "vel_y" "vel_z" "pressure" } 
  Finite Element Types:    "MONOMIAL" 
  Approximation Orders:    "CONSTANT" 

Execution Information:
  Executioner:             Transient
  TimeStepper:             ConstantDT
  TimeIntegrator:          ImplicitEuler
  Solver Mode:             Preconditioned JFNK
  PETSc Preconditioner:    lu 

Time Step 0, time = 0

Time Step 1, time = 2.3652e+06, dt = 2.3652e+06
Segmentation fault (core dumped)

any idea @GiudGiud?

AdrienWehrle commented 6 months ago

It looks like it's actually coming from the declaration of the viscosity, that I need to call to evaluate it at timestep t-1.

AdrienWehrle commented 6 months ago

I thought it might be because I'm trying to access an object that doesn't exist yet, so I added:

ADReal eta = 0;

// Get viscosity
if (_dt <= 1)
  {
    ADReal eta = 1e10;
  }
else
  {
     Moose::StateArg previous_time(1, Moose::SolutionIterationType::Time);
     ADReal eta = _viscosity(r, previous_time);
  }

but the segmentation fault persists.

GiudGiud commented 6 months ago

seg faults are a good problem to have they are easy to find with a debugger use this https://mooseframework.inl.gov/application_development/debugging.html

AdrienWehrle commented 6 months ago

Yes so it's definitely linked to the state at t = 0:

Assertion `state.state == 0' failed
getDirichletBoundaryFaceValue currently only supports evaluating at the current time/iteration state
at /home/adrien/UZH/projects/moose/framework/src/variables/MooseVariableFV.C, line 526
GiudGiud commented 6 months ago

yeah you wont be able to do that then. You d have to take great care to prevent the boundary temperature from being evaluated at the previous iteration if you want to still use the previous iteration in the rest of the domain

AdrienWehrle commented 6 months ago

I see. I'm accessing the viscosity at time t-1 to compute the strain rates, e.g.:

ADReal sxx = 2 * eta * u_x + sig_m;

to be able to compute the new viscosity as the viscosity depends on the second invariant of the strain rate tensor. Instead of this, do you think I could compute the strain rate out of this object with an action, and call those variables? Most of the objects I see I could use are from the tensor mechanics module and I don't think that would work with FV...

GiudGiud commented 6 months ago

Can you compute it with current data instead of lagged-by-an-iteration data?

AdrienWehrle commented 6 months ago

Yes so it's definitely linked to the state at t = 0:

Assertion `state.state == 0' failed
getDirichletBoundaryFaceValue currently only supports evaluating at the current time/iteration state
at /home/adrien/UZH/projects/moose/framework/src/variables/MooseVariableFV.C, line 526

It looks like that wasn't the origin of the segmentation fault.

If I use the current data, such as:

// Get viscosity
    if (_dt <= 1)
      {
        ADReal eta = 1e10;
      }
    else
      {
        ADReal eta = _viscosity(r, t);
      }

then the state error I got above indeed disappears but the segmentation fault persists, and I don't get much more even in debug mode. I'll dig into it.

But if replace _viscosity(r, t) for a constant, then I don't get a segmentation fault anymore, so it definitely comes from this.

Everything's ok when I evaluate other variables like _pressure(r, t). It's really because I'm calling the very variable that is being computed in the property.

AdrienWehrle commented 6 months ago

I feel like I'm doing circular reasoning here. It feels like I should add mu_sediment as a coupledvar, but then I'm being asked to feed it into the Sediment object although it comes from it...

GiudGiud commented 6 months ago

Do you use mu_sediment to compute mu_sediment? this would fail for sure

AdrienWehrle commented 6 months ago

Apologies, this segmentation fault is not a problem anymore since I had a mistake in my implementation of Drucker-Prager for the sediments. I was computing the second invariant of the stress tensor instead of the strain rate tensor, I hence don't need to evaluate the current viscosity in there anymore.