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
111 void kokkosCompute(ExecFlagType type, int group);
112
118#endif
119
125 std::set<std::string> getDependObjects(ExecFlagType type);
126 std::set<std::string> getDependObjects();
127
131 virtual libMesh::Order getMinQuadratureOrder() override;
132
137 bool needMaterialOnSide(BoundaryID bnd_id);
138
139 virtual libMesh::System & sys() { return _sys; }
140
141 virtual libMesh::System & system() override { return _sys; }
142 virtual const libMesh::System & system() const override { return _sys; }
143
146
148 virtual void copyCurrentIntoPreviousNL();
149
151
153
154#ifdef MOOSE_KOKKOS_ENABLED
157#endif
158
161 void variableWiseRelativeSolutionDifferenceNorm(std::vector<Number> & var_diffs) const;
162
163protected:
165 bool skip_current_to_old) override;
166 virtual void restoreAdditionalStates() override;
167
169 void computeNodalVars(ExecFlagType type, int group);
170 void computeMortarNodalVars(ExecFlagType type, int group);
171 void computeNodalVecVars(ExecFlagType type, int group);
172 void computeNodalArrayVars(ExecFlagType type, int group);
173 void computeElementalVars(ExecFlagType type, int group);
174 void computeElementalVecVars(ExecFlagType type, int group);
175 void computeElementalArrayVars(ExecFlagType type, int group);
176
177 template <typename AuxKernelType>
179
180 template <typename AuxKernelType>
182
192 std::vector<AuxKernelBase *> sortedAuxKernels(THREAD_ID tid, bool active_only);
193
195
197 const NumericVector<Number> * _current_solution;
198
200 std::vector<NumericVector<Number> *> _solution_state;
201
202 // Variables
203 std::vector<std::vector<MooseVariableFEBase *>> _nodal_vars;
204
206
209 std::vector<std::vector<MooseVariableFieldBase *>> _elem_vars;
211
212 // Storage for AuxScalarKernel objects
214
215#ifdef MOOSE_KOKKOS_ENABLED
216 // Storage for KokkosAuxKernel objects
219
230
233 std::map<ExecFlagType, std::vector<KokkosAuxStage>> _kokkos_aux_stages;
234#endif
235
238
241 friend class FlagElementsThread;
246
247 NumericVector<Number> & solutionInternal() const override { return *_sys.solution; }
248};
249
250#ifdef MOOSE_KOKKOS_ENABLED
256
262#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
void computeElementalVars(ExecFlagType type, int group)
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.
void clearScalarVariableCoupleableTags()
virtual void compute(ExecFlagType type) override
Compute auxiliary variables.
virtual void copyAdditionalStateBackwards(Moose::SolutionIterationType iteration_type, bool skip_current_to_old) override
Copy system-owned state not represented by solution vectors.
const ExecuteMooseObjectWarehouse< AuxKernelBase > & kokkosElemAuxWarehouse() const
const NumericVector< Number > * _current_solution
solution vector from nonlinear solver
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.
std::vector< AuxKernelBase * > sortedAuxKernels(THREAD_ID tid, bool active_only)
Get every AuxKernel, of any value type, on a thread, in dependency order.
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)
std::set< std::string > getDependObjects()
virtual void customSetup(const ExecFlagType &exec_type) override
void computeNodalVecVars(ExecFlagType type, int group)
void computeElementalVecVars(ExecFlagType type, int group)
void computeMortarNodalVars(ExecFlagType type, int group)
void buildKokkosAuxStages()
Group the active Kokkos auxiliary kernels of each execution flag into stages that can each be compute...
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.
virtual libMesh::System & system() override
Get the reference to the libMesh system.
virtual ~AuxiliarySystem()
std::set< int > _execution_order_groups
Execution order groups present within the simulation.
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.
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.
void computeNodalVarsHelper(const TheWarehouse::Query &query)
std::vector< std::vector< MooseVariableFEBase * > > _nodal_vars
virtual void serializeSolution()
void computeNodalVars(ExecFlagType type, int group)
std::map< ExecFlagType, std::vector< KokkosAuxStage > > _kokkos_aux_stages
Active Kokkos auxiliary kernels of each execution flag grouped into stages, where a kernel coupling t...
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 computeElementalArrayVars(ExecFlagType type, int group)
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 kokkosCompute(ExecFlagType type, int group)
void computeElementalVarsHelper(const TheWarehouse::Query &query)
void computeNodalArrayVars(ExecFlagType type, int group)
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
QueryCache is a convenient way to construct and pass around (possible partially constructed) warehous...
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...
Kokkos auxiliary kernels computed in a single device pass.
MooseObjectWarehouse< AuxKernelBase > nodal
Nodal kernels, which read coupled values from DOFs and are computed first.
MooseObjectWarehouse< AuxKernelBase > elemental
Elemental kernels, which read coupled values from the cached quadrature point values.