Skip to content

Commit

Permalink
override functions in ElementIDInterface for materials idaholab#16005
Browse files Browse the repository at this point in the history
  • Loading branch information
YaqiWang committed Oct 26, 2020
1 parent 9efaf92 commit da23907
Show file tree
Hide file tree
Showing 7 changed files with 188 additions and 4 deletions.
Expand Up @@ -6,7 +6,7 @@ Extra element IDs are identified with extra element ID names.
Extra element IDs are part of the mesh and can be recovered during the mesh recovery.
Please refer to [MeshGenerator](MeshGenerator.md) for how the extra element integer IDs are generated or imported.

The ElementIDInterface is designed for using extra element IDs in the mesh by MOOSE objects such as materials, user objects, aux kernels, etc.
The ElementIDInterface is designed for using extra element IDs in the mesh by MOOSE objects such as materials, user objects, aux kernels, DG kernels, interface kernels, IC (initial conditions), kernels, etc.
The following table summarizes the interface functions provided by this interface:

| Method | Description |
Expand All @@ -25,4 +25,7 @@ getAllElemIDs | Gets all the unique element IDs for an element integer with its
getElemIDsOnBlocks | Gets all the unique element IDs for an extra element integer with its index on a set of subdomains
getElementID | Gets an element integer for an element

Because MOOSE creates three copies of materials for the current element, element face and neighboring element face ([Material](syntax/Materials/index.md)), `getElementID` and `getElementIDByName` return the reference to either the current element ID or the neighbor element ID based on whether the current copy of material is for neighboring element or not. Correspondingly, directly calling `getElementIDNeighbor` and `getElementIDNeighborByName` is not allowed in `Material`.


It is noted that the element integer name *subdomain_id* is reserved by MOOSE for accessing subdomain IDs with this interface.
16 changes: 16 additions & 0 deletions framework/doc/content/syntax/Materials/index.md
Expand Up @@ -199,6 +199,22 @@ table lists the types of properties that are available for automatic output.

## Advanced Topics

### Evaluation of Material Properties on Element Faces

MOOSE creates three copies of a *non-boundary restricted* material for evaluations on quadrature points of elements, element faces on both the current element side and the neighboring element side.
The name of the element interior material is the material name from the input file, while the name of the element face material is the material name appended with `_face` and the name of the neighbor face material is the material name appended with `_neighbor`.
The element material can be identified in a material with its member variable `_bnd=false`.
The other two copies have `_bnd=true`.
The element face material and neighbor face material differentiate with each other by the value of another member variable `_neighbor`.
If a material declares multiple material properties and some of them are not needed on element faces, users can switch off their declaration and evaluation based on member variable `_bnd`.

### Interface Material Objects

MOOSE allows a material to be defined on an internal boundary of a mesh with a specific material type `InterfaceMaterial`.
Material properties declared in interface materials are available on both sides of the boundary.
Interface materials allows users to evaluate the properties on element faces based on quantities on both sides of the element face.
Interface materials are often used along with [InterfaceKernel](syntax/InterfaceKernels/index.md).

### Discrete Material Objects

A "[Discrete](http://www.dictionary.com/browse/discrete)" `Material` is an object that may be
Expand Down
43 changes: 43 additions & 0 deletions framework/include/materials/Material.h
Expand Up @@ -30,6 +30,49 @@ class Material : public MaterialBase, public Coupleable, public MaterialProperty

Material(const InputParameters & parameters);

/**
* Gets an element integer for the proper current element with a parameter of
* the object derived from this interface
* Note: This overrides the function in ElementIDInterface to assure derived materials
* to call the functions in ElementIDInterface properly.
*/
virtual const dof_id_type & getElementID(const std::string & id_parameter_name,
unsigned int comp = 0) const override
{
return _neighbor ? ElementIDInterface::getElementIDNeighbor(id_parameter_name, comp)
: ElementIDInterface::getElementID(id_parameter_name, comp);
}
/**
* Directly calling this function is not needed for materials because the same material has
* three copies for element interior, element side and neighbor side.
*/
virtual const dof_id_type & getElementIDNeighbor(const std::string & id_parameter_name,
unsigned int comp = 0) const override
{
mooseError("Directly calling getElementIDNeighbor is not allowed for materials intead of calling getElementID");
return ElementIDInterface::getElementIDNeighbor(id_parameter_name, comp);
}

