Loading...
Searching...
No Matches
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 | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2016 OpenFOAM Foundation
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26\*---------------------------------------------------------------------------*/
27
30#include "volFields.H"
31
32// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33
34namespace Foam
35{
36
37// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
38
41(
42 const fvPatch& p,
44)
45:
46 fixedGradientFvPatchVectorField(p, iF),
47 traction_(p.size(), Zero),
48 pressure_(p.size(), Zero)
49{
50 extrapolateInternal();
51 gradient() = Zero;
52}
53
54
55tractionDisplacementCorrectionFvPatchVectorField::
56tractionDisplacementCorrectionFvPatchVectorField
57(
58 const tractionDisplacementCorrectionFvPatchVectorField& tdpvf,
59 const fvPatch& p,
60 const DimensionedField<vector, volMesh>& iF,
61 const fvPatchFieldMapper& mapper
62)
63:
64 fixedGradientFvPatchVectorField(tdpvf, p, iF, mapper),
65 traction_(tdpvf.traction_, mapper),
66 pressure_(tdpvf.pressure_, mapper)
67{}
68
69
70tractionDisplacementCorrectionFvPatchVectorField::
71tractionDisplacementCorrectionFvPatchVectorField
72(
73 const fvPatch& p,
74 const DimensionedField<vector, volMesh>& iF,
75 const dictionary& dict
76)
77:
78 fixedGradientFvPatchVectorField(p, iF),
79 traction_("traction", dict, p.size()),
80 pressure_("pressure", dict, p.size())
81{
82 extrapolateInternal();
83 gradient() = Zero;
84}
85
86
87tractionDisplacementCorrectionFvPatchVectorField::
88tractionDisplacementCorrectionFvPatchVectorField
89(
90 const tractionDisplacementCorrectionFvPatchVectorField& tdpvf
91)
92:
93 fixedGradientFvPatchVectorField(tdpvf),
94 traction_(tdpvf.traction_),
95 pressure_(tdpvf.pressure_)
96{}
97
98
99tractionDisplacementCorrectionFvPatchVectorField::
100tractionDisplacementCorrectionFvPatchVectorField
101(
102 const tractionDisplacementCorrectionFvPatchVectorField& tdpvf,
103 const DimensionedField<vector, volMesh>& iF
104)
105:
106 fixedGradientFvPatchVectorField(tdpvf, iF),
107 traction_(tdpvf.traction_),
108 pressure_(tdpvf.pressure_)
109{}
110
111
112// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
113
114void tractionDisplacementCorrectionFvPatchVectorField::autoMap
115(
116 const fvPatchFieldMapper& m
117)
118{
119 fixedGradientFvPatchVectorField::autoMap(m);
120 traction_.autoMap(m);
121 pressure_.autoMap(m);
122}
123
124
125// Reverse-map the given fvPatchField onto this fvPatchField
126void tractionDisplacementCorrectionFvPatchVectorField::rmap
127(
128 const fvPatchVectorField& ptf,
129 const labelList& addr
130)
131{
132 fixedGradientFvPatchVectorField::rmap(ptf, addr);
133
134 const tractionDisplacementCorrectionFvPatchVectorField& dmptf =
135 refCast<const tractionDisplacementCorrectionFvPatchVectorField>(ptf);
136
137 traction_.rmap(dmptf.traction_, addr);
138 pressure_.rmap(dmptf.pressure_, addr);
139}
140
141
142// Update the coefficients associated with the patch field
143void tractionDisplacementCorrectionFvPatchVectorField::updateCoeffs()
144{
145 if (updated())
146 {
147 return;
148 }
149
150 const dictionary& mechanicalProperties = db().lookupObject<IOdictionary>
151 (
152 "mechanicalProperties"
153 );
154
155 const auto& rho = patch().lookupPatchField<volScalarField>("rho");
156 const auto& rhoE = patch().lookupPatchField<volScalarField>("E");
157 const auto& nu = patch().lookupPatchField<volScalarField>("nu");
158
160 scalarField mu(E/(2.0*(1.0 + nu)));
161 scalarField lambda(nu*E/((1.0 + nu)*(1.0 - 2.0*nu)));
162
163 if (mechanicalProperties.get<bool>("planeStress"))
164 {
165 lambda = nu*E/((1.0 + nu)*(1.0 - nu));
166 }
167
168 vectorField n(patch().nf());
169
170 const auto& sigmaD = patch().lookupPatchField<volSymmTensorField>("sigmaD");
171 const auto& sigmaExp = patch().lookupPatchField<volTensorField>("sigmaExp");
172
173 gradient() =
174 (
175 (traction_ + pressure_*n)/rho - (n & (sigmaD + sigmaExp))
176 )/(2.0*mu + lambda);
177
178 fixedGradientFvPatchVectorField::updateCoeffs();
179}
180
181
182// Write
183void tractionDisplacementCorrectionFvPatchVectorField::write(Ostream& os) const
184{
185 fvPatchField<vector>::write(os);
186 traction_.writeEntry("traction", os);
187 pressure_.writeEntry("pressure", os);
188 fvPatchField<vector>::writeValueEntry(os);
189}
190
191
192// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
193
195(
196 fvPatchVectorField,
197 tractionDisplacementCorrectionFvPatchVectorField
198);
199
200// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201
202} // End namespace Foam
203
204// ************************************************************************* //
label n
Macros for easy insertion into run-time selection tables.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition fvPatch.H:71
tractionDisplacementCorrectionFvPatchVectorField(const fvPatch &, const DimensionedField< vector, volMesh > &)
Construct from patch and internal field.
volScalarField & p
OBJstream os(runTime.globalPath()/outputName)
#define makePatchTypeField(PatchTypeField, typePatchTypeField)
Define a concrete fvPatchField type and add to run-time tables Example, (fvPatchScalarField,...
const std::string patch
OpenFOAM patch number as a std::string.
Namespace for OpenFOAM.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
GeometricField< tensor, fvPatchField, volMesh > volTensorField
Field< vector > vectorField
Specialisation of Field<T> for vector.
GeometricField< symmTensor, fvPatchField, volMesh > volSymmTensorField
static constexpr const zero Zero
Global zero (0).
Definition zero.H:127
volScalarField & rhoE
volScalarField & nu
dictionary dict
dimensionedScalar lambda("lambda", dimTime/sqr(dimLength), laminarTransport)