Skip to content

Commit

Permalink
Add new layer_bounding_block parameter in LayeredBase to allow NodalU…
Browse files Browse the repository at this point in the history
…serObjects executed on a boundary to be used with layers defined by a block. Closes #12479.
  • Loading branch information
gambka committed Dec 3, 2018
1 parent c9068b4 commit ab040fa
Show file tree
Hide file tree
Showing 9 changed files with 171 additions and 106 deletions.
2 changes: 1 addition & 1 deletion framework/include/userobject/LayeredBase.h
Expand Up @@ -133,7 +133,7 @@ class LayeredBase : private Restartable
bool _cumulative;

/// List of SubdomainIDs, if given
std::vector<SubdomainID> _blocks;
std::vector<SubdomainID> _layer_bounding_blocks;
};

#endif
22 changes: 15 additions & 7 deletions framework/src/userobject/LayeredBase.C
Expand Up @@ -54,6 +54,12 @@ validParams<LayeredBase>()
params.addParam<std::vector<SubdomainName>>(
"block", "The list of block ids (SubdomainID) that this object will be applied");

params.addParam<std::vector<SubdomainName>>("layer_bounding_block",
"List of block ids (SubdomainID) that are used to "
"determine the upper and lower geometric bounds for "
"all layers. If this is not specified, the ids "
"specified in 'block' are used for this purpose.");

return params;
}

