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" 44 _sys(subproblem.es().add_system<
System>(
name)),
45 _current_solution(_sys.current_local_solution.
get()),
46 _aux_scalar_storage(_app.getExecuteOnEnum()),
47 _nodal_aux_storage(_app.getExecuteOnEnum()),
48 _mortar_nodal_aux_storage(_app.getExecuteOnEnum()),
49 _elemental_aux_storage(_app.getExecuteOnEnum()),
50 _nodal_vec_aux_storage(_app.getExecuteOnEnum()),
51 _elemental_vec_aux_storage(_app.getExecuteOnEnum()),
52 _nodal_array_aux_storage(_app.getExecuteOnEnum()),
53 _elemental_array_aux_storage(_app.getExecuteOnEnum())
54 #ifdef MOOSE_KOKKOS_ENABLED
56 _kokkos_nodal_aux_storage(_app.getExecuteOnEnum()),
57 _kokkos_elemental_aux_storage(_app.getExecuteOnEnum())
65 auto & dof_map = _sys.get_dof_map();
66 dof_map.remove_algebraic_ghosting_functor(dof_map.default_algebraic_ghosting());
67 dof_map.set_implicit_neighbor_dofs(
false);
76 TIME_SECTION(
"initialSetup", 3,
"Initializing Auxiliary System");
107 #ifdef MOOSE_KOKKOS_ENABLED 133 #ifdef MOOSE_KOKKOS_ENABLED 156 #ifdef MOOSE_KOKKOS_ENABLED 197 #ifdef MOOSE_KOKKOS_ENABLED 220 #ifdef MOOSE_KOKKOS_ENABLED 238 #ifdef MOOSE_KOKKOS_ENABLED 249 const std::string & name,
254 auto fe_type =
FEType(Utility::string_to_enum<Order>(parameters.
get<
MooseEnum>(
"order")),
255 Utility::string_to_enum<FEFamily>(parameters.
get<
MooseEnum>(
"family")));
257 if (var_type ==
"MooseVariableScalar")
262 if (FEInterface::field_type(fe_type) ==
TYPE_VECTOR)
282 if (var->feType().family ==
LAGRANGE)
292 if (avar->feType().family ==
LAGRANGE)
303 const std::string & name,
308 const auto & base = parameters.
getBase();
309 if (base ==
"AuxKernel" || base ==
"Bounds")
311 std::shared_ptr<AuxKernel> kernel =
313 if (kernel->isNodal())
315 if (kernel->isMortar())
324 else if (base ==
"VectorAuxKernel")
326 std::shared_ptr<VectorAuxKernel> kernel =
328 if (kernel->isNodal())
330 if (kernel->isMortar())
331 mooseError(
"Vector mortar aux kernels not yet implemented");
338 else if (base ==
"ArrayAuxKernel")
340 std::shared_ptr<ArrayAuxKernel> kernel =
342 if (kernel->isNodal())
344 if (kernel->isMortar())
345 mooseError(
"Vector mortar aux kernels not yet implemented");
353 "Attempting to add AuxKernel of type '" + kernel_name +
"' and name '" +
name +
354 "' to the auxiliary system with invalid _moose_base: " + base);
360 const std::string & name,
365 std::shared_ptr<AuxScalarKernel> kernel =
375 var->computeElemValues();
380 var->computeElemValues();
388 var->computeElemValuesFace();
393 var->reinitAuxNeighbor();
394 var->computeElemValuesFace();
430 if (
_vars[0].scalars().size() > 0)
436 ti->computeTimeDerivatives();
439 if (
_vars[0].fieldVariables().size() > 0)
449 #ifdef MOOSE_KOKKOS_ENABLED 456 ti->computeTimeDerivatives();
463 std::set<std::string>
466 std::set<std::string> depend_objects;
470 const std::vector<std::shared_ptr<AuxKernel>> & auxs =
472 for (
const auto & aux : auxs)
474 const std::set<UserObjectName> & uo = aux->getDependObjects();
475 depend_objects.insert(uo.begin(), uo.end());
481 const std::vector<std::shared_ptr<VectorAuxKernel>> & auxs =
483 for (
const auto & aux : auxs)
485 const std::set<UserObjectName> & uo = aux->getDependObjects();
486 depend_objects.insert(uo.begin(), uo.end());
492 const std::vector<std::shared_ptr<ArrayAuxKernel>> & auxs =
494 for (
const auto & aux : auxs)
496 const std::set<UserObjectName> & uo = aux->getDependObjects();
497 depend_objects.insert(uo.begin(), uo.end());
503 const std::vector<std::shared_ptr<AuxKernel>> & auxs =
505 for (
const auto & aux : auxs)
507 const std::set<UserObjectName> & uo = aux->getDependObjects();
508 depend_objects.insert(uo.begin(), uo.end());
514 const std::vector<std::shared_ptr<AuxKernel>> & auxs =
516 for (
const auto & aux : auxs)
518 const std::set<UserObjectName> & uo = aux->getDependObjects();
519 depend_objects.insert(uo.begin(), uo.end());
525 const std::vector<std::shared_ptr<VectorAuxKernel>> & auxs =
527 for (
const auto & aux : auxs)
529 const std::set<UserObjectName> & uo = aux->getDependObjects();
530 depend_objects.insert(uo.begin(), uo.end());
536 const std::vector<std::shared_ptr<ArrayAuxKernel>> & auxs =
538 for (
const auto & aux : auxs)
540 const std::set<UserObjectName> & uo = aux->getDependObjects();
541 depend_objects.insert(uo.begin(), uo.end());
545 #ifdef MOOSE_KOKKOS_ENABLED 548 const std::vector<std::shared_ptr<AuxKernelBase>> & auxs =
550 for (
const auto & aux : auxs)
552 const std::set<UserObjectName> & uo = aux->getDependObjects();
553 depend_objects.insert(uo.begin(), uo.end());
559 const std::vector<std::shared_ptr<AuxKernelBase>> & auxs =
561 for (
const auto & aux : auxs)
563 const std::set<UserObjectName> & uo = aux->getDependObjects();
564 depend_objects.insert(uo.begin(), uo.end());
569 return depend_objects;
572 std::set<std::string>
575 std::set<std::string> depend_objects;
579 const std::vector<std::shared_ptr<AuxKernel>> & auxs =
581 for (
const auto & aux : auxs)
583 const std::set<UserObjectName> & uo = aux->getDependObjects();
584 depend_objects.insert(uo.begin(), uo.end());
590 const std::vector<std::shared_ptr<VectorAuxKernel>> & auxs =
592 for (
const auto & aux : auxs)
594 const std::set<UserObjectName> & uo = aux->getDependObjects();
595 depend_objects.insert(uo.begin(), uo.end());
601 const std::vector<std::shared_ptr<ArrayAuxKernel>> & auxs =
603 for (
const auto & aux : auxs)
605 const std::set<UserObjectName> & uo = aux->getDependObjects();
606 depend_objects.insert(uo.begin(), uo.end());
612 const std::vector<std::shared_ptr<AuxKernel>> & auxs =
_nodal_aux_storage.getActiveObjects();
613 for (
const auto & aux : auxs)
615 const std::set<UserObjectName> & uo = aux->getDependObjects();
616 depend_objects.insert(uo.begin(), uo.end());
622 const std::vector<std::shared_ptr<AuxKernel>> & auxs =
624 for (
const auto & aux : auxs)
626 const std::set<UserObjectName> & uo = aux->getDependObjects();
627 depend_objects.insert(uo.begin(), uo.end());
633 const std::vector<std::shared_ptr<VectorAuxKernel>> & auxs =
635 for (
const auto & aux : auxs)
637 const std::set<UserObjectName> & uo = aux->getDependObjects();
638 depend_objects.insert(uo.begin(), uo.end());
644 const std::vector<std::shared_ptr<ArrayAuxKernel>> & auxs =
646 for (
const auto & aux : auxs)
648 const std::set<UserObjectName> & uo = aux->getDependObjects();
649 depend_objects.insert(uo.begin(), uo.end());
653 #ifdef MOOSE_KOKKOS_ENABLED 656 const std::vector<std::shared_ptr<AuxKernelBase>> & auxs =
658 for (
const auto & aux : auxs)
660 const std::set<UserObjectName> & uo = aux->getDependObjects();
661 depend_objects.insert(uo.begin(), uo.end());
667 const std::vector<std::shared_ptr<AuxKernelBase>> & auxs =
669 for (
const auto & aux : auxs)
671 const std::set<UserObjectName> & uo = aux->getDependObjects();
672 depend_objects.insert(uo.begin(), uo.end());
677 return depend_objects;
684 const std::vector<std::shared_ptr<AuxScalarKernel>> & objects = storage.
getActiveObjects(0);
686 std::set<TagID> needed_sc_var_matrix_tags;
687 std::set<TagID> needed_sc_var_vector_tags;
688 for (
const auto & obj : objects)
690 auto & sc_var_coup_vtags = obj->getScalarVariableCoupleableVectorTags();
691 needed_sc_var_vector_tags.insert(sc_var_coup_vtags.begin(), sc_var_coup_vtags.end());
693 auto & sc_var_coup_mtags = obj->getScalarVariableCoupleableMatrixTags();
694 needed_sc_var_matrix_tags.insert(sc_var_coup_mtags.begin(), sc_var_coup_mtags.end());
718 TIME_SECTION(
"computeScalarVars", 1);
728 const std::vector<std::shared_ptr<AuxScalarKernel>> & objects =
732 for (
const auto & obj : objects)
736 for (
const auto & var : scalar_vars)
752 TIME_SECTION(
"computeNodalVars", 3);
755 computeNodalVarsHelper<AuxKernel>(nodal);
761 TIME_SECTION(
"computeNodalVecVars", 3);
764 computeNodalVarsHelper<VectorAuxKernel>(nodal);
771 computeNodalVarsHelper<ArrayAuxKernel>(nodal);
777 TIME_SECTION(
"computeMortarNodalVars", 3);
782 "We don't allow creation of block restricted mortar nodal aux kernels.");
787 for (
const auto & [bnd_id, mortar_nodal_auxes] :
789 for (
const auto index :
index_range(mortar_nodal_auxes))
796 _fe_problem, mortar_nodal_warehouse, bnd_id, index);
797 Threads::parallel_reduce(bnd_nodes, mnabt);
802 "Auxiliary variable computation:\n" +
803 std::string(e.
what()));
805 catch (MetaPhysicL::LogicError & e)
809 catch (std::exception & e)
813 if (!strstr(e.what(),
"Jacobian") && !strstr(e.what(),
"singular") &&
814 !strstr(e.what(),
"det != 0"))
818 "nodal Auxiliary variable computation:\n" +
819 std::string(e.what()));
835 TIME_SECTION(
"computeElementalVars", 3);
838 computeElementalVarsHelper<AuxKernel>(elemental);
844 TIME_SECTION(
"computeElementalVecVars", 3);
847 computeElementalVarsHelper<VectorAuxKernel>(elemental);
854 computeElementalVarsHelper<ArrayAuxKernel>(elemental);
859 std::vector<dof_id_type> & ,
860 std::vector<dof_id_type> &
869 std::vector<MooseVariableFEBase *>
vars =
_vars[0].fieldVariables();
870 for (
const auto & var :
vars)
874 FEType fe_type = var->feType();
897 template <
typename AuxKernelType>
910 Threads::parallel_reduce(range, eavt);
915 "Auxiliary variable computation:\n" +
916 std::string(e.
what()));
930 TIME_SECTION(
"computeElementalVecVars", 3);
938 Threads::parallel_reduce(bnd_elems, eabt);
943 "elemental Auxiliary variable computation:\n" +
944 std::string(e.
what()));
956 template <
typename AuxKernelType>
967 Threads::parallel_reduce(range, navt);
977 TIME_SECTION(
"computeBoundaryObjects", 3);
984 Threads::parallel_reduce(bnd_nodes, nabt);
995 std::vector<Number> & rel_diff_norms)
const 1004 std::vector<dof_id_type> local_indices_n;
1009 for (
const auto local_index : local_indices_n)
1013 diff_norm_n += Utility::pow<2, Number>(
value - value_old);
1014 norm_n += Utility::pow<2, Number>(
value);
1019 diff_norm_n =
sqrt(diff_norm_n);
1020 norm_n =
sqrt(norm_n);
1021 rel_diff_norms[n] = diff_norm_n / norm_n;
1027 template void AuxiliarySystem::computeElementalVarsHelper<VectorAuxKernel>(
1031 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
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.
FEProblemBase & _fe_problem
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()
ExecuteMooseObjectWarehouse< AuxKernelBase > _kokkos_elemental_aux_storage
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...
void kokkosCompute(ExecFlagType type)
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 ~AuxiliarySystem()
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
virtual void initialSetup() override
Setup Functions.
ExecuteMooseObjectWarehouse< VectorAuxKernel > _nodal_vec_aux_storage
std::vector< std::vector< MooseVariableFieldBase * > > _elem_vars
Elemental variables.
ExecuteMooseObjectWarehouse< AuxKernelBase > _kokkos_nodal_aux_storage
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 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)
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()
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...
const Elem & get(const ElemType type_in)
void computeElementalVecVars(ExecFlagType type)
virtual void subdomainSetup() override
virtual void timestepSetup()
virtual void localize(std::vector< T > &v_local) const=0