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/>.
25 Zoned multi-material rheology controlled by a material indicator field.
27 \*---------------------------------------------------------------------------*/
29 #include "multiMaterial.H"
30 #include "addToRunTimeSelectionTable.H"
31 #include "zeroGradientFvPatchFields.H"
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37 defineTypeNameAndDebug(multiMaterial, 0);
38 addToRunTimeSelectionTable(rheologyLaw, multiMaterial, dictionary);
42 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
44 Foam::tmp<Foam::scalarField> Foam::multiMaterial::indicator
49 const scalarField& mat = materials_.internalField();
51 tmp<scalarField> tresult(new scalarField(mat.size(), 0.0));
52 scalarField& result = tresult();
56 if (mat[matI] > i - SMALL && mat[matI] < i + 1 - SMALL)
67 Foam::multiMaterial::indicator(const label index, const label cellID) const
69 const scalar mat = materials_.internalField()[cellID];
72 if (mat > index - SMALL && mat < index + 1 - SMALL)
80 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
82 // Construct from dictionary
83 Foam::multiMaterial::multiMaterial
86 const volSymmTensorField& sigma,
87 const dictionary& dict
90 rheologyLaw(name, sigma, dict),
91 PtrList<rheologyLaw>(),
97 mesh().time().timeName(),
105 PtrList<rheologyLaw>& laws = *this;
107 PtrList<entry> lawEntries(dict.lookup("laws"));
108 laws.setSize(lawEntries.size());
117 lawEntries[lawI].keyword(),
119 lawEntries[lawI].dict()
126 min(materials_).value() < 0
127 || max(materials_).value() > laws.size() + SMALL
132 "multiMaterial::multiMaterial\n"
134 " const word& name,\n"
135 " const volSymmTensorField& sigma,\n"
136 " const dictionary& dict\n"
138 ) << "Invalid definition of material indicator field. "
139 << "Number of materials: " << laws.size()
140 << " max index: " << max(materials_)
141 << ". Should be " << laws.size() - 1
142 << abort(FatalError);
147 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
149 Foam::multiMaterial::~multiMaterial()
153 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
155 Foam::tmp<Foam::volScalarField> Foam::multiMaterial::rho() const
157 tmp<volScalarField> tresult
164 mesh().time().timeName(),
170 dimensionedScalar("zeroRho", dimDensity, 0),
171 zeroGradientFvPatchScalarField::typeName
174 volScalarField& result = tresult();
176 // Accumulate data for all fields
177 const PtrList<rheologyLaw>& laws = *this;
181 result.internalField() +=
182 indicator(lawI)*laws[lawI].rho()().internalField();
185 result.correctBoundaryConditions();
191 Foam::tmp<Foam::volScalarField> Foam::multiMaterial::E() const
193 tmp<volScalarField> tresult
200 mesh().time().timeName(),
206 dimensionedScalar("zeroE", dimForce/dimArea, 0),
207 zeroGradientFvPatchScalarField::typeName
210 volScalarField& result = tresult();
212 // Accumulate data for all fields
213 const PtrList<rheologyLaw>& laws = *this;
217 result.internalField() +=
218 indicator(lawI)*laws[lawI].E()().internalField();
221 result.correctBoundaryConditions();
227 Foam::tmp<Foam::volScalarField>
228 Foam::multiMaterial::E(const volScalarField& epsEq) const
230 tmp<volScalarField> tresult
237 mesh().time().timeName(),
243 dimensionedScalar("zeroE", dimForce/dimArea, 0),
244 zeroGradientFvPatchScalarField::typeName
247 volScalarField& result = tresult();
249 // Accumulate data for all fields
250 const PtrList<rheologyLaw>& laws = *this;
254 result.internalField() +=
255 indicator(lawI)*laws[lawI].E(epsEq)().internalField();
258 // forAll(result.boundaryField(),patchI)
260 // forAll (laws, lawI)
262 // result.boundaryField()[patchI] +=
263 // indicator(lawI)().boundaryField()[patchI]
264 // *laws[lawI].E(t)().boundaryField()[patchI];
268 result.correctBoundaryConditions();
274 Foam::tmp<Foam::volScalarField> Foam::multiMaterial::nu() const
276 tmp<volScalarField> tresult
283 mesh().time().timeName(),
289 dimensionedScalar("zeroE", dimless, 0),
290 zeroGradientFvPatchScalarField::typeName
293 volScalarField& result = tresult();
295 // Accumulate data for all fields
296 const PtrList<rheologyLaw>& laws = *this;
300 result.internalField() +=
301 indicator(lawI)*laws[lawI].nu()().internalField();
304 result.correctBoundaryConditions();
310 Foam::tmp<Foam::volScalarField> Foam::multiMaterial::Ep() const
312 tmp<volScalarField> tresult
319 mesh().time().timeName(),
325 dimensionedScalar("zeroEp", dimForce/dimArea, 0.0),
326 zeroGradientFvPatchScalarField::typeName
329 volScalarField& result = tresult();
331 // Accumulate data for all fields
332 const PtrList<rheologyLaw>& laws = *this;
336 result.internalField() +=
337 indicator(lawI)*laws[lawI].Ep()().internalField();
340 result.correctBoundaryConditions();
346 Foam::tmp<Foam::volScalarField>
347 Foam::multiMaterial::Ep(const volScalarField& epsEq) const
349 tmp<volScalarField> tresult
356 mesh().time().timeName(),
362 dimensionedScalar("zeroEp", dimForce/dimArea, 0),
363 zeroGradientFvPatchScalarField::typeName
366 volScalarField& result = tresult();
368 // Accumulate data for all fields
369 const PtrList<rheologyLaw>& laws = *this;
373 result.internalField() +=
374 indicator(lawI)*laws[lawI].Ep(epsEq)().internalField();
377 // forAll(result.boundaryField(),patchI)
379 // forAll (laws, lawI)
381 // result.boundaryField()[patchI] +=
382 // indicator(lawI)().boundaryField()[patchI]
383 // *laws[lawI].E(t)().boundaryField()[patchI];
387 result.correctBoundaryConditions();
393 Foam::tmp<Foam::volScalarField> Foam::multiMaterial::sigmaY() const
395 tmp<volScalarField> tresult
402 mesh().time().timeName(),
408 dimensionedScalar("zeroSigmaY", dimForce/dimArea, 0.0),
409 zeroGradientFvPatchScalarField::typeName
412 volScalarField& result = tresult();
414 // Accumulate data for all fields
415 const PtrList<rheologyLaw>& laws = *this;
419 result.internalField() +=
420 indicator(lawI)*laws[lawI].sigmaY()().internalField();
423 result.correctBoundaryConditions();
429 Foam::multiMaterial::sigmaY(const scalar epsilonPEq, const label cellID) const
431 // Accumulate data for all fields
432 const PtrList<rheologyLaw>& laws = *this;
438 indicator(lawI, cellID)*laws[lawI].sigmaY(epsilonPEq, cellID);
444 bool Foam::multiMaterial::plasticityModelNeeded() const
446 // Accumulate data for all fields
447 const PtrList<rheologyLaw>& laws = *this;
452 if (laws[lawI].plasticityModelNeeded())
462 Foam::tmp<Foam::volDiagTensorField> Foam::multiMaterial::K() const
464 tmp<volDiagTensorField> tresult
466 new volDiagTensorField
471 mesh().time().timeName(),
477 dimensionedDiagTensor("zeroK", dimForce/dimArea, diagTensor::zero),
478 zeroGradientFvPatchScalarField::typeName
481 volDiagTensorField& result = tresult();
483 // Accumulate data for all fields
484 const PtrList<rheologyLaw>& laws = *this;
488 result.internalField() +=
489 indicator(lawI)*laws[lawI].K()().internalField();
492 result.correctBoundaryConditions();
497 Foam::tmp<Foam::volSymmTensor4thOrderField> Foam::multiMaterial::C() const
499 tmp<volSymmTensor4thOrderField> tresult
501 new volSymmTensor4thOrderField
506 mesh().time().timeName(),
512 dimensionedSymmTensor4thOrder
513 ("zeroC", dimForce/dimArea, symmTensor4thOrder::zero),
514 zeroGradientFvPatchScalarField::typeName
517 volSymmTensor4thOrderField& result = tresult();
519 // Accumulate data for all fields
520 const PtrList<rheologyLaw>& laws = *this;
524 result.internalField() +=
525 indicator(lawI)*laws[lawI].C()().internalField();
528 result.correctBoundaryConditions();
534 void Foam::multiMaterial::correct()
536 PtrList<rheologyLaw>& laws = *this;
540 laws[lawI].correct();
545 // ************************************************************************* //