Expand All @@ -73,7 +79,7 @@ LayeredBase::LayeredBase(const InputParameters & parameters)
_layer_has_value(declareRestartableData<std::vector<int>>("layer_has_value")),
_layered_base_subproblem(*parameters.getCheckedPointerParam<SubProblem *>("_subproblem")),
_cumulative(parameters.get<bool>("cumulative")),
_blocks()
_layer_bounding_blocks()
{
if (_layered_base_params.isParamValid("num_layers") &&
_layered_base_params.isParamValid("bounds"))
Expand Down Expand Up @@ -101,8 +107,11 @@ LayeredBase::LayeredBase(const InputParameters & parameters)
if (!_interval_based && _sample_type == 1)
mooseError("'sample_type = interpolate' not supported with 'bounds' in ", _layered_base_name);

if (_layered_base_params.isParamValid("block"))
_blocks = _layered_base_subproblem.mesh().getSubdomainIDs(
if (_layered_base_params.isParamValid("layer_bounding_block"))
_layer_bounding_blocks = _layered_base_subproblem.mesh().getSubdomainIDs(
_layered_base_params.get<std::vector<SubdomainName>>("layer_bounding_block"));
else if (_layered_base_params.isParamValid("block"))
_layer_bounding_blocks = _layered_base_subproblem.mesh().getSubdomainIDs(
_layered_base_params.get<std::vector<SubdomainName>>("block"));

_layer_values.resize(_num_layers);
Expand Down Expand Up @@ -234,9 +243,7 @@ void
LayeredBase::initialize()
{
if (_using_displaced_mesh)
{
getBounds();
}

for (unsigned int i = 0; i < _layer_values.size(); i++)
{
Expand Down Expand Up @@ -322,7 +329,7 @@ LayeredBase::setLayerValue(unsigned int layer, Real value)
void
LayeredBase::getBounds()
{
if (_blocks.size() == 0)
if (_layer_bounding_blocks.size() == 0)
{
BoundingBox bounding_box = MeshTools::create_bounding_box(_layered_base_subproblem.mesh());
_direction_min = bounding_box.min()(_direction);
Expand All @@ -339,7 +346,8 @@ LayeredBase::getBounds()
{
auto subdomain_id = elem_ptr->subdomain_id();

if (std::find(_blocks.begin(), _blocks.end(), subdomain_id) == _blocks.end())
if (std::find(_layer_bounding_blocks.begin(), _layer_bounding_blocks.end(), subdomain_id) ==
_layer_bounding_blocks.end())
continue;

for (auto & node : elem_ptr->node_ref_range())
Expand Down
4 changes: 4 additions & 0 deletions framework/src/userobject/LayeredSideIntegral.C
Expand Up @@ -23,6 +23,10 @@ validParams<LayeredSideIntegral>()
LayeredSideIntegral::LayeredSideIntegral(const InputParameters & parameters)
: SideIntegralVariableUserObject(parameters), LayeredBase(parameters)
{
if (parameters.isParamValid("block") && parameters.isParamValid("boundary"))
mooseError("Both block and boundary cannot be specified in LayeredSideIntegral. If you want to "
"define the geometric bounds of the layers from a specified block set "
"layer_bounding_block instead.");
}

void
Expand Down

This file was deleted.

Binary file not shown.
Binary file not shown.
@@ -0,0 +1,129 @@
#
# The mesh consists of two blocks. Block 1 has a height and width of 1 whereas
# block 2 has a height of 2 and width of 1. A gap of 1 exists between the two
# blocks in the x direction. Elements are 0.25 high and 1 wide. The solution
# in block 1 is u = y and block 2 is u = 4y.
#
# Two sets of LayeredAverage values are computed. In both cases, four
# layers are used. In 'bounding_block1', the LayeredAverage values are computed
# on block 1 using the bounds (dimensions of block 2). In 'bounding_block2',
# the LayeredAverage values are computed on block 2 using the bounds (dimensions
# of block 1).
#
# In 'bounding_block1', since the layers are defined by the dimensions of block
# 2 only two layers appear in block one. The values in block 1 are thus:
# 0.25 for 0<y<0.5 and 0.75 for 0.5<y<1.
#
# In 'bounding_block2', since the layers are defined by the dimensions of block
# 1 four layers appear in block two. Any place over and above the top of the
# uppermost layer is included in the uppermost layer. Therefore, the first 3
# layers are 1/4 of the height of block 1 (0.25) whereas the 4th layer has a
# height of 1/4 of block 1 (0.25) plus the additional region in block 2 outside
# the bounds of block 1 (1.0) for a total height of 1.24.
# The values in block 2 are thus:
# 0.5 from 0<y<0.25, 1.5 from 0.25<y<0.5, 2.5 from 0.5<y<0.75, and 5.5 from
# y>0.75.
#
#

[Mesh]
file = layered_average_bounding_block.e
[]

[Variables]
[./u]
[../]
[]

[AuxVariables]
[./bounding_block1]
order = CONSTANT
family = MONOMIAL
[../]
[./bounding_block2]
order = CONSTANT
family = MONOMIAL
[../]
[]

[Kernels]
[./diff]
type = Diffusion
variable = u
[../]
[]

[AuxKernels]
[./bounding_block1]
type = SpatialUserObjectAux
block = 1
variable = bounding_block1
execute_on = timestep_end
user_object = bounding_block1
[../]
[./bounding_block2]
type = SpatialUserObjectAux
block = 2
variable = bounding_block2
execute_on = timestep_end
user_object = bounding_block2
[../]
[]

[BCs]
[./ll]
type = DirichletBC
variable = u
boundary = 1
value = 0
[../]
[./lu]
type = DirichletBC
variable = u
boundary = 2
value = 1
[../]
[./ul]
type = DirichletBC
variable = u
boundary = 3
value = 0
[../]
[./uu]
type = DirichletBC
variable = u
boundary = 4
value = 8
[../]
[]

[UserObjects]
[./bounding_block1]
type = LayeredAverage
direction = y
num_layers = 4
variable = u
execute_on = linear
block = 1
layer_bounding_block = 2
[../]
[./bounding_block2]
type = LayeredAverage
direction = y
num_layers = 4
block = 2
layer_bounding_block = 1
variable = u
execute_on = linear
[../]
[]

[Executioner]
type = Transient
dt = 1
end_time = 1
[]

[Outputs]
exodus = true
[]
9 changes: 9 additions & 0 deletions test/tests/userobjects/layered_average/tests
Expand Up @@ -100,4 +100,13 @@
design = '/LayeredAverage.md'
issues = '#8835 #12152'
[../]
[./block_restricted_bounding_block]
type = 'Exodiff'
input = 'layered_average_bounding_block.i'
exodiff = 'layered_average_bounding_block_out.e'

requirement = "MOOSE shall allow bounds for layered averages when using num_layers to come from a block different than the block restriction"
design = '/LayeredAverage.md'
issues = '#12479'
[../]
[]
13 changes: 13 additions & 0 deletions test/tests/userobjects/layered_side_integral/tests
@@ -1,19 +1,32 @@
[Tests]
design = '\LayeredSideIntegral.md'
issues = '#1289'
[./test]
type = 'Exodiff'
input = 'layered_side_integral_test.i'
exodiff = 'out.e'
requirement = "MOOSE shall correctly compute layered integrals along a specified boundary"
[../]

[./average]
type = 'Exodiff'
input = 'layered_side_average.i'
exodiff = 'layered_side_average_out.e'
requirement = "MOOSE shall allow taking averages of variables along a coordinate axis in layers on a boundary"
[../]

[./flux_average]
type = 'Exodiff'
input = 'layered_side_flux_average.i'
exodiff = 'layered_side_flux_average_out.e'
requirement = "MOOSE shall allow taking averages of the flux of variables along a coordinate axis in layers on a boundary"
[../]

[./layered_side_average_error_check]
type = RunException
input = 'layered_side_average.i'
cli_args = 'UserObjects/layered_side_average/block=0'
expect_err = "Both block and boundary cannot be specified in LayeredSideIntegral. If you want to define the geometric bounds of the layers from a specified block set layer_bounding_block instead."
requirement = "MOOSE shall not allow both the block and boundary parameter to be specified for layered side integrals"
[../]
[]

0 comments on commit ab040fa

Please sign in to comment.