From 35b13bc2e0641e65b2af3bbdf92379fbcaed1668 Mon Sep 17 00:00:00 2001 From: Antoine Jacquey Date: Wed, 3 Apr 2019 16:29:26 +0200 Subject: [PATCH] Added new BC and Action to hold stress. --- include/actions/LynxHoldStressAction.h | 43 +++++++++++++++ include/bcs/LynxHoldStressBC.h | 49 ++++++++++++++++++ src/actions/LynxHoldStressAction.C | 72 ++++++++++++++++++++++++++ src/base/LynxApp.C | 3 ++ src/bcs/LynxHoldStressBC.C | 69 ++++++++++++++++++++++++ 5 files changed, 236 insertions(+) create mode 100644 include/actions/LynxHoldStressAction.h create mode 100644 include/bcs/LynxHoldStressBC.h create mode 100644 src/actions/LynxHoldStressAction.C create mode 100644 src/bcs/LynxHoldStressBC.C diff --git a/include/actions/LynxHoldStressAction.h b/include/actions/LynxHoldStressAction.h new file mode 100644 index 0000000..e8193ff --- /dev/null +++ b/include/actions/LynxHoldStressAction.h @@ -0,0 +1,43 @@ +/******************************************************************************/ +/* LYNX, a MOOSE-based application */ +/* */ +/* Copyright (C) 2017 by Antoine B. Jacquey and Mauro Cacace */ +/* GFZ Potsdam, German Research Centre for Geosciences */ +/* */ +/* This program is free software: you can redistribute it and/or modify */ +/* it under the terms of the GNU General Public License as published by */ +/* the Free Software Foundation, either version 3 of the License, or */ +/* (at your option) any later version. */ +/* */ +/* This program is distributed in the hope that it will be useful, */ +/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ +/* GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with this program. If not, see */ +/******************************************************************************/ + +#ifndef LYNXHOLDSTRESSACTION_H +#define LYNXHOLDSTRESSACTION_H + +#include "Action.h" + +class LynxHoldStressAction; + +template <> +InputParameters validParams(); + +class LynxHoldStressAction : public Action +{ +public: + LynxHoldStressAction(const InputParameters & params); + + virtual void act() override; + +protected: + std::vector> _save_in_vars; + std::vector _has_save_in_vars; +}; + +#endif // LYNXHOLDSTRESSACTION_H diff --git a/include/bcs/LynxHoldStressBC.h b/include/bcs/LynxHoldStressBC.h new file mode 100644 index 0000000..fba4800 --- /dev/null +++ b/include/bcs/LynxHoldStressBC.h @@ -0,0 +1,49 @@ +/******************************************************************************/ +/* LYNX, a MOOSE-based application */ +/* */ +/* Copyright (C) 2017 by Antoine B. Jacquey and Mauro Cacace */ +/* GFZ Potsdam, German Research Centre for Geosciences */ +/* */ +/* This program is free software: you can redistribute it and/or modify */ +/* it under the terms of the GNU General Public License as published by */ +/* the Free Software Foundation, either version 3 of the License, or */ +/* (at your option) any later version. */ +/* */ +/* This program is distributed in the hope that it will be useful, */ +/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ +/* GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with this program. If not, see */ +/******************************************************************************/ + +#ifndef LYNXHOLDSTRESSBC_H +#define LYNXHOLDSTRESSBC_H + +#include "IntegratedBC.h" + +class LynxHoldStressBC; +class Function; + +template <> +InputParameters validParams(); + +class LynxHoldStressBC : public IntegratedBC +{ +public: + LynxHoldStressBC(const InputParameters & parameters); + +protected: + virtual Real computeQpResidual(); + + bool _coupled_pf; + const VariableValue & _pf; + const int _component; + const Real _bulk_modulus; + const Real _shear_modulus; + const MaterialProperty & _elastic_strain_old; + const MaterialProperty & _biot_coeff; +}; + +#endif // LYNXHOLDSTRESSBC_H diff --git a/src/actions/LynxHoldStressAction.C b/src/actions/LynxHoldStressAction.C new file mode 100644 index 0000000..2232f86 --- /dev/null +++ b/src/actions/LynxHoldStressAction.C @@ -0,0 +1,72 @@ +/******************************************************************************/ +/* LYNX, a MOOSE-based application */ +/* */ +/* Copyright (C) 2017 by Antoine B. Jacquey and Mauro Cacace */ +/* GFZ Potsdam, German Research Centre for Geosciences */ +/* */ +/* This program is free software: you can redistribute it and/or modify */ +/* it under the terms of the GNU General Public License as published by */ +/* the Free Software Foundation, either version 3 of the License, or */ +/* (at your option) any later version. */ +/* */ +/* This program is distributed in the hope that it will be useful, */ +/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ +/* GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with this program. If not, see */ +/******************************************************************************/ + +#include "LynxHoldStressAction.h" +#include "Factory.h" +#include "FEProblem.h" +#include "Conversion.h" + +registerMooseAction("LynxApp", LynxHoldStressAction, "add_bc"); + +template <> +InputParameters +validParams() +{ + InputParameters params = validParams(); + params.addClassDescription("Set up hold stress boundary conditions."); + params.addRequiredParam>( + "boundary", "The list of boundary IDs from the mesh where the pressure will be applied."); + params.addRequiredParam>( + "displacements", + "The displacements appropriate for the simulation geometry and coordinate system"); + // Elastic moduli parameters + params.addRangeCheckedParam( + "bulk_modulus", "bulk_modulus >= 0.0", "The drained bulk modulus of the material."); + params.addRangeCheckedParam( + "shear_modulus", "shear_modulus >= 0.0", "The shear modulus of the material."); + params.addCoupledVar("fluid_pressure", "The fluid pressure variable."); + return params; +} + +LynxHoldStressAction::LynxHoldStressAction(const InputParameters & params) : Action(params) {} + +void +LynxHoldStressAction::act() +{ + const std::string kernel_name = "LynxHoldStressBC"; + + std::vector displacements = + getParam>("displacements"); + + // Create pressure BCs + for (unsigned int i = 0; i < displacements.size(); ++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("use_displaced_mesh") = true; + params.set("component") = i; + params.set("variable") = displacements[i]; + + _problem->addBoundaryCondition(kernel_name, unique_kernel_name, params); + } +} diff --git a/src/base/LynxApp.C b/src/base/LynxApp.C index e207d81..8c01caa 100644 --- a/src/base/LynxApp.C +++ b/src/base/LynxApp.C @@ -46,6 +46,9 @@ associateSyntaxInner(Syntax & syntax, ActionFactory & /*action_factory*/) registerSyntax("EmptyAction", "BCs/LynxPressure"); registerSyntax("LynxPressureAction", "BCs/LynxPressure/*"); + + registerSyntax("EmptyAction", "BCs/LynxHoldStress"); + registerSyntax("LynxHoldStressAction", "BCs/LynxHoldStress/*"); } void diff --git a/src/bcs/LynxHoldStressBC.C b/src/bcs/LynxHoldStressBC.C new file mode 100644 index 0000000..88de1bc --- /dev/null +++ b/src/bcs/LynxHoldStressBC.C @@ -0,0 +1,69 @@ +/******************************************************************************/ +/* LYNX, a MOOSE-based application */ +/* */ +/* Copyright (C) 2017 by Antoine B. Jacquey and Mauro Cacace */ +/* GFZ Potsdam, German Research Centre for Geosciences */ +/* */ +/* This program is free software: you can redistribute it and/or modify */ +/* it under the terms of the GNU General Public License as published by */ +/* the Free Software Foundation, either version 3 of the License, or */ +/* (at your option) any later version. */ +/* */ +/* This program is distributed in the hope that it will be useful, */ +/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ +/* GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with this program. If not, see */ +/******************************************************************************/ + +#include "LynxHoldStressBC.h" +#include "Function.h" + +registerMooseObject("LynxApp", LynxHoldStressBC); + +template <> +InputParameters +validParams() +{ + InputParameters params = validParams(); + params.addClassDescription("Hold the stress on a given boundary in a given direction."); + params.addCoupledVar("fluid_pressure", "The fluid pressure variable."); + params.addRequiredParam("component", "The component for the pressure."); + // Elastic moduli parameters + params.addRangeCheckedParam( + "bulk_modulus", "bulk_modulus >= 0.0", "The drained bulk modulus of the material."); + params.addRangeCheckedParam( + "shear_modulus", "shear_modulus >= 0.0", "The shear modulus of the material."); + params.set("use_displaced_mesh") = false; + return params; +} + +LynxHoldStressBC::LynxHoldStressBC(const InputParameters & parameters) + : IntegratedBC(parameters), + _coupled_pf(isCoupled("fluid_pressure")), + _pf(_coupled_pf ? coupledValueOld("fluid_pressure") : _zero), + _component(getParam("component")), + _bulk_modulus(getParam("bulk_modulus")), + _shear_modulus(getParam("shear_modulus")), + _elastic_strain_old(getMaterialPropertyOld("elastic_strain")), + _biot_coeff(getMaterialProperty("biot_coefficient")) +{ + if (_component > 2) + mooseError("Invalid component given for ", name(), ": ", _component, ".\n"); +} + +Real +LynxHoldStressBC::computeQpResidual() +{ + Real vol_strain = _elastic_strain_old[_qp].trace(); + RankTwoTensor dev_strain = _elastic_strain_old[_qp].deviatoric(); + + RankTwoTensor stress = 2.0 * _shear_modulus * dev_strain; + stress.addIa(_bulk_modulus * vol_strain); + + Real value = -(stress(_component, _component) - _biot_coeff[_qp] * _pf[_qp]); + + return value * (_normals[_qp](_component) * _test[_i][_qp]); +} -- GitLab