https://mooseframework.inl.gov
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
22 class AuxKernelBase;
23 template <typename ComputeValueType>
28 class FEProblemBase;
29 class TimeIntegrator;
30 class AuxScalarKernel;
31 
32 // libMesh forward declarations
33 namespace libMesh
34 {
35 template <typename T>
36 class NumericVector;
37 }
38 
43 class AuxiliarySystem : public SystemBase,
44  public PerfGraphInterface,
46 {
47 public:
48  AuxiliarySystem(FEProblemBase & subproblem, const std::string & name);
49  virtual ~AuxiliarySystem();
50 
51  virtual void initialSetup() override;
52  virtual void reinit() override;
53  virtual void timestepSetup() override;
54  virtual void customSetup(const ExecFlagType & exec_type) override;
55  virtual void subdomainSetup() override;
56  virtual void residualSetup() override;
57  virtual void jacobianSetup() override;
58  virtual void updateActive(THREAD_ID tid);
59 
60  virtual void addVariable(const std::string & var_type,
61  const std::string & name,
62  InputParameters & parameters) override;
63 
70  void addKernel(const std::string & kernel_name,
71  const std::string & name,
72  InputParameters & parameters);
73 
74 #ifdef MOOSE_KOKKOS_ENABLED
75  void addKokkosKernel(const std::string & kernel_name,
76  const std::string & name,
77  InputParameters & parameters);
78 #endif
79 
86  void addScalarKernel(const std::string & kernel_name,
87  const std::string & name,
88  InputParameters & parameters);
89 
90  virtual void reinitElem(const Elem * elem, THREAD_ID tid) override;
91  virtual void reinitElemFace(const Elem * elem, unsigned int side, THREAD_ID tid) override;
92 
93  const NumericVector<Number> * const & currentSolution() const override
94  {
95  return _current_solution;
96  }
97 
98  virtual void serializeSolution();
99 
100  // This is an empty function since the Aux system doesn't have a matrix!
101  virtual void augmentSparsity(libMesh::SparsityPattern::Graph & /*sparsity*/,
102  std::vector<dof_id_type> & /*n_nz*/,
103  std::vector<dof_id_type> & /*n_oz*/) override;
104 
109  virtual void compute(ExecFlagType type) override;
110 
111 #ifdef MOOSE_KOKKOS_ENABLED
112  void kokkosCompute(ExecFlagType type);
113 #endif
114 
120  std::set<std::string> getDependObjects(ExecFlagType type);
121  std::set<std::string> getDependObjects();
122 
126  virtual libMesh::Order getMinQuadratureOrder() override;
127 
132  bool needMaterialOnSide(BoundaryID bnd_id);
133 
134  virtual libMesh::System & sys() { return _sys; }
135 
136  virtual libMesh::System & system() override { return _sys; }
137  virtual const libMesh::System & system() const override { return _sys; }
138 
141 
143  virtual void copyCurrentIntoPreviousNL();
144 
146 
148 
153 
157 
158 #ifdef MOOSE_KOKKOS_ENABLED
161 #endif
162 
165  void variableWiseRelativeSolutionDifferenceNorm(std::vector<Number> & var_diffs) const;
166 
167 protected:
168  void computeScalarVars(ExecFlagType type);
169  void computeNodalVars(ExecFlagType type);
176 
177  template <typename AuxKernelType>
179 
180  template <typename AuxKernelType>
182 
184 
187 
189  std::vector<NumericVector<Number> *> _solution_state;
190 
191  // Variables
192  std::vector<std::vector<MooseVariableFEBase *>> _nodal_vars;
193 
195 
198  std::vector<std::vector<MooseVariableFieldBase *>> _elem_vars;
200 
201  // Storage for AuxScalarKernel objects
203 
204  // Storage for AuxKernel objects
208 
209  // Storage for VectorAuxKernel objects
212 
213  // Storage for ArrayAuxKernel objects
216 
217 #ifdef MOOSE_KOKKOS_ENABLED
218  // Storage for KokkosAuxKernel objects
221 #endif
222 
224  friend class ComputeMarkerThread;
225  friend class FlagElementsThread;
230 
231  NumericVector<Number> & solutionInternal() const override { return *_sys.solution; }
232 };
233 
236 {
237  return _nodal_aux_storage;
238 }
239 
242 {
244 }
245 
248 {
249  return _nodal_vec_aux_storage;
250 }
251 
254 {
256 }
257 
260 {
261  return _elemental_aux_storage;
262 }
263 
266 {
268 }
269 
272 {
274 }
275 
276 #ifdef MOOSE_KOKKOS_ENABLED
279 {
281 }
282 
285 {
287 }
288 #endif
ExecuteMooseObjectWarehouse< AuxKernel > _nodal_aux_storage
ExecuteMooseObjectWarehouse< AuxKernel > _mortar_nodal_aux_storage
virtual void timestepSetup() override
void computeNodalVarsHelper(const MooseObjectWarehouse< AuxKernelType > &warehouse)
Base class for auxiliary kernels.
Definition: AuxKernelBase.h:42
void computeScalarVars(ExecFlagType type)
const ExecuteMooseObjectWarehouse< VectorAuxKernel > & nodalVectorAuxWarehouse() const
virtual void copyCurrentIntoPreviousNL()
Copies the current solution into the previous nonlinear iteration solution.
const ExecuteMooseObjectWarehouse< AuxKernel > & mortarNodalAuxWarehouse() const
virtual void reinit() override
Reinitialize the system when the degrees of freedom in this system have changed.
AuxiliarySystem(FEProblemBase &subproblem, const std::string &name)
ExecuteMooseObjectWarehouse< ArrayAuxKernel > _nodal_array_aux_storage
virtual void updateActive(THREAD_ID tid)
const NumericVector< Number > *const & currentSolution() const override
The solution vector that is currently being operated on.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
AuxKernelTempl< RealEigenVector > ArrayAuxKernel
void computeElementalVarsHelper(const MooseObjectWarehouse< AuxKernelType > &warehouse)
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
const NumericVector< Number > * _current_solution
solution vector from nonlinear solver
Base class for a system (of equations)
Definition: SystemBase.h:85
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.
virtual void residualSetup() override
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
void computeMortarNodalVars(ExecFlagType type)
A class for storing MooseObjects based on execution flag.
const ExecuteMooseObjectWarehouse< AuxKernel > & nodalAuxWarehouse() const
const ExecuteMooseObjectWarehouse< AuxKernel > & elemAuxWarehouse() const
const std::vector< std::unique_ptr< libMesh::NumericVector< libMesh::Number > > > & linearFVLimitedGradientContainer(const Moose::FV::GradientLimiterType limiter_type) const
Access the stored raw or limited cell-centered gradient components.
void requestLinearFVLimitedGradients(const Moose::FV::GradientLimiterType limiter_type, unsigned int variable_number)
Request storage and assembly of limiter-specific cell gradients.
virtual const std::string & name() const
Definition: SystemBase.C:1342
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
void computeNodalArrayVars(ExecFlagType type)
void computeElementalVars(ExecFlagType type)
Base class for making kernels that work on auxiliary scalar variables.
boundary_id_type BoundaryID
const ExecuteMooseObjectWarehouse< AuxKernelBase > & kokkosElemAuxWarehouse() const
SubProblem & subproblem()
Definition: SystemBase.h:102
virtual libMesh::Order getMinQuadratureOrder() override
Get the minimum quadrature order for evaluating elemental auxiliary variables.
std::unique_ptr< NumericVector< Number > > solution
const ExecuteMooseObjectWarehouse< VectorAuxKernel > & elemVectorAuxWarehouse() const
void kokkosCompute(ExecFlagType type)
const ExecuteMooseObjectWarehouse< AuxKernelBase > & kokkosNodalAuxWarehouse() const
virtual void addVariable(const std::string &var_type, const std::string &name, InputParameters &parameters) override
Canonical method for adding a variable.
Interface for objects interacting with the PerfGraph.
std::vector< NumericVector< Number > * > _solution_state
The current states of the solution (0 = current, 1 = old, etc)
virtual const libMesh::System & system() const override
AuxKernelTempl< RealVectorValue > VectorAuxKernel
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 libMesh::System & sys()
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
Base class for time integrators.
void addKernel(const std::string &kernel_name, const std::string &name, InputParameters &parameters)
Adds an auxiliary kernel.
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:18
virtual void compute(ExecFlagType type) override
Compute auxiliary variables.
void addKokkosKernel(const std::string &kernel_name, const std::string &name, InputParameters &parameters)
void computeNodalVars(ExecFlagType type)
const ExecuteMooseObjectWarehouse< ArrayAuxKernel > & elemArrayAuxWarehouse() const
void addScalarKernel(const std::string &kernel_name, const std::string &name, InputParameters &parameters)
Adds a scalar kernel.
ExecuteMooseObjectWarehouse< AuxKernel > _elemental_aux_storage
Base class for creating new auxiliary kernels and auxiliary boundary conditions.
Definition: AuxKernel.h:17
virtual void customSetup(const ExecFlagType &exec_type) override
virtual void serializeSolution()
void computeNodalVecVars(ExecFlagType type)
virtual libMesh::System & system() override
Get the reference to the libMesh system.
AuxKernelTempl< Real > AuxKernel
void computeElementalArrayVars(ExecFlagType type)
const ExecuteMooseObjectWarehouse< ArrayAuxKernel > & nodalArrayAuxWarehouse() const
ExecuteMooseObjectWarehouse< VectorAuxKernel > _elemental_vec_aux_storage
libMesh::System & _sys
A system that holds auxiliary variables.
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)
unsigned int THREAD_ID
Definition: MooseTypes.h:237
NumericVector< Number > & solutionInternal() const override
Internal getter for solution owned by libMesh.
virtual void subdomainSetup() override
Shared storage and allocation logic for linear finite-volume cell gradients for variables in the syst...