14#include "libmesh/quadrature.h"
15#include "libmesh/fe_interface.h"
24 "PorousFlowDictator",
"The UserObject that holds the list of PorousFlow variable names");
26 "at_nodes",
false,
"Evaluate Material properties at nodes instead of quadpoints");
28 params.
addClassDescription(
"This generalises MOOSE's Material class to allow for Materials that "
29 "hold information related to the nodes in the finite element");
33 params.
set<
bool>(
"_force_stateful_init") =
true;
40 _nodal_material(getParam<bool>(
"at_nodes")),
42 _pressure_variable_name(
"pressure_variable"),
43 _saturation_variable_name(
"saturation_variable"),
44 _temperature_variable_name(
"temperature_variable"),
45 _mass_fraction_variable_name(
"mass_fraction_variable")
64 for (
const auto & param : coupled_var_params)
72 mooseError(
"This Material has at_nodes = true, so it reads '",
74 "' at the nodes, but the variable supplied to it ('",
76 "') is not a nodal (Lagrange) variable. A variable read at the nodes must be "
77 "LAGRANGE. Other coupled variables of a nodal Material may well be "
78 "element-local: those read at the quadpoints instead, such as a reference "
79 "temperature or mineral concentration, accept a CONSTANT MONOMIAL.");
100 if (!storage.hasStatefulProperties())
103 auto & stateful_prop_id_to_prop_id = storage.
statefulProps();
104 for (
const auto i : index_range(stateful_prop_id_to_prop_id))
106 const auto prop_id = stateful_prop_id_to_prop_id[i];
142 if (numnodes < _qrule->n_points())
148 for (
unsigned int qp = numnodes; qp <
_qrule->n_points(); ++qp)
149 props[prop_id].qpCopy(qp, props[prop_id], numnodes - 1);
195 props[prop_id].resize(new_size);
197 for (
const auto state : storage.statefulIndexRange())
222 mooseAssert(num_dofs <= _current_elem->
n_nodes(),
223 "A nodal Material would visit " << num_dofs <<
" nodes of an element that has only "
234 "First-order LAGRANGE has "
235 << num_dofs <<
" degrees of freedom on an element with "
237 <<
" vertices, so the assumption that they sit on the vertices, in order, does "
238 "not hold for this element type");
246 unsigned nearest_qp = 0;
247 Real smallest_dist = std::numeric_limits<Real>::max();
248 for (
const auto qp : make_range(
_qrule->n_points()))
251 if (this_dist < smallest_dist)
254 smallest_dist = this_dist;
virtual const VariableValue & coupledValue(const std::string &var_name, unsigned int comp=0) const
const std::vector< MooseVariableFieldBase * > & getCoupledMooseVars() const
const MooseVariableFieldBase * getFieldVar(const std::string &var_name, unsigned int comp) const
unsigned int coupledComponents(const std::string &var_name) const
virtual bool isCoupled(const std::string &var_name, unsigned int i=0) const
virtual const VariableValue & coupledDofValues(const std::string &var_name, unsigned int comp=0) const
virtual void computeQpProperties()
virtual void initStatefulProperties(const unsigned int n_points)
std::set< unsigned int > _supplied_prop_ids
void onlyResizeIfSmaller(bool flag)
const MaterialPropertyStorage & getMaterialPropertyStorage() const
const MaterialProperties & props(const unsigned int state=0) const
void resize(const std::size_t size, const WriteKey)
MaterialData & _material_data
const std::vector< unsigned int > & statefulProps() const
virtual void computeProperties() override
static InputParameters validParams()
const Elem *const & _current_elem
const QBase *const & _qrule
const MooseArray< Point > & _q_point
void mooseError(Args &&... args) const
virtual bool isNodal() const
This holds maps between the nonlinear variables used in a PorousFlow simulation and the variable numb...
void registerNodalVariable(const VariableName &var_name) const
Register a variable that a nodal Material reads by degree of freedom.
const std::optional< libMesh::FEType > & shareNodalVariableFEType() const
The FE type shared by every variable that nodal Materials read by degree of freedom,...
std::vector< unsigned int > _supplied_old_prop_ids
stateful material property ids that this material supplies
virtual void initStatefulProperties(unsigned int n_points) override
Correctly sizes nodal materials, then initialises using Material::initStatefulProperties.
static InputParameters validParams()
virtual void initialSetup() override
virtual void computeProperties() override
Correctly sizes nodal materials, then computes using Material::computeProperties.
unsigned nearestQP(unsigned nodenum) const
Find the nearest quadpoint to the node labelled by nodenum in the current element.
void computeNodalProperties()
Compute the material properties at each node, and if the number of nodes is less than the number of q...
const VariableValue & nodalOrQpValue(const std::string &var_name, unsigned int comp=0)
The values of a coupled variable for this Material to read: its degree-of-freedom values if this is a...
void sizeNodalProperties()
Resizes properties to be equal to max(number of nodes, number of quadpoints) in the current element.
PorousFlowMaterial(const InputParameters ¶meters)
unsigned int nodalDofCount() const
The number of nodes of the current element that carry a degree of freedom of the variables that nodal...
const PorousFlowDictator & _dictator
The variable names UserObject for the PorousFlow variables.
const bool _nodal_material
Whether the derived class holds nodal values.
void checkNodalVariables(const std::vector< std::string > &coupled_var_params) const
Error if this is a nodal Material but a variable supplied to one of the named coupled-variable parame...
bool hasValue(const std::size_t i) const
static unsigned int n_dofs(const unsigned int dim, const FEType &fe_t, const ElemType t)
VariableValueTempl< false > VariableValue
const dof_id_type n_nodes