www.mooseframework.org
PorousFlowMaterial.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
7 
8 #include "PorousFlowMaterial.h"
9 #include "libmesh/quadrature.h"
10 #include <limits>
11 
12 template <>
13 InputParameters
15 {
16  InputParameters params = validParams<Material>();
17  params.addRequiredParam<UserObjectName>(
18  "PorousFlowDictator", "The UserObject that holds the list of Porous-Flow variable names");
19  params.addParam<bool>(
20  "at_nodes", false, "Evaluate Material properties at nodes instead of quadpoints");
21  params.addClassDescription("This generalises MOOSE's Material class to allow for Materials that "
22  "hold information related to the nodes in the finite element");
23  return params;
24 }
25 
26 PorousFlowMaterial::PorousFlowMaterial(const InputParameters & parameters)
27  : Material(parameters),
28  _nodal_material(getParam<bool>("at_nodes")),
29  _dictator(getUserObject<PorousFlowDictator>("PorousFlowDictator"))
30 {
31 }
32 
33 void
35 {
36  if (_nodal_material)
37  {
39  Material::initStatefulProperties(_current_elem->n_nodes());
40  }
41  else
42  Material::initStatefulProperties(n_points);
43 }
44 
45 void
47 {
48  if (_nodal_material)
49  {
51  for (_qp = 0; _qp < _current_elem->n_nodes(); ++_qp)
52  computeQpProperties();
53  }
54  else
55  Material::computeProperties();
56 }
57 
58 void
59 PorousFlowMaterial::sizeNodalProperty(const std::string & prop_name)
60 {
61  mooseAssert(_material_data->getMaterialPropertyStorage().hasProperty(prop_name),
62  "PorousFlowMaterial can not find nodal property " << prop_name);
63  const unsigned prop_id =
64  _material_data->getMaterialPropertyStorage().retrievePropertyId(prop_name);
65  // _material_data->props() returns MaterialProperties, which is a std::vector of PropertyValue.
66  _material_data->props()[prop_id]->resize(_current_elem->n_nodes());
67 }
68 
69 void
71 {
72  for (auto prop_name : getSuppliedItems())
73  sizeNodalProperty(prop_name);
74 }
75 
76 unsigned
77 PorousFlowMaterial::nearestQP(unsigned nodenum) const
78 {
79  unsigned nearest_qp = 0;
80  Real smallest_dist = std::numeric_limits<Real>::max();
81  for (unsigned qp = 1; qp < _qrule->n_points(); ++qp)
82  {
83  const Real this_dist = (_current_elem->point(nodenum) - _q_point[qp]).size();
84  if (this_dist < smallest_dist)
85  {
86  nearest_qp = qp;
87  smallest_dist = this_dist;
88  }
89  }
90  return nearest_qp;
91 }
void sizeNodalProperty(const std::string &prop_name)
Makes property with name prop_name to be size equal to the number of nodes in the current element...
void sizeAllSuppliedProperties()
Makes all supplied properties for this material to be size equal to the number of nodes in the curren...
virtual void computeProperties() override
virtual void initStatefulProperties(unsigned int n_points) override
const bool _nodal_material
whether the derived class holds nodal values
unsigned nearestQP(unsigned nodenum) const
Find the nearest quadpoint to the node labelled by nodenum in the current element.
InputParameters validParams< PorousFlowMaterial >()
PorousFlowMaterial(const InputParameters &parameters)
This holds maps between the nonlinear variables used in a PorousFlow simulation and the variable numb...