initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / applications / solvers / stressAnalysis / solidEquilibriumDisplacementFoam / tractionDisplacementCorrection / tractionDisplacementCorrectionFvPatchVectorField.C
blobd071ff7c78d52e8484729d8470aaf36af6bcaf44
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     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, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "tractionDisplacementCorrectionFvPatchVectorField.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "volFields.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 namespace Foam
36 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
38 tractionDisplacementCorrectionFvPatchVectorField::
39 tractionDisplacementCorrectionFvPatchVectorField
41     const fvPatch& p,
42     const DimensionedField<vector, volMesh>& iF
45     fixedGradientFvPatchVectorField(p, iF),
46     traction_(p.size(), vector::zero),
47     pressure_(p.size(), 0.0)
49     fvPatchVectorField::operator=(patchInternalField());
50     gradient() = vector::zero;
54 tractionDisplacementCorrectionFvPatchVectorField::
55 tractionDisplacementCorrectionFvPatchVectorField
57     const tractionDisplacementCorrectionFvPatchVectorField& tdpvf,
58     const fvPatch& p,
59     const DimensionedField<vector, volMesh>& iF,
60     const fvPatchFieldMapper& mapper
63     fixedGradientFvPatchVectorField(tdpvf, p, iF, mapper),
64     traction_(tdpvf.traction_, mapper),
65     pressure_(tdpvf.pressure_, mapper)
69 tractionDisplacementCorrectionFvPatchVectorField::
70 tractionDisplacementCorrectionFvPatchVectorField
72     const fvPatch& p,
73     const DimensionedField<vector, volMesh>& iF,
74     const dictionary& dict
77     fixedGradientFvPatchVectorField(p, iF),
78     traction_("traction", dict, p.size()),
79     pressure_("pressure", dict, p.size())
81     fvPatchVectorField::operator=(patchInternalField());
82     gradient() = vector::zero;
86 tractionDisplacementCorrectionFvPatchVectorField::
87 tractionDisplacementCorrectionFvPatchVectorField
89     const tractionDisplacementCorrectionFvPatchVectorField& tdpvf
92     fixedGradientFvPatchVectorField(tdpvf),
93     traction_(tdpvf.traction_),
94     pressure_(tdpvf.pressure_)
98 tractionDisplacementCorrectionFvPatchVectorField::
99 tractionDisplacementCorrectionFvPatchVectorField
101     const tractionDisplacementCorrectionFvPatchVectorField& tdpvf,
102     const DimensionedField<vector, volMesh>& iF
105     fixedGradientFvPatchVectorField(tdpvf, iF),
106     traction_(tdpvf.traction_),
107     pressure_(tdpvf.pressure_)
111 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
113 void tractionDisplacementCorrectionFvPatchVectorField::autoMap
115     const fvPatchFieldMapper& m
118     fixedGradientFvPatchVectorField::autoMap(m);
119     traction_.autoMap(m);
120     pressure_.autoMap(m);
124 // Reverse-map the given fvPatchField onto this fvPatchField
125 void tractionDisplacementCorrectionFvPatchVectorField::rmap
127     const fvPatchVectorField& ptf,
128     const labelList& addr
131     fixedGradientFvPatchVectorField::rmap(ptf, addr);
133     const tractionDisplacementCorrectionFvPatchVectorField& dmptf =
134         refCast<const tractionDisplacementCorrectionFvPatchVectorField>(ptf);
136     traction_.rmap(dmptf.traction_, addr);
137     pressure_.rmap(dmptf.pressure_, addr);
141 // Update the coefficients associated with the patch field
142 void tractionDisplacementCorrectionFvPatchVectorField::updateCoeffs()
144     if (updated())
145     {
146         return;
147     }
149     const dictionary& mechanicalProperties = db().lookupObject<IOdictionary>
150     (
151         "mechanicalProperties"
152     );
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));
162     Switch planeStress(mechanicalProperties.lookup("planeStress"));
164     if (planeStress)
165     {
166         lambda = nu*E/((1.0 + nu)*(1.0 - nu));
167     }
169     vectorField n = patch().nf();
171     const fvPatchField<symmTensor>& sigmaD =
172         patch().lookupPatchField<volSymmTensorField, symmTensor>("sigmaD");
174     const fvPatchField<tensor>& sigmaExp = 
175         patch().lookupPatchField<volTensorField, tensor>("sigmaExp");
177     gradient() =
178     (
179         (traction_ + pressure_*n)/rho.value() - (n & (sigmaD + sigmaExp))
180     )/(2.0*mu + lambda).value();
182     fixedGradientFvPatchVectorField::updateCoeffs();
186 // Write
187 void tractionDisplacementCorrectionFvPatchVectorField::write(Ostream& os) const
189     fvPatchVectorField::write(os);
190     traction_.writeEntry("traction", os);
191     pressure_.writeEntry("pressure", os);
192     writeEntry("value", os);
196 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198 makePatchTypeField
200     fvPatchVectorField,
201     tractionDisplacementCorrectionFvPatchVectorField
204 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
206 } // End namespace Foam
208 // ************************************************************************* //