1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
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
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 "tractionDisplacementCorrectionFvPatchVectorField.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "volFields.H"
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
37 tractionDisplacementCorrectionFvPatchVectorField::
38 tractionDisplacementCorrectionFvPatchVectorField
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 tractionDisplacementCorrectionFvPatchVectorField::
54 tractionDisplacementCorrectionFvPatchVectorField
56 const tractionDisplacementCorrectionFvPatchVectorField& tdpvf,
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 tractionDisplacementCorrectionFvPatchVectorField::
69 tractionDisplacementCorrectionFvPatchVectorField
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 tractionDisplacementCorrectionFvPatchVectorField::
86 tractionDisplacementCorrectionFvPatchVectorField
88 const tractionDisplacementCorrectionFvPatchVectorField& tdpvf
91 fixedGradientFvPatchVectorField(tdpvf),
92 traction_(tdpvf.traction_),
93 pressure_(tdpvf.pressure_)
97 tractionDisplacementCorrectionFvPatchVectorField::
98 tractionDisplacementCorrectionFvPatchVectorField
100 const tractionDisplacementCorrectionFvPatchVectorField& tdpvf,
101 const DimensionedField<vector, volMesh>& iF
104 fixedGradientFvPatchVectorField(tdpvf, iF),
105 traction_(tdpvf.traction_),
106 pressure_(tdpvf.pressure_)
110 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
112 void tractionDisplacementCorrectionFvPatchVectorField::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 tractionDisplacementCorrectionFvPatchVectorField::rmap
126 const fvPatchVectorField& ptf,
127 const labelList& addr
130 fixedGradientFvPatchVectorField::rmap(ptf, addr);
132 const tractionDisplacementCorrectionFvPatchVectorField& dmptf =
133 refCast<const tractionDisplacementCorrectionFvPatchVectorField>(ptf);
135 traction_.rmap(dmptf.traction_, addr);
136 pressure_.rmap(dmptf.pressure_, addr);
140 // Update the coefficients associated with the patch field
141 void tractionDisplacementCorrectionFvPatchVectorField::updateCoeffs()
148 const dictionary& mechanicalProperties = db().lookupObject<IOdictionary>
150 "mechanicalProperties"
153 const fvPatchField<scalar>& rho =
154 patch().lookupPatchField<volScalarField, scalar>("rho");
156 const fvPatchField<scalar>& rhoE =
157 patch().lookupPatchField<volScalarField, scalar>("E");
159 const fvPatchField<scalar>& nu =
160 patch().lookupPatchField<volScalarField, scalar>("nu");
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));
166 Switch planeStress(mechanicalProperties.lookup("planeStress"));
170 lambda = nu*E/((1.0 + nu)*(1.0 - nu));
173 vectorField n(patch().nf());
175 const fvPatchField<symmTensor>& sigmaD =
176 patch().lookupPatchField<volSymmTensorField, symmTensor>("sigmaD");
178 const fvPatchField<tensor>& sigmaExp =
179 patch().lookupPatchField<volTensorField, tensor>("sigmaExp");
183 (traction_ + pressure_*n)/rho - (n & (sigmaD + sigmaExp))
186 fixedGradientFvPatchVectorField::updateCoeffs();
191 void tractionDisplacementCorrectionFvPatchVectorField::write(Ostream& os) const
193 fvPatchVectorField::write(os);
194 traction_.writeEntry("traction", os);
195 pressure_.writeEntry("pressure", os);
196 writeEntry("value", os);
200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
205 tractionDisplacementCorrectionFvPatchVectorField
208 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
210 } // End namespace Foam
212 // ************************************************************************* //