Skip to content
Permalink
Browse files

Merge pull request #13117 from cpgr/pfjoin

Fix PorousFlowAddMaterialAction and PorousFlowAddMaterialJoiner
  • Loading branch information...
permcody committed Mar 26, 2019
2 parents 834a2fe + 04f8536 commit 9d99261d4cde4a5671b6f3eea853926520ee7298
@@ -49,6 +49,9 @@ class PorousFlowAddMaterialJoiner : public Action

/// Name of the PorousFlowDictator
std::string _dictator_name;

/// Vector of already joined materials (to avoid joining them again)
std::vector<std::string> _already_joined;
};

#endif // POROUSFLOWADDMATERIALJOINER_H
@@ -160,6 +160,8 @@ PorousFlowAddMaterialAction::isPFMaterialRequired(std::string pf_material_type,
bool
PorousFlowAddMaterialAction::isPFMaterialPresent(AddMaterialAction * material, bool at_nodes)
{
bool is_present = false;

// Need to check that it hasn't been added in the input file also to
// avoid a duplicate material property error
for (auto & ama_material : _ama_materials)
@@ -175,7 +177,7 @@ PorousFlowAddMaterialAction::isPFMaterialPresent(AddMaterialAction * material, b
// If the material isn't related to a fluid phase, it is present if
// its at_nodes parameter is equal to the given at_nodes
if (mat_at_nodes == at_nodes && !pars.isParamValid("phase"))
return true;
is_present = true;

// If the material is related to a fluid phase, it is present if
// its at_nodes parameter is equal to the given at_nodes, and its
@@ -185,13 +187,18 @@ PorousFlowAddMaterialAction::isPFMaterialPresent(AddMaterialAction * material, b
const unsigned int phase = pars.get<unsigned int>("phase");

if (mat_params.isParamValid("phase") && mat_params.get<unsigned int>("phase") == phase)
return true;
is_present = true;
}

// Finally, if the material is block restricted then it is not already
// present if the block parameter is not identical
if (mat_params.get<std::vector<SubdomainName>>("block") !=
pars.get<std::vector<SubdomainName>>("block"))
is_present = false;
}
}

// If all of these conditions aren't satisfied, then the material is already present
return false;
return is_present;
}

void
@@ -28,7 +28,7 @@ validParams<PorousFlowAddMaterialJoiner>()
}

PorousFlowAddMaterialJoiner::PorousFlowAddMaterialJoiner(const InputParameters & params)
: Action(params)
: Action(params), _already_joined()
{
}

@@ -142,14 +142,27 @@ PorousFlowAddMaterialJoiner::addJoiner(bool at_nodes,
const std::string & material_property,
const std::string & output_name)
{
if (!hasJoiner(material_property))
bool is_joined = false;

// Check if this material is already joined
if (std::find(_already_joined.begin(), _already_joined.end(), material_property) !=
_already_joined.end())
is_joined = true;

if (hasJoiner(material_property))
is_joined = true;

if (!is_joined)
{
std::string material_type = "PorousFlowJoiner";
InputParameters params = _factory.getValidParams(material_type);
params.set<UserObjectName>("PorousFlowDictator") = _dictator_name;
params.set<bool>("at_nodes") = at_nodes;
params.set<std::string>("material_property") = material_property;
_problem->addMaterial(material_type, output_name, params);

// Add material to the already joined list
_already_joined.push_back(material_property);
}
}

@@ -0,0 +1,183 @@
# Tests that the actions to automatically add PorousFlowJoiner's and the correct
# qp or nodal version of each material work as expected when a material is block
# restricted. Tests both phase dependent properties (like relative permeability)
# as well as phase-independent materials (like porosity)

[GlobalParams]
PorousFlowDictator = dictator
[]

[Mesh]
type = GeneratedMesh
dim = 2
ny = 2
[]

[MeshModifiers]
[./subdomain0]
type = SubdomainBoundingBox
bottom_left = '0 0 0'
top_right = '1 0.5 0'
block_id = 0
[../]
[./subdomain1]
type = SubdomainBoundingBox
bottom_left = '0 0.5 0'
top_right = '1 1 0'
block_id = 1
[../]
[]

[Variables]
[./p0]
initial_condition = 1
[../]
[./p1]
initial_condition = 1.1
[../]
[]

[AuxVariables]
[./porosity]
family = MONOMIAL
order = CONSTANT
[../]
[./kl]
family = MONOMIAL
order = CONSTANT
[../]
[./kg]
family = MONOMIAL
order = CONSTANT
[../]
[]

