Skip to content

Commit

Permalink
Merge pull request #13161 from jiangwen84/inclined_bc_action
Browse files Browse the repository at this point in the history
Add inclined no displacement bc ACTION
  • Loading branch information
bwspenc committed Apr 11, 2019
2 parents f263fc4 + 5b8c8ec commit 0ea7a33
Show file tree
Hide file tree
Showing 13 changed files with 303 additions and 134 deletions.
@@ -0,0 +1,5 @@
# InclinedNoDisplacementBC Action

## Description

The `InclinedNoDisplacementBC` Action is used to create a set of InclinedNoDisplacementBC for a string of displacement variables. See the description, example use, and parameters on the [InclinedNoDisplacementBC](/InclinedNoDisplacementBC/index.md) action system page.

This file was deleted.

@@ -0,0 +1,11 @@
# PenaltyInclinedNoDisplacementBC

!syntax description /BCs/PenaltyInclinedNoDisplacementBC

## Description

`PenaltyInclinedNoDisplacementBC` is a `IntegratedBC` used for enforcing inclined boundary conditions $\mathbf{u}\cdot \mathbf{normal} = 0$ for mechanics problems. With a penalty method, the residual is given as
\begin{equation}
\mathcal{R}_i = \alpha(\mathbf{u}\cdot \mathbf{normal})\mathbf{normal}(\text{component})\psi_i
\end{equation}
where $\alpha$ is the penalty parameter and `component` corresponds to the direction in which to apply the residual. The normal directly comes from the surface normal defined in a mesh.
@@ -0,0 +1,21 @@
# Inclined No Displacement Boundary Condition Action System

!syntax description /BCs/InclinedNoDisplacementBC/InclinedNoDisplacementBCAction

## Description

The InclinedNoDisplacementBCAction Action, given in the input file as simply `InclinedNoDisplacementBC`, is designed to simplify the input file when several variables have the same inclined no displacement boundary condition [Inclined no displacement boundary condition](PenaltyInclinedNoDisplacementBC.md) applied in the normal component.

## Example Input Syntax

!listing modules/tensor_mechanics/test/tests/inclined_bc/inclined_bc_action.i block=BCs/InclinedNoDisplacementBC

!syntax parameters /BCs/InclinedNoDisplacementBC/InclinedNoDisplacementBCAction

## Associated Actions

!syntax list /BCs/InclinedNoDisplacementBC objects=True actions=False subsystems=False

!syntax list /BCs/InclinedNoDisplacementBC objects=False actions=False subsystems=True

!syntax list /BCs/InclinedNoDisplacementBC objects=False actions=True subsystems=False
@@ -0,0 +1,36 @@
//* 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

#ifndef INCLINEDNODISPLACEMENTBCACTION_H
#define INCLINEDNODISPLACEMENTBCACTION_H

#include "Action.h"

class InclinedNoDisplacementBCAction : public Action
{
public:
InclinedNoDisplacementBCAction(const InputParameters & params);

virtual void act() override;

protected:
/// displacement variables
std::vector<VariableName> _displacements;

/// number of displacement variables
unsigned int _ndisp;

/// auxvariables to save residuals
std::vector<AuxVariableName> _save_in;
};

template <>
InputParameters validParams<InclinedNoDisplacementBCAction>();

#endif // INCLINEDNODISPLACEMENTBCACTION_H
Expand Up @@ -7,24 +7,24 @@
//* Licensed under LGPL 2.1, please see LICENSE for details //* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html //* https://www.gnu.org/licenses/lgpl-2.1.html


#ifndef PENALTYINCLINEDBC_H #ifndef PENALTYINCLINEDNODISPLACEMENTBC_H
#define PENALTYINCLINEDBC_H #define PENALTYINCLINEDNODISPLACEMENTBC_H


#include "IntegratedBC.h" #include "IntegratedBC.h"


class PenaltyInclinedBC; class PenaltyInclinedNoDisplacementBC;
class Function; class Function;


template <> template <>
InputParameters validParams<PenaltyInclinedBC>(); InputParameters validParams<PenaltyInclinedNoDisplacementBC>();


/** /**
* Weakly enforce an inclined BC (u\dot n = 0) using a penalty method. * Weakly enforce an inclined BC (u\dot n = 0) using a penalty method.
*/ */
class PenaltyInclinedBC : public IntegratedBC class PenaltyInclinedNoDisplacementBC : public IntegratedBC
{ {
public: public:
PenaltyInclinedBC(const InputParameters & parameters); PenaltyInclinedNoDisplacementBC(const InputParameters & parameters);


protected: protected:
virtual Real computeQpResidual() override; virtual Real computeQpResidual() override;
Expand All @@ -39,7 +39,7 @@ class PenaltyInclinedBC : public IntegratedBC
std::vector<unsigned int> _disp_var; std::vector<unsigned int> _disp_var;


private: private:
Real _p; Real _penalty;
}; };


