Merge branch 'master' of ssh://git.code.sf.net/p/foam-extend/foam-extend-3.2
[foam-extend-3.2.git] / applications / solvers / solidMechanics / deprecatedSolvers / stressedFoam / tractionDisplacement / tractionDisplacementFvPatchVectorField.C
blobfc96c78d992553ff0986377a17a43bcd19b4757d
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend is free software: you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation, either version 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "tractionDisplacementFvPatchVectorField.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "volFields.H"
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 namespace Foam
35 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
37 tractionDisplacementFvPatchVectorField::
38 tractionDisplacementFvPatchVectorField
40     const fvPatch& p,
41     const DimensionedField<vector, volMesh>& iF
44     fixedGradientFvPatchVectorField(p, iF),
45     traction_(p.size(), vector::zero),
46     pressure_(p.size(), 0.0)
48     fvPatchVectorField::operator=(patchInternalField());
49     gradient() = vector::zero;
53 tractionDisplacementFvPatchVectorField::
54 tractionDisplacementFvPatchVectorField
56     const tractionDisplacementFvPatchVectorField& tdpvf,
57     const fvPatch& p,
58     const DimensionedField<vector, volMesh>& iF,
59     const fvPatchFieldMapper& mapper
62     fixedGradientFvPatchVectorField(tdpvf, p, iF, mapper),
63     traction_(tdpvf.traction_, mapper),
64     pressure_(tdpvf.pressure_, mapper)
68 tractionDisplacementFvPatchVectorField::
69 tractionDisplacementFvPatchVectorField
71     const fvPatch& p,
72     const DimensionedField<vector, volMesh>& iF,
73     const dictionary& dict
76     fixedGradientFvPatchVectorField(p, iF),
77     traction_("traction", dict, p.size()),
78     pressure_("pressure", dict, p.size())
80     fvPatchVectorField::operator=(patchInternalField());
81     gradient() = vector::zero;
85 tractionDisplacementFvPatchVectorField::
86 tractionDisplacementFvPatchVectorField
88     const tractionDisplacementFvPatchVectorField& tdpvf
91     fixedGradientFvPatchVectorField(tdpvf),
92     traction_(tdpvf.traction_),
93     pressure_(tdpvf.pressure_)
97 tractionDisplacementFvPatchVectorField::
98 tractionDisplacementFvPatchVectorField
100     const tractionDisplacementFvPatchVectorField& tdpvf,
101     const DimensionedField<vector, volMesh>& iF
104     fixedGradientFvPatchVectorField(tdpvf, iF),
105     traction_(tdpvf.traction_),
106     pressure_(tdpvf.pressure_)
110 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
112 void tractionDisplacementFvPatchVectorField::autoMap
114     const fvPatchFieldMapper& m
117     fixedGradientFvPatchVectorField::autoMap(m);
118     traction_.autoMap(m);
119     pressure_.autoMap(m);
123 // Reverse-map the given fvPatchField onto this fvPatchField
124 void tractionDisplacementFvPatchVectorField::rmap
126     const fvPatchVectorField& ptf,
127     const labelList& addr
130     fixedGradientFvPatchVectorField::rmap(ptf, addr);
132     const tractionDisplacementFvPatchVectorField& dmptf =
133         refCast<const tractionDisplacementFvPatchVectorField>(ptf);
135     traction_.rmap(dmptf.traction_, addr);
136     pressure_.rmap(dmptf.pressure_, addr);
140 // Update the coefficients associated with the patch field
141 void tractionDisplacementFvPatchVectorField::updateCoeffs()
143     if (updated())
144     {
145         return;
146     }
148     const dictionary& mechanicalProperties =
149         db().lookupObject<IOdictionary>("mechanicalProperties");
151     const dictionary& thermalProperties =
152         db().lookupObject<IOdictionary>("thermalProperties");
154     dimensionedScalar rho(mechanicalProperties.lookup("rho"));
155     dimensionedScalar rhoE(mechanicalProperties.lookup("E"));
156     dimensionedScalar nu(mechanicalProperties.lookup("nu"));
158     dimensionedScalar E = rhoE/rho;
159     dimensionedScalar mu = E/(2.0*(1.0 + nu));
160     dimensionedScalar lambda = nu*E/((1.0 + nu)*(1.0 - 2.0*nu));
161     dimensionedScalar threeK = E/(1.0 - 2.0*nu);
163     Switch planeStress(mechanicalProperties.lookup("planeStress"));
165     if (planeStress)
166     {
167         lambda = nu*E/((1.0 + nu)*(1.0 - nu));
168         threeK = E/(1.0 - nu);
169     }
171     vectorField n = patch().nf();
173     const fvPatchTensorField& gradU =
174         patch().lookupPatchField<volTensorField, tensor>("grad(U)");
176     gradient() =
177     (
178         (traction_ - pressure_*n)/rho.value()
179       - (n & (mu.value()*gradU.T() - (mu + lambda).value()*gradU))
180       - n*tr(gradU)*lambda.value()
181     )/(2.0*mu + lambda).value();
184     Switch thermalStress(thermalProperties.lookup("thermalStress"));
186     if (thermalStress)
187     {
188         dimensionedScalar alpha(thermalProperties.lookup("alpha"));
189         dimensionedScalar threeKalpha = threeK*alpha;
191         const fvPatchScalarField& T =
192             patch().lookupPatchField<volScalarField, scalar>("T");
194         gradient() += n*threeKalpha.value()*T/(2.0*mu + lambda).value();
195     }
197     fixedGradientFvPatchVectorField::updateCoeffs();
201 // Write
202 void tractionDisplacementFvPatchVectorField::write(Ostream& os) const
204     fvPatchVectorField::write(os);
205     traction_.writeEntry("traction", os);
206     pressure_.writeEntry("pressure", os);
207     writeEntry("value", os);
211 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
213 makePatchTypeField(fvPatchVectorField, tractionDisplacementFvPatchVectorField);
215 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217 } // End namespace Foam
219 // ************************************************************************* //