MOOSE Newsletter (November 2019)
Mesh MetaData Store
MOOSE has gained a new feature that makes it easier to manage mesh related attributes during simulation setup, namely the mesh "MetaData" Store. The purpose of this object is to hold any kind of attribute or property that a developer may wish to publish about the mesh for use in other objects.
There are a few reasons why you may want to use the MetaData store:
- No need to dynamic cast the underlying mesh object to gain access to methods or attributes. - Solves the problem of not having access to Mesh during recover. - No need to handle getting parameters from the mesh differently for normal startup vs recover runs.
Storing properties in the store means that you won't have to dynamic cast the underlying mesh object to get access to specific APIs or properties on your mesh. Another benefit of using the store is that you don't have to treat your normal simulation and recover simulations any differently from one and other. You'll be able to retrieve properties the same way in either case simplifying your startup code. This makes a lot of difference if you are using the MeshGeneration system to build your mesh programmatically. The MetaData store is populated very early on recover runs so the data is available during the execution of any custom Actions that you might create.
Interface Material
MOOSE now has the ability to create InterfaceMaterial
objects. InterfaceMaterials
are capable of grabbing element face and neighbor face variable values as well as element face and neighbor face material properties, allowing for creation of truly interfacial properties that are a blend of the quantities on the connected subdomains. An example application of InterfaceMaterials
is for cohesive zone modelling. Example input files include (test/tests/materials/interface_material/interface_value_material.i), (test/tests/materials/interface_material/interface_value_material_split_mesh.i), and (test/tests/materials/interface_material/interface_value_material_split_mesh_stateful.i). Source examples of InterfaceMaterial
derived objects are (test/src/materials/InterfaceValueMaterial.C) and (test/src/materials/JumpInterfaceMaterial.C). Header examples can be found at (test/include/materials/InterfaceValueMaterial.h) and (test/include/materials/JumpInterfaceMaterial.h).
libpng detection test has moved to MOOSE's configure
Does anyone remember when MOOSE got a proper configure system? No? Good, then that means we did our job correctly. The test for the existence of libpng, which was hacked into one of the MOOSE Makefiles was moved to MOOSE's configure system for better reliability. It turns out that the detection failed in rare cases but it was annoying to deal with on systems where it did. Now, we run this test during configure so that we can reliably work with or without it based on the configure result.
MOOSE's configure system
We managed to make it 10 years without a configure script. We did this because we wanted to keep the build process simple for our developers and we were able to delegate all of our configure needs to libMesh's configure system. Well we finally caved and added a full-blown configure system to MOOSE. We are using the GNU Autotools for now, but the most important part is that nobody needs to change their work flow to accommodate the new configure script. It is completely optional at this point and we hope to keep it that way indefinitely.
There are a few optional library configurations that you may choose to activate by running the script yourself. You can always check out what options are available by going to the framework
directory and running ./configure --help
.
Miscellaneous enhancements and bug fixes
The TestHarness properly skips tests that require the presence of libpng.
Kernels for eigenvalue system
We made all kernels in the eigenvalue system consistent with those used in the nonlinear system. That being said, any existing kernels for regular nonlinear calculations can be used in the eigenvalue system without any changes.
Conservative transfer with L2 Lagrange
Conservative transfer supports L2 Lagrange nonlinear variable now.
IntegralBC support in eigenvalue system
We enhanced the eigenvalue system to support the IntegralBC. This help neutron transport calculations where the IntegralBC boundary conditions are often used in eigenvalue calculations.
(test/tests/materials/interface_material/interface_value_material.i)
[Mesh]
[gen]
type = GeneratedMeshGenerator
dim = 2
nx = 2
xmax = 2
ny = 2
ymax = 2
elem_type = QUAD4
[]
[./subdomain_id]
input = gen
type = SubdomainBoundingBoxGenerator
bottom_left = '1 0 0'
top_right = '2 2 0'
block_id = 1
[../]
[./interface]
type = SideSetsBetweenSubdomainsGenerator
input = subdomain_id
primary_block = '0'
paired_block = '1'
new_boundary = 'interface'
[../]
[]
[Variables]
[./u]
block = 0
[../]
[./v]
block = 1
[../]
[]
[Kernels]
[./diff]
type = MatDiffusion
variable = u
diffusivity = 'diffusivity'
block = 0
[../]
[./diff_v]
type = MatDiffusion
variable = v
diffusivity = 'diffusivity'
block = 1
[../]
[]
[InterfaceKernels]
[tied]
type = PenaltyInterfaceDiffusion
variable = u
neighbor_var = v
jump_prop_name = "average_jump"
penalty = 1e6
boundary = 'interface'
[]
[]
[BCs]
[u_left]
type = DirichletBC
boundary = 'left'
variable = u
value = 1
[]
[v_right]
type = DirichletBC
boundary = 'right'
variable = v
value = 0
[]
[]
[Materials]
[./stateful1]
type = StatefulMaterial
block = 0
initial_diffusivity = 1
# outputs = all
[../]
[./stateful2]
type = StatefulMaterial
block = 1
initial_diffusivity = 2
# outputs = all
[../]
[./interface_material_avg]
type = InterfaceValueMaterial
mat_prop_primary = diffusivity
mat_prop_secondary = diffusivity
var_primary = diffusivity_var
var_secondary = diffusivity_var
mat_prop_out_basename = diff
boundary = interface
interface_value_type = average
mat_prop_var_out_basename = diff_var
nl_var_primary = u
nl_var_secondary = v
[../]
[./interface_material_jump_primary_minus_secondary]
type = ADInterfaceValueMaterial # To test generic routines
mat_prop_primary = diffusivity
mat_prop_secondary = diffusivity
var_primary = diffusivity_var
var_secondary = diffusivity_var
mat_prop_out_basename = diff
boundary = interface
interface_value_type = jump_primary_minus_secondary
mat_prop_var_out_basename = diff_var
nl_var_primary = u
nl_var_secondary = v
[../]
[./interface_material_jump_secondary_minus_primary]
type = InterfaceValueMaterial
mat_prop_primary = diffusivity
mat_prop_secondary = diffusivity
var_primary = diffusivity_var
var_secondary = diffusivity_var
mat_prop_out_basename = diff
boundary = interface
interface_value_type = jump_secondary_minus_primary
mat_prop_var_out_basename = diff_var
nl_var_primary = u
nl_var_secondary = v
[../]
[./interface_material_jump_abs]
type = InterfaceValueMaterial
mat_prop_primary = diffusivity
mat_prop_secondary = diffusivity
var_primary = diffusivity_var
var_secondary = diffusivity_var
mat_prop_out_basename = diff
boundary = interface
interface_value_type = jump_abs
mat_prop_var_out_basename = diff_var
nl_var_primary = u
nl_var_secondary = v
[../]
[./interface_material_primary]
type = InterfaceValueMaterial
mat_prop_primary = diffusivity
mat_prop_secondary = diffusivity
var_primary = diffusivity_var
var_secondary = diffusivity_var
mat_prop_out_basename = diff
boundary = interface
interface_value_type = primary
mat_prop_var_out_basename = diff_var
nl_var_primary = u
nl_var_secondary = v
[../]
[./interface_material_secondary]
type = InterfaceValueMaterial
mat_prop_primary = diffusivity
mat_prop_secondary = diffusivity
var_primary = diffusivity_var
var_secondary = diffusivity_var
mat_prop_out_basename = diff
mat_prop_var_out_basename = diff_var
boundary = interface
interface_value_type = secondary
nl_var_primary = u
nl_var_secondary = v
[../]
[]
[AuxKernels]
[./interface_material_avg]
type = MaterialRealAux
property = diff_average
variable = diffusivity_average
boundary = interface
[]
[./interface_material_jump_primary_minus_secondary]
type = MaterialRealAux
property = diff_jump_primary_minus_secondary
variable = diffusivity_jump_primary_minus_secondary
boundary = interface
[]
[./interface_material_jump_secondary_minus_primary]
type = MaterialRealAux
property = diff_jump_secondary_minus_primary
variable = diffusivity_jump_secondary_minus_primary
boundary = interface
[]
[./interface_material_jump_abs]
type = MaterialRealAux
property = diff_jump_abs
variable = diffusivity_jump_abs
boundary = interface
[]
[./interface_material_primary]
type = MaterialRealAux
property = diff_primary
variable = diffusivity_primary
boundary = interface
[]
[./interface_material_secondary]
type = MaterialRealAux
property = diff_secondary
variable = diffusivity_secondary
boundary = interface
[]
[diffusivity_var]
type = MaterialRealAux
property = diffusivity
variable = diffusivity_var
[]
[]
[AuxVariables]
[diffusivity_var]
family = MONOMIAL
order = CONSTANT
[]
[./diffusivity_average]
family = MONOMIAL
order = CONSTANT
[]
[./diffusivity_jump_primary_minus_secondary]
family = MONOMIAL
order = CONSTANT
[]
[./diffusivity_jump_secondary_minus_primary]
family = MONOMIAL
order = CONSTANT
[]
[./diffusivity_jump_abs]
family = MONOMIAL
order = CONSTANT
[]
[./diffusivity_primary]
family = MONOMIAL
order = CONSTANT
[]
[./diffusivity_secondary]
family = MONOMIAL
order = CONSTANT
[]
[]
[Executioner]
type = Steady
solve_type = NEWTON
[]
[Outputs]
exodus = true
[]
(test/tests/materials/interface_material/interface_value_material_split_mesh.i)
[Mesh]
[gen]
type = GeneratedMeshGenerator
dim = 2
nx = 2
xmax = 2
ny = 2
ymax = 2
elem_type = QUAD4
[]
[./subdomain_id]
input = gen
type = SubdomainBoundingBoxGenerator
bottom_left = '1 0 0'
top_right = '2 2 0'
block_id = 1
[../]
[./split]
type = BreakMeshByBlockGenerator
input = subdomain_id
[../]
[]
[Variables]
[./u]
block = 0
[../]
[./v]
block = 1
[../]
[]
[Kernels]
[./diff]
type = MatDiffusion
variable = u
diffusivity = 'diffusivity'
block = 0
[../]
[./diff_v]
type = MatDiffusion
variable = v
diffusivity = 'diffusivity'
block = 1
[../]
[]
[InterfaceKernels]
[tied]
type = PenaltyInterfaceDiffusion
variable = u
neighbor_var = v
jump_prop_name = "average_jump"
penalty = 1e6
boundary = 'interface'
[]
[]
[BCs]
[u_left]
type = DirichletBC
boundary = 'left'
variable = u
value = 1
[]
[v_right]
type = DirichletBC
boundary = 'right'
variable = v
value = 0
[]
[]
[Materials]
[./stateful1]
type = StatefulMaterial
block = 0
initial_diffusivity = 1
# outputs = all
[../]
[./stateful2]
type = StatefulMaterial
block = 1
initial_diffusivity = 2
# outputs = all
[../]
[./interface_material_avg]
type = InterfaceValueMaterial
mat_prop_primary = diffusivity
mat_prop_secondary = diffusivity
var_primary = diffusivity_var
var_secondary = diffusivity_var
mat_prop_out_basename = diff
boundary = interface
interface_value_type = average
mat_prop_var_out_basename = diff_var
nl_var_primary = u
nl_var_secondary = v
[../]
[./interface_material_jump_primary_minus_secondary]
type = InterfaceValueMaterial
mat_prop_primary = diffusivity
mat_prop_secondary = diffusivity
var_primary = diffusivity_var
var_secondary = diffusivity_var
mat_prop_out_basename = diff
boundary = interface
interface_value_type = jump_primary_minus_secondary
mat_prop_var_out_basename = diff_var
nl_var_primary = u
nl_var_secondary = v
[../]
[./interface_material_jump_secondary_minus_primary]
type = InterfaceValueMaterial
mat_prop_primary = diffusivity
mat_prop_secondary = diffusivity
var_primary = diffusivity_var
var_secondary = diffusivity_var
mat_prop_out_basename = diff
boundary = interface
interface_value_type = jump_secondary_minus_primary
mat_prop_var_out_basename = diff_var
nl_var_primary = u
nl_var_secondary = v
[../]
[./interface_material_jump_abs]
type = InterfaceValueMaterial
mat_prop_primary = diffusivity
mat_prop_secondary = diffusivity
var_primary = diffusivity_var
var_secondary = diffusivity_var
mat_prop_out_basename = diff
boundary = interface
interface_value_type = jump_abs
mat_prop_var_out_basename = diff_var
nl_var_primary = u
nl_var_secondary = v
[../]
[./interface_material_primary]
type = InterfaceValueMaterial
mat_prop_primary = diffusivity
mat_prop_secondary = diffusivity
var_primary = diffusivity_var
var_secondary = diffusivity_var
mat_prop_out_basename = diff
boundary = interface
interface_value_type = primary
mat_prop_var_out_basename = diff_var
nl_var_primary = u
nl_var_secondary = v
[../]
[./interface_material_secondary]
type = InterfaceValueMaterial
mat_prop_primary = diffusivity
mat_prop_secondary = diffusivity
var_primary = diffusivity_var
var_secondary = diffusivity_var
mat_prop_out_basename = diff
mat_prop_var_out_basename = diff_var
boundary = interface
interface_value_type = secondary
nl_var_primary = u
nl_var_secondary = v
[../]
[]
[AuxKernels]
[./interface_material_avg]
type = MaterialRealAux
property = diff_average
variable = diffusivity_average
boundary = interface
[]
[./interface_material_jump_primary_minus_secondary]
type = MaterialRealAux
property = diff_jump_primary_minus_secondary
variable = diffusivity_jump_primary_minus_secondary
boundary = interface
[]
[./interface_material_jump_secondary_minus_primary]
type = MaterialRealAux
property = diff_jump_secondary_minus_primary
variable = diffusivity_jump_secondary_minus_primary
boundary = interface
[]
[./interface_material_jump_abs]
type = MaterialRealAux
property = diff_jump_abs
variable = diffusivity_jump_abs
boundary = interface
[]
[./interface_material_primary]
type = MaterialRealAux
property = diff_primary
variable = diffusivity_primary
boundary = interface
[]
[./interface_material_secondary]
type = MaterialRealAux
property = diff_secondary
variable = diffusivity_secondary
boundary = interface
[]
[diffusivity_var]
type = MaterialRealAux
property = diffusivity
variable = diffusivity_var
[]
[]
[AuxVariables]
[diffusivity_var]
family = MONOMIAL
order = CONSTANT
[]
[./diffusivity_average]
family = MONOMIAL
order = CONSTANT
[]
[./diffusivity_jump_primary_minus_secondary]
family = MONOMIAL
order = CONSTANT
[]
[./diffusivity_jump_secondary_minus_primary]
family = MONOMIAL
order = CONSTANT
[]
[./diffusivity_jump_abs]
family = MONOMIAL
order = CONSTANT
[]
[./diffusivity_primary]
family = MONOMIAL
order = CONSTANT
[]
[./diffusivity_secondary]
family = MONOMIAL
order = CONSTANT
[]
[]
[Executioner]
type = Steady
solve_type = NEWTON
[]
[Outputs]
exodus = true
[]
(test/tests/materials/interface_material/interface_value_material_split_mesh_stateful.i)
[Mesh]
[gen]
type = GeneratedMeshGenerator
dim = 2
nx = 2
xmax = 2
ny = 2
ymax = 2
elem_type = QUAD4
[]
[./subdomain_id]
input = gen
type = SubdomainBoundingBoxGenerator
bottom_left = '1 0 0'
top_right = '2 2 0'
block_id = 1
[../]
[./split]
type = BreakMeshByBlockGenerator
input = subdomain_id
[../]
[]
[Variables]
[./u]
block = 0
[../]
[./v]
block = 1
[../]
[]
[Kernels]
[./diff]
type = MatDiffusion
variable = u
diffusivity = 'diffusivity'
block = 0
[../]
[./diff_v]
type = MatDiffusion
variable = v
diffusivity = 'diffusivity'
block = 1
[../]
[]
[InterfaceKernels]
[tied]
type = PenaltyInterfaceDiffusion
variable = u
neighbor_var = v
penalty = 1e6
jump_prop_name = "average_jump"
boundary = 'interface'
[]
[]
[BCs]
[u_left]
type = DirichletBC
boundary = 'left'
variable = u
value = 1
[]
[v_right]
type = DirichletBC
boundary = 'right'
variable = v
value = 0
[]
[]
[Materials]
[./stateful1]
type = StatefulMaterial
block = 0
initial_diffusivity = 1
# outputs = all
[../]
[./stateful2]
type = StatefulMaterial
block = 1
initial_diffusivity = 2
# outputs = all
[../]
[./interface_material_avg]
type = InterfaceValueMaterial
mat_prop_primary = diffusivity
mat_prop_secondary = diffusivity
var_primary = diffusivity_var
var_secondary = diffusivity_var
mat_prop_out_basename = diff
boundary = interface
interface_value_type = average
mat_prop_var_out_basename = diff_var
nl_var_primary = u
nl_var_secondary = v
couple_old_values_and_properties = true
[../]
[./interface_material_jump_primary_minus_secondary]
type = InterfaceValueMaterial
mat_prop_primary = diffusivity
mat_prop_secondary = diffusivity
var_primary = diffusivity_var
var_secondary = diffusivity_var
mat_prop_out_basename = diff
boundary = interface
interface_value_type = jump_primary_minus_secondary
mat_prop_var_out_basename = diff_var
nl_var_primary = u
nl_var_secondary = v
couple_old_values_and_properties = true
[../]
[./interface_material_jump_secondary_minus_primary]
type = InterfaceValueMaterial
mat_prop_primary = diffusivity
mat_prop_secondary = diffusivity
var_primary = diffusivity_var
var_secondary = diffusivity_var
mat_prop_out_basename = diff
boundary = interface
interface_value_type = jump_secondary_minus_primary
mat_prop_var_out_basename = diff_var
nl_var_primary = u
nl_var_secondary = v
couple_old_values_and_properties = true
[../]
[./interface_material_jump_abs]
type = InterfaceValueMaterial
mat_prop_primary = diffusivity
mat_prop_secondary = diffusivity
var_primary = diffusivity_var
var_secondary = diffusivity_var
mat_prop_out_basename = diff
boundary = interface
interface_value_type = jump_abs
mat_prop_var_out_basename = diff_var
nl_var_primary = u
nl_var_secondary = v
couple_old_values_and_properties = true
[../]
[./interface_material_primary]
type = InterfaceValueMaterial
mat_prop_primary = diffusivity
mat_prop_secondary = diffusivity
var_primary = diffusivity_var
var_secondary = diffusivity_var
mat_prop_out_basename = diff
boundary = interface
interface_value_type = primary
mat_prop_var_out_basename = diff_var
nl_var_primary = u
nl_var_secondary = v
couple_old_values_and_properties = true
[../]
[./interface_material_secondary]
type = InterfaceValueMaterial
mat_prop_primary = diffusivity
mat_prop_secondary = diffusivity
var_primary = diffusivity_var
var_secondary = diffusivity_var
mat_prop_out_basename = diff
mat_prop_var_out_basename = diff_var
boundary = interface
interface_value_type = secondary
nl_var_primary = u
nl_var_secondary = v
couple_old_values_and_properties = true
[../]
[]
[AuxKernels]
[./interface_material_avg]
type = MaterialRealAux
property = diff_average
variable = diffusivity_average
boundary = interface
[]
[./interface_material_jump_primary_minus_secondary]
type = MaterialRealAux
property = diff_jump_primary_minus_secondary
variable = diffusivity_jump_primary_minus_secondary
boundary = interface
[]
[./interface_material_jump_secondary_minus_primary]
type = MaterialRealAux
property = diff_jump_secondary_minus_primary
variable = diffusivity_jump_secondary_minus_primary
boundary = interface
[]
[./interface_material_jump_abs]
type = MaterialRealAux
property = diff_jump_abs
variable = diffusivity_jump_abs
boundary = interface
[]
[./interface_material_primary]
type = MaterialRealAux
property = diff_primary
variable = diffusivity_primary
boundary = interface
[]
[./interface_material_secondary]
type = MaterialRealAux
property = diff_secondary
variable = diffusivity_secondary
boundary = interface
[]
[./interface_material_avg_prev]
type = MaterialRealAux
property = diff_average_prev
variable = diffusivity_average_prev
boundary = interface
[]
[./interface_material_jump_primary_minus_secondary_prev]
type = MaterialRealAux
property = diff_jump_primary_minus_secondary_prev
variable = diffusivity_jump_primary_minus_secondary_prev
boundary = interface
[]
[./interface_material_jump_secondary_minus_primary_prev]
type = MaterialRealAux
property = diff_jump_secondary_minus_primary_prev
variable = diffusivity_jump_secondary_minus_primary_prev
boundary = interface
[]
[./interface_material_jump_abs_prev]
type = MaterialRealAux
property = diff_jump_abs_prev
variable = diffusivity_jump_abs_prev
boundary = interface
[]
[./interface_material_primary_prev]
type = MaterialRealAux
property = diff_primary_prev
variable = diffusivity_primary_prev
boundary = interface
[]
[./interface_material_secondary_prev]
type = MaterialRealAux
property = diff_secondary_prev
variable = diffusivity_secondary_prev
boundary = interface
[]
[diffusivity_var]
type = MaterialRealAux
property = diffusivity
variable = diffusivity_var
[]
[]
[AuxVariables]
[diffusivity_var]
family = MONOMIAL
order = CONSTANT
[]
[./diffusivity_average]
family = MONOMIAL
order = CONSTANT
[]
[./diffusivity_jump_primary_minus_secondary]
family = MONOMIAL
order = CONSTANT
[]
[./diffusivity_jump_secondary_minus_primary]
family = MONOMIAL
order = CONSTANT
[]
[./diffusivity_jump_abs]
family = MONOMIAL
order = CONSTANT
[]
[./diffusivity_primary]
family = MONOMIAL
order = CONSTANT
[]
[./diffusivity_secondary]
family = MONOMIAL
order = CONSTANT
[]
[./diffusivity_average_prev]
family = MONOMIAL
order = CONSTANT
[]
[./diffusivity_jump_primary_minus_secondary_prev]
family = MONOMIAL
order = CONSTANT
[]
[./diffusivity_jump_secondary_minus_primary_prev]
family = MONOMIAL
order = CONSTANT
[]
[./diffusivity_jump_abs_prev]
family = MONOMIAL
order = CONSTANT
[]
[./diffusivity_primary_prev]
family = MONOMIAL
order = CONSTANT
[]
[./diffusivity_secondary_prev]
family = MONOMIAL
order = CONSTANT
[]
[]
[Executioner]
type = Transient
solve_type = NEWTON
num_steps = 3
dt = 0.5
[]
[Outputs]
exodus = true
[]
(test/src/materials/InterfaceValueMaterial.C)
// This file is part of the MOOSE framework
// https://www.mooseframework.org
//
// All rights reserved, see COPYRIGHT for full restrictions
// https://github.com/idaholab/moose/blob/master/COPYRIGHT
//
// Licensed under LGPL 2.1, please see LICENSE for details
// https://www.gnu.org/licenses/lgpl-2.1.html
#include "InterfaceValueMaterial.h"
#include "InterfaceValueTools.h"
registerMooseObject("MooseTestApp", InterfaceValueMaterial);
registerMooseObject("MooseTestApp", ADInterfaceValueMaterial);
template <bool is_ad>
InputParameters
InterfaceValueMaterialTempl<is_ad>::validParams()
{
InputParameters params = InterfaceMaterial::validParams();
params.addClassDescription("Calculates a variable's jump value across an interface.");
params.addRequiredParam<std::string>(
"mat_prop_primary", "The material property on the primary side of the interface");
params.addRequiredParam<std::string>(
"mat_prop_secondary", "The material property on the secondary side of the interface");
params.addRequiredParam<std::string>("mat_prop_out_basename",
"The base name for the output material property");
params.addRequiredCoupledVar(
"var_primary",
"A variable on the primary side of the interface that should be equivalent to the value of "
"the primary material property (through MaterialRealAux for example");
params.addRequiredCoupledVar(
"var_secondary",
"A variable on the secondary side of the interface that should be equivalent to the value of "
"the secondary material property (through MaterialRealAux for example");
params.addRequiredCoupledVar("nl_var_primary",
"Primary side non-linear variable for jump computation");
params.addRequiredCoupledVar("nl_var_secondary",
"Secondary side non-linear variable for jump computation");
params.addRequiredParam<std::string>("mat_prop_var_out_basename",
"The base name for the output material property");
params.addParam<MooseEnum>("interface_value_type",
InterfaceValueTools::InterfaceAverageOptions(),
"Type of scalar output");
params.addParam<bool>("couple_old_values_and_properties",
false,
"get also old variable and material properties values");
return params;
}
template <bool is_ad>
InterfaceValueMaterialTempl<is_ad>::InterfaceValueMaterialTempl(const InputParameters & parameters)
: InterfaceMaterial(parameters),
_mp_primary_name(getParam<std::string>("mat_prop_primary")),
_mp_secondary_name(getParam<std::string>("mat_prop_secondary")),
_mp_primary(getMaterialPropertyByName<Real>(_mp_primary_name)),
_mp_secondary(getNeighborMaterialPropertyByName<Real>(_mp_secondary_name)),
_var_primary(coupledGenericValue<is_ad>("var_primary")),
_var_secondary(coupledGenericNeighborValue<is_ad>("var_secondary")),
_nl_var_primary(coupledValue("nl_var_primary")),
_nl_var_secondary(coupledNeighborValue("nl_var_secondary")),
_couple_old_values_and_properties(getParam<bool>("couple_old_values_and_properties")),
_mp_primary_old(_couple_old_values_and_properties
? &getMaterialPropertyOldByName<Real>(_mp_primary_name)
: nullptr),
_mp_secondary_old(_couple_old_values_and_properties
? &getNeighborMaterialPropertyOld<Real>(_mp_secondary_name)
: nullptr),
_var_primary_old(_couple_old_values_and_properties ? &coupledValueOld("var_primary") : nullptr),
_var_secondary_old(_couple_old_values_and_properties ? &coupledNeighborValueOld("var_secondary")
: nullptr),
_nl_var_primary_old(_couple_old_values_and_properties ? &coupledValueOld("nl_var_primary")
: nullptr),
_nl_var_secondary_old(
_couple_old_values_and_properties ? &coupledNeighborValueOld("nl_var_secondary") : nullptr),
_interface_value_type(parameters.get<MooseEnum>("interface_value_type")),
_mp_out_base_name(getParam<std::string>("mat_prop_out_basename")),
_mp_var_out_base_name(getParam<std::string>("mat_prop_var_out_basename")),
_interface_value(
declareProperty<Real>(_mp_out_base_name + "_" + std::string(_interface_value_type))),
_interface_value_2(
declareProperty<Real>(_mp_var_out_base_name + "_" + std::string(_interface_value_type))),
_interface_value_old(
getMaterialPropertyOld<Real>(_mp_out_base_name + "_" + std::string(_interface_value_type))),
_interface_value_2_old(getMaterialPropertyOld<Real>(_mp_var_out_base_name + "_" +
std::string(_interface_value_type))),
_interface_value_prev(declareProperty<Real>(_mp_out_base_name + "_" +
std::string(_interface_value_type) + "_prev")),
_interface_value_prev_2(declareProperty<Real>(_mp_var_out_base_name + "_" +
std::string(_interface_value_type) + "_prev_2")),
_jump(declareProperty<Real>(std::string(_interface_value_type) + "_jump")),
_jump_prev(declareProperty<Real>(std::string(_interface_value_type) + "_jump_prev"))
{
}
template <bool is_ad>
void
InterfaceValueMaterialTempl<is_ad>::computeQpProperties()
{
mooseAssert(_neighbor_elem, "Neighbor elem is NULL!");
mooseAssert(_mp_primary[_qp] == _var_primary[_qp],
"the material property and variable values on the primary side do not coincide.");
mooseAssert(_mp_secondary[_qp] == _var_secondary[_qp],
"the material property and variable values on the secondary side do not coincide.");
_interface_value[_qp] =
InterfaceValueTools::getQuantity(_interface_value_type, _mp_primary[_qp], _mp_secondary[_qp]);
_interface_value_2[_qp] =
InterfaceValueTools::getQuantity(_interface_value_type,
MetaPhysicL::raw_value(_var_primary[_qp]),
MetaPhysicL::raw_value(_var_secondary[_qp]));
_jump[_qp] = _nl_var_primary[_qp] - _nl_var_secondary[_qp];
if (_couple_old_values_and_properties)
{
_interface_value_prev[_qp] = InterfaceValueTools::getQuantity(
_interface_value_type, (*_mp_primary_old)[_qp], (*_mp_secondary_old)[_qp]);
_interface_value_prev_2[_qp] = InterfaceValueTools::getQuantity(
_interface_value_type, (*_var_primary_old)[_qp], (*_var_secondary_old)[_qp]);
_jump_prev[_qp] = (*_nl_var_primary_old)[_qp] - (*_nl_var_secondary_old)[_qp];
}
}
template <bool is_ad>
void
InterfaceValueMaterialTempl<is_ad>::initQpStatefulProperties()
{
mooseAssert(_neighbor_elem, "Neighbor elem is NULL!");
_interface_value[_qp] = 0;
_interface_value_2[_qp] = 0;
}
template class InterfaceValueMaterialTempl<false>;
template class InterfaceValueMaterialTempl<true>;
(test/src/materials/JumpInterfaceMaterial.C)
// This file is part of the MOOSE framework
// https://www.mooseframework.org
//
// All rights reserved, see COPYRIGHT for full restrictions
// https://github.com/idaholab/moose/blob/master/COPYRIGHT
//
// Licensed under LGPL 2.1, please see LICENSE for details
// https://www.gnu.org/licenses/lgpl-2.1.html
#include "JumpInterfaceMaterial.h"
registerMooseObject("MooseTestApp", JumpInterfaceMaterial);
InputParameters
JumpInterfaceMaterial::validParams()
{
InputParameters params = InterfaceMaterial::validParams();
params.addClassDescription("Calculates a variable's jump value across an interface.");
params.addRequiredCoupledVar("var", "Name of the variable");
params.addRequiredCoupledVar("neighbor_var", "Name of the neighbor variable");
return params;
}
JumpInterfaceMaterial::JumpInterfaceMaterial(const InputParameters & parameters)
: InterfaceMaterial(parameters),
_value(coupledValue("var")),
_neighbor_value(coupledNeighborValue("neighbor_var")),
_ad_value(adCoupledValue("var")),
_ad_neighbor_value(adCoupledNeighborValue("neighbor_var")),
_jump(declareProperty<Real>("jump")),
_ad_jump(declareADProperty<Real>("ad_jump"))
{
}
void
JumpInterfaceMaterial::computeQpProperties()
{
_jump[_qp] = _value[_qp] - _neighbor_value[_qp];
_ad_jump[_qp] = _ad_value[_qp] - _ad_neighbor_value[_qp];
}
(test/include/materials/InterfaceValueMaterial.h)
// This file is part of the MOOSE framework
// https://www.mooseframework.org
//
// All rights reserved, see COPYRIGHT for full restrictions
// https://github.com/idaholab/moose/blob/master/COPYRIGHT
//
// Licensed under LGPL 2.1, please see LICENSE for details
// https://www.gnu.org/licenses/lgpl-2.1.html
#pragma once
#include "InterfaceMaterial.h"
/**
* Interface material calculates a variable's jump value across an interface
*/
template <bool is_ad>
class InterfaceValueMaterialTempl : public InterfaceMaterial
{
public:
static InputParameters validParams();
InterfaceValueMaterialTempl(const InputParameters & parameters);
protected:
virtual void computeQpProperties() override;
virtual void initQpStatefulProperties() override;
const std::string _mp_primary_name;
const std::string _mp_secondary_name;
const MaterialProperty<Real> & _mp_primary;
const MaterialProperty<Real> & _mp_secondary;
const GenericVariableValue<is_ad> & _var_primary;
const GenericVariableValue<is_ad> & _var_secondary;
const VariableValue & _nl_var_primary;
const VariableValue & _nl_var_secondary;
/// old values
const bool _couple_old_values_and_properties;
const MaterialProperty<Real> * const _mp_primary_old;
const MaterialProperty<Real> * const _mp_secondary_old;
const VariableValue * const _var_primary_old;
const VariableValue * const _var_secondary_old;
const VariableValue * const _nl_var_primary_old;
const VariableValue * const _nl_var_secondary_old;
/// the value type to be computed across the interface
const MooseEnum _interface_value_type;
const std::string _mp_out_base_name;
const std::string _mp_var_out_base_name;
MaterialProperty<Real> & _interface_value;
MaterialProperty<Real> & _interface_value_2;
const MaterialProperty<Real> & _interface_value_old;
const MaterialProperty<Real> & _interface_value_2_old;
MaterialProperty<Real> & _interface_value_prev;
MaterialProperty<Real> & _interface_value_prev_2;
MaterialProperty<Real> & _jump;
// previous jump value
MaterialProperty<Real> & _jump_prev;
};
typedef InterfaceValueMaterialTempl<false> InterfaceValueMaterial;
typedef InterfaceValueMaterialTempl<true> ADInterfaceValueMaterial;
(test/include/materials/JumpInterfaceMaterial.h)
// This file is part of the MOOSE framework
// https://www.mooseframework.org
//
// All rights reserved, see COPYRIGHT for full restrictions
// https://github.com/idaholab/moose/blob/master/COPYRIGHT
//
// Licensed under LGPL 2.1, please see LICENSE for details
// https://www.gnu.org/licenses/lgpl-2.1.html
#pragma once
#include "InterfaceMaterial.h"
#include "MaterialProperty.h"
/**
* Interface material calculates a variable's jump value across an interface
*/
class JumpInterfaceMaterial : public InterfaceMaterial
{
public:
static InputParameters validParams();
JumpInterfaceMaterial(const InputParameters & parameters);
protected:
virtual void computeQpProperties() override;
const VariableValue & _value;
const VariableValue & _neighbor_value;
const ADVariableValue & _ad_value;
const ADVariableValue & _ad_neighbor_value;
MaterialProperty<Real> & _jump;
ADMaterialProperty<Real> & _ad_jump;
};