www.mooseframework.org
PorousFlowMaterial.C
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 #include "PorousFlowMaterial.h"
11 #include "libmesh/quadrature.h"
12 #include <limits>
13 
14 template <>
15 InputParameters
17 {
18  InputParameters params = validParams<Material>();
19  params.addRequiredParam<UserObjectName>(
20  "PorousFlowDictator", "The UserObject that holds the list of PorousFlow variable names");
21  params.addParam<bool>(
22  "at_nodes", false, "Evaluate Material properties at nodes instead of quadpoints");
23  params.addPrivateParam<std::string>("pf_material_type", "pf_material");
24  params.addClassDescription("This generalises MOOSE's Material class to allow for Materials that "
25  "hold information related to the nodes in the finite element");
26  return params;
27 }
28 
29 PorousFlowMaterial::PorousFlowMaterial(const InputParameters & parameters)
30  : Material(parameters),
31  _nodal_material(getParam<bool>("at_nodes")),
32  _dictator(getUserObject<PorousFlowDictator>("PorousFlowDictator")),
33  _pressure_variable_name("pressure_variable"),
34  _saturation_variable_name("saturation_variable"),
35  _temperature_variable_name("temperature_variable"),
36  _mass_fraction_variable_name("mass_fraction_variable")
37 {
38 }
39 
40 void
42 {
43  if (_nodal_material)
44  _material_data->onlyResizeIfSmaller(true);
45 }
46 
47 void
49 {
50  if (_nodal_material)
51  {
52  // size the properties to max(number_of_nodes, number_of_quadpoints)
54 
55  // compute the values for number_of_nodes
56  Material::initStatefulProperties(_current_elem->n_nodes());
57  }
58  else
59  Material::initStatefulProperties(n_points);
60 }
61 
62 void
64 {
65  if (_nodal_material)
66  {
67  // size the properties to max(number_of_nodes, number_of_quadpoints)
69 
70  // compute the values for number_of_nodes
71  for (_qp = 0; _qp < _current_elem->n_nodes(); ++_qp)
72  computeQpProperties();
73  }
74  else
75  Material::computeProperties();
76 }
77 
78 void
80 {
81  /*
82  * For nodal materials, the Properties should be sized as the maximum of
83  * the number of nodes and the number of quadpoints.
84  * We only actually need "number of nodes" pieces of information, which are
85  * computed by computeProperties(), so the n_points - _current_elem->n_nodes()
86  * elements at the end of the std::vector will always be zero, but they
87  * are needed because MOOSE does copy operations (etc) that assumes that
88  * the std::vector is sized to number of quadpoints.
89  *
90  * On boundary materials, the number of nodes may be larger than the number of
91  * qps on the face of the element, in which case the remaining entries in the
92  * material properties storage will be zero.
93  */
94  _material_data->resize(std::max(_current_elem->n_nodes(), _qrule->n_points()));
95 }
96 
97 unsigned
98 PorousFlowMaterial::nearestQP(unsigned nodenum) const
99 {
100  unsigned nearest_qp = 0;
101  Real smallest_dist = std::numeric_limits<Real>::max();
102  for (unsigned qp = 1; qp < _qrule->n_points(); ++qp)
103  {
104  const Real this_dist = (_current_elem->point(nodenum) - _q_point[qp]).norm();
105  if (this_dist < smallest_dist)
106  {
107  nearest_qp = qp;
108  smallest_dist = this_dist;
109  }
110  }
111  return nearest_qp;
112 }
PorousFlowMaterial::initStatefulProperties
virtual void initStatefulProperties(unsigned int n_points) override
Correctly sizes nodal materials, then initialises using Material::initStatefulProperties.
Definition: PorousFlowMaterial.C:48
validParams< PorousFlowMaterial >
InputParameters validParams< PorousFlowMaterial >()
Definition: PorousFlowMaterial.C:16
PorousFlowMaterial::nearestQP
unsigned nearestQP(unsigned nodenum) const
Find the nearest quadpoint to the node labelled by nodenum in the current element.
Definition: PorousFlowMaterial.C:98
PorousFlowMaterial::PorousFlowMaterial
PorousFlowMaterial(const InputParameters &parameters)
Definition: PorousFlowMaterial.C:29
PorousFlowDictator
This holds maps between the nonlinear variables used in a PorousFlow simulation and the variable numb...
Definition: PorousFlowDictator.h:71
PorousFlowMaterial::computeProperties
virtual void computeProperties() override
Correctly sizes nodal materials, then computes using Material::computeProperties.
Definition: PorousFlowMaterial.C:63
PorousFlowMaterial::_nodal_material
const bool _nodal_material
Whether the derived class holds nodal values.
Definition: PorousFlowMaterial.h:68
PorousFlowMaterial.h
PorousFlowMaterial::sizeNodalProperties
void sizeNodalProperties()
Resizes properties to be equal to max(number of nodes, number of quadpoints) in the current element.
Definition: PorousFlowMaterial.C:79
PorousFlowMaterial::initialSetup
virtual void initialSetup() override
Definition: PorousFlowMaterial.C:41