/**
* Gets an element integer for the proper current element with the element integer name
* Note: This overrides the function in ElementIDInterface to assure derived materials
* to call the functions in ElementIDInterface properly.
*/
virtual const dof_id_type & getElementIDByName(const std::string & id_parameter_name) const override
{
return _neighbor ? ElementIDInterface::getElementIDNeighborByName(id_parameter_name)
: ElementIDInterface::getElementIDByName(id_parameter_name);
}
/**
* Directly calling this function is not needed for materials because the same material has
* three copies for element interior, element side and neighbor side.
*/
virtual const dof_id_type & getElementIDNeighborByName(const std::string & id_parameter_name) const override
{
mooseError("Directly calling getElementIDNeighborByName is not allowed for materials intead of calling getElementIDByName");
return ElementIDInterface::getElementIDNeighborByName(id_parameter_name);
}

virtual void computeProperties() override;

///@{
Expand Down
117 changes: 117 additions & 0 deletions test/tests/auxkernels/mesh_integer/dg_mesh_integer.i
@@ -0,0 +1,117 @@
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 2
xmin = 0
xmax = 1
ymin = 0
ymax = 1
nx = 5
ny = 5
extra_element_integers = 'material_id'
[]
[set_material_id0]
type = SubdomainBoundingBoxGenerator
input = gmg
bottom_left = '0 0 0'
top_right = '0.8 0.6 0'
block_id = 0
location = INSIDE
integer_name = material_id
[]
[set_material_id1]
type = SubdomainBoundingBoxGenerator
input = set_material_id0
bottom_left = '0 0 0'
top_right = '0.8 0.6 0'
block_id = 1
location = OUTSIDE
integer_name = material_id
[]
[]

[Variables]
[u]
family = L2_LAGRANGE
order = FIRST
[]
[]

[Kernels]
[diff]
type = MatDiffusion
variable = u
diffusivity = dc
[]
[timederivative]
type = TimeDerivative
variable = u
[]
[sourceterm]
type = BodyForce
variable = u
function = 1
[]
[]

[DGKernels]
[dg_diff]
type = DGDiffusion
variable = u
diff = dc
epsilon = -1
sigma = 6
[]
[]

[AuxVariables]
[id]
family = MONOMIAL
order = CONSTANT
[]
[]

[AuxKernels]
[id]
type = ElementIntegerAux
variable = id
integer_names = material_id
[]
[]

[BCs]
[vacuum]
type = VacuumBC
variable = u
boundary = 'right left top bottom'
[]
[]

[Materials]
[dc]
type = ConstantIDMaterial
prop_name = dc
prop_values = '1 2'
id_name = material_id
[]
[]

[Postprocessors]
[unorm]
type = ElementL2Norm
variable = u
[]
[]

[Executioner]
type = Transient

end_time = 0.1
dt = 0.01
nl_abs_tol = 1.e-15
[]

[Outputs]
execute_on = 'timestep_end'
exodus = true
[]
Binary file not shown.
2 changes: 0 additions & 2 deletions test/tests/auxkernels/mesh_integer/mesh_integer.i
@@ -1,6 +1,4 @@
[Mesh]
type = MeshGeneratorMesh

[gmg]
type = GeneratedMeshGenerator
dim = 2
Expand Down
9 changes: 8 additions & 1 deletion test/tests/auxkernels/mesh_integer/tests
@@ -1,10 +1,17 @@
[Tests]
issues = '#13764'
design = 'syntax/Mesh/index.md'
[./mesh_integer]
type = 'Exodiff'
input = 'mesh_integer.i'
exodiff = 'mesh_integer_out.e'
issues = '#13764'
requirement = "MOOSE shall include the ability to use extra element integers."
[../]
[./dg_mesh_integer]
type = 'Exodiff'
input = 'mesh_integer.i'
exodiff = 'mesh_integer_out.e'
issues = '#16005'
requirement = "MOOSE shall include the ability to use extra element integers."
[../]
[]

0 comments on commit da23907

Please sign in to comment.