Go to the documentation of this file.
24 #include "libmesh/numeric_vector.h"
41 _mproblem(parameters.have_parameter<
FEProblemBase *>(
"_fe_problem_base")
46 _ref_mesh(_mproblem.mesh()),
47 _displacements(getParam<
std::vector<
std::string>>(
"displacements")),
49 _mproblem.getNonlinearSystemBase(),
50 _mproblem.getNonlinearSystemBase().name(),
53 _mproblem.getAuxiliarySystem(),
54 _mproblem.getAuxiliarySystem().name(),
56 _geometric_search_data(*this, _mesh),
57 _eq_init_timer(registerTimedSection(
"eq::init", 2)),
58 _update_mesh_timer(registerTimedSection(
"updateMesh", 3)),
59 _sync_solutions_timer(registerTimedSection(
"syncSolutions", 5)),
60 _update_geometric_search_timer(registerTimedSection(
"updateGeometricSearch", 3))
63 unsigned int n_threads = libMesh::n_threads();
66 for (
unsigned int i = 0; i < n_threads; ++i)
87 std::set<dof_id_type> &
99 for (
unsigned int tid = 0; tid < libMesh::n_threads(); ++tid)
106 for (
THREAD_ID tid = 0; tid < libMesh::n_threads(); ++tid)
109 std::vector<unsigned> disp_numbers;
112 const auto & disp_variable =
getVariable(tid, disp_string);
114 disp_numbers.push_back(disp_variable.number());
116 _assembly[tid]->assignDisplacements(std::move(disp_numbers));
166 const NumericVector<Number> & aux_soln)
180 CONSOLE_TIMED_PRINT(
"Updating displaced mesh");
218 Threads::parallel_reduce(node_range, udmt);
249 const NumericVector<Number> & aux_soln)
252 CONSOLE_TIMED_PRINT(
"Updating displaced mesh");
267 Threads::parallel_reduce(node_range, udmt);
321 std::map<TagName, TagID> &
376 const std::string & var_name,
390 mooseError(
"No variable with name '" + var_name +
"'");
401 mooseError(
"No variable with name '" + var_name +
"'");
410 mooseError(
"No variable with name '" + var_name +
"'");
434 mooseError(
"No variable with name '" + var_name +
"'");
445 mooseError(
"Unable to find a system containing the variable " + var_name);
450 const std::string & name,
458 const std::string & name,
493 const std::vector<dof_id_type> & dof_indices,
500 _assembly[tid]->prepareBlock(ivar, jvar, dof_indices);
507 _assembly[tid]->setCurrentSubdomainID(did);
513 SubdomainID did = elem->neighbor_ptr(side)->subdomain_id();
514 _assembly[tid]->setCurrentNeighborSubdomainID(did);
520 const std::vector<dof_id_type> & idof_indices,
521 const std::vector<dof_id_type> & jdof_indices,
524 _assembly[tid]->prepareBlockNonlocal(ivar, jvar, idof_indices, jdof_indices);
544 unsigned int n_points = points.size();
548 _assembly[tid]->reinitAtPhysical(elem, points);
570 const std::vector<Point> & phys_points_in_elem,
574 _assembly[tid]->reinitAtPhysical(elem, phys_points_in_elem);
629 const Elem * neighbor = elem->neighbor_ptr(side);
630 unsigned int neighbor_side = neighbor->which_neighbor_am_i(elem);
632 _assembly[tid]->reinitElemAndNeighbor(elem, side, neighbor, neighbor_side);
649 unsigned int neighbor_side,
650 const std::vector<Point> & physical_points,
654 _assembly[tid]->reinitNeighborAtPhysical(neighbor, neighbor_side, physical_points);
669 const std::vector<Point> & physical_points,
673 _assembly[tid]->reinitNeighborAtPhysical(neighbor, physical_points);
757 _assembly[tid]->setResidualNeighbor(residual);
807 std::vector<dof_id_type> & dof_indices,
810 _assembly[tid]->addJacobianBlock(jacobian, ivar, jvar,
dof_map, dof_indices);
818 const std::vector<dof_id_type> & idof_indices,
819 const std::vector<dof_id_type> & jdof_indices,
822 _assembly[tid]->addJacobianBlockNonlocal(
823 jacobian, ivar, jvar,
dof_map, idof_indices, jdof_indices);
831 std::vector<dof_id_type> & dof_indices,
832 std::vector<dof_id_type> & neighbor_dof_indices,
836 jacobian, ivar, jvar,
dof_map, dof_indices, neighbor_dof_indices);
964 Threads::parallel_reduce(node_range, rdmt);
973 const CouplingMatrix *
virtual void onTimestepEnd() override
virtual TagID getVectorTagID(const TagName &tag_name)
Get a TagID from a TagName.
virtual VectorMooseVariable & getVectorVariable(THREAD_ID tid, const std::string &var_name) override
Returns the variable reference for requested VectorMooseVariable which may be in any system.
virtual void solve() override
virtual void addJacobian(THREAD_ID tid) override
MooseMesh & _ref_mesh
reference mesh
std::vector< std::string > _displacements
virtual TagName vectorTagName(TagID tag)
Retrieve the name associated with a TagID.
virtual void checkExceptionAndStopSolve(bool print_message=true)
Check to see if an exception has occurred on any processor and stop the solve.
virtual void addCachedJacobian(THREAD_ID tid) override
virtual void reinitNode(const Node *node, THREAD_ID tid)
Reinit nodal assembly info.
virtual void addJacobianBlock(SparseMatrix< Number > &jacobian, unsigned int ivar, unsigned int jvar, const DofMap &dof_map, std::vector< dof_id_type > &dof_indices, THREAD_ID tid) override
defineLegacyParams(DisplacedProblem)
virtual bool vectorTagExists(TagID tag) override
Check to see if a particular Tag exists.
Class for scalar variables (they are different).
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
virtual void setCurrentSubdomainID(const Elem *elem, THREAD_ID tid) override
void mooseError(Args &&... args) const
virtual bool hasVariable(const std::string &var_name) const override
Whether or not this problem has the variable.
void update(GeometricSearchType type=ALL)
Update all of the search objects.
virtual TagName vectorTagName(TagID tag) override
Retrieve the name associated with a TagID.
virtual void update()
Update the system (doing libMesh magic)
virtual void prepare(const Elem *elem, THREAD_ID tid) override
const NumericVector< Number > * _aux_solution
virtual MooseVariableFEBase & getVariable(THREAD_ID tid, const std::string &var_name, Moose::VarKindType expected_var_type=Moose::VarKindType::VAR_ANY, Moose::VarFieldType expected_var_field_type=Moose::VarFieldType::VAR_FIELD_ANY) override
Returns the variable reference for requested variable which must be of the expected_var_type (Nonline...
virtual void addResidualNeighbor(THREAD_ID tid) override
virtual void reinitNodes(const std::vector< dof_id_type > &nodes, THREAD_ID tid) override
virtual void prepareShapes(unsigned int var, THREAD_ID tid) override
const std::string & type() const
Get the type of this object.
const CouplingMatrix * couplingMatrix() const override
The coupling matrix defining what blocks exist in the preconditioning matrix.
virtual DofMap & dofMap()
Gets writeable reference to the dof map.
virtual void prepareBlockNonlocal(unsigned int ivar, unsigned int jvar, const std::vector< dof_id_type > &idof_indices, const std::vector< dof_id_type > &jdof_indices, THREAD_ID tid)
virtual void reinitNodes(const std::vector< dof_id_type > &nodes, THREAD_ID tid)
Reinit variables at a set of nodes.
virtual void cacheJacobianNeighbor(THREAD_ID tid) override
virtual TagID getVectorTagID(const TagName &tag_name) override
Get a TagID from a TagName.
Provides a way for users to bail out of the current solve.
virtual void prepareFaceShapes(unsigned int var, THREAD_ID tid) override
GeometricSearchType
Used to select groups of geometric search objects to update.
virtual void updateMesh(bool mesh_changing=false)
Copy the solutions on the undisplaced systems to the displaced systems and reinitialize the geometry ...
virtual bool computingInitialResidual() const override
Returns true if the problem is in the process of computing it's initial residual.
virtual TagName matrixTagName(TagID tag) override
Retrieve the name associated with a TagID.
const NumericVector< Number > *const & currentSolution() const override
The solution vector that is currently being operated on.
const InputParameters & parameters() const
Get the parameters of the object.
virtual void reinitElemFace(const Elem *elem, unsigned int side, BoundaryID bnd_id, THREAD_ID tid)
Reinit assembly info for a side of an element.
virtual void reinitNeighbor(const Elem *elem, THREAD_ID tid)
Compute the values of the variables at all the current points.
virtual std::map< TagName, TagID > & getVectorTags() override
Return all vector tags, where a tag is represented by a map from name to ID.
virtual bool computingInitialResidual() const override
Returns true if the problem is in the process of computing it's initial residual.
virtual bool isTransient() const override
virtual void addCachedResidual(THREAD_ID tid) override
virtual void updateGeomSearch(GeometricSearchData::GeometricSearchType type=GeometricSearchData::ALL) override
void updatePointLocator(const MooseMesh &mesh)
Called during FEProblemBase::meshChanged() to update the PointLocator object used by the DiracKernels...
virtual void setNeighborSubdomainID(const Elem *elem, unsigned int side, THREAD_ID tid) override
virtual MooseVariableScalar & getScalarVariable(THREAD_ID tid, const std::string &var_name)
Gets a reference to a scalar variable with specified number.
VectorValue< Real > RealVectorValue
virtual std::map< TagName, TagID > & getVectorTags()
Return all vector tags, where a tag is represented by a map from name to ID.
virtual void addCachedResidualDirectly(NumericVector< Number > &residual, THREAD_ID tid)
virtual unsigned int numMatrixTags() const
The total number of tags.
virtual void reinitElemFace(const Elem *elem, unsigned int side, BoundaryID bnd_id, THREAD_ID tid) override
virtual void reinitNodesNeighbor(const std::vector< dof_id_type > &nodes, THREAD_ID tid)
Reinit variables at a set of neighbor nodes.
void addTimeIntegrator(std::shared_ptr< TimeIntegrator > ti) override
virtual bool matrixTagExists(const TagName &tag_name) override
Check to see if a particular Tag exists.
virtual void cacheJacobian(THREAD_ID tid) override
virtual TagID addVectorTag(TagName tag_name)
Create a Tag.
const NumericVector< Number > * _nl_solution
virtual void addVariable(const std::string &var_type, const std::string &var_name, InputParameters ¶meters)
Canonical method for adding a variable.
virtual TagID addMatrixTag(TagName tag_name) override
Create a Tag.
virtual void getDiracElements(std::set< const Elem * > &elems) override
Fills "elems" with the elements that should be looped over for Dirac Kernels.
virtual MooseVariable & getStandardVariable(THREAD_ID tid, const std::string &var_name) override
Returns the variable reference for requested MooseVariable which may be in any system.
virtual void reinitNode(const Node *node, THREAD_ID tid) override
void meshChanged()
Declares that the MooseMesh has changed, invalidates cached data and rebuilds caches.
virtual void init() override
virtual TransientExplicitSystem & sys()
virtual void ghostGhostedBoundaries() override
Causes the boundaries added using addGhostedBoundary to actually be ghosted.
std::shared_ptr< TimeIntegrator > getSharedTimeIntegrator()
virtual bool reinitDirac(const Elem *elem, THREAD_ID tid) override
Returns true if the Problem has Dirac kernels it needs to compute on elem.
virtual void reinitElem(const Elem *elem, THREAD_ID tid) override
Generic class for solving transient nonlinear problems.
GeometricSearchData _geometric_search_data
virtual Moose::CoordinateSystemType getCoordSystem(SubdomainID sid) override
virtual bool isTransient() const override
virtual unsigned int numMatrixTags() const override
The total number of tags.
virtual void prepareNonlocal(THREAD_ID tid)
virtual void cacheResidualNeighbor(THREAD_ID tid) override
virtual Moose::CoordinateSystemType getCoordSystem(SubdomainID sid) override
virtual void addGhostedElem(dof_id_type elem_id) override
Will make sure that all dofs connected to elem_id are ghosted to this processor.
virtual TagID timeVectorTag() override
Ideally, we should not need this API.
virtual void addGhostedBoundary(BoundaryID boundary_id) override
Will make sure that all necessary elements from boundary_id are ghosted to this processor.
void clearPoints()
Remove all of the current points and elements.
virtual void prepareFace(const Elem *elem, THREAD_ID tid) override
virtual void saveOldSolutions()
Allocate vectors and save old solutions into them.
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
virtual bool hasScalarVariable(const std::string &var_name) const
virtual void prepareNeighbor(THREAD_ID tid)
Prepare the system for use.
virtual void prepareFace(THREAD_ID tid, bool resize_data)
Prepare the system for use on sides.
boundary_id_type BoundaryID
registerMooseObject("MooseApp", DisplacedProblem)
virtual void addJacobianNeighbor(THREAD_ID tid) override
virtual bool converged() override
virtual void initAdaptivity()
virtual void setResidual(NumericVector< Number > &residual, THREAD_ID tid) override
MooseVariableFEBase & getVariableHelper(THREAD_ID tid, const std::string &var_name, Moose::VarKindType expected_var_type, Moose::VarFieldType expected_var_field_type, SystemBase &nl, SystemBase &aux)
Helper function called by getVariable that handles the logic for checking whether Variables of the re...
static InputParameters validParams()
PerfID _eq_init_timer
Timers.
virtual MooseVariableScalar & getScalarVariable(THREAD_ID tid, const std::string &var_name) override
Returns the scalar variable reference from whichever system contains it.
virtual void setException(const std::string &message)
Set an exception.
const NumericVector< Number > *const & currentSolution() const override
The solution vector that is currently being operated on.
virtual void reinitNodesNeighbor(const std::vector< dof_id_type > &nodes, THREAD_ID tid) override
virtual void reinitScalars(THREAD_ID tid, bool reinit_for_derivative_reordering=false) override
fills the VariableValue arrays for scalar variables from the solution vector
void undisplaceMesh()
Resets the displaced mesh to the reference mesh.
subdomain_id_type SubdomainID
LineSearch * getLineSearch() override
PerfID _update_mesh_timer
LineSearch * getLineSearch() override
getter for the MOOSE line search
virtual ArrayMooseVariable & getArrayVariable(THREAD_ID tid, const std::string &var_name) override
Returns the variable reference for requested ArrayMooseVariable which may be in any system.
virtual void restoreOldSolutions()
Restore the old and older solutions when the saved solutions present.
virtual void addJacobianBlockNonlocal(SparseMatrix< Number > &jacobian, unsigned int ivar, unsigned int jvar, const DofMap &dof_map, const std::vector< dof_id_type > &idof_indices, const std::vector< dof_id_type > &jdof_indices, THREAD_ID tid)
virtual void reinitOffDiagScalars(THREAD_ID tid) override
DisplacedProblem(const InputParameters ¶meters)
virtual void prepare(THREAD_ID tid)
Prepare the system for use.
virtual System & getSystem(const std::string &var_name) override
Returns the equation system containing the variable provided.
virtual TagID nonTimeVectorTag() override
PerfID _update_geometric_search_timer
DisplacedSystem _displaced_aux
DisplacedSystem _displaced_nl
virtual void prepareAssembly(THREAD_ID tid) override
virtual const char * what() const
Get out the error message.
virtual void addJacobianNonlocal(THREAD_ID tid)
virtual void syncSolutions()
Copy the solutions on the undisplaced systems to the displaced systems.
virtual void saveOldSolutions()
Save the old and older solutions.
std::set< const Elem * > & getElements()
Returns a writeable reference to the _elements container.
virtual void reinitNodeFace(const Node *node, BoundaryID bnd_id, THREAD_ID tid)
Reinit nodal assembly info on a face.
void reinit()
Completely redo all geometric search objects.
static InputParameters validParams()
virtual bool converged() override
virtual void reinitNeighbor(const Elem *elem, unsigned int side, THREAD_ID tid) override
virtual std::set< dof_id_type > & ghostedElems() override
Return the list of elements that should have their DoFs ghosted to this processor.
VarKindType
Framework-wide stuff.
virtual TagID getMatrixTagID(const TagName &tag_name)
Get a TagID from a TagName.
bool hasJacobian() const
Returns _has_jacobian.
DiracKernelInfo _dirac_kernel_info
virtual unsigned int numVectorTags() const
The total number of tags.
virtual void addAuxVariable(const std::string &var_type, const std::string &name, InputParameters ¶meters)
virtual bool matrixTagExists(const TagName &tag_name)
Check to see if a particular Tag exists.
virtual void createQRules(QuadratureType type, Order order, Order volume_order, Order face_order)
MooseVariableFE< T > & getFieldVariable(THREAD_ID tid, const std::string &var_name)
Gets a reference to a variable of with specified name.
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
virtual void addGhostedElem(dof_id_type elem_id) override
Will make sure that all dofs connected to elem_id are ghosted to this processor.
virtual void prepareNeighborShapes(unsigned int var, THREAD_ID tid) override
virtual unsigned int numVectorTags() const override
The total number of tags.
MultiPointMap & getPoints()
Returns a writeable reference to the _points container.
NonlinearSystemBase & getNonlinearSystemBase()
AuxiliarySystem & getAuxiliarySystem()
bool _default_ghosting
Whether or not to use default libMesh coupling.
virtual void ghostGhostedBoundaries() override
Causes the boundaries added using addGhostedBoundary to actually be ghosted.
virtual std::set< dof_id_type > & ghostedElems()
Return the list of elements that should have their DoFs ghosted to this processor.
virtual void reinitNeighborFace(const Elem *elem, unsigned int side, BoundaryID bnd_id, THREAD_ID tid)
Compute the values of the variables at all the current points.
virtual TagName matrixTagName(TagID tag)
Retrieve the name associated with a TagID.
virtual bool vectorTagExists(TagID tag)
Check to see if a particular Tag exists.
FEProblemBase & _mproblem
virtual void reinitNodeFace(const Node *node, BoundaryID bnd_id, THREAD_ID tid) override
std::vector< std::unique_ptr< Assembly > > _assembly
virtual void addVariable(const std::string &var_type, const std::string &name, InputParameters ¶meters)
virtual void reinitScalars(THREAD_ID tid, bool reinit_for_derivative_reordering=false)
Reinit scalar varaibles.
virtual bool hasScalarVariable(const std::string &var_name) const override
Returns a Boolean indicating whether any system contains a variable with the name provided.
virtual void restoreOldSolutions()
Restore old solutions from the backup vectors and deallocate them.
virtual bool hasVariable(const std::string &var_name) const
Query a system for a variable.
virtual TagID addMatrixTag(TagName tag_name)
Create a Tag.
virtual void addResidual(THREAD_ID tid) override
virtual void onTimestepBegin() override
virtual void setResidualNeighbor(NumericVector< Number > &residual, THREAD_ID tid) override
Eigen::Matrix< Real, Eigen::Dynamic, 1 > RealEigenVector
virtual void addGhostedBoundary(BoundaryID boundary_id) override
Will make sure that all necessary elements from boundary_id are ghosted to this processor.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
virtual TagID getMatrixTagID(const TagName &tag_name) override
Get a TagID from a TagName.
virtual void cacheResidual(THREAD_ID tid) override
virtual void reinitNeighborPhys(const Elem *neighbor, unsigned int neighbor_side, const std::vector< Point > &physical_points, THREAD_ID tid) override
virtual TagID addVectorTag(TagName tag_name) override
Create a Tag.
void clearQuadratureNodes()
Clear out any existing quadrature nodes.
virtual void init() override
Initialize the system.
bool constJacobian() const
Returns _const_jacobian (whether a MOOSE object has specified that the Jacobian is the same as the pr...
virtual void meshChanged() override
virtual void reinitElem(const Elem *elem, THREAD_ID tid)
Reinit an element assembly info.
virtual System & system() override
Get the reference to the libMesh system.
Class for stuff related to variables.
virtual void prepareAssemblyNeighbor(THREAD_ID tid)
void extraSendList(std::vector< dof_id_type > &send_list, void *context)
///< Type of coordinate system
virtual void clearDiracInfo() override
Gets called before Dirac Kernels are asked to add the points they are supposed to be evaluated in.
const CouplingMatrix * couplingMatrix() const override
The coupling matrix defining what blocks exist in the preconditioning matrix.
virtual const std::string & name() const
Get the name of the object.
virtual void reinitElemPhys(const Elem *elem, const std::vector< Point > &phys_points_in_elem, THREAD_ID tid, bool=false) override
virtual void cacheJacobianNonlocal(THREAD_ID tid)
PerfID _sync_solutions_timer