Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / applications / solvers / stressAnalysis / solidDisplacementFoam / tractionDisplacement / tractionDisplacementFvPatchVectorField.C
blob542e5ed45fd24827ce0feb85718ec2d8bbb20762
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2004-2010 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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.
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.
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/>.
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 void tractionDisplacementFvPatchVectorField::rmap
125     const fvPatchVectorField& ptf,
126     const labelList& addr
129     fixedGradientFvPatchVectorField::rmap(ptf, addr);
131     const tractionDisplacementFvPatchVectorField& dmptf =
132         refCast<const tractionDisplacementFvPatchVectorField>(ptf);
134     traction_.rmap(dmptf.traction_, addr);
135     pressure_.rmap(dmptf.pressure_, addr);
139 void tractionDisplacementFvPatchVectorField::updateCoeffs()
141     if (updated())
142     {
143         return;
144     }
146     const dictionary& mechanicalProperties =
147         db().lookupObject<IOdictionary>("mechanicalProperties");
149     const dictionary& thermalProperties =
150         db().lookupObject<IOdictionary>("thermalProperties");
152     dimensionedScalar rho(mechanicalProperties.lookup("rho"));
153     dimensionedScalar rhoE(mechanicalProperties.lookup("E"));
154     dimensionedScalar nu(mechanicalProperties.lookup("nu"));
156     dimensionedScalar E = rhoE/rho;
157     dimensionedScalar mu = E/(2.0*(1.0 + nu));
158     dimensionedScalar lambda = nu*E/((1.0 + nu)*(1.0 - 2.0*nu));
159     dimensionedScalar threeK = E/(1.0 - 2.0*nu);
161     Switch planeStress(mechanicalProperties.lookup("planeStress"));
163     if (planeStress)
164     {
165         lambda = nu*E/((1.0 + nu)*(1.0 - nu));
166         threeK = E/(1.0 - nu);
167     }
169     scalar twoMuLambda = (2*mu + lambda).value();
171     vectorField n(patch().nf());
173     const fvPatchField<symmTensor>& sigmaD =
174         patch().lookupPatchField<volSymmTensorField, symmTensor>("sigmaD");
176     gradient() =
177     (
178         (traction_ + pressure_*n)/rho.value()
179       + twoMuLambda*fvPatchField<vector>::snGrad() - (n & sigmaD)
180     )/twoMuLambda;
182     Switch thermalStress(thermalProperties.lookup("thermalStress"));
184     if (thermalStress)
185     {
186         dimensionedScalar alpha(thermalProperties.lookup("alpha"));
187         dimensionedScalar threeKalpha = threeK*alpha;
189         const fvPatchField<scalar>& T =
190             patch().lookupPatchField<volScalarField, scalar>("T");
192         gradient() += n*threeKalpha.value()*T/twoMuLambda;
193     }
195     fixedGradientFvPatchVectorField::updateCoeffs();
199 void tractionDisplacementFvPatchVectorField::write(Ostream& os) const
201     fvPatchVectorField::write(os);
202     traction_.writeEntry("traction", os);
203     pressure_.writeEntry("pressure", os);
204     writeEntry("value", os);
208 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
210 makePatchTypeField
212     fvPatchVectorField,
213     tractionDisplacementFvPatchVectorField
216 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
218 } // End namespace Foam
220 // ************************************************************************* //