Skip to content

Commit

Permalink
WIP: Remove BlockRestrictable assumptions about 'variable' parameter
Browse files Browse the repository at this point in the history
Assuming the blocks ids to match 'variable' command is not very robust, what if it is coupled?
(refs idaholab#9889)
  • Loading branch information
aeslaughter committed Oct 19, 2017
1 parent 8664ebb commit 3618bd3
Show file tree
Hide file tree
Showing 24 changed files with 49 additions and 26 deletions.
10 changes: 9 additions & 1 deletion framework/src/actions/SetupResidualDebugAction.C
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "FEProblem.h"
#include "MooseVariable.h"
#include "NonlinearSystemBase.h"
#include "Conversion.h"

template <>
InputParameters
Expand Down Expand Up @@ -50,6 +51,7 @@ SetupResidualDebugAction::act()
{
// add aux-variable
MooseVariable & var = _problem->getVariable(0, var_name);
InputParameters params = _factory.getValidParams("DebugResidualAux");
const std::set<SubdomainID> & subdomains = var.activeSubdomains();

std::stringstream aux_var_ss;
Expand All @@ -59,14 +61,20 @@ SetupResidualDebugAction::act()
if (subdomains.empty())
_problem->addAuxVariable(aux_var_name, FEType(FIRST, LAGRANGE));
else
{
_problem->addAuxVariable(aux_var_name, FEType(FIRST, LAGRANGE), &subdomains);
std::vector<SubdomainName> block_names;
block_names.reserve(subdomains.size());
for (const SubdomainID & id : subdomains)
block_names.push_back(Moose::stringify(id));
params.set<std::vector<SubdomainName>>("block") = block_names;
}

// add aux-kernel
std::stringstream kern_ss;
kern_ss << "residual_" << var.name() << "_kernel";
std::string kern_name = kern_ss.str();

InputParameters params = _factory.getValidParams("DebugResidualAux");
params.set<AuxVariableName>("variable") = aux_var_name;
params.set<NonlinearVariableName>("debug_variable") = var.name();
params.set<MultiMooseEnum>("execute_on") = "linear timestep_end";
Expand Down
22 changes: 1 addition & 21 deletions framework/src/base/BlockRestrictable.C
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "MooseVariable.h"
#include "SystemBase.h"
#include "Conversion.h"
#include "MooseVariableInterface.h"

template <>
InputParameters
Expand Down Expand Up @@ -104,29 +105,8 @@ BlockRestrictable::initializeBlockRestrictable(const MooseObject * moose_object)
_blk_ids.insert(Moose::ANY_BLOCK_ID);
else
_blk_ids.insert(vec_ids.begin(), vec_ids.end());

// Check that supplied blocks are within the variable domain
if (parameters.isParamValid("variable") &&
(parameters.have_parameter<NonlinearVariableName>("variable") ||
parameters.have_parameter<AuxVariableName>("variable")))
{
// A pointer to the variable class
std::set<SubdomainID> var_ids = variableSubdomainIDs(parameters);

// Test if the variable blockIDs are valid for this object
if (!isBlockSubset(var_ids))
mooseError("In object ",
_blk_name,
" the defined blocks are outside of the domain of the variable");
}
}

// The 'block' input parameter is undefined, if the object contains a variable, set the subdomain
// ids to those of the variable
else if (parameters.isParamValid("variable") &&
(parameters.have_parameter<NonlinearVariableName>("variable") ||
parameters.have_parameter<AuxVariableName>("variable")))
_blk_ids = variableSubdomainIDs(parameters);

// Produce error if the object is not allowed to be both block and boundary restricted
if (!_blk_dual_restrictable && !_boundary_ids.empty() && !_boundary_ids.empty())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
value = 8
operator = /
coupled = two
block = 1
[../]

[./coupled_right]
Expand All @@ -58,6 +59,7 @@
value = 8
operator = /
coupled = two
block = 2
[../]

[./two]
Expand Down
1 change: 1 addition & 0 deletions test/tests/auxkernels/gap_value/gap_value.i
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
type = GapValueAux
variable = gap_value
boundary = leftright
block = left
paired_variable = u
paired_boundary = rightleft
[../]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
type = GapValueAux
variable = gap_value
boundary = leftright
block = left
paired_variable = u
paired_boundary = rightleft
[../]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
boundary = leftright
paired_variable = u
paired_boundary = rightleft
block = left
[../]
[]

Expand Down
2 changes: 2 additions & 0 deletions test/tests/geomsearch/patch_update_strategy/always.i
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@
type = CoefDiffusion
variable = u
coef = 1
block = right
[../]
[./time]
type = TimeDerivative
variable = u
block = right
[../]
[]

Expand Down
3 changes: 2 additions & 1 deletion test/tests/geomsearch/patch_update_strategy/auto.i
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@
type = CoefDiffusion
variable = u
coef = 1
block = right
[../]
[./time]
type = TimeDerivative
variable = u
block = right
[../]
[]

Expand Down Expand Up @@ -104,4 +106,3 @@
[Outputs]
exodus = true
[]

2 changes: 2 additions & 0 deletions test/tests/geomsearch/patch_update_strategy/never.i
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@
type = CoefDiffusion
variable = u
coef = 1
block = right
[../]
[./time]
type = TimeDerivative
variable = u
block = right
[../]
[]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
type = BodyForce
variable = u
value = 1
block = 0
[../]
[]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
type = BodyForce
variable = u
value = 1
block = 0
[../]
[]

Expand Down
1 change: 1 addition & 0 deletions test/tests/kernels/block_kernel/block_vars.i
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
[./diff_u]
type = Diffusion
variable = u
block = 1
[../]

[./diff_v]
Expand Down
2 changes: 2 additions & 0 deletions test/tests/mortar/2d/conforming-2nd-order.i
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@
[./diff]
type = Diffusion
variable = u
block = '1 2'
[../]
[./ffn]
type = BodyForce
variable = u
function = ffn
block = '1 2'
[../]
[]

Expand Down
2 changes: 2 additions & 0 deletions test/tests/mortar/2d/conforming.i
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@
[./diff]
type = Diffusion
variable = u
block = '1 2'
[../]
[./ffn]
type = BodyForce
variable = u
function = ffn
block = '1 2'
[../]
[]

Expand Down
4 changes: 4 additions & 0 deletions test/tests/mortar/2d/conforming_two_var.i
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,24 @@
[./diff_u]
type = Diffusion
variable = u
block = '1 2'
[../]
[./ffn]
type = BodyForce
variable = u
function = ffn
block = '1 2'
[../]
[./diff_v]
type = Diffusion
variable = v
block = '1 2'
[../]
[./coupled_u]
type = CoupledForce
variable = v
v = u
block = '1 2'
[../]
[]

Expand Down
2 changes: 2 additions & 0 deletions test/tests/mortar/2d/equalgradient.i
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@
[./diff]
type = Diffusion
variable = u
block = '1 2'
[../]
[./dt]
type = TimeDerivative
variable = u
block = '1 2'
[../]
[]

Expand Down
2 changes: 2 additions & 0 deletions test/tests/mortar/2d/non-conforming-2nd-order.i
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@
[./diff]
type = Diffusion
variable = u
block = '1 2'
[../]
[./ffn]
type = BodyForce
variable = u
function = ffn
block = '1 2'
[../]
[]

Expand Down
2 changes: 2 additions & 0 deletions test/tests/mortar/2d/non-conforming.i
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@
[./diff]
type = Diffusion
variable = u
block = '1 2'
[../]
[./ffn]
type = BodyForce
variable = u
function = ffn
block = '1 2'
[../]
[]

Expand Down
2 changes: 2 additions & 0 deletions test/tests/mortar/3d/conforming-2nd-order.i
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@
[./diff]
type = Diffusion
variable = u
block = '1 2'
[../]
[./ffn]
type = BodyForce
variable = u
function = forcing_fn
block = '1 2'
[../]
[]

Expand Down
2 changes: 2 additions & 0 deletions test/tests/mortar/3d/conforming.i
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@
[./diff]
type = Diffusion
variable = u
block = '1 2'
[../]
[./ffn]
type = BodyForce
variable = u
function = forcing_fn
block = '1 2'
[../]
[]

Expand Down
2 changes: 2 additions & 0 deletions test/tests/mortar/3d/non-conforming-2nd-order.i
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@
[./diff]
type = Diffusion
variable = u
block = '1 2'
[../]
[./ffn]
type = BodyForce
variable = u
function = forcing_fn
block = '1 2'
[../]
[]

Expand Down
2 changes: 2 additions & 0 deletions test/tests/mortar/3d/non-conforming.i
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@
[./diff]
type = Diffusion
variable = u
block = '1 2'
[../]
[./ffn]
type = BodyForce
variable = u
function = forcing_fn
block = '1 2'
[../]
[]

Expand Down
2 changes: 2 additions & 0 deletions test/tests/outputs/residual/output_residual_test.i
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,13 @@
[./ie_v]
type = TimeDerivative
variable = v
block = 1
[../]

[./diff_v]
type = Diffusion
variable = v
block = 1
[../]

[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
[./diff_u]
type = Diffusion
variable = u
block = 1
[../]
[./diff_v]
type = Diffusion
Expand Down Expand Up @@ -63,9 +64,6 @@

[Executioner]
type = Steady

# Preconditioned JFNK (default)
solve_type = 'PJFNK'
[]

[Outputs]
Expand Down

0 comments on commit 3618bd3

Please sign in to comment.