27 #include "libmesh/quadrature_gauss.h" 28 #include "libmesh/node_range.h" 29 #include "libmesh/numeric_vector.h" 30 #include "libmesh/default_coupling.h" 31 #include "libmesh/string_to_enum.h" 32 #include "libmesh/fe_interface.h" 41 _sys(subproblem.es().add_system<
System>(
name)),
42 _current_solution(_sys.current_local_solution.
get()),
43 _aux_scalar_storage(_app.getExecuteOnEnum()),
44 _nodal_aux_storage(_app.getExecuteOnEnum()),
45 _mortar_nodal_aux_storage(_app.getExecuteOnEnum()),
46 _elemental_aux_storage(_app.getExecuteOnEnum()),
47 _nodal_vec_aux_storage(_app.getExecuteOnEnum()),
48 _elemental_vec_aux_storage(_app.getExecuteOnEnum()),
49 _nodal_array_aux_storage(_app.getExecuteOnEnum()),
50 _elemental_array_aux_storage(_app.getExecuteOnEnum())
59 dof_map.set_implicit_neighbor_dofs(
false);
68 TIME_SECTION(
"initialSetup", 3,
"Initializing Auxiliary System");
205 const std::string & name,
210 auto fe_type =
FEType(Utility::string_to_enum<Order>(parameters.
get<
MooseEnum>(
"order")),
211 Utility::string_to_enum<FEFamily>(parameters.
get<
MooseEnum>(
"family")));
213 if (var_type ==
"MooseVariableScalar")
218 if (FEInterface::field_type(fe_type) ==
TYPE_VECTOR)
238 if (var->feType().family ==
LAGRANGE)
248 if (avar->feType().family ==
LAGRANGE)
259 const std::string & name,
264 if (parameters.
get<std::string>(
"_moose_base") ==
"AuxKernel" ||
265 parameters.
get<std::string>(
"_moose_base") ==
"Bounds")
267 std::shared_ptr<AuxKernel> kernel =
269 if (kernel->isNodal())
271 if (kernel->isMortar())
280 else if (parameters.
get<std::string>(
"_moose_base") ==
"VectorAuxKernel")
282 std::shared_ptr<VectorAuxKernel> kernel =
284 if (kernel->isNodal())
286 if (kernel->isMortar())
287 mooseError(
"Vector mortar aux kernels not yet implemented");
294 else if (parameters.
get<std::string>(
"_moose_base") ==
"ArrayAuxKernel")
296 std::shared_ptr<ArrayAuxKernel> kernel =
298 if (kernel->isNodal())
300 if (kernel->isMortar())
301 mooseError(
"Vector mortar aux kernels not yet implemented");
309 "Attempting to add AuxKernel of type '" + kernel_name +
"' and name '" +
name +
310 "' to the auxiliary system with invalid _moose_base: " +
311 parameters.
get<std::string>(
"_moose_base"));
317 const std::string & name,
322 std::shared_ptr<AuxScalarKernel> kernel =
332 var->computeElemValues();
337 var->computeElemValues();
345 var->computeElemValuesFace();
350 var->reinitAuxNeighbor();
351 var->computeElemValuesFace();
387 if (
_vars[0].scalars().size() > 0)
393 ti->computeTimeDerivatives();
396 if (
_vars[0].fieldVariables().size() > 0)
409 ti->computeTimeDerivatives();
416 std::set<std::string>
419 std::set<std::string> depend_objects;
423 const std::vector<std::shared_ptr<AuxKernel>> & auxs =
425 for (
const auto & aux : auxs)
427 const std::set<UserObjectName> & uo = aux->getDependObjects();
428 depend_objects.insert(uo.begin(), uo.end());
434 const std::vector<std::shared_ptr<VectorAuxKernel>> & auxs =
436 for (
const auto & aux : auxs)
438 const std::set<UserObjectName> & uo = aux->getDependObjects();
439 depend_objects.insert(uo.begin(), uo.end());
445 const std::vector<std::shared_ptr<ArrayAuxKernel>> & auxs =
447 for (
const auto & aux : auxs)
449 const std::set<UserObjectName> & uo = aux->getDependObjects();
450 depend_objects.insert(uo.begin(), uo.end());
456 const std::vector<std::shared_ptr<AuxKernel>> & auxs =
458 for (
const auto & aux : auxs)
460 const std::set<UserObjectName> & uo = aux->getDependObjects();
461 depend_objects.insert(uo.begin(), uo.end());
467 const std::vector<std::shared_ptr<AuxKernel>> & auxs =
469 for (
const auto & aux : auxs)
471 const std::set<UserObjectName> & uo = aux->getDependObjects();
472 depend_objects.insert(uo.begin(), uo.end());
478 const std::vector<std::shared_ptr<VectorAuxKernel>> & auxs =
480 for (
const auto & aux : auxs)
482 const std::set<UserObjectName> & uo = aux->getDependObjects();
483 depend_objects.insert(uo.begin(), uo.end());
489 const std::vector<std::shared_ptr<ArrayAuxKernel>> & auxs =
491 for (
const auto & aux : auxs)
493 const std::set<UserObjectName> & uo = aux->getDependObjects();
494 depend_objects.insert(uo.begin(), uo.end());
498 return depend_objects;
501 std::set<std::string>
504 std::set<std::string> depend_objects;
508 const std::vector<std::shared_ptr<AuxKernel>> & auxs =
510 for (
const auto & aux : auxs)
512 const std::set<UserObjectName> & uo = aux->getDependObjects();
513 depend_objects.insert(uo.begin(), uo.end());
519 const std::vector<std::shared_ptr<VectorAuxKernel>> & auxs =
521 for (
const auto & aux : auxs)
523 const std::set<UserObjectName> & uo = aux->getDependObjects();
524 depend_objects.insert(uo.begin(), uo.end());
530 const std::vector<std::shared_ptr<ArrayAuxKernel>> & auxs =
532 for (
const auto & aux : auxs)
534 const std::set<UserObjectName> & uo = aux->getDependObjects();
535 depend_objects.insert(uo.begin(), uo.end());
541 const std::vector<std::shared_ptr<AuxKernel>> & auxs =
_nodal_aux_storage.getActiveObjects();
542 for (
const auto & aux : auxs)
544 const std::set<UserObjectName> & uo = aux->getDependObjects();
545 depend_objects.insert(uo.begin(), uo.end());
551 const std::vector<std::shared_ptr<AuxKernel>> & auxs =
553 for (
const auto & aux : auxs)
555 const std::set<UserObjectName> & uo = aux->getDependObjects();
556 depend_objects.insert(uo.begin(), uo.end());
562 const std::vector<std::shared_ptr<VectorAuxKernel>> & auxs =
564 for (
const auto & aux : auxs)
566 const std::set<UserObjectName> & uo = aux->getDependObjects();
567 depend_objects.insert(uo.begin(), uo.end());
573 const std::vector<std::shared_ptr<ArrayAuxKernel>> & auxs =
575 for (
const auto & aux : auxs)
577 const std::set<UserObjectName> & uo = aux->getDependObjects();
578 depend_objects.insert(uo.begin(), uo.end());
582 return depend_objects;
589 const std::vector<std::shared_ptr<AuxScalarKernel>> & objects = storage.
getActiveObjects(0);
591 std::set<TagID> needed_sc_var_matrix_tags;
592 std::set<TagID> needed_sc_var_vector_tags;
593 for (
const auto & obj : objects)
595 auto & sc_var_coup_vtags = obj->getScalarVariableCoupleableVectorTags();
596 needed_sc_var_vector_tags.insert(sc_var_coup_vtags.begin(), sc_var_coup_vtags.end());
598 auto & sc_var_coup_mtags = obj->getScalarVariableCoupleableMatrixTags();
599 needed_sc_var_matrix_tags.insert(sc_var_coup_mtags.begin(), sc_var_coup_mtags.end());
623 TIME_SECTION(
"computeScalarVars", 1);
633 const std::vector<std::shared_ptr<AuxScalarKernel>> & objects =
637 for (
const auto & obj : objects)
641 for (
const auto & var : scalar_vars)
657 TIME_SECTION(
"computeNodalVars", 3);
660 computeNodalVarsHelper<AuxKernel>(nodal);
666 TIME_SECTION(
"computeNodalVecVars", 3);
669 computeNodalVarsHelper<VectorAuxKernel>(nodal);
676 computeNodalVarsHelper<ArrayAuxKernel>(nodal);
682 TIME_SECTION(
"computeMortarNodalVars", 3);
687 "We don't allow creation of block restricted mortar nodal aux kernels.");
692 for (
const auto & [bnd_id, mortar_nodal_auxes] :
694 for (
const auto index :
index_range(mortar_nodal_auxes))
701 _fe_problem, mortar_nodal_warehouse, bnd_id, index);
702 Threads::parallel_reduce(bnd_nodes, mnabt);
707 "nodal Auxiliary variable computation:\n" +
708 std::string(e.what()));
713 "Auxiliary variable computation:\n" +
714 std::string(e.
what()));
716 catch (MetaPhysicL::LogicError & e)
734 TIME_SECTION(
"computeElementalVars", 3);
737 computeElementalVarsHelper<AuxKernel>(elemental);
743 TIME_SECTION(
"computeElementalVecVars", 3);
746 computeElementalVarsHelper<VectorAuxKernel>(elemental);
753 computeElementalVarsHelper<ArrayAuxKernel>(elemental);
758 std::vector<dof_id_type> & ,
759 std::vector<dof_id_type> &
768 std::vector<MooseVariableFEBase *>
vars =
_vars[0].fieldVariables();
769 for (
const auto & var :
vars)
773 FEType fe_type = var->feType();
796 template <
typename AuxKernelType>
809 Threads::parallel_reduce(range, eavt);
814 "Auxiliary variable computation:\n" +
815 std::string(e.
what()));
829 TIME_SECTION(
"computeElementalVecVars", 3);
837 Threads::parallel_reduce(bnd_elems, eabt);
842 "elemental Auxiliary variable computation:\n" +
843 std::string(e.
what()));
855 template <
typename AuxKernelType>
866 Threads::parallel_reduce(range, navt);
876 TIME_SECTION(
"computeBoundaryObjects", 3);
883 Threads::parallel_reduce(bnd_nodes, nabt);
894 std::vector<Number> & rel_diff_norms)
const 903 std::vector<dof_id_type> local_indices_n;
908 for (
const auto local_index : local_indices_n)
912 diff_norm_n += Utility::pow<2, Number>(
value - value_old);
913 norm_n += Utility::pow<2, Number>(
value);
918 diff_norm_n =
sqrt(diff_norm_n);
919 norm_n =
sqrt(norm_n);
920 rel_diff_norms[n] = diff_norm_n / norm_n;
926 template void AuxiliarySystem::computeElementalVarsHelper<VectorAuxKernel>(
930 template void AuxiliarySystem::computeNodalVarsHelper<VectorAuxKernel>(
std::string name(const ElemQuality q)
std::vector< std::shared_ptr< TimeIntegrator > > _time_integrators
Time integrator.
void addObject(std::shared_ptr< T > object, THREAD_ID tid=0, bool recurse=true) override
Adds an object to the storage structure.
ExecuteMooseObjectWarehouse< AuxKernel > _nodal_aux_storage
ExecuteMooseObjectWarehouse< AuxKernel > _mortar_nodal_aux_storage
virtual void timestepSetup() override
libMesh::ConstElemRange * getActiveLocalElementRange()
Return pointers to range objects for various types of ranges (local nodes, boundary elems...
virtual void clearActiveScalarVariableCoupleableVectorTags(const THREAD_ID tid) override
void computeNodalVarsHelper(const MooseObjectWarehouse< AuxKernelType > &warehouse)
virtual const char * what() const
Get out the error message.
const std::vector< MooseVariableScalar * > & getScalarVariables(THREAD_ID tid)
bool hasActiveBlockObjects(THREAD_ID tid=0) const
void computeScalarVars(ExecFlagType type)
void sort(THREAD_ID tid=0)
Performs a sort using the DependencyResolver.
This class evaluates a single mortar nodal aux kernel.
NumericVector< Number > & solution()
virtual void addVariable(const std::string &var_type, const std::string &var_name, InputParameters ¶meters)
Canonical method for adding a variable.
virtual void copyCurrentIntoPreviousNL()
Copies the current solution into the previous nonlinear iteration solution.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
virtual void clearActiveScalarVariableCoupleableMatrixTags(const THREAD_ID tid) override
void updateActive(THREAD_ID tid=0) override
Updates the active objects storage.
virtual void setActiveScalarVariableCoupleableMatrixTags(std::set< TagID > &mtags, const THREAD_ID tid) override
virtual void reinitScalars(const THREAD_ID tid, bool reinit_for_derivative_reordering=false) override
fills the VariableValue arrays for scalar variables from the solution vector
void local_variable_indices(T &idx, const MeshBase &mesh, unsigned int var_num) const
void translateMetaPhysicLError(const MetaPhysicL::LogicError &)
emit a relatively clear error message when we catch a MetaPhysicL logic error
T * get(const std::unique_ptr< T > &u)
The MooseUtils::get() specializations are used to support making forwards-compatible code changes fro...
AuxiliarySystem(FEProblemBase &subproblem, const std::string &name)
ExecuteMooseObjectWarehouse< ArrayAuxKernel > _nodal_array_aux_storage
virtual void updateActive(THREAD_ID tid)
virtual void setException(const std::string &message)
Set an exception, which is stored at this point by toggling a member variable in this class...
virtual void customSetup(const ExecFlagType &exec_type, THREAD_ID tid=0) const
const NumericVector< Number > *const & currentSolution() const override
The solution vector that is currently being operated on.
Order default_quadrature_order() const
void computeElementalVarsHelper(const MooseObjectWarehouse< AuxKernelType > &warehouse)
const Parallel::Communicator & _communicator
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
Base class for a system (of equations)
ExecuteMooseObjectWarehouse< AuxScalarKernel > _aux_scalar_storage
bool needMaterialOnSide(BoundaryID bnd_id)
Indicated whether this system needs material properties on boundaries.
virtual void reinitElem(const Elem *elem, THREAD_ID tid) override
Reinit an element assembly info.
std::unique_ptr< NumericVector< Number > > _serialized_solution
Serialized version of the solution vector, or nullptr if a serialized solution is not needed...
virtual void residualSetup() override
libMesh::ConstNodeRange * getLocalNodeRange()
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
void computeMortarNodalVars(ExecFlagType type)
dof_id_type n_dofs() const
virtual unsigned int nVariables() const
Get the number of variables in this system.
bool hasActiveBoundaryObjects(THREAD_ID tid=0) const
virtual const std::string & name() const
virtual void jacobianSetup()
void setScalarVariableCoupleableTags(ExecFlagType type)
void clearScalarVariableCoupleableTags()
std::set< std::string > getDependObjects()
virtual void jacobianSetup() override
ExecuteMooseObjectWarehouse< ArrayAuxKernel > _elemental_array_aux_storage
const std::vector< std::shared_ptr< T > > & getActiveObjects(THREAD_ID tid=0) const
Retrieve complete vector to the active all/block/boundary restricted objects for a given thread...
void computeNodalArrayVars(ExecFlagType type)
virtual std::unique_ptr< Base > create()=0
void computeElementalVars(ExecFlagType type)
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
Base class for making kernels that work on auxiliary scalar variables.
boundary_id_type BoundaryID
virtual void timestepSetup(THREAD_ID tid=0) const
virtual libMesh::Order getMinQuadratureOrder() override
Get the minimum quadrature order for evaluating elemental auxiliary variables.
virtual void setActiveScalarVariableCoupleableVectorTags(std::set< TagID > &vtags, const THREAD_ID tid) override
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
virtual void initialSetup(THREAD_ID tid=0) const
Convenience methods for calling object setup methods.
virtual void addVariable(const std::string &var_type, const std::string &name, InputParameters ¶meters) override
Canonical method for adding a variable.
Interface for objects interacting with the PerfGraph.
void jacobianSetup(THREAD_ID tid=0) const override
Convenience methods for calling object setup methods.
const std::map< BoundaryID, std::vector< std::shared_ptr< T > > > & getActiveBoundaryObjects(THREAD_ID tid=0) const
virtual void reinitElemFace(const Elem *elem, unsigned int side, THREAD_ID tid) override
Reinit assembly info for a side of an element.
virtual void augmentSparsity(libMesh::SparsityPattern::Graph &, std::vector< dof_id_type > &, std::vector< dof_id_type > &) override
Will modify the sparsity pattern to add logical geometric connections.
std::vector< std::vector< MooseVariableFEBase * > > _nodal_vars
ExecuteMooseObjectWarehouse< VectorAuxKernel > _nodal_vec_aux_storage
std::vector< std::vector< MooseVariableFieldBase * > > _elem_vars
Elemental variables.
FEProblemBase & _fe_problem
the governing finite element/volume problem
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Provides a way for users to bail out of the current solve.
virtual void initialSetup() override
Setup Functions.
virtual void subdomainSetup()
void addKernel(const std::string &kernel_name, const std::string &name, InputParameters ¶meters)
Adds an auxiliary kernel.
Class for containing MooseEnum item information.
bool hasActiveObjects(THREAD_ID tid=0) const
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template * sqrt(_arg)) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(tanh
virtual void compute(ExecFlagType type) override
Compute auxiliary variables.
IntRange< T > make_range(T beg, T end)
void computeNodalVars(ExecFlagType type)
virtual const NumericVector< Number > * solutionPreviousNewton() const
virtual void customSetup(const ExecFlagType &exec_type)
void addScalarKernel(const std::string &kernel_name, const std::string &name, InputParameters ¶meters)
Adds a scalar kernel.
ExecuteMooseObjectWarehouse< AuxKernel > _elemental_aux_storage
virtual void customSetup(const ExecFlagType &exec_type) override
libMesh::StoredRange< MooseMesh::const_bnd_elem_iterator, const BndElement * > * getBoundaryElementRange()
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
virtual void serializeSolution()
void computeNodalVecVars(ExecFlagType type)
void computeElementalArrayVars(ExecFlagType type)
void remove_algebraic_ghosting_functor(GhostingFunctor &evaluable_functor)
ExecuteMooseObjectWarehouse< VectorAuxKernel > _elemental_vec_aux_storage
NumericVector< Number > & solutionOld()
virtual void initialSetup()
Setup Functions.
bool defaultGhosting()
Whether or not the user has requested default ghosting ot be on.
virtual Real & dt() const
const DofMap & get_dof_map() const
virtual void residualSetup()
virtual ~AuxiliarySystem()
void residualSetup(THREAD_ID tid=0) const override
virtual void subdomainSetup(THREAD_ID tid=0) const
libMesh::StoredRange< MooseMesh::const_bnd_node_iterator, const BndNode * > * getBoundaryNodeRange()
auto index_range(const T &sizable)
void variableWiseRelativeSolutionDifferenceNorm(std::vector< Number > &var_diffs) const
Computes and stores ||current - old|| / ||current|| for each variable in the given vector...
void computeElementalVecVars(ExecFlagType type)
virtual void subdomainSetup() override
virtual void timestepSetup()
virtual void localize(std::vector< T > &v_local) const=0