This repository has been archived on 2023-11-20. You can view files and clone it, but cannot push or open issues or pull requests.
foam-extend4.1-coherent-io/applications/solvers/solidMechanics/deprecatedSolvers/materialModels/rheologyModel/rheologyLaws/multiMaterial/multiMaterial.C

261 lines
6.4 KiB
C
Raw Normal View History

/*---------------------------------------------------------------------------*\
========= |
2013-12-11 16:09:41 +00:00
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration |
2013-12-11 16:09:41 +00:00
\\ / A nd | For copyright notice see file Copyright
\\/ M anipulation |
-------------------------------------------------------------------------------
License
2013-12-11 16:09:41 +00:00
This file is part of foam-extend.
2013-12-11 16:09:41 +00:00
foam-extend is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
2013-12-11 16:09:41 +00:00
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
2013-12-11 16:09:41 +00:00
foam-extend is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
2013-12-11 16:09:41 +00:00
along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
Description
Zoned multi-material rheology controlled by a material indicator field.
\*---------------------------------------------------------------------------*/
#include "multiMaterial.H"
#include "addToRunTimeSelectionTable.H"
#include "zeroGradientFvPatchFields.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(multiMaterial, 0);
addToRunTimeSelectionTable(rheologyLaw, multiMaterial, dictionary);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::tmp<Foam::scalarField> Foam::multiMaterial::indicator
(
const label i
) const
{
const scalarField& mat = materials_.internalField();
tmp<scalarField> tresult(new scalarField(mat.size(), 0.0));
scalarField& result = tresult();
forAll (mat, matI)
{
if (mat[matI] > i - SMALL && mat[matI] < i + 1 - SMALL)
{
result[matI] = 1.0;
}
}
return tresult;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from dictionary
Foam::multiMaterial::multiMaterial
(
const word& name,
const volSymmTensorField& sigma,
const dictionary& dict
)
:
rheologyLaw(name, sigma, dict),
PtrList<rheologyLaw>(),
materials_
(
IOobject
(
"materials",
mesh().time().timeName(),
mesh(),
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh()
)
{
PtrList<rheologyLaw>& laws = *this;
PtrList<entry> lawEntries(dict.lookup("laws"));
laws.setSize(lawEntries.size());
forAll (laws, lawI)
{
laws.set
(
lawI,
rheologyLaw::New
(
lawEntries[lawI].keyword(),
sigma,
lawEntries[lawI].dict()
)
);
}
if
(
min(materials_).value() < 0
|| max(materials_).value() > laws.size() + SMALL
)
{
FatalErrorIn
(
"multiMaterial::multiMaterial\n"
"(\n"
" const word& name,\n"
" const volSymmTensorField& sigma,\n"
" const dictionary& dict\n"
")"
) << "Invalid definition of material indicator field. "
<< "Number of materials: " << laws.size()
<< " max index: " << max(materials_)
<< ". Should be " << laws.size() - 1
<< abort(FatalError);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::multiMaterial::~multiMaterial()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::tmp<Foam::volScalarField> Foam::multiMaterial::rho() const
{
tmp<volScalarField> tresult
(
new volScalarField
(
IOobject
(
"rho",
mesh().time().timeName(),
mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh(),
dimensionedScalar("zeroRho", dimDensity, 0),
zeroGradientFvPatchScalarField::typeName
)
);
volScalarField& result = tresult();
// Accumulate data for all fields
const PtrList<rheologyLaw>& laws = *this;
forAll (laws, lawI)
{
result.internalField() +=
indicator(lawI)*laws[lawI].rho()().internalField();
}
result.correctBoundaryConditions();
return tresult;
}
Foam::tmp<Foam::volScalarField> Foam::multiMaterial::E() const
{
tmp<volScalarField> tresult
(
new volScalarField
(
IOobject
(
"E",
mesh().time().timeName(),
mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh(),
dimensionedScalar("zeroE", dimForce/dimArea, 0),
zeroGradientFvPatchScalarField::typeName
)
);
volScalarField& result = tresult();
// Accumulate data for all fields
const PtrList<rheologyLaw>& laws = *this;
forAll (laws, lawI)
{
result.internalField() +=
indicator(lawI)*laws[lawI].E()().internalField();
}
result.correctBoundaryConditions();
return tresult;
}
Foam::tmp<Foam::volScalarField> Foam::multiMaterial::nu() const
{
tmp<volScalarField> tresult
(
new volScalarField
(
IOobject
(
"nu",
mesh().time().timeName(),
mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh(),
dimensionedScalar("zeroE", dimless, 0),
zeroGradientFvPatchScalarField::typeName
)
);
volScalarField& result = tresult();
// Accumulate data for all fields
const PtrList<rheologyLaw>& laws = *this;
forAll (laws, lawI)
{
result.internalField() +=
indicator(lawI)*laws[lawI].nu()().internalField();
}
result.correctBoundaryConditions();
return tresult;
}
void Foam::multiMaterial::correct()
{
PtrList<rheologyLaw>& laws = *this;
forAll (laws, lawI)
{
laws[lawI].correct();
}
}
// ************************************************************************* //