www.mooseframework.org
AuxiliarySystem.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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/explicit_system.h"
18 #include "libmesh/transient_system.h"
19 
20 // Forward declarations
21 template <typename ComputeValueType>
25 class FEProblemBase;
26 class TimeIntegrator;
27 class AuxScalarKernel;
28 
29 // libMesh forward declarations
30 namespace libMesh
31 {
32 template <typename T>
33 class NumericVector;
34 }
35 
41 {
42 public:
43  AuxiliarySystem(FEProblemBase & subproblem, const std::string & name);
44  virtual ~AuxiliarySystem();
45 
46  virtual void init() override;
47  virtual void addExtraVectors() override;
48 
49  virtual void initialSetup();
50  virtual void timestepSetup();
51  virtual void subdomainSetup();
52  virtual void residualSetup();
53  virtual void jacobianSetup();
54  virtual void updateActive(THREAD_ID tid);
55 
56  virtual void addVariable(const std::string & var_name,
57  const FEType & type,
58  Real scale_factor,
59  const std::set<SubdomainID> * const active_subdomains = NULL) override;
60 
67  void addTimeIntegrator(const std::string & type,
68  const std::string & name,
69  InputParameters parameters) override;
71 
76  void addDotVectors();
77 
84  void
85  addKernel(const std::string & kernel_name, const std::string & name, InputParameters parameters);
86 
93  void addScalarKernel(const std::string & kernel_name,
94  const std::string & name,
95  InputParameters parameters);
96 
97  virtual void reinitElem(const Elem * elem, THREAD_ID tid) override;
98  virtual void
99  reinitElemFace(const Elem * elem, unsigned int side, BoundaryID bnd_id, THREAD_ID tid) override;
100 
101  const NumericVector<Number> * const & currentSolution() const override
102  {
103  _current_solution = _sys.current_local_solution.get();
104  return _current_solution;
105  }
106 
107  NumericVector<Number> * solutionUDot() override { return _u_dot; }
108  NumericVector<Number> * solutionUDotDot() override { return _u_dotdot; }
109  NumericVector<Number> * solutionUDotOld() override { return _u_dot_old; }
110  NumericVector<Number> * solutionUDotDotOld() override { return _u_dotdot_old; }
111  const NumericVector<Number> * solutionUDot() const override { return _u_dot; }
112  const NumericVector<Number> * solutionUDotDot() const override { return _u_dotdot; }
113  const NumericVector<Number> * solutionUDotOld() const override { return _u_dot_old; }
114  const NumericVector<Number> * solutionUDotDotOld() const override { return _u_dotdot_old; }
115 
116  virtual void serializeSolution();
117  virtual NumericVector<Number> & serializedSolution() override;
118 
119  // This is an empty function since the Aux system doesn't have a matrix!
120  virtual void augmentSparsity(SparsityPattern::Graph & /*sparsity*/,
121  std::vector<dof_id_type> & /*n_nz*/,
122  std::vector<dof_id_type> & /*n_oz*/) override;
123 
128  virtual void compute(ExecFlagType type);
129 
135  std::set<std::string> getDependObjects(ExecFlagType type);
136  std::set<std::string> getDependObjects();
148  NumericVector<Number> &
149  addVector(const std::string & vector_name, const bool project, const ParallelType type) override;
150 
154  virtual Order getMinQuadratureOrder() override;
155 
160  bool needMaterialOnSide(BoundaryID bnd_id);
161 
162  NumericVector<Number> & solution() override { return *_sys.solution; }
163  NumericVector<Number> & solutionOld() override { return *_sys.old_local_solution; }
164  NumericVector<Number> & solutionOlder() override { return *_sys.older_local_solution; }
165  NumericVector<Number> * solutionPreviousNewton() override { return _solution_previous_nl; }
166 
167  const NumericVector<Number> & solution() const override { return *_sys.solution; }
168  const NumericVector<Number> & solutionOld() const override { return *_sys.old_local_solution; }
169  const NumericVector<Number> & solutionOlder() const override
170  {
171  return *_sys.older_local_solution;
172  }
173  const NumericVector<Number> * solutionPreviousNewton() const override
174  {
175  return _solution_previous_nl;
176  }
177 
178  virtual TransientExplicitSystem & sys() { return _sys; }
179 
180  virtual System & system() override { return _sys; }
181  virtual const System & system() const override { return _sys; }
182 
183  virtual void setPreviousNewtonSolution();
184 
186 
188 
189  // protected:
195 
196  template <typename AuxKernelType>
198  const std::vector<std::vector<MooseVariableFEBase *>> & vars,
199  const PerfID timer);
200 
201  template <typename AuxKernelType>
203  const std::vector<std::vector<MooseVariableFEBase *>> & vars,
204  const PerfID timer);
205 
207 
209 
211  mutable const NumericVector<Number> * _current_solution;
213  NumericVector<Number> & _serialized_solution;
215  NumericVector<Number> * _solution_previous_nl;
217  std::shared_ptr<TimeIntegrator> _time_integrator;
219  NumericVector<Number> * _u_dot;
221  NumericVector<Number> * _u_dotdot;
222 
224  NumericVector<Number> * _u_dot_old;
226  NumericVector<Number> * _u_dotdot_old;
227 
230 
231  // Variables
232  std::vector<std::vector<MooseVariableFEBase *>> _nodal_vars;
233  std::vector<std::vector<MooseVariableFEBase *>> _nodal_std_vars;
234  std::vector<std::vector<MooseVariableFEBase *>> _nodal_vec_vars;
235 
236  std::vector<std::vector<MooseVariableFEBase *>> _elem_vars;
237  std::vector<std::vector<MooseVariableFEBase *>> _elem_std_vars;
238  std::vector<std::vector<MooseVariableFEBase *>> _elem_vec_vars;
239 
240  // Storage for AuxScalarKernel objects
242 
243  // Storage for AuxKernel objects
246 
247  // Storage for VectorAuxKernel objects
250 
257 
259  friend class ComputeMarkerThread;
260  friend class FlagElementsThread;
265 };
266 
std::vector< std::vector< MooseVariableFEBase * > > _elem_std_vars
ExecuteMooseObjectWarehouse< AuxKernel > _nodal_aux_storage
NumericVector< Number > & _serialized_solution
Serialized version of the solution vector.
void computeScalarVars(ExecFlagType type)
std::vector< std::vector< MooseVariableFEBase * > > _elem_vec_vars
NumericVector< Number > * _u_dotdot
solution vector for u^dotdot
const NumericVector< Number > * solutionPreviousNewton() const override
virtual void augmentSparsity(SparsityPattern::Graph &, std::vector< dof_id_type > &, std::vector< dof_id_type > &) override
Will modify the sparsity pattern to add logical geometric connections.
NumericVector< Number > * _u_dot
solution vector for u^dot
const NumericVector< Number > * solutionUDot() const override
AuxiliarySystem(FEProblemBase &subproblem, const std::string &name)
virtual void updateActive(THREAD_ID tid)
const PerfID _compute_elemental_vec_vars_timer
const NumericVector< Number > *const & currentSolution() const override
The solution vector that is currently being operated on.
virtual TransientExplicitSystem & sys()
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
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:92
ExecuteMooseObjectWarehouse< AuxScalarKernel > _aux_scalar_storage
virtual void addExtraVectors() override
Method called during initialSetup to add extra system vector if they are required by the simulation...
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.
const NumericVector< Number > * solutionUDotDot() const override
NumericVector< Number > & solutionOld() override
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
virtual void residualSetup()
unsigned int PerfID
Definition: MooseTypes.h:163
void addDotVectors()
Adds u_dot, u_dotdot, u_dot_old and u_dotdot_old vectors if requested by the time integrator...
virtual void timestepSetup()
NumericVector< Number > * solutionUDot() override
const PerfID _compute_nodal_vars_timer
virtual const std::string & name() const
Definition: SystemBase.C:1088
const PerfID _compute_nodal_vec_vars_timer
void setScalarVariableCoupleableTags(ExecFlagType type)
void clearScalarVariableCoupleableTags()
std::set< std::string > getDependObjects()
void computeElementalVars(ExecFlagType type)
virtual void setPreviousNewtonSolution()
NumericVector< Number > & addVector(const std::string &vector_name, const bool project, const ParallelType type) override
Adds a solution length vector to the system.
Base class for making kernels that work on auxiliary scalar variables.
std::vector< std::vector< MooseVariableFEBase * > > _nodal_std_vars
const NumericVector< Number > & solution() const override
boundary_id_type BoundaryID
virtual void jacobianSetup()
virtual void addTimeIntegrator(const std::string &, const std::string &, InputParameters)
Definition: SystemBase.h:721
FEProblemBase & _fe_problem
const NumericVector< Number > & solutionOlder() const override
virtual Order getMinQuadratureOrder() override
Get the minimum quadrature order for evaluating elemental auxiliary variables.
NumericVector< Number > & solution() override
TransientSystem< ExplicitSystem > TransientExplicitSystem
std::vector< std::vector< MooseVariableFEBase * > > _nodal_vec_vars
void computeNodalVarsHelper(const MooseObjectWarehouse< AuxKernelType > &warehouse, const std::vector< std::vector< MooseVariableFEBase *>> &vars, const PerfID timer)
void computeElementalVarsHelper(const MooseObjectWarehouse< AuxKernelType > &warehouse, const std::vector< std::vector< MooseVariableFEBase *>> &vars, const PerfID timer)
NumericVector< Number > * solutionUDotDot() override
virtual SubProblem & subproblem()
Definition: SystemBase.h:105
const NumericVector< Number > * solutionUDotOld() const override
NumericVector< Number > * solutionUDotOld() override
const PerfID _compute_elemental_vars_timer
NumericVector< Number > * solutionUDotDotOld() override
TransientExplicitSystem & _sys
Interface for objects that needs transient capabilities.
const PerfID _compute_scalar_vars_timer
Timers.
void addTimeIntegrator(const std::string &type, const std::string &name, InputParameters parameters) override
Add a time integrator.
AuxKernelTempl< RealVectorValue > VectorAuxKernel
virtual const System & system() const override
bool _need_serialized_solution
Whether or not a copy of the residual needs to be made.
std::vector< std::vector< MooseVariableFEBase * > > _nodal_vars
virtual void compute(ExecFlagType type)
Compute auxiliary variables.
ExecuteMooseObjectWarehouse< VectorAuxKernel > _nodal_vec_aux_storage
NumericVector< Number > * _u_dot_old
Old solution vector for u^dot.
const NumericVector< Number > & solutionOld() const override
MatType type
Base class for time integrators.
std::vector< std::vector< MooseVariableFEBase * > > _elem_vars
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:21
virtual System & system() override
Get the reference to the libMesh system.
void computeNodalVars(ExecFlagType type)
void addScalarKernel(const std::string &kernel_name, const std::string &name, InputParameters parameters)
Adds a scalar kernel.
NumericVector< Number > * solutionPreviousNewton() override
virtual void reinitElemFace(const Elem *elem, unsigned int side, BoundaryID bnd_id, THREAD_ID tid) override
Reinit assembly info for a side of an element.
ExecuteMooseObjectWarehouse< AuxKernel > _elemental_aux_storage
virtual NumericVector< Number > & serializedSolution() override
Returns a reference to a serialized version of the solution vector for this subproblem.
Base class for creating new auxiliary kernels and auxiliary boundary conditions.
Definition: AuxKernel.h:33
NumericVector< Number > & solutionOlder() override
const NumericVector< Number > * solutionUDotDotOld() const override
virtual void serializeSolution()
void computeNodalVecVars(ExecFlagType type)
virtual void initialSetup()
AuxKernelTempl< Real > AuxKernel
virtual void addVariable(const std::string &var_name, const FEType &type, Real scale_factor, const std::set< SubdomainID > *const active_subdomains=NULL) override
Adds a variable to the system.
ExecuteMooseObjectWarehouse< VectorAuxKernel > _elemental_vec_aux_storage
NumericVector< Number > * _u_dotdot_old
Old solution vector for u^dotdot.
virtual void init() override
Initialize the system.
NumericVector< Number > * _solution_previous_nl
Solution vector of the previous nonlinear iterate.
virtual ~AuxiliarySystem()
A system that holds auxiliary variables.
std::shared_ptr< TimeIntegrator > _time_integrator
Time integrator.
void computeElementalVecVars(ExecFlagType type)
unsigned int THREAD_ID
Definition: MooseTypes.h:161
void addKernel(const std::string &kernel_name, const std::string &name, InputParameters parameters)
Adds an auxiliary kernel.
virtual void subdomainSetup()