https://mooseframework.inl.gov
Loading...
Searching...
No Matches
AuxiliarySystem.h
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10#pragma once
11
12// MOOSE includes
13#include "SystemBase.h"
16#include "PerfGraphInterface.h"
17
18#include "libmesh/system.h"
19#include "libmesh/transient_system.h"
20
21// Forward declarations
22class AuxKernelBase;
23template <typename ComputeValueType>
24class AuxKernelTempl;
28class FEProblemBase;
29class TimeIntegrator;
30class AuxScalarKernel;
31
32// libMesh forward declarations
33namespace libMesh
34{
35template <typename T>
36class NumericVector;
37}
38
44{
45public:
46 AuxiliarySystem(FEProblemBase & subproblem, const std::string & name);
48
49 virtual void initSolutionState() override;
50 virtual void initialSetup() override;
51 virtual void reinit() override;
52 virtual void timestepSetup() override;
53 virtual void customSetup(const ExecFlagType & exec_type) override;
54 virtual void subdomainSetup() override;
55 virtual void residualSetup() override;
56 virtual void jacobianSetup() override;
57 virtual void updateActive(THREAD_ID tid);
58
59 virtual void addVariable(const std::string & var_type,
60 const std::string & name,
61 InputParameters & parameters) override;
62
69 void addKernel(const std::string & kernel_name,
70 const std::string & name,
71 InputParameters & parameters);
72
73#ifdef MOOSE_KOKKOS_ENABLED
74 void addKokkosKernel(const std::string & kernel_name,
75 const std::string & name,
76 InputParameters & parameters);
77#endif
78
85 void addScalarKernel(const std::string & kernel_name,
86 const std::string & name,
87 InputParameters & parameters);
88
89 virtual void reinitElem(const Elem * elem, THREAD_ID tid) override;
90 virtual void reinitElemFace(const Elem * elem, unsigned int side, THREAD_ID tid) override;
91
92 const NumericVector<Number> * const & currentSolution() const override
93 {
94 return _current_solution;
95 }
96
97 virtual void serializeSolution();
98
99 // This is an empty function since the Aux system doesn't have a matrix!
100 virtual void augmentSparsity(libMesh::SparsityPattern::Graph & /*sparsity*/,
101 std::vector<dof_id_type> & /*n_nz*/,
102 std::vector<dof_id_type> & /*n_oz*/) override;
103
108 virtual void compute(ExecFlagType type) override;
109
110#ifdef MOOSE_KOKKOS_ENABLED
112#endif
113
119 std::set<std::string> getDependObjects(ExecFlagType type);
120 std::set<std::string> getDependObjects();
121
125 virtual libMesh::Order getMinQuadratureOrder() override;
126
131 bool needMaterialOnSide(BoundaryID bnd_id);
132
133 virtual libMesh::System & sys() { return _sys; }
134
135 virtual libMesh::System & system() override { return _sys; }
136 virtual const libMesh::System & system() const override { return _sys; }
137
140
142 virtual void copyCurrentIntoPreviousNL();
143
145
147
152
156
157#ifdef MOOSE_KOKKOS_ENABLED
160#endif
161
164 void variableWiseRelativeSolutionDifferenceNorm(std::vector<Number> & var_diffs) const;
165
166protected:
168 bool skip_current_to_old) override;
169 virtual void restoreAdditionalStates() override;
170
179
180 template <typename AuxKernelType>
182
183 template <typename AuxKernelType>
185
187
189 const NumericVector<Number> * _current_solution;
190
192 std::vector<NumericVector<Number> *> _solution_state;
193
194 // Variables
195 std::vector<std::vector<MooseVariableFEBase *>> _nodal_vars;
196
198
201 std::vector<std::vector<MooseVariableFieldBase *>> _elem_vars;
203
204 // Storage for AuxScalarKernel objects
206
207 // Storage for AuxKernel objects
211
212 // Storage for VectorAuxKernel objects
215
216 // Storage for ArrayAuxKernel objects
219
220#ifdef MOOSE_KOKKOS_ENABLED
221 // Storage for KokkosAuxKernel objects
224#endif
225
228 friend class FlagElementsThread;
233
234 NumericVector<Number> & solutionInternal() const override { return *_sys.solution; }
235};
236
242
248
254
260
266
272
278
279#ifdef MOOSE_KOKKOS_ENABLED
285
291#endif
boundary_id_type BoundaryID
AuxKernelTempl< Real > AuxKernel
AuxKernelTempl< RealVectorValue > VectorAuxKernel
AuxKernelTempl< RealEigenVector > ArrayAuxKernel
unsigned int THREAD_ID
Definition MooseTypes.h:237
Base class for auxiliary kernels.
Base class for creating new auxiliary kernels and auxiliary boundary conditions.
Definition AuxKernel.h:28
Base class for making kernels that work on auxiliary scalar variables.
A system that holds auxiliary variables.
virtual void copyCurrentIntoPreviousNL()
Copies the current solution into the previous nonlinear iteration solution.
NumericVector< Number > & solutionInternal() const override
Internal getter for solution owned by libMesh.
bool needMaterialOnSide(BoundaryID bnd_id)
Indicated whether this system needs material properties on boundaries.
virtual void jacobianSetup() override
virtual void residualSetup() override
virtual libMesh::System & sys()
void computeScalarVars(ExecFlagType type)
void addKernel(const std::string &kernel_name, const std::string &name, InputParameters &parameters)
Adds an auxiliary kernel.
ExecuteMooseObjectWarehouse< ArrayAuxKernel > _nodal_array_aux_storage
void clearScalarVariableCoupleableTags()
virtual void compute(ExecFlagType type) override
Compute auxiliary variables.
void kokkosCompute(ExecFlagType type)
virtual void copyAdditionalStateBackwards(Moose::SolutionIterationType iteration_type, bool skip_current_to_old) override
Copy system-owned state not represented by solution vectors.
void computeMortarNodalVars(ExecFlagType type)
const ExecuteMooseObjectWarehouse< AuxKernelBase > & kokkosElemAuxWarehouse() const
void computeElementalVars(ExecFlagType type)
void computeElementalVarsHelper(const MooseObjectWarehouse< AuxKernelType > &warehouse)
const NumericVector< Number > * _current_solution
solution vector from nonlinear solver
const ExecuteMooseObjectWarehouse< AuxKernel > & mortarNodalAuxWarehouse() const
virtual const libMesh::System & system() const override
virtual void subdomainSetup() override
void addKokkosKernel(const std::string &kernel_name, const std::string &name, InputParameters &parameters)
const ExecuteMooseObjectWarehouse< AuxKernelBase > & kokkosNodalAuxWarehouse() const
ExecuteMooseObjectWarehouse< AuxKernelBase > _kokkos_elemental_aux_storage
virtual libMesh::Order getMinQuadratureOrder() override
Get the minimum quadrature order for evaluating elemental auxiliary variables.
virtual void initSolutionState() override
Initializes the solution state.
ExecuteMooseObjectWarehouse< AuxKernel > _elemental_aux_storage
void computeNodalVecVars(ExecFlagType type)
void variableWiseRelativeSolutionDifferenceNorm(std::vector< Number > &var_diffs) const
Computes and stores ||current - old|| / ||current|| for each variable in the given vector.
void setScalarVariableCoupleableTags(ExecFlagType type)
const ExecuteMooseObjectWarehouse< VectorAuxKernel > & nodalVectorAuxWarehouse() const
std::set< std::string > getDependObjects()
virtual void customSetup(const ExecFlagType &exec_type) override
ExecuteMooseObjectWarehouse< ArrayAuxKernel > _elemental_array_aux_storage
ExecuteMooseObjectWarehouse< VectorAuxKernel > _elemental_vec_aux_storage
ExecuteMooseObjectWarehouse< AuxKernel > _nodal_aux_storage
void computeElementalVecVars(ExecFlagType type)
const ExecuteMooseObjectWarehouse< AuxKernel > & nodalAuxWarehouse() const
ExecuteMooseObjectWarehouse< VectorAuxKernel > _nodal_vec_aux_storage
virtual void restoreAdditionalStates() override
Restore system-owned state not represented by solution vectors.
void addScalarKernel(const std::string &kernel_name, const std::string &name, InputParameters &parameters)
Adds a scalar kernel.
virtual void reinitElem(const Elem *elem, THREAD_ID tid) override
Reinit an element assembly info.
ExecuteMooseObjectWarehouse< AuxKernel > _mortar_nodal_aux_storage
virtual libMesh::System & system() override
Get the reference to the libMesh system.
virtual ~AuxiliarySystem()
virtual void addVariable(const std::string &var_type, const std::string &name, InputParameters &parameters) override
Canonical method for adding a variable.
ExecuteMooseObjectWarehouse< AuxKernelBase > _kokkos_nodal_aux_storage
const NumericVector< Number > *const & currentSolution() const override
The solution vector that is currently being operated on.
const ExecuteMooseObjectWarehouse< VectorAuxKernel > & elemVectorAuxWarehouse() const
void computeElementalArrayVars(ExecFlagType type)
void computeNodalVars(ExecFlagType type)
virtual void updateActive(THREAD_ID tid)
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< MooseVariableFieldBase * > > _elem_vars
Elemental variables.
const ExecuteMooseObjectWarehouse< ArrayAuxKernel > & nodalArrayAuxWarehouse() const
const ExecuteMooseObjectWarehouse< ArrayAuxKernel > & elemArrayAuxWarehouse() const
std::vector< std::vector< MooseVariableFEBase * > > _nodal_vars
const ExecuteMooseObjectWarehouse< AuxKernel > & elemAuxWarehouse() const
virtual void serializeSolution()
ExecuteMooseObjectWarehouse< AuxScalarKernel > _aux_scalar_storage
libMesh::System & _sys
virtual void reinitElemFace(const Elem *elem, unsigned int side, THREAD_ID tid) override
Reinit assembly info for a side of an element.
void computeNodalArrayVars(ExecFlagType type)
virtual void timestepSetup() override
virtual void initialSetup() override
Setup Functions.
std::vector< NumericVector< Number > * > _solution_state
The current states of the solution (0 = current, 1 = old, etc)
virtual void reinit() override
Reinitialize the system when the degrees of freedom in this system have changed.
void computeNodalVarsHelper(const MooseObjectWarehouse< AuxKernelType > &warehouse)
A class for storing MooseObjects based on execution flag.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
Registration, update, and allocation logic for linear finite-volume cell gradients.
void updateFVGradient(const LinearFVGradientReader &reader)
Update a registered gradient reader explicitly.
LinearFVGradientReader registerFVGradient(unsigned int variable_number, const FVGradientMethod &method, unsigned int oldest_state=0)
Register a variable for gradient values produced by a method object.
Class for containing MooseEnum item information.
A storage container for MooseObjects that inherit from SetupInterface.
Interface for objects interacting with the PerfGraph.
Base class for a system (of equations)
Definition SystemBase.h:87
SubProblem & subproblem()
Definition SystemBase.h:102
virtual const std::string & name() const
Base class for time integrators.
std::unique_ptr< NumericVector< Number > > solution
SolutionIterationType
Definition MooseTypes.h:270
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...