LCOV - code coverage report
Current view: top level - src/actions - PorousFlowUnsaturated.C (source / functions) Hit Total Coverage
Test: porous_flow Test Coverage Lines: 122 126 96.8 %
Date: 2017-11-21 14:47:27 Functions: 5 5 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             : #include "PorousFlowUnsaturated.h"
       8             : 
       9             : #include "FEProblem.h"
      10             : #include "Conversion.h"
      11             : #include "libmesh/string_to_enum.h"
      12             : 
      13             : template <>
      14             : InputParameters
      15          25 : validParams<PorousFlowUnsaturated>()
      16             : {
      17          25 :   InputParameters params = validParams<PorousFlowSinglePhaseBase>();
      18          75 :   params.addParam<bool>("add_saturation_aux", true, "Add an AuxVariable that records saturation");
      19         100 :   params.addRangeCheckedParam<Real>(
      20             :       "van_genuchten_alpha",
      21             :       1.0E-6,
      22             :       "van_genuchten_alpha > 0.0",
      23          25 :       "Van Genuchten alpha parameter used to determine saturation from porepressure");
      24         100 :   params.addRangeCheckedParam<Real>(
      25             :       "van_genuchten_m",
      26             :       0.6,
      27             :       "van_genuchten_m > 0 & van_genuchten_m < 1",
      28          25 :       "Van Genuchten m parameter used to determine saturation from porepressure");
      29          75 :   MooseEnum relperm_type_choice("FLAC Corey", "FLAC");
      30          75 :   params.addParam<MooseEnum>("relative_permeability_type",
      31             :                              relperm_type_choice,
      32             :                              "Type of relative-permeability function.  FLAC relperm = (1+m)S^m - "
      33             :                              "mS^(1+m).  Corey relperm = S^m.  m is the exponent.  Here S = "
      34          25 :                              "(saturation - residual)/(1 - residual)");
      35         100 :   params.addRangeCheckedParam<Real>("relative_permeability_exponent",
      36             :                                     3.0,
      37             :                                     "relative_permeability_exponent>=0",
      38          25 :                                     "Relative permeability exponent");
      39         100 :   params.addRangeCheckedParam<Real>(
      40             :       "residual_saturation",
      41             :       0.0,
      42             :       "residual_saturation>=0.0 & residual_saturation<1.0",
      43          25 :       "Residual saturation to use in the relative permeability expression");
      44          50 :   params.addClassDescription("Adds Kernels and fluid-property Materials necessary to simulate a "
      45             :                              "single-phase saturated-unsaturated flow problem.  The saturation is "
      46             :                              "computed using van Genuchten's expression.  No Kernels for diffusion "
      47             :                              "and dispersion of fluid components are added.  To run a simulation "
      48             :                              "you will also need to provide various other Materials for each mesh "
      49             :                              "block, depending on your simulation type, viz: permeability, "
      50             :                              "porosity, elasticity tensor, strain calculator, stress calculator, "
      51          25 :                              "matrix internal energy, thermal conductivity, diffusivity");
      52          25 :   return params;
      53             : }
      54             : 
      55          25 : PorousFlowUnsaturated::PorousFlowUnsaturated(const InputParameters & params)
      56             :   : PorousFlowSinglePhaseBase(params),
      57          75 :     _add_saturation_aux(getParam<bool>("add_saturation_aux")),
      58          75 :     _van_genuchten_alpha(getParam<Real>("van_genuchten_alpha")),
      59          75 :     _van_genuchten_m(getParam<Real>("van_genuchten_m")),
      60             :     _relperm_type(
      61          50 :         getParam<MooseEnum>("relative_permeability_type").getEnum<RelpermTypeChoiceEnum>()),
      62          75 :     _relative_permeability_exponent(getParam<Real>("relative_permeability_exponent")),
      63         225 :     _s_res(getParam<Real>("residual_saturation"))
      64             : {
      65          50 :   _objects_to_add.push_back("PorousFlowAdvectiveFlux");
      66          25 :   if (_simulation_type == SimulationTypeChoiceEnum::TRANSIENT)
      67          40 :     _objects_to_add.push_back("PorousFlowMassTimeDerivative");
      68          25 :   if ((_coupling_type == CouplingTypeEnum::HydroMechanical ||
      69          10 :        _coupling_type == CouplingTypeEnum::ThermoHydroMechanical) &&
      70          10 :       _simulation_type == SimulationTypeChoiceEnum::TRANSIENT)
      71          20 :     _objects_to_add.push_back("PorousFlowMassVolumetricExpansion");
      72          25 :   if (_coupling_type == CouplingTypeEnum::ThermoHydro ||
      73             :       _coupling_type == CouplingTypeEnum::ThermoHydroMechanical)
      74          10 :     _objects_to_add.push_back("PorousFlowHeatAdvection");
      75          25 :   if (_add_saturation_aux)
      76          40 :     _objects_to_add.push_back("SaturationAux");
      77          25 : }
      78             : 
      79             : void
      80          25 : PorousFlowUnsaturated::act()
      81             : {
      82          25 :   PorousFlowSinglePhaseBase::act();
      83             : 
      84             :   // add the kernels
      85          50 :   if (_current_task == "add_kernel")
      86             :   {
      87           5 :     std::string kernel_name = "PorousFlowUnsaturated_AdvectiveFlux";
      88           5 :     std::string kernel_type = "PorousFlowAdvectiveFlux";
      89          10 :     InputParameters params = _factory.getValidParams(kernel_type);
      90          15 :     params.set<UserObjectName>("PorousFlowDictator") = _dictator_name;
      91          10 :     params.set<RealVectorValue>("gravity") = _gravity;
      92             : 
      93           6 :     for (unsigned i = 0; i < _num_mass_fraction_vars; ++i)
      94             :     {
      95           3 :       kernel_name = "PorousFlowUnsaturated_AdvectiveFlux" + Moose::stringify(i);
      96           2 :       params.set<unsigned int>("fluid_component") = i;
      97           4 :       params.set<NonlinearVariableName>("variable") = _mass_fraction_vars[i];
      98           1 :       _problem->addKernel(kernel_type, kernel_name, params);
      99             :     }
     100          15 :     kernel_name = "PorousFlowUnsaturated_AdvectiveFlux" + Moose::stringify(_num_mass_fraction_vars);
     101          10 :     params.set<unsigned int>("fluid_component") = _num_mass_fraction_vars;
     102          10 :     params.set<NonlinearVariableName>("variable") = _pp_var;
     103           5 :     _problem->addKernel(kernel_type, kernel_name, params);
     104             :   }
     105          50 :   if (_current_task == "add_kernel" && _simulation_type == SimulationTypeChoiceEnum::TRANSIENT)
     106             :   {
     107           4 :     std::string kernel_name = "PorousFlowUnsaturated_MassTimeDerivative";
     108           4 :     std::string kernel_type = "PorousFlowMassTimeDerivative";
     109           8 :     InputParameters params = _factory.getValidParams(kernel_type);
     110          12 :     params.set<UserObjectName>("PorousFlowDictator") = _dictator_name;
     111             : 
     112           5 :     for (unsigned i = 0; i < _num_mass_fraction_vars; ++i)
     113             :     {
     114           3 :       kernel_name = "PorousFlowUnsaturated_MassTimeDerivative" + Moose::stringify(i);
     115           2 :       params.set<unsigned int>("fluid_component") = i;
     116           4 :       params.set<NonlinearVariableName>("variable") = _mass_fraction_vars[i];
     117           1 :       _problem->addKernel(kernel_type, kernel_name, params);
     118             :     }
     119             :     kernel_name =
     120          12 :         "PorousFlowUnsaturated_MassTimeDerivative" + Moose::stringify(_num_mass_fraction_vars);
     121           8 :     params.set<unsigned int>("fluid_component") = _num_mass_fraction_vars;
     122           8 :     params.set<NonlinearVariableName>("variable") = _pp_var;
     123           4 :     _problem->addKernel(kernel_type, kernel_name, params);
     124             :   }
     125             : 
     126          50 :   if ((_coupling_type == CouplingTypeEnum::HydroMechanical ||
     127          10 :        _coupling_type == CouplingTypeEnum::ThermoHydroMechanical) &&
     128          27 :       _current_task == "add_kernel" && _simulation_type == SimulationTypeChoiceEnum::TRANSIENT)
     129             :   {
     130           2 :     std::string kernel_name = "PorousFlowUnsaturated_MassVolumetricExpansion";
     131           2 :     std::string kernel_type = "PorousFlowMassVolumetricExpansion";
     132           4 :     InputParameters params = _factory.getValidParams(kernel_type);
     133           6 :     params.set<UserObjectName>("PorousFlowDictator") = _dictator_name;
     134           2 :     for (unsigned i = 0; i < _num_mass_fraction_vars; ++i)
     135             :     {
     136           0 :       kernel_name = "PorousFlowUnsaturated_MassVolumetricExpansion" + Moose::stringify(i);
     137           0 :       params.set<unsigned>("fluid_component") = i;
     138           0 :       params.set<NonlinearVariableName>("variable") = _mass_fraction_vars[i];
     139           0 :       _problem->addKernel(kernel_type, kernel_name, params);
     140             :     }
     141             :     kernel_name =
     142           6 :         "PorousFlowUnsaturated_MassVolumetricExpansion" + Moose::stringify(_num_mass_fraction_vars);
     143           4 :     params.set<unsigned>("fluid_component") = _num_mass_fraction_vars;
     144           4 :     params.set<NonlinearVariableName>("variable") = _pp_var;
     145           2 :     _problem->addKernel(kernel_type, kernel_name, params);
     146             :   }
     147             : 
     148          50 :   if ((_coupling_type == CouplingTypeEnum::ThermoHydro ||
     149          30 :        _coupling_type == CouplingTypeEnum::ThermoHydroMechanical) &&
     150           5 :       _current_task == "add_kernel")
     151             :   {
     152           1 :     std::string kernel_name = "PorousFlowUnsaturated_HeatAdvection";
     153           1 :     std::string kernel_type = "PorousFlowHeatAdvection";
     154           2 :     InputParameters params = _factory.getValidParams(kernel_type);
     155           4 :     params.set<NonlinearVariableName>("variable") = _temperature_var[0];
     156           3 :     params.set<UserObjectName>("PorousFlowDictator") = _dictator_name;
     157           2 :     params.set<RealVectorValue>("gravity") = _gravity;
     158           1 :     _problem->addKernel(kernel_type, kernel_name, params);
     159             :   }
     160             : 
     161             :   // Add the capillary pressure UserObject
     162          25 :   std::string capillary_pressure_name = "PorousFlowUnsaturated_CapillaryPressureVG";
     163          50 :   addCapillaryPressureVG(_van_genuchten_m, _van_genuchten_alpha, capillary_pressure_name);
     164             : 
     165          75 :   if (_deps.dependsOn(_objects_to_add, "PorousFlowPS_qp") && _current_task == "add_material")
     166             :   {
     167           5 :     std::string material_type = "PorousFlow1PhaseP";
     168          10 :     InputParameters params = _factory.getValidParams(material_type);
     169             : 
     170           5 :     std::string material_name = "PorousFlowUnsaturated_1PhaseP_VG_qp";
     171          15 :     params.set<UserObjectName>("PorousFlowDictator") = _dictator_name;
     172          15 :     params.set<std::vector<VariableName>>("porepressure") = {_pp_var};
     173          15 :     params.set<UserObjectName>("capillary_pressure") = capillary_pressure_name;
     174           5 :     _problem->addMaterial(material_type, material_name, params);
     175             :   }
     176          75 :   if (_deps.dependsOn(_objects_to_add, "PorousFlowPS_nodal") && _current_task == "add_material")
     177             :   {
     178           5 :     std::string material_type = "PorousFlow1PhaseP";
     179          10 :     InputParameters params = _factory.getValidParams(material_type);
     180             : 
     181           5 :     std::string material_name = "PorousFlowUnsaturated_1PhaseP_VG_nodal";
     182          15 :     params.set<UserObjectName>("PorousFlowDictator") = _dictator_name;
     183          15 :     params.set<std::vector<VariableName>>("porepressure") = {_pp_var};
     184          15 :     params.set<UserObjectName>("capillary_pressure") = capillary_pressure_name;
     185          10 :     params.set<bool>("at_nodes") = true;
     186           5 :     _problem->addMaterial(material_type, material_name, params);
     187             :   }
     188             : 
     189          50 :   if (_deps.dependsOn(_objects_to_add, "PorousFlowRelativePermeability_qp"))
     190             :   {
     191          20 :     if (_relperm_type == RelpermTypeChoiceEnum::FLAC)
     192           5 :       addRelativePermeabilityFLAC(false, 0, _relative_permeability_exponent, _s_res, _s_res);
     193             :     else
     194          15 :       addRelativePermeabilityCorey(false, 0, _relative_permeability_exponent, _s_res, _s_res);
     195             :   }
     196          50 :   if (_deps.dependsOn(_objects_to_add, "PorousFlowRelativePermeability_nodal"))
     197             :   {
     198          25 :     if (_relperm_type == RelpermTypeChoiceEnum::FLAC)
     199           5 :       addRelativePermeabilityFLAC(true, 0, _relative_permeability_exponent, _s_res, _s_res);
     200             :     else
     201          20 :       addRelativePermeabilityCorey(true, 0, _relative_permeability_exponent, _s_res, _s_res);
     202             :   }
     203             : 
     204          65 :   if (_deps.dependsOn(_objects_to_add, "PorousFlowVolumetricStrain_qp") ||
     205          55 :       _deps.dependsOn(_objects_to_add, "PorousFlowVolumetricStrain_nodal"))
     206          10 :     addVolumetricStrainMaterial(_coupled_displacements, true);
     207             : 
     208             :   // add relevant AuxVariables and AuxKernels
     209          25 :   if (_add_saturation_aux)
     210          20 :     addSaturationAux(0);
     211        2524 : }

Generated by: LCOV version 1.11