#endif #endif
@@ -0,0 +1,72 @@
//* 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 "InclinedNoDisplacementBCAction.h"
#include "Factory.h"
#include "FEProblem.h"
#include "Conversion.h"

registerMooseAction("TensorMechanicsApp", InclinedNoDisplacementBCAction, "add_bc");

template <>
InputParameters
validParams<InclinedNoDisplacementBCAction>()
{
InputParameters params = validParams<Action>();
params.addClassDescription("Set up inclined no displacement boundary conditions");

params.addRequiredParam<std::vector<BoundaryName>>(
"boundary", "The list of boundary IDs from the mesh where the pressure will be applied");

params.addParam<std::vector<VariableName>>(
"displacements",
"The displacements appropriate for the simulation geometry and coordinate system");
params.addParam<std::vector<AuxVariableName>>("save_in", "The displacement residuals");

params.addRequiredParam<Real>("penalty", "Penalty parameter");
return params;
}

InclinedNoDisplacementBCAction::InclinedNoDisplacementBCAction(const InputParameters & params)
: Action(params),
_displacements(getParam<std::vector<VariableName>>("displacements")),
_ndisp(_displacements.size()),
_save_in(getParam<std::vector<AuxVariableName>>("save_in"))
{
if (_ndisp == 1)
mooseError("InclinedNoDisplacementBC is specific to 2D and 3D models.");

if (_save_in.size() != 0 && _save_in.size() != _ndisp)
mooseError("Number of save_in variables should equal to the number of displacement variables ",
_displacements.size());
}

void
InclinedNoDisplacementBCAction::act()
{
const std::string kernel_name = "PenaltyInclinedNoDisplacementBC";

// Create pressure BCs
for (unsigned int i = 0; i < _ndisp; ++i)
{
// Create unique kernel name for each of the components
std::string unique_kernel_name = kernel_name + "_" + _name + "_" + Moose::stringify(i);

InputParameters params = _factory.getValidParams(kernel_name);
params.applyParameters(parameters());
params.set<bool>("use_displaced_mesh") = false;
params.set<unsigned int>("component") = i;
params.set<NonlinearVariableName>("variable") = _displacements[i];

if (_save_in.size() == _ndisp)
params.set<std::vector<AuxVariableName>>("save_in") = {_save_in[i]};

_problem->addBoundaryCondition(kernel_name, unique_kernel_name, params);
}
}
2 changes: 2 additions & 0 deletions modules/tensor_mechanics/src/base/TensorMechanicsApp.C
Expand Up @@ -43,6 +43,8 @@ associateSyntaxInner(Syntax & syntax, ActionFactory & /*action_factory*/)


registerSyntax("EmptyAction", "BCs/Pressure"); registerSyntax("EmptyAction", "BCs/Pressure");
registerSyntax("PressureAction", "BCs/Pressure/*"); registerSyntax("PressureAction", "BCs/Pressure/*");
registerSyntax("EmptyAction", "BCs/InclinedNoDisplacementBC");
registerSyntax("InclinedNoDisplacementBCAction", "BCs/InclinedNoDisplacementBC/*");
registerSyntax("EmptyAction", "BCs/CoupledPressure"); registerSyntax("EmptyAction", "BCs/CoupledPressure");
registerSyntax("CoupledPressureAction", "BCs/CoupledPressure/*"); registerSyntax("CoupledPressureAction", "BCs/CoupledPressure/*");


Expand Down
Expand Up @@ -7,17 +7,17 @@
//* Licensed under LGPL 2.1, please see LICENSE for details //* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html //* https://www.gnu.org/licenses/lgpl-2.1.html


#include "PenaltyInclinedBC.h" #include "PenaltyInclinedNoDisplacementBC.h"
#include "Function.h" #include "Function.h"


registerMooseObject("TensorMechanicsApp", PenaltyInclinedBC); registerMooseObject("TensorMechanicsApp", PenaltyInclinedNoDisplacementBC);


