24 "Discretizes a diffusion equation with the continuous Galerkin finite element method");
26 "use_automatic_differentiation",
28 "Whether to use automatic differentiation for all the terms in the equation");
38 _use_ad(getParam<bool>(
"use_automatic_differentiation"))
48 std::string kernel_type;
50 kernel_type =
_use_ad ?
"ADMatDiffusion" :
"MatDiffusion";
53 const auto & d = getParam<MooseFunctorName>(
"diffusivity_functor");
55 kernel_type =
"FunctionDiffusion";
58 "No diffusion kernel implemented for the diffusivity type of ",
62 kernel_type =
_use_ad ?
"ADDiffusion" :
"Diffusion";
64 params.
set<NonlinearVariableName>(
"variable") =
_var_name;
70 params.
set<MaterialPropertyName>(
"diffusivity") =
71 getParam<MaterialPropertyName>(
"diffusivity_matprop");
73 params.
set<FunctionName>(
"function") = getParam<MooseFunctorName>(
"diffusivity_functor");
82 std::string kernel_type;
83 const auto & source = getParam<MooseFunctorName>(
"source_functor");
85 getProblem().hasPostprocessorValueByName(source))
86 kernel_type =
_use_ad ?
"ADBodyForce" :
"BodyForce";
88 kernel_type =
_use_ad ?
"ADCoupledForce" :
"CoupledForce";
91 "No kernel defined for a source term in CG for the type of '",
96 params.
set<NonlinearVariableName>(
"variable") =
_var_name;
100 const auto coef = getParam<Real>(
"source_coef");
102 params.
set<Real>(
"value") = MooseUtils::convert<Real>(source) * coef;
105 params.
set<Real>(
"value") = coef;
106 params.
set<FunctionName>(
"function") = source;
110 params.
set<Real>(
"value") = coef;
111 params.
set<PostprocessorName>(
"postprocessor") = source;
115 params.
set<Real>(
"coef") = coef;
116 params.
set<std::vector<VariableName>>(
"v") = {source};
125 const std::string kernel_type =
_use_ad ?
"ADTimeDerivative" :
"TimeDerivative";
127 params.
set<NonlinearVariableName>(
"variable") =
_var_name;
138 const auto & boundary_fluxes = getParam<std::vector<MooseFunctorName>>(
"boundary_fluxes");
141 const auto & bc_flux = boundary_fluxes[i];
145 std::string bc_type =
"";
147 bc_type =
_use_ad ?
"ADNeumannBC" :
"NeumannBC";
149 bc_type =
"CoupledVarNeumannBC";
151 bc_type =
_use_ad ?
"ADFunctionNeumannBC" :
"FunctionNeumannBC";
152 else if (
getProblem().hasPostprocessorValueByName(bc_flux))
153 bc_type =
"PostprocessorNeumannBC";
155 bc_type =
"FunctorNeumannBC";
159 params.
set<NonlinearVariableName>(
"variable") =
_var_name;
164 params.
set<Real>(
"value") = MooseUtils::convert<Real>(bc_flux);
166 params.
set<std::vector<VariableName>>(
"v") = {bc_flux};
168 params.
set<FunctionName>(
"function") = bc_flux;
170 params.
set<PostprocessorName>(
"postprocessor") = bc_flux;
172 params.
set<MooseFunctorName>(
"functor") = bc_flux;
180 const auto & boundary_values = getParam<std::vector<MooseFunctorName>>(
"boundary_values");
183 const auto & bc_value = boundary_values[i];
185 std::string bc_type =
"";
187 bc_type =
_use_ad ?
"ADDirichletBC" :
"DirichletBC";
189 bc_type =
_use_ad ?
"ADMatchedValueBC" :
"MatchedValueBC";
191 bc_type =
_use_ad ?
"ADFunctionDirichletBC" :
"FunctionDirichletBC";
192 else if (
getProblem().hasPostprocessorValueByName(bc_value))
193 bc_type =
"PostprocessorDirichletBC";
195 bc_type =
"FunctorDirichletBC";
198 params.
set<NonlinearVariableName>(
"variable") =
_var_name;
203 params.
set<Real>(
"value") = MooseUtils::convert<Real>(bc_value);
205 params.
set<std::vector<VariableName>>(
"v") = {bc_value};
207 params.
set<FunctionName>(
"function") = bc_value;
209 params.
set<PostprocessorName>(
"postprocessor") = bc_value;
211 params.
set<MooseFunctorName>(
"functor") = bc_value;
229 const std::string variable_type =
"MooseVariable";
231 params.
set<
MooseEnum>(
"order") = getParam<MooseEnum>(
"variable_order");
241 const auto bc_type_fixed =
"FunctorDirichletBC";
243 const auto bc_type_flux =
"FunctorNeumannBC";
248 for (
const auto & bc_pair : comp_pair.second)
250 params_fixed.
set<NonlinearVariableName>(
"variable") =
_var_name;
251 params_flux.
set<NonlinearVariableName>(
"variable") =
_var_name;
253 const auto bc_type = bc_pair.second.second;
254 const auto functor_name = bc_pair.second.first;
255 params_fixed.
set<MooseFunctorName>(
"functor") = functor_name;
256 params_flux.
set<MooseFunctorName>(
"functor") = functor_name;
258 const auto surface_name = bc_pair.first.second;
259 params_fixed.
set<std::vector<BoundaryName>>(
"boundary") = {surface_name};
260 params_flux.
set<std::vector<BoundaryName>>(
"boundary") = {surface_name};
265 "_fixed_value_" + surface_name,
270 "_flux_" + surface_name,
273 mooseError(
"Boundary condition type not implemented");
registerDiffusionPhysicsBaseTasks("MooseApp", DiffusionCG)
registerMooseAction("MooseApp", DiffusionCG, "add_kernel")
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Creates all the objects needed to solve a diffusion equation with a continuous Galerkin finite elemen...
virtual void addFEBCs() override
virtual void addBoundaryConditionsFromComponents() override
static InputParameters validParams()
DiffusionCG(const InputParameters ¶meters)
virtual void addSolverVariables() override
The default implementation of these routines will do nothing as we do not expect all Physics to be de...
const bool _use_ad
Whether to use automatic differentiation or not.
virtual void addFEKernels() override
Base class to host all common parameters and attributes of Physics actions to solve the diffusion equ...
const std::vector< BoundaryName > & _neumann_boundaries
Boundaries on which a Neumann boundary condition is applied.
const VariableName & _var_name
Name of the diffused variable.
static InputParameters validParams()
const std::vector< BoundaryName > & _dirichlet_boundaries
Boundaries on which a Dirichlet boundary condition is applied.
virtual void addVariable(const std::string &var_type, const std::string &var_name, InputParameters ¶ms)
Canonical method for adding a non-linear variable.
bool hasPostprocessorValueByName(const PostprocessorName &name) const
Whether or not a Postprocessor value exists by a given name.
virtual void addBoundaryCondition(const std::string &bc_name, const std::string &name, InputParameters ¶meters)
virtual void addKernel(const std::string &kernel_name, const std::string &name, InputParameters ¶meters)
virtual bool hasFunction(const std::string &name, const THREAD_ID tid=0)
InputParameters getValidParams(const std::string &name) const
Get valid parameters for the object.
void paramError(const std::string ¶m, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
bool isParamSetByUser(const std::string &name) const
Test if the supplied parameter is set by a user, as opposed to not set or set to default.
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
static InputParameters validParams()
Base class to help creating an entire physics.
virtual FEProblemBase & getProblem()
Get the problem for this physics Useful to add objects to the simulation.
Factory & getFactory()
Get the factory for this physics The factory lets you get the parameters for objects.
bool shouldCreateTimeDerivative(const VariableName &var_name, const std::vector< SubdomainName > &blocks, const bool error_if_already_defined) const
Returns whether this Physics should create the variable.
void assignBlocks(InputParameters ¶ms, const std::vector< SubdomainName > &blocks) const
Set the blocks parameter to the input parameters of an object this Physics will create.
void reportPotentiallyMissedParameters(const std::vector< std::string > ¶m_names, const std::string &object_type, const std::string &object_name="") const
When this is called, we are knowingly not using the value of these parameters.
std::string prefix() const
Use prefix() to disambiguate names.
const SolverSystemName & getSolverSystem(unsigned int variable_index) const
Get the solver system for this variable index.
bool shouldCreateVariable(const VariableName &var_name, const std::vector< SubdomainName > &blocks, const bool error_if_aux)
Returns whether this Physics should create the variable.
std::vector< SubdomainName > _blocks
Keep track of the subdomains the Physics is defined on.
Interface class to help components interact with Physics.
std::map< std::string, std::map< std::pair< VariableName, BoundaryName >, std::pair< MooseFunctorName, ComponentBoundaryConditionInterface::BoundaryConditionType > > > _components_boundary_conditions
Map of components to variables and boundary conditions.
bool parsesToReal(const std::string &input, Real *parsed_real)