Skip to content
Permalink
Browse files

Merge pull request #13161 from jiangwen84/inclined_bc_action

Add inclined no displacement bc ACTION
  • Loading branch information...
bwspenc committed Apr 11, 2019
2 parents f263fc4 + 5b8c8ec commit 0ea7a33cca18d9f98c37bb5db9e6e669406f1dd8
@@ -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.

Oops, something went wrong.
@@ -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
@@ -7,24 +7,24 @@
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html

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

#include "IntegratedBC.h"

class PenaltyInclinedBC;
class PenaltyInclinedNoDisplacementBC;
class Function;

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

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

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

private:
Real _p;
Real _penalty;
};

#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);
}
}
@@ -43,6 +43,8 @@ associateSyntaxInner(Syntax & syntax, ActionFactory & /*action_factory*/)

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

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

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

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

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

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

Real
PenaltyInclinedBC::computeQpResidual()
PenaltyInclinedNoDisplacementBC::computeQpResidual()
{
Real v = 0;
for (unsigned int i = 0; i < _ndisp; ++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
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];
}

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

return 0.0;
@@ -34,33 +34,17 @@
function = '-1000*t'
[../]
[../]
[./right_x]
type = PenaltyInclinedBC
variable = disp_x
boundary = right
penalty = 1.0e8
component = 0
[../]
[./right_y]
type = PenaltyInclinedBC
variable = 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
[./InclinedNoDisplacementBC]
[./right]
boundary = right
penalty = 1.0e8
displacements = 'disp_x disp_y'
[../]
[./bottom]
boundary = bottom
penalty = 1.0e8
displacements = 'disp_x disp_y'
[../]
[../]
[]

Oops, something went wrong.

0 comments on commit 0ea7a33

Please sign in to comment.
You can’t perform that action at this time.