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/>.
26 \*---------------------------------------------------------------------------*/
28 #include "cohesiveLawFvPatchVectorField.H"
29 #include "addToRunTimeSelectionTable.H"
30 #include "volFields.H"
31 #include "rheologyModel.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
40 cohesiveLawFvPatchVectorField::cohesiveLawFvPatchVectorField
43 const DimensionedField<vector, volMesh>& iF
46 fixedGradientFvPatchVectorField(p, iF),
47 cohesiveLawPtr_(NULL),
48 relaxationFactor_(1.0),
49 traction_(p.size(), vector::zero)
53 cohesiveLawFvPatchVectorField::cohesiveLawFvPatchVectorField
56 const DimensionedField<vector, volMesh>& iF,
57 const dictionary& dict
60 fixedGradientFvPatchVectorField(p, iF),
63 cohesiveLaw::New(dict.lookup("cohesiveLaw"), dict).ptr()
65 relaxationFactor_(readScalar(dict.lookup("relaxationFactor"))),
66 traction_(p.size(), vector::zero)
68 fvPatchVectorField::operator=(patchInternalField());
69 gradient() = vector::zero;
73 cohesiveLawFvPatchVectorField::cohesiveLawFvPatchVectorField
75 const cohesiveLawFvPatchVectorField& cpf
78 fixedGradientFvPatchVectorField(cpf),
79 cohesiveLawPtr_(cpf.cohesiveLawPtr_->clone().ptr()),
80 relaxationFactor_(cpf.relaxationFactor_),
81 traction_(cpf.traction_)
85 cohesiveLawFvPatchVectorField::cohesiveLawFvPatchVectorField
87 const cohesiveLawFvPatchVectorField& cpf,
89 const DimensionedField<vector, volMesh>& iF,
90 const fvPatchFieldMapper& mapper
93 fixedGradientFvPatchVectorField(cpf, p, iF, mapper),
94 cohesiveLawPtr_(cpf.cohesiveLawPtr_->clone().ptr()),
95 relaxationFactor_(cpf.relaxationFactor_),
96 traction_(cpf.traction_, mapper)
100 cohesiveLawFvPatchVectorField::cohesiveLawFvPatchVectorField
102 const cohesiveLawFvPatchVectorField& cpf,
103 const DimensionedField<vector, volMesh>& iF
106 fixedGradientFvPatchVectorField(cpf, iF),
107 cohesiveLawPtr_(cpf.cohesiveLawPtr_->clone().ptr()),
108 relaxationFactor_(cpf.relaxationFactor_),
109 traction_(cpf.traction_)
113 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
115 const cohesiveLaw& cohesiveLawFvPatchVectorField::law() const
117 if (!cohesiveLawPtr_)
121 "const cohesiveLaw& cohesiveLawFvPatchVectorField::law() const"
122 ) << "Law pointer not set" << abort(FatalError);
125 return *cohesiveLawPtr_;
129 void cohesiveLawFvPatchVectorField::autoMap
131 const fvPatchFieldMapper& m
134 if (cohesiveLawPtr_ == NULL)
136 FatalErrorIn("cohesiveFvPatchVectorField::autoMap")
137 << "NULL cohesive law"
138 << abort(FatalError);
141 fixedGradientFvPatchVectorField::autoMap(m);
143 traction_.autoMap(m);
147 // Reverse-map the given fvPatchField onto this fvPatchField
148 void cohesiveLawFvPatchVectorField::rmap
150 const fvPatchVectorField& ptf,
151 const labelList& addr
154 fixedGradientFvPatchVectorField::rmap(ptf, addr);
156 const cohesiveLawFvPatchVectorField& dmptf =
157 refCast<const cohesiveLawFvPatchVectorField>(ptf);
159 // No need to grab the cohesive zone pointer more than once
160 if (!cohesiveLawPtr_)
162 cohesiveLawPtr_ = dmptf.cohesiveLawPtr_->clone().ptr();
164 relaxationFactor_ = dmptf.relaxationFactor_;
167 traction_.rmap(dmptf.traction_, addr);
171 // Update the coefficients associated with the patch field
172 void cohesiveLawFvPatchVectorField::updateCoeffs()
179 // Looking up rheology
181 const fvPatchField<scalar>& mu =
182 patch().lookupPatchField<volScalarField, scalar>("mu");
184 const fvPatchField<scalar>& lambda =
185 patch().lookupPatchField<volScalarField, scalar>("lambda");
187 vectorField n = patch().nf();
189 const fvPatchField<tensor>& gradU =
190 patch().lookupPatchField<volTensorField, tensor>("grad(U)");
192 // Patch displacement
193 const vectorField& U = *this;
196 tensorField sigma = mu*(gradU + gradU.T()) + I*(lambda*tr(gradU));
198 // Normal stress component
199 scalarField sigmaN = (n & (n & sigma));
201 scalarField delta = -(n & U);
203 label sizeByTwo = patch().size()/2;
205 for(label i = 0; i < sizeByTwo; i++)
207 scalar tmp = delta[i];
208 delta[i] += delta[sizeByTwo + i];
209 delta[sizeByTwo + i] += tmp;
212 forAll (traction_, faceI)
214 if (delta[faceI] < 0)
216 // Return from traction to symmetryPlane??
217 traction_[faceI] = law().sigmaMax().value()*n[faceI];
219 else if(delta[faceI] > law().deltaC().value())
222 traction_[faceI] = vector::zero;
226 // Calculate cohesive traction from cohesive zone model
227 traction_[faceI] = law().traction(delta[faceI])*n[faceI];
234 - (n & (mu*gradU.T() - (mu + lambda)*gradU))
238 fixedGradientFvPatchVectorField::updateCoeffs();
243 void cohesiveLawFvPatchVectorField::write(Ostream& os) const
245 fvPatchVectorField::write(os);
246 traction_.writeEntry("traction", os);
247 os.writeKeyword("cohesiveLaw") << law().type()
248 << token::END_STATEMENT << nl;
249 os.writeKeyword("relaxationFactor") << relaxationFactor_
250 << token::END_STATEMENT << nl;
252 writeEntry("value", os);
256 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
258 makePatchTypeField(fvPatchVectorField, cohesiveLawFvPatchVectorField);
260 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
262 } // End namespace Foam
264 // ************************************************************************* //