tractionDisplacementCorrectionFvPatchVectorField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
28 #include "volFields.H"
29 
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 
35 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
36 
39 (
40  const fvPatch& p,
41  const DimensionedField<vector, volMesh>& iF
42 )
43 :
44  fixedGradientFvPatchVectorField(p, iF),
45  traction_(p.size(), Zero),
46  pressure_(p.size(), 0.0)
47 {
48  fvPatchVectorField::operator=(patchInternalField());
49  gradient() = Zero;
50 }
51 
52 
53 tractionDisplacementCorrectionFvPatchVectorField::
54 tractionDisplacementCorrectionFvPatchVectorField
55 (
56  const tractionDisplacementCorrectionFvPatchVectorField& tdpvf,
57  const fvPatch& p,
58  const DimensionedField<vector, volMesh>& iF,
59  const fvPatchFieldMapper& mapper
60 )
61 :
62  fixedGradientFvPatchVectorField(tdpvf, p, iF, mapper),
63  traction_(tdpvf.traction_, mapper),
64  pressure_(tdpvf.pressure_, mapper)
65 {}
66 
67 
68 tractionDisplacementCorrectionFvPatchVectorField::
69 tractionDisplacementCorrectionFvPatchVectorField
70 (
71  const fvPatch& p,
72  const DimensionedField<vector, volMesh>& iF,
73  const dictionary& dict
74 )
75 :
76  fixedGradientFvPatchVectorField(p, iF),
77  traction_("traction", dict, p.size()),
78  pressure_("pressure", dict, p.size())
79 {
80  fvPatchVectorField::operator=(patchInternalField());
81  gradient() = Zero;
82 }
83 
84 
85 tractionDisplacementCorrectionFvPatchVectorField::
86 tractionDisplacementCorrectionFvPatchVectorField
87 (
88  const tractionDisplacementCorrectionFvPatchVectorField& tdpvf
89 )
90 :
91  fixedGradientFvPatchVectorField(tdpvf),
92  traction_(tdpvf.traction_),
93  pressure_(tdpvf.pressure_)
94 {}
95 
96 
97 tractionDisplacementCorrectionFvPatchVectorField::
98 tractionDisplacementCorrectionFvPatchVectorField
99 (
100  const tractionDisplacementCorrectionFvPatchVectorField& tdpvf,
101  const DimensionedField<vector, volMesh>& iF
102 )
103 :
104  fixedGradientFvPatchVectorField(tdpvf, iF),
105  traction_(tdpvf.traction_),
106  pressure_(tdpvf.pressure_)
107 {}
108 
109 
110 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
111 
112 void tractionDisplacementCorrectionFvPatchVectorField::autoMap
113 (
114  const fvPatchFieldMapper& m
115 )
116 {
117  fixedGradientFvPatchVectorField::autoMap(m);
118  traction_.autoMap(m);
119  pressure_.autoMap(m);
120 }
121 
122 
123 // Reverse-map the given fvPatchField onto this fvPatchField
124 void tractionDisplacementCorrectionFvPatchVectorField::rmap
125 (
126  const fvPatchVectorField& ptf,
127  const labelList& addr
128 )
129 {
130  fixedGradientFvPatchVectorField::rmap(ptf, addr);
131 
132  const tractionDisplacementCorrectionFvPatchVectorField& dmptf =
133  refCast<const tractionDisplacementCorrectionFvPatchVectorField>(ptf);
134 
135  traction_.rmap(dmptf.traction_, addr);
136  pressure_.rmap(dmptf.pressure_, addr);
137 }
138 
139 
140 // Update the coefficients associated with the patch field
141 void tractionDisplacementCorrectionFvPatchVectorField::updateCoeffs()
142 {
143  if (updated())
144  {
145  return;
146  }
147 
148  const dictionary& mechanicalProperties = db().lookupObject<IOdictionary>
149  (
150  "mechanicalProperties"
151  );
152 
153  const fvPatchField<scalar>& rho =
154  patch().lookupPatchField<volScalarField, scalar>("rho");
155 
156  const fvPatchField<scalar>& rhoE =
157  patch().lookupPatchField<volScalarField, scalar>("E");
158 
159  const fvPatchField<scalar>& nu =
160  patch().lookupPatchField<volScalarField, scalar>("nu");
161 
162  scalarField E(rhoE/rho);
163  scalarField mu(E/(2.0*(1.0 + nu)));
164  scalarField lambda(nu*E/((1.0 + nu)*(1.0 - 2.0*nu)));
165 
166  Switch planeStress(mechanicalProperties.lookup("planeStress"));
167 
168  if (planeStress)
169  {
170  lambda = nu*E/((1.0 + nu)*(1.0 - nu));
171  }
172 
173  vectorField n(patch().nf());
174 
175  const fvPatchField<symmTensor>& sigmaD =
176  patch().lookupPatchField<volSymmTensorField, symmTensor>("sigmaD");
177 
178  const fvPatchField<tensor>& sigmaExp =
179  patch().lookupPatchField<volTensorField, tensor>("sigmaExp");
180 
181  gradient() =
182  (
183  (traction_ + pressure_*n)/rho - (n & (sigmaD + sigmaExp))
184  )/(2.0*mu + lambda);
185 
186  fixedGradientFvPatchVectorField::updateCoeffs();
187 }
188 
189 
190 // Write
192 {
194  traction_.writeEntry("traction", os);
195  pressure_.writeEntry("pressure", os);
196  writeEntry("value", os);
197 }
198 
199 
200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201 
203 (
205  tractionDisplacementCorrectionFvPatchVectorField
206 );
207 
208 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
209 
210 } // End namespace Foam
211 
212 // ************************************************************************* //
#define makePatchTypeField(PatchTypeField, typePatchTypeField)
Definition: fvPatchField.H:655
GeometricField< symmTensor, fvPatchField, volMesh > volSymmTensorField
Definition: volFieldsFwd.H:58
fvPatchField< vector > fvPatchVectorField
GeometricField< tensor, fvPatchField, volMesh > volTensorField
Definition: volFieldsFwd.H:59
volVectorField vectorField(fieldObject, mesh)
Macros for easy insertion into run-time selection tables.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
SymmTensor< scalar > symmTensor
SymmTensor of scalars.
Definition: symmTensor.H:48
List< label > labelList
A List of labels.
Definition: labelList.H:56
static const zero Zero
Definition: zero.H:91
volScalarField scalarField(fieldObject, mesh)
tractionDisplacementCorrectionFvPatchVectorField(const fvPatch &, const DimensionedField< vector, volMesh > &)
Construct from patch and internal field.
const dimensionedScalar mu
Atomic mass unit.
dimensionedScalar lambda(laminarTransport.lookup("lambda"))
label n
volScalarField & nu
Tensor< scalar > tensor
Tensor of scalars.
Definition: tensor.H:51
runTime write()
Namespace for OpenFOAM.