idaholab / moose

Multiphysics Object Oriented Simulation Environment
https://www.mooseframework.org
GNU Lesser General Public License v2.1
1.78k stars 1.05k forks source link

Fix combined EBSD mechanics example #8320

Open permcody opened 7 years ago

permcody commented 7 years ago

Description of the enhancement or error report

File is out of date (this isn't actually correct but it's close): ~/project/moose/modules/combined/examples/EBSD_reconstruction_grain_growth_mech.i

Rationale for the enhancement or information for reproducing the error

Needs update and probably a check-syntax test

Identified impact

(i.e. Internal object changes, limited interface changes, public API change, or a list of specific applications impacted)

dschwen commented 7 years ago

I'm working on fixing this example. However i noticed that the test segfaults in GrainTracker.C (during remapping in swapSolutionValuesHelper on line 1346 _nl.solution().set(dof_index, 0.0);) if you put displacements = 'disp_x disp_y' into the [Mesh] block (or the [GlobalParams] block, which is how I found out).

permcody commented 7 years ago

I just looked at this and the problem is this line of code no longer works: https://github.com/idaholab/moose/blob/devel/modules/phase_field/src/postprocessors/GrainTracker.C#L57

I think this happened during a big refactor that @fdkong did. It's not easy to get ahold of the NonlinearSystem now from a subproblem reference. I'm not sure what the best solution is here, Shall we add a new method to subproblem to return the nonlinear system? Otherwise, I have to dynamic cast down to one of the children (I don't know which cast will succeed) before attempting to retrieve the NonlinearSystem. It seems like we can do better.

fdkong commented 7 years ago

I just looked at this and the problem is this line of code no longer works: https://github.com/idaholab/moose/blob/devel/modules/phase_field/src/postprocessors/GrainTracker.C#L57

I think this happened during a big refactor that @fdkong did. It's not easy to get ahold of the NonlinearSystem now from a subproblem reference. I'm not sure what the best solution is here, Shall we add a new method to subproblem to return the nonlinear system? Otherwise, I have to dynamic cast down to one of the children (I don't know which cast will succeed) before attempting to retrieve the NonlinearSystem. It seems like we can do better.

Use parameters.getCheckedPointerParam<FEProblemBase *>("_fe_problem_base", "This might happen if you don't have a mesh") to obtain a FEProblemBase, and then get .getNonlinearSystemBase().

permcody commented 7 years ago

That's not the problem. Daniel figured out that if you add displacements, this test fails. I ran it through the debugger and the static cast silently fails! It's because we are receiving a DisplacedProblem instead of an FEProblem when we do that. I just want the NonlinearSystemBase.

fdkong commented 7 years ago

That's not the problem. Daniel figured out that if you add displacements, this test fails. I ran it through the debugger and the static cast silently fails! It's because we are receiving a DisplacedProblem instead of an FEProblem when we do that. I just want the NonlinearSystemBase.

add .getNonlinearSystemBase() as a virtual function of subproblem, and in DisplacedProblem add .getNonlinearSystemBase() as well. DisplacedProblem already holds a FEProblemBase, so it is easy to return NonlinearSystemBase

.getNonlinearSystemBase()
{
 ` return _mproblem.getNonlinearSystemBase()`
}
permcody commented 7 years ago

Something still doesn't feel right about this interface but I'm not sure what. It turns out that UserObjects have references to FEProblemBase so now I'm not sure why this cast fails. I guess choosing which NonlinearSystem to to return might require us to look at the _use_displaced_system parameter. This might not be a 5 min fix.

permcody commented 7 years ago

@dschwen - I managed to fix the immediate problems with the GrainTracker but there's still something wrong with the mechanics in this example. Perhaps you can scan over the input file and see what else is out of date? Here's the error message I receive in devel mode:

Finished inside of trackGrains Running remap Grains Finished inside of updateFieldInfo Finished inside of GrainTracker

Time Step  2, time = 20
                dt = 10
Assertion `rhs.size() == row_dofs.size()' failed.
rhs.size() = 5
row_dofs.size() = 4
Assertion `rhs.size() == row_dofs.size()' failed.
rhs.size() = 6
row_dofs.size() = 4

[4] ../src/base/dof_map_constraints.C, line 1969, compiled nodate at notime
Assertion `rhs.size() == row_dofs.size()' failed.
rhs.size() = 5
row_dofs.size() = 4

[7] ../src/base/dof_map_constraints.C, line 1969, compiled nodate at 

[1] ../src/base/dof_map_constraints.C, line 1969, compiled nodate at notime
Assertion `rhs.size() == row_dofs.size()' failed.
rhs.size() = 5
row_dofs.size() = 4

https://github.com/permcody/moose/commit/807fdd2afec3e870a8884a02d65c22ea8a5878bf

dschwen commented 7 years ago

_sub_Re[i][var->number()] and var->dofIndices() do not have the same size in Assembly::cacheResidual(). Running in a debugger now to see which is the offending variable...

dschwen commented 7 years ago

This is downstream of _displaced_problem->cacheResidual(tid);