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 template <typename ComputeValueType>
26 class FEProblemBase;
27 class TimeIntegrator;
28 class AuxScalarKernel;
29 
30 // libMesh forward declarations
31 namespace libMesh
32 {
33 template <typename T>
34 class NumericVector;
35 }
36 
42 {
43 public:
44  AuxiliarySystem(FEProblemBase & subproblem, const std::string & name);
45  virtual ~AuxiliarySystem();
46 
47  virtual void initialSetup() override;
48  virtual void timestepSetup() override;
49  virtual void customSetup(const ExecFlagType & exec_type) override;
50  virtual void subdomainSetup() override;
51  virtual void residualSetup() override;
52  virtual void jacobianSetup() override;
53  virtual void updateActive(THREAD_ID tid);
54 
55  virtual void addVariable(const std::string & var_type,
56  const std::string & name,
57  InputParameters & parameters) override;
58 
65  void addKernel(const std::string & kernel_name,
66  const std::string & name,
67  InputParameters & parameters);
68 
75  void addScalarKernel(const std::string & kernel_name,
76  const std::string & name,
77  InputParameters & parameters);
78 
79  virtual void reinitElem(const Elem * elem, THREAD_ID tid) override;
80  virtual void reinitElemFace(const Elem * elem, unsigned int side, THREAD_ID tid) override;
81 
82  const NumericVector<Number> * const & currentSolution() const override
83  {
84  return _current_solution;
85  }
86 
87  virtual void serializeSolution();
88 
89  // This is an empty function since the Aux system doesn't have a matrix!
90  virtual void augmentSparsity(libMesh::SparsityPattern::Graph & /*sparsity*/,
91  std::vector<dof_id_type> & /*n_nz*/,
92  std::vector<dof_id_type> & /*n_oz*/) override;
93 
98  virtual void compute(ExecFlagType type) override;
99 
105  std::set<std::string> getDependObjects(ExecFlagType type);
106  std::set<std::string> getDependObjects();
107 
111  virtual libMesh::Order getMinQuadratureOrder() override;
112 
117  bool needMaterialOnSide(BoundaryID bnd_id);
118 
119  virtual libMesh::System & sys() { return _sys; }
120 
121  virtual libMesh::System & system() override { return _sys; }
122  virtual const libMesh::System & system() const override { return _sys; }
123 
125  virtual void copyCurrentIntoPreviousNL();
126 
128 
130 
134 
138 
141  void variableWiseRelativeSolutionDifferenceNorm(std::vector<Number> & var_diffs) const;
142 
143 protected:
144  void computeScalarVars(ExecFlagType type);
145  void computeNodalVars(ExecFlagType type);
152 
153  template <typename AuxKernelType>
155 
156  template <typename AuxKernelType>
158 
160 
163 
165  std::vector<NumericVector<Number> *> _solution_state;
166 
167  // Variables
168  std::vector<std::vector<MooseVariableFEBase *>> _nodal_vars;
169 
171 
174  std::vector<std::vector<MooseVariableFieldBase *>> _elem_vars;
176 
177  // Storage for AuxScalarKernel objects
179 
180  // Storage for AuxKernel objects
184 
185  // Storage for VectorAuxKernel objects
188 
189  // Storage for ArrayAuxKernel objects
192 
194  friend class ComputeMarkerThread;
195  friend class FlagElementsThread;
200 
201  NumericVector<Number> & solutionInternal() const override { return *_sys.solution; }
202 };
203 
206 {
207  return _nodal_aux_storage;
208 }
209 
212 {
213  return _nodal_vec_aux_storage;
214 }
215 
218 {
220 }
221 
224 {
225  return _elemental_aux_storage;
226 }
227 
230 {
232 }
233 
236 {
238 }
ExecuteMooseObjectWarehouse< AuxKernel > _nodal_aux_storage
ExecuteMooseObjectWarehouse< AuxKernel > _mortar_nodal_aux_storage
virtual void timestepSetup() override
void computeNodalVarsHelper(const MooseObjectWarehouse< AuxKernelType > &warehouse)
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:1330
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
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
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 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()
ExecuteMooseObjectWarehouse< VectorAuxKernel > _nodal_vec_aux_storage
std::vector< std::vector< MooseVariableFieldBase * > > _elem_vars
Elemental variables.
virtual void initialSetup() override
Setup Functions.
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 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:36
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
virtual ~AuxiliarySystem()
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