Skip to content

Commit

Permalink
Move PenaltyDirichletBC from tests and add solid_mechanics test closes
Browse files Browse the repository at this point in the history
…idaholab#5268

Also made the penalty a required parameter.  Seems to me that if
you're using penalty anything, you'd better know what the penalty
is.
  • Loading branch information
bwspenc committed Jun 19, 2015
1 parent 782ff0e commit afe324d
Show file tree
Hide file tree
Showing 15 changed files with 165 additions and 11 deletions.
Expand Up @@ -45,8 +45,6 @@ class PenaltyDirichletBC : public IntegratedBC
virtual Real computeQpJacobian();

private:
Function & _func;

Real _p;
Real _v;
};
Expand Down
4 changes: 4 additions & 0 deletions framework/src/base/Moose.C
Expand Up @@ -58,9 +58,11 @@
// bcs
#include "ConvectiveFluxBC.h"
#include "DirichletBC.h"
#include "PenaltyDirichletBC.h"
#include "PresetBC.h"
#include "NeumannBC.h"
#include "FunctionDirichletBC.h"
#include "FunctionPenaltyDirichletBC.h"
#include "FunctionPresetBC.h"
#include "FunctionNeumannBC.h"
#include "MatchedValueBC.h"
Expand Down Expand Up @@ -427,9 +429,11 @@ registerObjects(Factory & factory)
// bcs
registerBoundaryCondition(ConvectiveFluxBC);
registerBoundaryCondition(DirichletBC);
registerBoundaryCondition(PenaltyDirichletBC);
registerBoundaryCondition(PresetBC);
registerBoundaryCondition(NeumannBC);
registerBoundaryCondition(FunctionDirichletBC);
registerBoundaryCondition(FunctionPenaltyDirichletBC);
registerBoundaryCondition(FunctionPresetBC);
registerBoundaryCondition(FunctionNeumannBC);
registerBoundaryCondition(MatchedValueBC);
Expand Down
Expand Up @@ -18,7 +18,7 @@ template<>
InputParameters validParams<FunctionPenaltyDirichletBC>()
{
InputParameters params = validParams<IntegratedBC>();
params.addParam<Real>("penalty",1e6,"Penalty scalar");
params.addRequiredParam<Real>("penalty", "Penalty scalar");
params.addRequiredParam<FunctionName>("function", "Forcing function");

return params;
Expand Down
Expand Up @@ -18,16 +18,14 @@ template<>
InputParameters validParams<PenaltyDirichletBC>()
{
InputParameters params = validParams<IntegratedBC>();
params.addParam<Real>("penalty",1e5,"Penalty scalar");
params.addRequiredParam<Real>("penalty", "Penalty scalar");
params.addParam<Real>("value", 0.0, "Boundary value of the variable");
params.addRequiredParam<FunctionName>("function", "Forcing function");

return params;
}

PenaltyDirichletBC::PenaltyDirichletBC(const std::string & name, InputParameters parameters) :
IntegratedBC(name, parameters),
_func(getFunction("function")),
_p(getParam<Real>("penalty")),
_v(getParam<Real>("value"))
{}
Expand Down
Binary file not shown.
142 changes: 142 additions & 0 deletions modules/solid_mechanics/tests/penalty_dirichlet/penalty_dirichlet.i
@@ -0,0 +1,142 @@
#This tests the PenaltyDirichletBC and PenaltyFunctionDirichletBC on
#a simple solid mechanics problem. A unit cube of material has
#penalty BCs on the left and right hand side. The penalty for both of
#those BCs is the same as the stiffness of the block in that direction,
#so the compliance is due to the left BC, block, and right BC in equal
#portions. As a result, the displacement on the left side is 1/3 the
#displacement imposed by the function, and on the right side it is 2/3
#that value.

[Mesh]
type = GeneratedMesh
dim = 2
xmin = 0.0
xmax = 1.0
ymin = 0.0
ymax = 1.0
nx = 2
ny = 2
displacements = 'disp_x disp_y'
[]

[Variables]
[./disp_x]
order = FIRST
family = LAGRANGE
[../]
[./disp_y]
order = FIRST
family = LAGRANGE
[../]
[]

[AuxVariables]
[./stress_xx]
order = CONSTANT
family = MONOMIAL
[../]
[./stress_yy]
order = CONSTANT
family = MONOMIAL
[../]
[./stress_zz]
order = CONSTANT
family = MONOMIAL
[../]
[]

[SolidMechanics]
[./solid]
disp_x = disp_x
disp_y = disp_y
[../]
[]

[AuxKernels]
[./stress_xx]
type = MaterialTensorAux
variable = stress_xx
tensor = stress
index = 0
[../]
[./stress_yy]
type = MaterialTensorAux
variable = stress_yy
tensor = stress
index = 1
[../]
[./stress_zz]
type = MaterialTensorAux
variable = stress_zz
tensor = stress
index = 2
[../]
[]

[Functions]
[./pull]
type = PiecewiseLinear
xy_data = '0 0
1 0.001'
[../]
[]

[BCs]
[./left_x]
type = PenaltyDirichletBC
variable = disp_x
boundary = left
value = 0.0
penalty = 1e4
[../]
[./right_x]
type = FunctionPenaltyDirichletBC
variable = disp_x
boundary = right
function = pull
penalty = 1e4
[../]
[./bottom_y]
type = DirichletBC
variable = disp_y
boundary = bottom
value = 0.0
[../]
[]

[Materials]
[./solid]
type = Elastic
block = 0
disp_x = disp_x
disp_y = disp_y
youngs_modulus = 1e4
poissons_ratio = 0.0
[../]
[]

[Executioner]
type = Transient

#Preconditioned JFNK (default)
solve_type = 'PJFNK'

petsc_options = '-snes_ksp_ew '
petsc_options_iname = '-ksp_gmres_restart -pc_type -pc_hypre_type'
petsc_options_value = '101 hypre boomeramg'
nl_rel_tol = 1e-12
l_tol = 1e-5
start_time = 0.0
dt = 1
num_steps = 1
[]

[Outputs]
file_base = out
output_initial = true
print_linear_residuals = true
print_perf_log = true
[./exodus]
type = Exodus
[../]
[]
7 changes: 7 additions & 0 deletions modules/solid_mechanics/tests/penalty_dirichlet/tests
@@ -0,0 +1,7 @@
[Tests]
[./test]
type = 'Exodiff'
input = 'penalty_dirichlet.i'
exodiff = 'out.e'
[../]
[]
4 changes: 0 additions & 4 deletions test/src/base/MooseTestApp.C
Expand Up @@ -131,8 +131,6 @@
#include "DGMDDBC.h"
#include "DGFunctionConvectionDirichletBC.h"
#include "CoupledKernelGradBC.h"
#include "PenaltyDirichletBC.h"
#include "FunctionPenaltyDirichletBC.h"

#include "ExplicitODE.h"
#include "ImplicitODEx.h"
Expand Down Expand Up @@ -341,8 +339,6 @@ MooseTestApp::registerObjects(Factory & factory)

registerBoundaryCondition(DGMDDBC);
registerBoundaryCondition(DGFunctionConvectionDirichletBC);
registerBoundaryCondition(PenaltyDirichletBC);
registerBoundaryCondition(FunctionPenaltyDirichletBC);

registerBoundaryCondition(CoupledKernelGradBC);

Expand Down
Expand Up @@ -56,6 +56,7 @@
variable = u
function = solution
boundary = 'top left right bottom'
penalty = 1e6
[../]
[]

Expand Down
Expand Up @@ -55,8 +55,8 @@
type = PenaltyDirichletBC
variable = u
value = 0
function = solution
boundary = 'top left right bottom'
penalty = 1e5
[../]
[]

Expand Down
Expand Up @@ -104,6 +104,7 @@
variable = u
function = slnu
boundary = 'left right top bottom'
penalty = 1e6
[../]
[./bc_v]
type = FunctionDirichletBC
Expand All @@ -117,6 +118,7 @@
variable = u
function = slnu
boundary = 'left right top bottom'
penalty = 1e6
[../]
[./bc_u_tb]
type = CoupledKernelGradBC
Expand Down
2 changes: 2 additions & 0 deletions test/tests/misc/check_error/coupled_grad_without_declare.i
Expand Up @@ -107,6 +107,7 @@
variable = u
function = slnu
boundary = 'left right top bottom'
penalty = 1e6
[../]
[./bc_v]
type = FunctionDirichletBC
Expand All @@ -120,6 +121,7 @@
variable = u
function = slnu
boundary = 'left right top bottom'
penalty = 1e6
[../]
[./bc_u_tb]
type = CoupledKernelGradBC
Expand Down
2 changes: 2 additions & 0 deletions test/tests/outputs/debug/show_var_residual_norms.i
Expand Up @@ -104,6 +104,7 @@
variable = u
function = slnu
boundary = 'left right top bottom'
penalty = 1e6
[../]
[./bc_v]
type = FunctionDirichletBC
Expand All @@ -117,6 +118,7 @@
variable = u
function = slnu
boundary = 'left right top bottom'
penalty = 1e6
[../]
[./bc_u_tb]
type = CoupledKernelGradBC
Expand Down
2 changes: 2 additions & 0 deletions test/tests/outputs/debug/show_var_residual_norms_debug.i
Expand Up @@ -104,6 +104,7 @@
variable = u
function = slnu
boundary = 'left right top bottom'
penalty = 1e6
[../]
[./bc_v]
type = FunctionDirichletBC
Expand All @@ -117,6 +118,7 @@
variable = u
function = slnu
boundary = 'left right top bottom'
penalty = 1e6
[../]
[./bc_u_tb]
type = CoupledKernelGradBC
Expand Down

0 comments on commit afe324d

Please sign in to comment.