forked from idaholab/moose
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
try using mesh integers but get error idaholab#13764
- Loading branch information
Showing
10 changed files
with
304 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
//* 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 "AuxKernel.h" | ||
|
||
class ElementIntegerAux; | ||
|
||
template <> | ||
InputParameters validParams<ElementIntegerAux>(); | ||
|
||
class ElementIntegerAux : public AuxKernel | ||
{ | ||
public: | ||
ElementIntegerAux(const InputParameters & parameters); | ||
|
||
protected: | ||
virtual Real computeValue() override; | ||
|
||
unsigned int _id; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
//* 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 "ElementIntegerAux.h" | ||
|
||
registerMooseObject("MooseApp", ElementIntegerAux); | ||
|
||
template <> | ||
InputParameters | ||
validParams<ElementIntegerAux>() | ||
{ | ||
InputParameters params = validParams<AuxKernel>(); | ||
params.addClassDescription("Creates a field showing the element integer."); | ||
params.addParam<std::string>("integer_name", | ||
"Element integer to be assigned (default to subdomain ID)"); | ||
return params; | ||
} | ||
|
||
ElementIntegerAux::ElementIntegerAux(const InputParameters & parameters) | ||
: AuxKernel(parameters), | ||
_id(_mesh.getMesh().get_elem_integer_index(getParam<std::string>("integer_name"))) | ||
{ | ||
if (isNodal()) | ||
mooseError("ElementIntegerAux must be for an elemental variable"); | ||
} | ||
|
||
Real | ||
ElementIntegerAux::computeValue() | ||
{ | ||
return _current_elem->get_extra_integer(_id); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
//* 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 "Material.h" | ||
|
||
class ConstantIDMaterial; | ||
|
||
template <> | ||
InputParameters validParams<ConstantIDMaterial>(); | ||
|
||
class ConstantIDMaterial : public Material | ||
{ | ||
public: | ||
ConstantIDMaterial(const InputParameters & parameters); | ||
|
||
protected: | ||
virtual void computeQpProperties() override; | ||
|
||
unsigned int _id; | ||
MaterialProperty<Real> & _prop; | ||
std::vector<Real> _values; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
//* 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 "ConstantIDMaterial.h" | ||
|
||
registerMooseObject("MooseTestApp", ConstantIDMaterial); | ||
|
||
template <> | ||
InputParameters | ||
validParams<ConstantIDMaterial>() | ||
{ | ||
InputParameters params = validParams<Material>(); | ||
params.addRequiredParam<MaterialPropertyName>("prop_name", "The name of the property"); | ||
params.addRequiredParam<std::vector<Real>>( | ||
"prop_values", "List of values to be used for property values based on element integer"); | ||
params.addRequiredParam<std::string>("id_name", "The element integer name"); | ||
|
||
return params; | ||
} | ||
|
||
ConstantIDMaterial::ConstantIDMaterial(const InputParameters & parameters) | ||
: Material(parameters), | ||
_id(_mesh.getMesh().get_elem_integer_index(getParam<std::string>("id_name"))), | ||
_prop(declareProperty<Real>(getParam<MaterialPropertyName>("prop_name"))), | ||
_values(getParam<std::vector<Real>>("prop_values")) | ||
{ | ||
} | ||
|
||
void | ||
ConstantIDMaterial::computeQpProperties() | ||
{ | ||
_prop[_qp] = _values[_current_elem->get_extra_integer(_id)]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
[Mesh] | ||
type = GeneratedMesh | ||
dim = 2 | ||
xmin = 0 | ||
xmax = 1 | ||
ymin = 0 | ||
ymax = 1 | ||
nx = 5 | ||
ny = 5 | ||
extra_integers = 'material_id' | ||
[] | ||
|
||
[MeshModifiers] | ||
[set_material_id0] | ||
type = SubdomainBoundingBox | ||
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 = SubdomainBoundingBox | ||
bottom_left = '0 0 0' | ||
top_right = '0.8 0.6 0' | ||
block_id = 1 | ||
location = OUTSIDE | ||
integer_name = material_id | ||
[] | ||
[] | ||
|
||
[Variables] | ||
[u][] | ||
[] | ||
|
||
[Kernels] | ||
[diff] | ||
type = MatDiffusion | ||
variable = u | ||
diffusivity = dc | ||
[] | ||
[timederivative] | ||
type = TimeDerivative | ||
variable = u | ||
[] | ||
[sourceterm] | ||
type = BodyForce | ||
variable = u | ||
function = 1 | ||
[] | ||
[] | ||
|
||
[AuxVariables] | ||
[id] | ||
family = MONOMIAL | ||
order = CONSTANT | ||
[] | ||
[] | ||
|
||
[AuxKernels] | ||
[id] | ||
type = ElementIntegerAux | ||
variable = id | ||
integer_name = 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 | ||
[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[Tests] | ||
issues = '#13764' | ||
design = 'syntax/Mesh/index.md' | ||
[./mesh_integer] | ||
type = 'Exodiff' | ||
input = 'mesh_integer.i' | ||
exodiff = 'mesh_integer_out.e' | ||
requirement = "MOOSE shall include the ability to use extra element integers." | ||
[../] | ||
[] |