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"
15 #include "PerfGraphInterface.h"
16 
17 #include "libmesh/system.h"
18 #include "libmesh/transient_system.h"
19 
20 // Forward declarations
21 class AuxKernelBase;
22 template <typename ComputeValueType>
27 class FEProblemBase;
28 class TimeIntegrator;
29 class AuxScalarKernel;
30 
31 // libMesh forward declarations
32 namespace libMesh
33 {
34 template <typename T>
35 class NumericVector;
36 }
37 
43 {
44 public:
45  AuxiliarySystem(FEProblemBase & subproblem, const std::string & name);
46  virtual ~AuxiliarySystem();
47 
48  virtual void initialSetup() override;
49  virtual void timestepSetup() override;
50  virtual void customSetup(const ExecFlagType & exec_type) override;
51  virtual void subdomainSetup() override;
52  virtual void residualSetup() override;
53  virtual void jacobianSetup() override;
54  virtual void updateActive(THREAD_ID tid);
55 
56  virtual void addVariable(const std::string & var_type,
57  const std::string & name,
58  InputParameters & parameters) override;
59 
66  void addKernel(const std::string & kernel_name,
67  const std::string & name,
68  InputParameters & parameters);
69 
70 #ifdef MOOSE_KOKKOS_ENABLED
71  void addKokkosKernel(const std::string & kernel_name,
72  const std::string & name,
73  InputParameters & parameters);
74 #endif
75 
82  void addScalarKernel(const std::string & kernel_name,
83  const std::string & name,
84  InputParameters & parameters);
85 
86  virtual void reinitElem(const Elem * elem, THREAD_ID tid) override;
87  virtual void reinitElemFace(const Elem * elem, unsigned int side, THREAD_ID tid) override;
88 
89  const NumericVector<Number> * const & currentSolution() const override
90  {
91  return _current_solution;
92  }
93 
94  virtual void serializeSolution();
95 
96  // This is an empty function since the Aux system doesn't have a matrix!
97  virtual void augmentSparsity(libMesh::SparsityPattern::Graph & /*sparsity*/,
98  std::vector<dof_id_type> & /*n_nz*/,
99  std::vector<dof_id_type> & /*n_oz*/) override;
100 
105  virtual void compute(ExecFlagType type) override;
106 
107 #ifdef MOOSE_KOKKOS_ENABLED
108  void kokkosCompute(ExecFlagType type);
109 #endif
110 
116  std::set<std::string> getDependObjects(ExecFlagType type);
117  std::set<std::string> getDependObjects();
118 
122  virtual libMesh::Order getMinQuadratureOrder() override;
123 
128  bool needMaterialOnSide(BoundaryID bnd_id);
129 
130  virtual libMesh::System & sys() { return _sys; }
131 
132  virtual libMesh::System & system() override { return _sys; }
133  virtual const libMesh::System & system() const override { return _sys; }
134 
136  virtual void copyCurrentIntoPreviousNL();
137 
139 
141 
145 
149 
150 #ifdef MOOSE_KOKKOS_ENABLED
153 #endif
154 
157  void variableWiseRelativeSolutionDifferenceNorm(std::vector<Number> & var_diffs) const;
158 
159 protected:
160  void computeScalarVars(ExecFlagType type);
161  void computeNodalVars(ExecFlagType type);
168 
169  template <typename AuxKernelType>
171 
172  template <typename AuxKernelType>
174 
176 
179 
181  std::vector<NumericVector<Number> *> _solution_state;
182 
183  // Variables
184  std::vector<std::vector<MooseVariableFEBase *>> _nodal_vars;
185 
187 
190  std::vector<std::vector<MooseVariableFieldBase *>> _elem_vars;
192 
193  // Storage for AuxScalarKernel objects
195 
196  // Storage for AuxKernel objects
200 
201  // Storage for VectorAuxKernel objects
204 
205  // Storage for ArrayAuxKernel objects
208 
209 #ifdef MOOSE_KOKKOS_ENABLED
210  // Storage for KokkosAuxKernel objects
213 #endif
214 
216  friend class ComputeMarkerThread;
217  friend class FlagElementsThread;
222 
223  NumericVector<Number> & solutionInternal() const override { return *_sys.solution; }
224 };
225 
228 {
229  return _nodal_aux_storage;
230 }
231 
234 {
235  return _nodal_vec_aux_storage;
236 }
237 
240 {
242 }
243 
246 {
247  return _elemental_aux_storage;
248 }
249 
252 {
254 }
255 
258 {
260 }
261 
262 #ifdef MOOSE_KOKKOS_ENABLED
265 {
267 }
268 
271 {
273 }
274 #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.
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:84
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
virtual const std::string & name() const
Definition: SystemBase.C:1340
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:101
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:209
NumericVector< Number > & solutionInternal() const override
Internal getter for solution owned by libMesh.
virtual void subdomainSetup() override