Forward compatibility: flex
[foam-extend-3.2.git] / src / solidModels / fvPatchFields / analyticalPlateHoleTraction / analyticalPlateHoleTractionFvPatchVectorField.C
blobe4945c28605c0911e974b8baba166bd008e9433c
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 "analyticalPlateHoleTractionFvPatchVectorField.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "volFields.H"
29 #include "constitutiveModel.H"
30 #include "volFields.H"
31 #include "fvc.H"
32 #include "fixedValueFvPatchFields.H"
33 #include "coordinateSystem.H"
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 namespace Foam
40 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
42 analyticalPlateHoleTractionFvPatchVectorField::
43 analyticalPlateHoleTractionFvPatchVectorField
45     const fvPatch& p,
46     const DimensionedField<vector, volMesh>& iF
49     fixedGradientFvPatchVectorField(p, iF),
50     UName_("undefined")
52     fvPatchVectorField::operator=(patchInternalField());
53     gradient() = vector::zero;
57 analyticalPlateHoleTractionFvPatchVectorField::
58 analyticalPlateHoleTractionFvPatchVectorField
60     const fvPatch& p,
61     const DimensionedField<vector, volMesh>& iF,
62     const dictionary& dict
65     fixedGradientFvPatchVectorField(p, iF),
66     UName_("U")
68     fvPatchVectorField::operator=(patchInternalField());
69     gradient() = vector::zero;
73 analyticalPlateHoleTractionFvPatchVectorField::
74 analyticalPlateHoleTractionFvPatchVectorField
76     const analyticalPlateHoleTractionFvPatchVectorField& stpvf,
77     const fvPatch& p,
78     const DimensionedField<vector, volMesh>& iF,
79     const fvPatchFieldMapper& mapper
82     fixedGradientFvPatchVectorField(stpvf, p, iF, mapper),
83     UName_(stpvf.UName_)
87 analyticalPlateHoleTractionFvPatchVectorField::
88 analyticalPlateHoleTractionFvPatchVectorField
90     const analyticalPlateHoleTractionFvPatchVectorField& stpvf
93     fixedGradientFvPatchVectorField(stpvf),
94     UName_(stpvf.UName_)
98 analyticalPlateHoleTractionFvPatchVectorField::
99 analyticalPlateHoleTractionFvPatchVectorField
101     const analyticalPlateHoleTractionFvPatchVectorField& stpvf,
102     const DimensionedField<vector, volMesh>& iF
105     fixedGradientFvPatchVectorField(stpvf, iF),
106     UName_(stpvf.UName_)
110 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
112 void analyticalPlateHoleTractionFvPatchVectorField::autoMap
114     const fvPatchFieldMapper& m
117     fixedGradientFvPatchVectorField::autoMap(m);
121 // Reverse-map the given fvPatchField onto this fvPatchField
122 void analyticalPlateHoleTractionFvPatchVectorField::rmap
124     const fvPatchVectorField& ptf,
125     const labelList& addr
128     fixedGradientFvPatchVectorField::rmap(ptf, addr);
132 // Update the coefficients associated with the patch field
133 void analyticalPlateHoleTractionFvPatchVectorField::updateCoeffs()
135     if (updated())
136     {
137         return;
138     }
140     vectorField n = patch().nf();
142      const constitutiveModel& rheology =
143          this->db().objectRegistry::lookupObject<constitutiveModel>
144          ("rheologyProperties");
145     scalarField mu =
146         rheology.mu()().boundaryField()[patch().index()];
147     scalarField lambda =
148         rheology.lambda()().boundaryField()[patch().index()];
150     const fvPatchField<tensor>& gradU =
151         patch().lookupPatchField<volTensorField, tensor>
152         ("grad(" + UName_ + ")");
154     vectorField Traction(n.size(),vector::zero);
156     const vectorField& Cf = patch().Cf();
158     forAll(Traction, faceI)
159       {
160     vector curC(Cf[faceI].x(), Cf[faceI].y(), 0);
161     vector curN = n[faceI];
163     if (patch().name() == "hole")
164       {
165         curC /= mag(curC);
166         curC *= 0.5;
168         curN = -curC/mag(curC);
169       }
171     Traction[faceI] =
172       (n[faceI] & plateHoleSolution(curC));
173       }
175     //- set patch gradient
176     vectorField newGradient =
177       Traction
178       - (n & (mu*gradU.T() - (mu + lambda)*gradU))
179       - n*lambda*tr(gradU);
181     newGradient /= (2.0*mu + lambda);
183     gradient() = newGradient;
185     fixedGradientFvPatchVectorField::updateCoeffs();
189 void analyticalPlateHoleTractionFvPatchVectorField::evaluate
190 (const Pstream::commsTypes)
192     if (!this->updated())
193     {
194         this->updateCoeffs();
195     }
197     const fvPatchField<tensor>& gradDU =
198         patch().lookupPatchField<volTensorField, tensor>
199         (
200             "grad(" + UName_ + ")"
201         );
203     vectorField n = patch().nf();
204     vectorField delta = patch().delta();
206     vectorField k = delta - n*(n&delta);
208     Field<vector>::operator=
209     (
210         this->patchInternalField()
211       + (k&gradDU.patchInternalField())
212       + gradient()/this->patch().deltaCoeffs()
213     );
215     fvPatchField<vector>::evaluate();
218 // Write
219 void analyticalPlateHoleTractionFvPatchVectorField::write(Ostream& os) const
221     fvPatchVectorField::write(os);
222     writeEntry("value", os);
225 symmTensor analyticalPlateHoleTractionFvPatchVectorField::plateHoleSolution
226 (const vector& C)
228     tensor sigma = tensor::zero;
230     scalar T = 10000;
231     scalar a = 0.5;
233     scalar r = ::sqrt(sqr(C.x()) + sqr(C.y()));
234     scalar theta = Foam::atan2(C.y(), C.x());
236     coordinateSystem cs("polarCS", C, vector(0, 0, 1), C/mag(C));
238     sigma.xx() =
239         T*(1 - sqr(a)/sqr(r))/2
240       + T*(1 + 3*pow(a,4)/pow(r,4) - 4*sqr(a)/sqr(r))*::cos(2*theta)/2;
242     sigma.xy() =
243       - T*(1 - 3*pow(a,4)/pow(r,4) + 2*sqr(a)/sqr(r))*::sin(2*theta)/2;
245     sigma.yx() = sigma.xy();
247     sigma.yy() =
248         T*(1 + sqr(a)/sqr(r))/2
249       - T*(1 + 3*pow(a,4)/pow(r,4))*::cos(2*theta)/2;
252     // Transformation to global coordinate system
253     sigma = ((cs.R()&sigma)&cs.R().T());
255     symmTensor S = symmTensor::zero;
257     S.xx() = sigma.xx();
258     S.xy() = sigma.xy();
259     S.yy() = sigma.yy();
261     return S;
264 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
266 makePatchTypeField
268     fvPatchVectorField,
269     analyticalPlateHoleTractionFvPatchVectorField
272 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
274 } // End namespace Foam
276 // ************************************************************************* //