1 /*---------------------------------------------------------------------------*\
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 -------------------------------------------------------------------------------
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 "tractionDisplacementFvPatchVectorField.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "volFields.H"
29 #include "rheologyModel.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
38 tractionDisplacementFvPatchVectorField::
39 tractionDisplacementFvPatchVectorField
42 const DimensionedField<vector, volMesh>& iF
45 fixedGradientFvPatchVectorField(p, iF),
47 rheologyName_("undefined"),
48 traction_(p.size(), vector::zero),
49 pressure_(p.size(), 0.0)
51 fvPatchVectorField::operator=(patchInternalField());
52 gradient() = vector::zero;
56 tractionDisplacementFvPatchVectorField::
57 tractionDisplacementFvPatchVectorField
60 const DimensionedField<vector, volMesh>& iF,
61 const dictionary& dict
64 fixedGradientFvPatchVectorField(p, iF),
65 UName_(dict.lookup("U")),
66 rheologyName_(dict.lookup("rheology")),
67 traction_("traction", dict, p.size()),
68 pressure_("pressure", dict, p.size())
70 fvPatchVectorField::operator=(patchInternalField());
71 gradient() = vector::zero;
72 Info << "rf: " << rheologyName_ << endl;
76 tractionDisplacementFvPatchVectorField::
77 tractionDisplacementFvPatchVectorField
79 const tractionDisplacementFvPatchVectorField& tdpvf,
81 const DimensionedField<vector, volMesh>& iF,
82 const fvPatchFieldMapper& mapper
85 fixedGradientFvPatchVectorField(tdpvf, p, iF, mapper),
87 rheologyName_(tdpvf.rheologyName_),
88 traction_(tdpvf.traction_, mapper),
89 pressure_(tdpvf.pressure_, mapper)
93 tractionDisplacementFvPatchVectorField::
94 tractionDisplacementFvPatchVectorField
96 const tractionDisplacementFvPatchVectorField& tdpvf
99 fixedGradientFvPatchVectorField(tdpvf),
100 UName_(tdpvf.UName_),
101 rheologyName_(tdpvf.rheologyName_),
102 traction_(tdpvf.traction_),
103 pressure_(tdpvf.pressure_)
107 tractionDisplacementFvPatchVectorField::
108 tractionDisplacementFvPatchVectorField
110 const tractionDisplacementFvPatchVectorField& tdpvf,
111 const DimensionedField<vector, volMesh>& iF
114 fixedGradientFvPatchVectorField(tdpvf, iF),
115 UName_(tdpvf.UName_),
116 rheologyName_(tdpvf.rheologyName_),
117 traction_(tdpvf.traction_),
118 pressure_(tdpvf.pressure_)
122 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
124 void tractionDisplacementFvPatchVectorField::autoMap
126 const fvPatchFieldMapper& m
129 fixedGradientFvPatchVectorField::autoMap(m);
130 traction_.autoMap(m);
131 pressure_.autoMap(m);
135 // Reverse-map the given fvPatchField onto this fvPatchField
136 void tractionDisplacementFvPatchVectorField::rmap
138 const fvPatchVectorField& ptf,
139 const labelList& addr
142 fixedGradientFvPatchVectorField::rmap(ptf, addr);
144 const tractionDisplacementFvPatchVectorField& dmptf =
145 refCast<const tractionDisplacementFvPatchVectorField>(ptf);
147 traction_.rmap(dmptf.traction_, addr);
148 pressure_.rmap(dmptf.pressure_, addr);
152 // Update the coefficients associated with the patch field
153 void tractionDisplacementFvPatchVectorField::updateCoeffs()
160 // Looking up rheology
161 const rheologyModel& rheology =
162 this->db().objectRegistry::lookupObject<rheologyModel>(rheologyName_);
164 const scalarField mu = rheology.mu()().boundaryField()[patch().index()];
165 const scalarField lambda =
166 rheology.lambda()().boundaryField()[patch().index()];
168 vectorField n = patch().nf();
170 const fvPatchField<tensor>& gradU =
171 patch().lookupPatchField<volTensorField, tensor>("grad(" +UName_ + ")");
175 (traction_ - (pressure_)*n)
176 - (n & (mu*gradU.T() - (mu + lambda)*gradU))
180 fixedGradientFvPatchVectorField::updateCoeffs();
185 void tractionDisplacementFvPatchVectorField::write(Ostream& os) const
187 fvPatchVectorField::write(os);
188 os.writeKeyword("U") << UName_ << token::END_STATEMENT << nl;
189 os.writeKeyword("rheology") << rheologyName_ << token::END_STATEMENT << nl;
190 traction_.writeEntry("traction", os);
191 pressure_.writeEntry("pressure", os);
192 writeEntry("value", os);
196 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198 makePatchTypeField(fvPatchVectorField, tractionDisplacementFvPatchVectorField);
200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
202 } // End namespace Foam
204 // ************************************************************************* //