tractionDisplacementFvPatchVectorField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2 
3  DAFoam : Discrete Adjoint with OpenFOAM
4  Version : v3
5 
6  This file is modified from OpenFOAM's source code
7  applications/solvers/stressAnalysis/solidDisplacementFoam/tractionDisplacement/
8  tractionDisplacementFvPatchVectorField.C
9 
10  OpenFOAM: The Open Source CFD Toolbox
11 
12  Copyright (C): 2011-2016 OpenFOAM Foundation
13 
14  OpenFOAM License:
15 
16  OpenFOAM is free software: you can redistribute it and/or modify it
17  under the terms of the GNU General Public License as published by
18  the Free Software Foundation, either version 3 of the License, or
19  (at your option) any later version.
20 
21  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
22  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
23  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24  for more details.
25 
26  You should have received a copy of the GNU General Public License
27  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
28 
29 \*---------------------------------------------------------------------------*/
30 
32 #include "addToRunTimeSelectionTable.H"
33 #include "volFields.H"
34 
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 
37 namespace Foam
38 {
39 
40 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
41 
44  const fvPatch& p,
45  const DimensionedField<vector, volMesh>& iF)
46  : fixedGradientFvPatchVectorField(p, iF),
47  traction_(p.size(), Zero),
48  pressure_(p.size(), 0.0)
49 {
50  fvPatchVectorField::operator=(patchInternalField());
51  gradient() = Zero;
52 }
53 
57  const fvPatch& p,
58  const DimensionedField<vector, volMesh>& iF,
59  const fvPatchFieldMapper& mapper)
60  : fixedGradientFvPatchVectorField(tdpvf, p, iF, mapper),
61  traction_(tdpvf.traction_, mapper),
62  pressure_(tdpvf.pressure_, mapper)
63 {
64 }
65 
66 
69  const fvPatch& p,
70  const DimensionedField<vector, volMesh>& iF,
71  const dictionary& dict)
72  : fixedGradientFvPatchVectorField(p, iF),
73  traction_("traction", dict, p.size()),
74  pressure_("pressure", dict, p.size())
75 {
76  fvPatchVectorField::operator=(patchInternalField());
77  gradient() = Zero;
78 }
79 
83  : fixedGradientFvPatchVectorField(tdpvf),
84  traction_(tdpvf.traction_),
85  pressure_(tdpvf.pressure_)
86 {
87 }
88 
92  const DimensionedField<vector, volMesh>& iF)
93  : fixedGradientFvPatchVectorField(tdpvf, iF),
94  traction_(tdpvf.traction_),
95  pressure_(tdpvf.pressure_)
96 {
97 }
98 
99 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
100 
102  const fvPatchFieldMapper& m)
103 {
104 
105  fixedGradientFvPatchVectorField::autoMap(m);
106  traction_.autoMap(m);
107  pressure_.autoMap(m);
108 
109 }
110 
112  const fvPatchVectorField& ptf,
113  const labelList& addr)
114 {
115 
116  fixedGradientFvPatchVectorField::rmap(ptf, addr);
117 
119  refCast<const tractionDisplacementFvPatchVectorField>(ptf);
120 
121  traction_.rmap(dmptf.traction_, addr);
122  pressure_.rmap(dmptf.pressure_, addr);
123 
124 }
125 
127 {
128  if (updated())
129  {
130  return;
131  }
132 
133  const dictionary& mechanicalProperties =
134  db().lookupObject<IOdictionary>("mechanicalProperties");
135 
136  const fvPatchField<scalar>& rho =
137  patch().lookupPatchField<volScalarField, scalar>("solid:rho");
138 
139  const fvPatchField<scalar>& rhoE =
140  patch().lookupPatchField<volScalarField, scalar>("E");
141 
142  const fvPatchField<scalar>& nu =
143  patch().lookupPatchField<volScalarField, scalar>("solid:nu");
144 
145  scalarField E(rhoE / rho);
146  scalarField mu(E / (2.0 * (1.0 + nu)));
147  scalarField lambda(nu * E / ((1.0 + nu) * (1.0 - 2.0 * nu)));
148 
149  Switch planeStress(mechanicalProperties.lookup("planeStress"));
150 
151  if (planeStress)
152  {
153  lambda = nu * E / ((1.0 + nu) * (1.0 - nu));
154  }
155 
156  scalarField twoMuLambda(2 * mu + lambda);
157 
158  vectorField n(patch().nf());
159 
160  // NOTE: we can't use the built-in gradient() computation because
161  // it is designed for transient problem, i.e., snGrad() is actually
162  // related to gradient()
163  // Here we implement our owned BC for steady-state
164  const fvPatchField<tensor>& gradD =
165  patch().lookupPatchField<volTensorField, tensor>("gradD");
166  gradient() = ((traction_ - pressure_ * n) / rho
167  - (n & (mu * gradD.T() - (mu + lambda) * gradD))
168  - n * tr(gradD) * lambda)
169  / (2.0 * mu + lambda);
170 
171  fixedGradientFvPatchVectorField::updateCoeffs();
172 }
173 
175 {
176  fvPatchVectorField::write(os);
177  traction_.writeEntry("traction", os);
178  pressure_.writeEntry("pressure", os);
179  writeEntry("value", os);
180 }
181 
182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
183 
185  fvPatchVectorField,
187 
188 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
189 
190 } // End namespace Foam
191 
192 // ************************************************************************* //
mu
volScalarField & mu
Definition: createRefsSolidDisplacement.H:6
Foam::tractionDisplacementFvPatchVectorField::autoMap
virtual void autoMap(const fvPatchFieldMapper &)
Definition: tractionDisplacementFvPatchVectorField.C:101
p
volScalarField & p
Definition: createRefsPimple.H:6
Foam::tractionDisplacementFvPatchVectorField::tractionDisplacementFvPatchVectorField
tractionDisplacementFvPatchVectorField(const fvPatch &, const DimensionedField< vector, volMesh > &)
Definition: tractionDisplacementFvPatchVectorField.C:43
Foam::tractionDisplacementFvPatchVectorField::updateCoeffs
virtual void updateCoeffs()
Definition: tractionDisplacementFvPatchVectorField.C:126
Foam::makePatchTypeField
makePatchTypeField(fvPatchScalarField, multiFreqScalarFvPatchField)
Foam
Definition: multiFreqScalarFvPatchField.C:144
Foam::tractionDisplacementFvPatchVectorField::rmap
virtual void rmap(const fvPatchVectorField &, const labelList &)
Definition: tractionDisplacementFvPatchVectorField.C:111
Foam::tractionDisplacementFvPatchVectorField
Definition: tractionDisplacementFvPatchVectorField.H:50
Foam::tractionDisplacementFvPatchVectorField::write
virtual void write(Ostream &) const
Definition: tractionDisplacementFvPatchVectorField.C:174
gradD
volTensorField & gradD
Definition: createRefsSolidDisplacement.H:10
tractionDisplacementFvPatchVectorField.H
lambda
volScalarField & lambda
Definition: createRefsSolidDisplacement.H:7
rho
volScalarField & rho
Definition: createRefsRhoSimpleC.H:8