template <> template <>
InputParameters InputParameters
validParams<PenaltyInclinedBC>() validParams<PenaltyInclinedNoDisplacementBC>()
{ {
InputParameters params = validParams<IntegratedBC>(); InputParameters params = validParams<IntegratedBC>();
params.addRequiredParam<Real>("penalty", "Penalty scalar"); params.addRequiredParam<Real>("penalty", "Penalty parameter");
params.addRequiredParam<unsigned int>( params.addRequiredParam<unsigned int>(
"component", "An integer corresponding to the direction (0 for x, 1 for y, 2 for z)"); "component", "An integer corresponding to the direction (0 for x, 1 for y, 2 for z)");
params.addRequiredCoupledVar("displacements", params.addRequiredCoupledVar("displacements",
Expand All @@ -26,13 +26,13 @@ validParams<PenaltyInclinedBC>()
return params; return params;
} }


PenaltyInclinedBC::PenaltyInclinedBC(const InputParameters & parameters) PenaltyInclinedNoDisplacementBC::PenaltyInclinedNoDisplacementBC(const InputParameters & parameters)
: IntegratedBC(parameters), : IntegratedBC(parameters),
_component(getParam<unsigned int>("component")), _component(getParam<unsigned int>("component")),
_ndisp(coupledComponents("displacements")), _ndisp(coupledComponents("displacements")),
_disp(3), _disp(3),
_disp_var(_ndisp), _disp_var(_ndisp),
_p(getParam<Real>("penalty")) _penalty(getParam<Real>("penalty"))
{ {
for (unsigned int i = 0; i < _ndisp; ++i) for (unsigned int i = 0; i < _ndisp; ++i)
{ {
Expand All @@ -42,30 +42,30 @@ PenaltyInclinedBC::PenaltyInclinedBC(const InputParameters & parameters)
} }


Real Real
PenaltyInclinedBC::computeQpResidual() PenaltyInclinedNoDisplacementBC::computeQpResidual()
{ {
Real v = 0; Real v = 0;
for (unsigned int i = 0; i < _ndisp; ++i) for (unsigned int i = 0; i < _ndisp; ++i)
v += (*_disp[i])[_qp] * _normals[_qp](i); v += (*_disp[i])[_qp] * _normals[_qp](i);


return _p * _test[_i][_qp] * v * _normals[_qp](_component); return _penalty * _test[_i][_qp] * v * _normals[_qp](_component);
} }


Real Real
PenaltyInclinedBC::computeQpJacobian() PenaltyInclinedNoDisplacementBC::computeQpJacobian()
{ {
return _p * _phi[_j][_qp] * _normals[_qp](_component) * _normals[_qp](_component) * return _penalty * _phi[_j][_qp] * _normals[_qp](_component) * _normals[_qp](_component) *
_test[_i][_qp]; _test[_i][_qp];
} }


Real Real
PenaltyInclinedBC::computeQpOffDiagJacobian(unsigned int jvar) PenaltyInclinedNoDisplacementBC::computeQpOffDiagJacobian(unsigned int jvar)
{ {
for (unsigned int coupled_component = 0; coupled_component < _ndisp; ++coupled_component) for (unsigned int coupled_component = 0; coupled_component < _ndisp; ++coupled_component)
if (jvar == _disp_var[coupled_component]) if (jvar == _disp_var[coupled_component])
{ {
return _p * _phi[_j][_qp] * _normals[_qp](coupled_component) * _normals[_qp](_component) * return _penalty * _phi[_j][_qp] * _normals[_qp](coupled_component) *
_test[_i][_qp]; _normals[_qp](_component) * _test[_i][_qp];
} }


return 0.0; return 0.0;
Expand Down
38 changes: 11 additions & 27 deletions modules/tensor_mechanics/test/tests/inclined_bc/inclined_bc_2d.i
Expand Up @@ -34,33 +34,17 @@
function = '-1000*t' function = '-1000*t'
[../] [../]
[../] [../]
[./right_x] [./InclinedNoDisplacementBC]
type = PenaltyInclinedBC [./right]
variable = disp_x boundary = right
boundary = right penalty = 1.0e8
penalty = 1.0e8 displacements = 'disp_x disp_y'
component = 0 [../]
[../] [./bottom]
[./right_y] boundary = bottom
type = PenaltyInclinedBC penalty = 1.0e8
variable = disp_y displacements = 'disp_x disp_y'
boundary = right [../]
penalty = 1.0e8
component = 1
[../]
[./bottom_x]
type = PenaltyInclinedBC
variable = disp_x
boundary = bottom
penalty = 1.0e8
component = 0
[../]
[./bottom_y]
type = PenaltyInclinedBC
variable = disp_y
boundary = bottom
penalty = 1.0e8
component = 1
[../] [../]
[] []


Expand Down

0 comments on commit 0ea7a33

Please sign in to comment.