[AuxKernels]
[./porosity]
type = PorousFlowPropertyAux
property = porosity
variable = porosity
[../]
[./kl]
type = PorousFlowPropertyAux
property = relperm
variable = kl
phase = 0
[../]
[./kg]
type = PorousFlowPropertyAux
property = relperm
variable = kg
phase = 1
[../]
[]

[Kernels]
[./p0]
type = PorousFlowMassTimeDerivative
variable = p0
[../]
[./p1]
type = PorousFlowAdvectiveFlux
gravity = '0 0 0'
variable = p1
[../]
[]

[Modules]
[./FluidProperties]
[./fluid0]
type = SimpleFluidProperties
[../]
[./fluid1]
type = SimpleFluidProperties
[../]
[../]
[]

[Materials]
[./temperature]
type = PorousFlowTemperature
[../]
[./ppss]
type = PorousFlow2PhasePP
phase0_porepressure = p0
phase1_porepressure = p1
capillary_pressure = pc
[../]
[./krl0]
type = PorousFlowRelativePermeabilityConst
kr = 0.7
phase = 0
block = 0
[../]
[./krg0]
type = PorousFlowRelativePermeabilityConst
kr = 0.8
phase = 1
block = 0
[../]
[./krl1]
type = PorousFlowRelativePermeabilityConst
kr = 0.5
phase = 0
block = 1
[../]
[./krg1]
type = PorousFlowRelativePermeabilityConst
kr = 0.4
phase = 1
block = 1
[../]
[./perm]
type = PorousFlowPermeabilityConst
permeability = '1 0 0 0 1 0 0 0 1'
[../]
[./fluid0]
type = PorousFlowSingleComponentFluid
fp = fluid0
phase = 0
[../]
[./fluid1]
type = PorousFlowSingleComponentFluid
fp = fluid1
phase = 1
[../]
[./massfrac]
type = PorousFlowMassFraction
[../]
[./porosity0]
type = PorousFlowPorosityConst
porosity = 0.1
block = 0
[../]
[./porosity1]
type = PorousFlowPorosityConst
porosity = 0.2
block = 1
[../]
[]


[Executioner]
type = Transient
end_time = 1
nl_abs_tol = 1e-10
[]

[UserObjects]
[./dictator]
type = PorousFlowDictator
porous_flow_vars = 'p0 p1'
number_fluid_phases = 2
number_fluid_components = 1
[../]
[./pc]
type = PorousFlowCapillaryPressureConst
pc = 0
[../]
[]

[Outputs]
exodus = true
[]
@@ -44,7 +44,7 @@
no_error_deprecated = true
requirement = "The system shall produce a warning when attempting to add materials to the simulation when using the PorousFlowFullySaturated Action."
issues = "#10093"
design = "brineco2.md"
design = "PorousFlowAddMaterialJoiner.md"
[../]
[./addjoiner_exception]
type = RunException
@@ -54,23 +54,23 @@
threading = '!pthreads'
requirement = "The system shall produce an error when attempting to add materials to the simulation when using the PorousFlowFullySaturated Action and the --error-deprecated flag is also supplied."
issues = "#10093"
design = "brineco2.md"
design = "PorousFlowAddMaterialJoiner.md"
[../]
[./addmaterials]
type = RunApp
input = addmaterials.i
threading = '!pthreads'
requirement = "The system shall handle adding materials properly when the add_nodes parameter and the at_nodes=true parameters are both active in the PorousFlowFullySaturated Action."
issues = "#10093"
design = "brineco2.md"
design = "PorousFlowAddMaterialAction.md"
[../]
[./addmaterials2]
type = RunApp
input = addmaterials2.i
threading = '!pthreads'
requirement = "The system shall handle adding materials properly when the add_nodes parameter is supplied in the PorousFlowFullySaturated Action."
issues = "#10093"
design = "brineco2.md"
design = "PorousFlowAddMaterialAction.md"
[../]
[./basicthm_h]
type = Exodiff
@@ -112,4 +112,13 @@
issues = "#8574"
design = "PorousFlowBasicTHM.md"
[../]
[./block_restricted]
type = Exodiff
input = block_restricted_materials.i
exodiff = block_restricted_materials_out.e
threading = '!pthreads'
requirement = "The system shall handle adding materials properly when materials are block restricted"
issues = "#10093"
design = "PorousFlowAddMaterialJoiner.md PorousFlowAddMaterialAction.md"
[../]
[]
@@ -0,0 +1,2 @@
time,pp_analytical,pp_base
1000000,-0.27729877038248,-0.27729773931439
Oops, something went wrong.

0 comments on commit 9d99261

Please sign in to comment.
You can’t perform that action at this time.