1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
5 \\ / A nd | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
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 "tractionDisplacementThermoFvPatchVectorField.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "volFields.H"
29 #include "rheologyModel.H"
30 #include "thermalModel.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
39 tractionDisplacementThermoFvPatchVectorField::
40 tractionDisplacementThermoFvPatchVectorField
43 const DimensionedField<vector, volMesh>& iF
46 fixedGradientFvPatchVectorField(p, iF),
49 rheologyName_("undefined"),
50 thermoName_("undefined"),
51 traction_(p.size(), vector::zero),
52 pressure_(p.size(), 0.0)
54 fvPatchVectorField::operator=(patchInternalField());
55 gradient() = vector::zero;
59 tractionDisplacementThermoFvPatchVectorField::
60 tractionDisplacementThermoFvPatchVectorField
63 const DimensionedField<vector, volMesh>& iF,
64 const dictionary& dict
67 fixedGradientFvPatchVectorField(p, iF),
68 UName_(dict.lookup("U")),
69 TName_(dict.lookup("T")),
70 rheologyName_(dict.lookup("rheology")),
71 thermoName_(dict.lookup("thermo")),
72 traction_("traction", dict, p.size()),
73 pressure_("pressure", dict, p.size())
75 fvPatchVectorField::operator=(patchInternalField());
76 gradient() = vector::zero;
80 tractionDisplacementThermoFvPatchVectorField::
81 tractionDisplacementThermoFvPatchVectorField
83 const tractionDisplacementThermoFvPatchVectorField& tdpvf,
85 const DimensionedField<vector, volMesh>& iF,
86 const fvPatchFieldMapper& mapper
89 fixedGradientFvPatchVectorField(tdpvf, p, iF, mapper),
92 rheologyName_(tdpvf.rheologyName_),
93 thermoName_(tdpvf.thermoName_),
94 traction_(tdpvf.traction_, mapper),
95 pressure_(tdpvf.pressure_, mapper)
99 tractionDisplacementThermoFvPatchVectorField::
100 tractionDisplacementThermoFvPatchVectorField
102 const tractionDisplacementThermoFvPatchVectorField& tdpvf
105 fixedGradientFvPatchVectorField(tdpvf),
106 UName_(tdpvf.UName_),
107 TName_(tdpvf.TName_),
108 rheologyName_(tdpvf.rheologyName_),
109 thermoName_(tdpvf.thermoName_),
110 traction_(tdpvf.traction_),
111 pressure_(tdpvf.pressure_)
115 tractionDisplacementThermoFvPatchVectorField::
116 tractionDisplacementThermoFvPatchVectorField
118 const tractionDisplacementThermoFvPatchVectorField& tdpvf,
119 const DimensionedField<vector, volMesh>& iF
122 fixedGradientFvPatchVectorField(tdpvf, iF),
123 UName_(tdpvf.UName_),
124 TName_(tdpvf.TName_),
125 rheologyName_(tdpvf.rheologyName_),
126 thermoName_(tdpvf.thermoName_),
127 traction_(tdpvf.traction_),
128 pressure_(tdpvf.pressure_)
132 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
134 void tractionDisplacementThermoFvPatchVectorField::autoMap
136 const fvPatchFieldMapper& m
139 fixedGradientFvPatchVectorField::autoMap(m);
140 traction_.autoMap(m);
141 pressure_.autoMap(m);
145 // Reverse-map the given fvPatchField onto this fvPatchField
146 void tractionDisplacementThermoFvPatchVectorField::rmap
148 const fvPatchVectorField& ptf,
149 const labelList& addr
152 fixedGradientFvPatchVectorField::rmap(ptf, addr);
154 const tractionDisplacementThermoFvPatchVectorField& dmptf =
155 refCast<const tractionDisplacementThermoFvPatchVectorField>(ptf);
157 traction_.rmap(dmptf.traction_, addr);
158 pressure_.rmap(dmptf.pressure_, addr);
162 // Update the coefficients associated with the patch field
163 void tractionDisplacementThermoFvPatchVectorField::updateCoeffs()
170 // Looking up rheology
171 const rheologyModel& rheology =
172 this->db().objectRegistry::
173 lookupObject<rheologyModel>(rheologyName_);
175 const scalarField mu = rheology.mu()().boundaryField()[patch().index()];
176 const scalarField lambda =
177 rheology.lambda()().boundaryField()[patch().index()];
179 vectorField n = patch().nf();
181 const fvPatchField<tensor>& gradU =
182 patch().lookupPatchField<volTensorField, tensor>("grad(" +UName_ + ")");
187 const thermalModel& thermo =
188 this->db().objectRegistry::lookupObject<thermalModel>(thermoName_);
190 const fvPatchField<scalar>& T =
191 patch().lookupPatchField<volScalarField, scalar>(TName_);
193 const scalarField rhoThreeKalpha =
194 rheology.rho()().boundaryField()[patch().index()]*
195 rheology.threeK()().boundaryField()[patch().index()]*
196 thermo.alpha()().boundaryField()[patch().index()];
198 const scalarField T0 = thermo.T0()().boundaryField()[patch().index()];
202 (traction_ - (pressure_)*n)
203 - (n & (mu*gradU.T() - (mu + lambda)*gradU))
205 + n*rhoThreeKalpha*(T - T0)
208 fixedGradientFvPatchVectorField::updateCoeffs();
213 void tractionDisplacementThermoFvPatchVectorField::write
218 fvPatchVectorField::write(os);
219 os.writeKeyword("U") << UName_ << token::END_STATEMENT << nl;
220 os.writeKeyword("T") << TName_ << token::END_STATEMENT << nl;
221 os.writeKeyword("rheology") << rheologyName_ << token::END_STATEMENT << nl;
222 os.writeKeyword("thermo") << thermoName_ << token::END_STATEMENT << nl;
223 traction_.writeEntry("traction", os);
224 pressure_.writeEntry("pressure", os);
225 writeEntry("value", os);
229 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
234 tractionDisplacementThermoFvPatchVectorField
238 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
240 } // End namespace Foam
242 // ************************************************************************* //