LCOV - code coverage report
Current view: top level - src/materials - PorousFlowMaterial.C (source / functions) Hit Total Coverage
Test: porous_flow Test Coverage Lines: 40 40 100.0 %
Date: 2017-11-21 14:47:27 Functions: 9 9 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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
      14        2704 : validParams<PorousFlowMaterial>()
      15             : {
      16        2704 :   InputParameters params = validParams<Material>();
      17        8112 :   params.addRequiredParam<UserObjectName>(
      18        2704 :       "PorousFlowDictator", "The UserObject that holds the list of Porous-Flow variable names");
      19        8112 :   params.addParam<bool>(
      20        2704 :       "at_nodes", false, "Evaluate Material properties at nodes instead of quadpoints");
      21        5408 :   params.addClassDescription("This generalises MOOSE's Material class to allow for Materials that "
      22        2704 :                              "hold information related to the nodes in the finite element");
      23        2704 :   return params;
      24             : }
      25             : 
      26        8112 : PorousFlowMaterial::PorousFlowMaterial(const InputParameters & parameters)
      27             :   : Material(parameters),
      28       24336 :     _nodal_material(getParam<bool>("at_nodes")),
      29       32448 :     _dictator(getUserObject<PorousFlowDictator>("PorousFlowDictator"))
      30             : {
      31        8112 : }
      32             : 
      33             : void
      34      239668 : PorousFlowMaterial::initStatefulProperties(unsigned int n_points)
      35             : {
      36      239668 :   if (_nodal_material)
      37             :   {
      38      127120 :     sizeAllSuppliedProperties();
      39      127120 :     Material::initStatefulProperties(_current_elem->n_nodes());
      40             :   }
      41             :   else
      42      112548 :     Material::initStatefulProperties(n_points);
      43      239668 : }
      44             : 
      45             : void
      46    16243896 : PorousFlowMaterial::computeProperties()
      47             : {
      48    16243896 :   if (_nodal_material)
      49             :   {
      50     9647571 :     sizeAllSuppliedProperties();
      51    45334457 :     for (_qp = 0; _qp < _current_elem->n_nodes(); ++_qp)
      52    35686886 :       computeQpProperties();
      53             :   }
      54             :   else
      55     6596325 :     Material::computeProperties();
      56    16243890 : }
      57             : 
      58             : void
      59    30573975 : 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    30573975 :       _material_data->getMaterialPropertyStorage().retrievePropertyId(prop_name);
      65             :   // _material_data->props() returns MaterialProperties, which is a std::vector of PropertyValue.
      66    61147950 :   _material_data->props()[prop_id]->resize(_current_elem->n_nodes());
      67    30573975 : }
      68             : 
      69             : void
      70     9774691 : PorousFlowMaterial::sizeAllSuppliedProperties()
      71             : {
      72    50123357 :   for (auto prop_name : getSuppliedItems())
      73    30573975 :     sizeNodalProperty(prop_name);
      74     9774691 : }
      75             : 
      76             : unsigned
      77       47456 : PorousFlowMaterial::nearestQP(unsigned nodenum) const
      78             : {
      79             :   unsigned nearest_qp = 0;
      80             :   Real smallest_dist = std::numeric_limits<Real>::max();
      81      583264 :   for (unsigned qp = 1; qp < _qrule->n_points(); ++qp)
      82             :   {
      83      325568 :     const Real this_dist = (_current_elem->point(nodenum) - _q_point[qp]).size();
      84      162784 :     if (this_dist < smallest_dist)
      85             :     {
      86             :       nearest_qp = qp;
      87             :       smallest_dist = this_dist;
      88             :     }
      89             :   }
      90       47456 :   return nearest_qp;
      91        2499 : }

Generated by: LCOV version 1.11