rearranged solidMechanics and added symmTensor4thOrder and diagTensor fields

This commit is contained in:
Philip Cardiff 2013-10-14 09:26:40 +01:00
parent ab6cd72839
commit 87cb5a32fa
952 changed files with 199074 additions and 691164 deletions

View file

@ -3,18 +3,21 @@ cd ${0%/*} || exit 1 # run from this directory
set -x
wmake libso solidModels
wmake elasticContactIncrSolidFoam
wmake elasticContactNonLinULSolidFoam
wmake elasticContactSolidFoam
wmake elasticGravitySolidFoam
wmake elasticAcpSolidFoam
wmake elasticIncrAcpSolidFoam
wmake elasticIncrSolidFoam
wmake elasticNonLinIncrTLSolidFoam
wmake elasticNonLinTLSolidFoam
wmake elasticNonLinULSolidFoam
wmake elasticPlasticNonLinULSolidFoam
wmake elasticOrthoAcpSolidFoam
wmake elasticOrthoNonLinULSolidFoam
wmake elasticOrthoSolidFoam
wmake elasticPlasticSolidFoam
wmake elasticPlasticNonLinTLSolidFoam
wmake elasticPlasticNonLinULSolidFoam
wmake elasticSolidFoam
wmake elasticThermalSolidFoam
wmake icoFsiElasticNonLinULSolidFoam
wmake viscoElasticSolidFoam
(cd utilities; wmake all)

View file

@ -0,0 +1,19 @@
#!/bin/sh
cd ${0%/*} || exit 1 # run from this directory
set -x
wmake libso materialModels
wmake stressedFoam
wmake contactStressFoam
wmake newStressedFoam
wmake newContactStressFoam
wmake stressFemFoam
wmake icoFsiFoam
wmake solidDisplacementFoam
wmake solidEquilibriumDisplacementFoam

View file

@ -0,0 +1,6 @@
contactPatchPair.C
contactPatchPairUpdateContact.C
contactPatchPairSlavePressure.C
contactStressFoam.C
EXE = $(FOAM_APPBIN)/contactStressFoam

View file

@ -0,0 +1,6 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-llduSolvers

View file

@ -0,0 +1,26 @@
Info << "Calculating patch traction" << endl;
PtrList<vectorField> traction(mesh.boundary().size());
{
const surfaceVectorField::GeometricBoundaryField& Apatches =
mesh.Sf().boundaryField();
const surfaceScalarField::GeometricBoundaryField& magApatches =
mesh.magSf().boundaryField();
forAll(traction, patchI)
{
vectorField n = Apatches[patchI]/magApatches[patchI];
traction.set
(
patchI,
new vectorField
(
patchTraction[patchI]
- patchPressure[patchI]*n
)
);
}
}

View file

@ -0,0 +1,106 @@
if (runTime.outputTime())
{
volTensorField sigma =
rho*
(
mu*(gradU + gradU.T())
+ I*
(
lambda*tr(gradU)
)
);
volScalarField sigmaEq
(
IOobject
(
"sigmaEq",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
sqrt((3.0/2.0)*magSqr(dev(sigma)))
);
volScalarField sigmaxx
(
IOobject
(
"sigmaxx",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
sigma.component(tensor::XX)
);
volScalarField sigmayy
(
IOobject
(
"sigmayy",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
sigma.component(tensor::YY)
);
volScalarField sigmazz
(
IOobject
(
"sigmazz",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
sigma.component(tensor::ZZ)
);
volScalarField sigmaxy
(
IOobject
(
"sigmaxy",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
sigma.component(tensor::XY)
);
volScalarField sigmaxz
(
IOobject
(
"sigmaxz",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
sigma.component(tensor::XZ)
);
volScalarField sigmayz
(
IOobject
(
"sigmayz",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
sigma.component(tensor::YZ)
);
runTime.write();
}

View file

@ -0,0 +1,86 @@
{
volVectorField::GeometricBoundaryField& Upatches = U.boundaryField();
const volTensorField::GeometricBoundaryField& gradUpatches =
gradU.boundaryField();
const surfaceVectorField::GeometricBoundaryField& Apatches =
mesh.Sf().boundaryField();
const surfaceScalarField::GeometricBoundaryField& magApatches =
mesh.magSf().boundaryField();
vectorField nGradPatch = Apatches[gradPatch]/magApatches[gradPatch];
vectorField nDirPatch = Apatches[dirPatch]/magApatches[dirPatch];
// Update contact
contactPair.updateContact(U);
reversePair.updateContact(U);
const scalarField& touchFraction = contactPair.touchFraction();
const scalarField& reverseFraction = reversePair.touchFraction();
//Info << "touchFraction: " << touchFraction << endl;
// Mark contact surfaces
contactArea.boundaryField()[dirPatch] = touchFraction;
contactArea.boundaryField()[gradPatch] = reverseFraction;
// Cast will fall over in incorrect
directionMixedFvPatchVectorField& UpatchDir =
refCast<directionMixedFvPatchVectorField>(Upatches[dirPatch]);
// set the traction and value for directionMixed patch
UpatchDir.valueFraction() =
(1.0 - urf)*UpatchDir.valueFraction()
+ I*urf*touchFraction;
// UpatchDir.value() = contactPair.slaveDisplacement();
UpatchDir.refValue() =
nDirPatch*
min
(
(nDirPatch & UpatchDir) + urf*touchFraction*touchTolerance,
(nDirPatch & contactPair.slaveDisplacement())
);
// traction[dirPatch] = 0 because there's no friction!!
// set the traction for the gradient patch (using the new valueFraction!)
vectorField newTraction =
nGradPatch*
(
reversePair.slavePressure
(
nDirPatch &
(
mu.value()*
(
gradUpatches[dirPatch]
+ gradUpatches[dirPatch].T()
)
+ I*(lambda.value()*tr(gradUpatches[dirPatch]))
) & nDirPatch
)
);
// Info<< "contact: "
// <<
// (nDirPatch &
// (
// mu.value()*
// (
// gradUpatches[dirPatch]
// + gradUpatches[dirPatch].T()
// )
// + I*(lambda.value()*tr(gradUpatches[dirPatch]))
// ) & nDirPatch)*rho.value()
// << endl;
traction[gradPatch] =
(1.0 - urf)*traction[gradPatch]
+ urf*newTraction*reverseFraction;
}

View file

@ -0,0 +1,81 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "contactPatchPair.H"
#include "volFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
contactPatchPair::contactPatchPair
(
const fvMesh& m,
const label master,
const label slave,
const scalar tolerance
)
:
mesh_(m),
masterPatchIndex_(master),
slavePatchIndex_(slave),
masterInterpolate_(m.boundaryMesh()[masterPatchIndex_]),
slaveInterpolate_(m.boundaryMesh()[slavePatchIndex_]),
patchToPatchInterpolate_
(
m.boundaryMesh()[masterPatchIndex_],
m.boundaryMesh()[slavePatchIndex_],
intersection::FULL_RAY,
intersection::CONTACT_SPHERE
),
tol_(tolerance),
touchFraction_
(
mesh_.boundaryMesh()[slavePatchIndex_].size(),
pTraits<scalar>::zero
),
slaveDisplacement_
(
mesh_.boundaryMesh()[slavePatchIndex_].size(),
pTraits<vector>::zero
)
{}
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,144 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
contactPatchPair
Description
SourceFiles
contactPatchPair.C
contactPatchPairSlavePressure.C
contactPatchPairUpdateContact.C
\*---------------------------------------------------------------------------*/
#ifndef contactPatchPair_H
#define contactPatchPair_H
#include "fvMesh.H"
#include "primitivePatchInterpolation.H"
#include "patchToPatchInterpolation.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class contactPatchPair Declaration
\*---------------------------------------------------------------------------*/
class contactPatchPair
{
// Private data
//- Reference to mesh
const fvMesh& mesh_;
//- Index of the directionMixed patch
const label masterPatchIndex_;
//- Index of the gradient patch
const label slavePatchIndex_;
//- Master patch interpolator
primitivePatchInterpolation masterInterpolate_;
//- Slave patch interpolator
primitivePatchInterpolation slaveInterpolate_;
//- Patch to patch interpolator
patchToPatchInterpolation patchToPatchInterpolate_;
//- Contact tolerance
const scalar tol_;
//- Touch fraction
scalarField touchFraction_;
//- Slave displacement
vectorField slaveDisplacement_;
// Private Member Functions
//- Disallow default bitwise copy construct
contactPatchPair(const contactPatchPair&);
//- Disallow default bitwise assignment
void operator=(const contactPatchPair&);
public:
// Constructors
//- Construct from components
contactPatchPair
(
const fvMesh& m,
const label master,
const label slave,
const scalar tolerance
);
// Member Functions
//- Update contact data
void updateContact
(
const volVectorField& disp
);
//- Return contact fraction for patch
const scalarField& touchFraction() const
{
return touchFraction_;
}
//- Return slave patch displacement
const vectorField& slaveDisplacement() const
{
return slaveDisplacement_;
}
//- Return slave patch pressure
tmp<scalarField> slavePressure
(
const scalarField& traction
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,68 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
\*---------------------------------------------------------------------------*/
#include "contactPatchPair.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
tmp<scalarField> contactPatchPair::slavePressure
(
const scalarField& pressure
) const
{
// scalarField result =
// slaveInterpolate_.pointToFaceInterpolate
// (
// patchToPatchInterpolate_.pointInterpolate<scalar>
// (
// masterInterpolate_.faceToPointInterpolate
// (
// pressure
// )
// )
// );
tmp<scalarField> tresult =
patchToPatchInterpolate_.faceInterpolate<scalar>(pressure);
tresult = min(tresult, scalar(0));
return tresult;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,105 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
\*---------------------------------------------------------------------------*/
#include "contactPatchPair.H"
#include "volPointInterpolation.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void contactPatchPair::updateContact
(
const volVectorField& disp
)
{
vectorField slaveVertexResult =
patchToPatchInterpolate_.pointInterpolate<vector>
(
masterInterpolate_.faceToPointInterpolate
(
disp.boundaryField()[masterPatchIndex_]
)
);
const vectorField& projectionDirection =
mesh_.boundaryMesh()[slavePatchIndex_].pointNormals();
// use this for touch fraction
scalarField vertexSlaveGap =
(
(
slaveVertexResult
- slaveInterpolate_.faceToPointInterpolate
(
disp.boundaryField()[slavePatchIndex_]
)
)
& projectionDirection
) + patchToPatchInterpolate_.pointDistanceToIntersection() - tol_;
// use this for slaveDisplacement
vectorField vertexSlaveDisplacement =
slaveVertexResult
+ patchToPatchInterpolate_.pointDistanceToIntersection()
*projectionDirection;
// calculate area in contact
const faceList& slavePatchLocalFaces =
mesh_.boundaryMesh()[slavePatchIndex_].localFaces();
const pointField& slavePatchLocalPoints =
mesh_.boundaryMesh()[slavePatchIndex_].localPoints();
touchFraction_ = 0;
forAll (slavePatchLocalFaces, faceI)
{
touchFraction_[faceI] =
slavePatchLocalFaces[faceI].areaInContact
(
slavePatchLocalPoints,
vertexSlaveGap
);
}
// calculate contact direction
slaveDisplacement_ =
slaveInterpolate_.pointToFaceInterpolate(vertexSlaveDisplacement);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,120 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Application
stressedFoam
Description
Transient/steady-state solver of linear-elastic, small-strain deformation
of solid bodies in contact.
Simple linear elasticity structural analysis code.
Solves for the displacement vector field U,
also generating the stress tensor field sigma.
Code can be compiled for simple stress analysis,
and dynamic stress analysis.
Additionally, special handling of very non-orthogonal meshes may be added.
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "fixedGradientFvPatchFields.H"
#include "directionMixedFvPatchFields.H"
#include "contactPatchPair.H"
#include "pointFields.H"
#include "transformField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
# include "setRootCase.H"
# include "createTime.H"
# include "createMesh.H"
# include "createFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< "\nCalculating displacement field\n" << endl;
volTensorField gradU = fvc::grad(U);
for (runTime++; !runTime.end(); runTime++)
{
Info<< "Iteration: " << runTime.timeName() << nl << endl;
# include "../stressedFoam/readStressedFoamControls.H"
int iCorr=0;
scalar initialResidual=0;
# include "contactBoundaries.H"
do
{
# include "tractionBoundaries.H"
fvVectorMatrix UEqn
(
# ifdef Dynamic
fvm::d2dt2(U)
==
# endif
fvm::laplacian(2*mu + lambda, U, "laplacian(DU,U)")
+ fvc::div
(
mu*gradU.T() + lambda*(I*tr(gradU)) - (mu + lambda)*gradU,
"div(sigma)"
)
);
UEqn.setComponentReference(6, 0, vector::Z, 0);
initialResidual = UEqn.solve().initialResidual();
gradU = fvc::grad(U);
} while (initialResidual > convergenceTolerance && ++iCorr < nCorr);
# include "calculateStress.H"
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
}
Info<< "End\n" << endl;
return(0);
}
// ************************************************************************* //

View file

@ -0,0 +1,140 @@
mesh.weights();
Info<< "Reading field U\n" << endl;
volVectorField U
(
IOobject
(
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< "Reading material properties\n" << endl;
IOdictionary mechanicalProperties
(
IOobject
(
"mechanicalProperties",
"constant",
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
dimensionedScalar rho
(
mechanicalProperties.lookup("rho")
);
dimensionedScalar rhoE
(
mechanicalProperties.lookup("E")
);
dimensionedScalar nu
(
mechanicalProperties.lookup("nu")
);
Info<< "Normalising E : E/rho\n" << endl;
dimensionedScalar E = rhoE/rho;
Info<< "Reading boundary conditions\n" << endl;
IOdictionary boundaryConditions
(
IOobject
(
"boundaryConditions",
"constant",
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
Info<< "Reading patchPressure\n" << endl;
scalarField rhoPatchPressure
(
boundaryConditions.lookup("patchPressure")
);
Info<< "Normalising patchPressure : patchPressure/rho\n" << endl;
scalarField patchPressure = rhoPatchPressure/rho.value();
Info<< "Reading patchTraction\n" << endl;
vectorField rhoPatchTraction
(
boundaryConditions.lookup("patchTraction")
);
Info<< "Normalising patchTraction : patchTraction/rho\n" << endl;
vectorField patchTraction = rhoPatchTraction/rho.value();
Info<< "Calculating Lame's coefficients\n" << endl;
dimensionedScalar mu = E/(2.0*(1.0 + nu));
dimensionedScalar lambda = nu*E/((1.0 + nu)*(1.0 - 2.0*nu));
dimensionedScalar threeK = E/(1.0 - 2.0*nu);
Switch planeStress
(
mechanicalProperties.lookup("planeStress")
);
if (planeStress)
{
Info<< "Plane Stress\n" << endl;
//- change lambda and threeK for plane stress
lambda = nu*E/((1.0 + nu)*(1.0 - nu));
}
else
{
Info<< "Plane Strain\n" << endl;
}
Info<< "mu = " << mu.value() << " Pa/rho\n";
Info<< "lambda = " << lambda.value() << " Pa/rho\n";
# include "calculatePatchTraction.H"
Info<< "Reading contact patch IDs etc.\n" << endl;
const dictionary& contactPatchDict
(
mesh.solutionDict().subDict("contactPatch")
);
label gradPatch(readLabel(contactPatchDict.lookup("gradPatchID")));
label dirPatch(readLabel(contactPatchDict.lookup("dirPatchID")));
scalar urf(readScalar(contactPatchDict.lookup("contactUnderrelaxation")));
scalar touchTolerance
(
readScalar(contactPatchDict.lookup("touchTolerance"))
);
Info << "Creating contact pairs" << endl;
contactPatchPair contactPair(mesh, gradPatch, dirPatch, touchTolerance);
contactPatchPair reversePair(mesh, dirPatch, gradPatch, touchTolerance);
volScalarField contactArea
(
IOobject
(
"contactArea",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar(0)
);

View file

@ -0,0 +1,17 @@
(
traction[patchI]
- (n &
(
mu.value()*gradUpatches[patchI].T()
- (mu + lambda).value()*gradUpatches[patchI]
)
)
- n*
(
lambda.value()*tr(gradUpatches[patchI])
)
)/(2.0*mu + lambda).value();

View file

@ -0,0 +1,46 @@
{
volVectorField::GeometricBoundaryField& Upatches = U.boundaryField();
const volTensorField::GeometricBoundaryField& gradUpatches =
gradU.boundaryField();
const surfaceVectorField::GeometricBoundaryField& Apatches =
mesh.Sf().boundaryField();
const surfaceScalarField::GeometricBoundaryField& magApatches =
mesh.magSf().boundaryField();
forAll(Upatches, patchI)
{
if
(
Upatches[patchI].type()
== fixedGradientFvPatchVectorField::typeName
)
{
fixedGradientFvPatchVectorField& Upatch =
refCast<fixedGradientFvPatchVectorField>(Upatches[patchI]);
vectorField n = Apatches[patchI]/magApatches[patchI];
Upatch.gradient() =
# include "traction.H"
}
if
(
Upatches[patchI].type()
== directionMixedFvPatchVectorField::typeName
)
{
directionMixedFvPatchVectorField& Upatch =
refCast<directionMixedFvPatchVectorField>(Upatches[patchI]);
vectorField n = Apatches[patchI]/magApatches[patchI];
Upatch.refGrad() =
# include "traction.H"
}
}
}

View file

@ -0,0 +1,4 @@
tractionDisplacement/tractionDisplacementFvPatchVectorField.C
icoFsiFoam.C
EXE = $(FOAM_APPBIN)/icoFsiFoam

View file

@ -0,0 +1,16 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/dynamicMesh/dynamicFvMesh/lnInclude \
-I$(LIB_SRC)/dynamicMesh/dynamicMesh/lnInclude \
$(WM_DECOMP_INC) \
-I$(LIB_SRC)/tetFiniteElement/lnInclude \
-I$(LIB_SRC)/dynamicMesh/meshMotion/tetDecompositionMotionSolver/lnInclude \
EXE_LIBS = \
-lfiniteVolume \
-ldynamicFvMesh \
-ldynamicMesh \
-ltetFiniteElement \
$(WM_DECOMP_LIBS) \
-llduSolvers

View file

@ -0,0 +1,59 @@
Info<< "Reading transportProperties\n" << endl;
IOdictionary transportProperties
(
IOobject
(
"transportProperties",
runTime.constant(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
dimensionedScalar nu
(
transportProperties.lookup("nu")
);
dimensionedScalar rhoFluid
(
transportProperties.lookup("rho")
);
Info<< "Reading field p\n" << endl;
volScalarField p
(
IOobject
(
"p",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< "Reading field U\n" << endl;
volVectorField U
(
IOobject
(
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
# include "createPhi.H"
label pRefCell = 0;
scalar pRefValue = 0.0;
setRefCell(p, mesh.solutionDict().subDict("PISO"), pRefCell, pRefValue);

View file

@ -0,0 +1,13 @@
Info<< "Reading field U\n" << endl;
volVectorField Usolid
(
IOobject
(
"U",
runTime.timeName(),
stressMesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
stressMesh
);

View file

@ -0,0 +1,13 @@
fvMesh stressMesh
(
IOobject
(
"solid",
runTime.timeName(),
runTime,
IOobject::MUST_READ
)
);
const volPointInterpolation& cpi = volPointInterpolation::New(stressMesh);

View file

@ -0,0 +1,98 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Application
icoFoam
Description
Transient solver for incompressible, laminar flow of Newtonian fluids with
mesh motion. Set up as a fake fluid structure interaction solver
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "dynamicFvMesh.H"
#include "patchToPatchInterpolation.H"
#include "tractionDisplacement/tractionDisplacementFvPatchVectorField.H"
#include "tetFemMatrices.H"
#include "tetPointFields.H"
#include "faceTetPolyPatch.H"
#include "tetPolyPatchInterpolation.H"
#include "fixedValueTetPolyPatchFields.H"
#include "pointMesh.H"
#include "pointFields.H"
#include "volPointInterpolation.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
# include "setRootCase.H"
# include "createTime.H"
# include "createDynamicFvMesh.H"
# include "createStressMesh.H"
# include "createFields.H"
# include "createStressFields.H"
# include "readMechanicalProperties.H"
# include "readCouplingProperties.H"
# include "readTimeControls.H"
# include "initContinuityErrs.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< "\nStarting time loop\n" << endl;
while (runTime.run())
{
# include "readPISOControls.H"
# include "readTimeControls.H"
# include "CourantNo.H"
# include "setDeltaT.H"
runTime++;
Info<< "Time = " << runTime.timeName() << nl << endl;
# include "setPressure.H"
# include "solveSolid.H"
# include "setMotion.H"
# include "solveFluid.H"
runTime.write();
Info<< "ExecutionTime = "
<< runTime.elapsedCpuTime()
<< " s\n\n" << endl;
}
Info<< "End\n" << endl;
return(0);
}
// ************************************************************************* //

View file

@ -0,0 +1,85 @@
Info << "Reading coupling properties" << endl;
IOdictionary couplingProperties
(
IOobject
(
"couplingProperties",
runTime.constant(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
// Read solid patch data
word solidPatchName(couplingProperties.lookup("solidPatch"));
label solidPatchID =
stressMesh.boundaryMesh().findPatchID(solidPatchName);
// Read fluid patch data
word fluidPatchName(couplingProperties.lookup("fluidPatch"));
label fluidPatchID =
mesh.boundaryMesh().findPatchID(fluidPatchName);
if (solidPatchID < 0 || fluidPatchID < 0)
{
FatalErrorIn(args.executable())
<< "Problem with patch interpolation definition"
<< abort(FatalError);
}
// Create interpolators
patchToPatchInterpolation interpolatorFluidSolid
(
mesh.boundaryMesh()[fluidPatchID],
stressMesh.boundaryMesh()[solidPatchID]
);
patchToPatchInterpolation interpolatorSolidFluid
(
stressMesh.boundaryMesh()[solidPatchID],
mesh.boundaryMesh()[fluidPatchID]
);
// Grab solid patch field
tractionDisplacementFvPatchVectorField& tForce =
refCast<tractionDisplacementFvPatchVectorField>
(
Usolid.boundaryField()[solidPatchID]
);
// Grab motion field
// Read fluid patch data
word movingRegionName(couplingProperties.lookup("movingRegion"));
const fvMesh& motionMesh =
runTime.objectRegistry::lookupObject<fvMesh>(movingRegionName);
tetPointVectorField& motionU =
const_cast<tetPointVectorField&>
(
motionMesh.objectRegistry::lookupObject<tetPointVectorField>
(
"motionU"
)
);
fixedValueTetPolyPatchVectorField& motionUFluidPatch =
refCast<fixedValueTetPolyPatchVectorField>
(
motionU.boundaryField()[fluidPatchID]
);
tetPolyPatchInterpolation tppi
(
refCast<const faceTetPolyPatch>(motionUFluidPatch.patch())
);

View file

@ -0,0 +1,41 @@
Info<< "Reading mechanical properties\n" << endl;
IOdictionary mechanicalProperties
(
IOobject
(
"mechanicalProperties",
runTime.constant(),
stressMesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
dimensionedScalar rho(mechanicalProperties.lookup("rho"));
dimensionedScalar rhoE(mechanicalProperties.lookup("E"));
dimensionedScalar nuS(mechanicalProperties.lookup("nu"));
Info<< "Normalising E : E/rho\n" << endl;
dimensionedScalar E = rhoE/rho;
Info<< "Calculating Lame's coefficients\n" << endl;
dimensionedScalar mu = E/(2.0*(1.0 + nuS));
dimensionedScalar lambda = nuS*E/((1.0 + nuS)*(1.0 - 2.0*nuS));
Switch planeStress(mechanicalProperties.lookup("planeStress"));
if (planeStress)
{
Info<< "Plane Stress\n" << endl;
// Change lambda for plane stress
lambda = nuS*E/((1.0 + nuS)*(1.0 - nuS));
}
else
{
Info<< "Plane Strain\n" << endl;
}
Info<< "mu = " << mu.value() << " Pa\n";
Info<< "lambda = " << lambda.value() << " Pa\n";

View file

@ -2,4 +2,4 @@
stressMesh.solutionDict().subDict("stressedFoam");
int nCorr(readInt(stressControl.lookup("nCorrectors")));
scalar convergenceTolerance(readScalar(stressControl.lookup("DU")));
scalar convergenceTolerance(readScalar(stressControl.lookup("U")));

View file

@ -0,0 +1,35 @@
{
// Setting mesh motion
pointVectorField solidPointsDispl =
cpi.interpolate(Usolid - Usolid.oldTime());
vectorField newPoints =
stressMesh.points()
+ solidPointsDispl.internalField();
stressMesh.movePoints(newPoints);
vectorField fluidPatchPointsDispl =
interpolatorSolidFluid.pointInterpolate
(
solidPointsDispl.boundaryField()[solidPatchID].
patchInternalField()
);
motionUFluidPatch ==
tppi.pointToPointInterpolate
(
fluidPatchPointsDispl/runTime.deltaT().value()
);
mesh.update();
# include "volContinuity.H"
Info << "Motion magnitude: mean = "
<< average(mag(Usolid.boundaryField()[solidPatchID]))
<< " max = "
<< max(mag(Usolid.boundaryField()[solidPatchID])) << endl;
}

View file

@ -0,0 +1,25 @@
{
// Setting pressure on solid patch
Info << "Setting pressure" << endl;
scalarField solidPatchPressure =
interpolatorFluidSolid.faceInterpolate
(
p.boundaryField()[fluidPatchID]
);
solidPatchPressure *= rhoFluid.value();
tForce.pressure() = solidPatchPressure;
vector totalPressureForce =
sum
(
p.boundaryField()[fluidPatchID]*
mesh.Sf().boundaryField()[fluidPatchID]
);
Info << "Total pressure force = " << totalPressureForce << endl;
}

View file

@ -0,0 +1,52 @@
{
// SIMPLE loop
for (int corr=0; corr<nCorr; corr++)
{
fvVectorMatrix UEqn
(
fvm::ddt(U)
+ fvm::div(phi, U)
- fvm::laplacian(nu, U)
);
UEqn.relax();
solve(UEqn == -fvc::grad(p));
U = UEqn.H()/UEqn.A();
U.correctBoundaryConditions();
adjustPhi(phi, U, p);
phi = fvc::interpolate(U) & mesh.Sf();
p.storePrevIter();
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
fvScalarMatrix pEqn
(
fvm::laplacian(1.0/UEqn.A(), p) == fvc::div(phi)
);
pEqn.setReference(pRefCell, pRefValue);
pEqn.solve();
if (nonOrth == nNonOrthCorr)
{
phi -= pEqn.flux();
}
}
p.relax();
# include "movingMeshContinuityErrs.H"
U -= fvc::grad(p)/UEqn.A();
U.correctBoundaryConditions();
// Make the fluxes relative
phi -= fvc::meshPhi(U);
}
}

View file

@ -0,0 +1,26 @@
{
# include "readStressedFoamControls.H"
int iCorr = 0;
scalar initialResidual = 0;
do
{
volTensorField gradU = fvc::grad(Usolid);
fvVectorMatrix UEqn
(
fvm::d2dt2(Usolid)
==
fvm::laplacian(2*mu + lambda, Usolid, "laplacian(DU,U)")
+ fvc::div
(
mu*gradU.T() + lambda*(I*tr(gradU)) - (mu + lambda)*gradU,
"div(sigma)"
)
);
initialResidual = UEqn.solve().initialResidual();
} while (initialResidual > convergenceTolerance && ++iCorr < nCorr);
}

View file

@ -0,0 +1,203 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "tractionDisplacementFvPatchVectorField.H"
#include "addToRunTimeSelectionTable.H"
#include "volFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
tractionDisplacementFvPatchVectorField::
tractionDisplacementFvPatchVectorField
(
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF
)
:
fixedGradientFvPatchVectorField(p, iF),
traction_(p.size(), vector::zero),
pressure_(p.size(), 0.0)
{
fvPatchVectorField::operator=(patchInternalField());
gradient() = vector::zero;
}
tractionDisplacementFvPatchVectorField::
tractionDisplacementFvPatchVectorField
(
const tractionDisplacementFvPatchVectorField& tdpvf,
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
fixedGradientFvPatchVectorField(tdpvf, p, iF, mapper),
traction_(tdpvf.traction_, mapper),
pressure_(tdpvf.pressure_, mapper)
{}
tractionDisplacementFvPatchVectorField::
tractionDisplacementFvPatchVectorField
(
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF,
const dictionary& dict
)
:
fixedGradientFvPatchVectorField(p, iF),
traction_("traction", dict, p.size()),
pressure_("pressure", dict, p.size())
{
fvPatchVectorField::operator=(patchInternalField());
gradient() = vector::zero;
}
tractionDisplacementFvPatchVectorField::
tractionDisplacementFvPatchVectorField
(
const tractionDisplacementFvPatchVectorField& tdpvf
)
:
fixedGradientFvPatchVectorField(tdpvf),
traction_(tdpvf.traction_),
pressure_(tdpvf.pressure_)
{}
tractionDisplacementFvPatchVectorField::
tractionDisplacementFvPatchVectorField
(
const tractionDisplacementFvPatchVectorField& tdpvf,
const DimensionedField<vector, volMesh>& iF
)
:
fixedGradientFvPatchVectorField(tdpvf, iF),
traction_(tdpvf.traction_),
pressure_(tdpvf.pressure_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void tractionDisplacementFvPatchVectorField::autoMap
(
const fvPatchFieldMapper& m
)
{
fixedGradientFvPatchVectorField::autoMap(m);
traction_.autoMap(m);
pressure_.autoMap(m);
}
// Reverse-map the given fvPatchField onto this fvPatchField
void tractionDisplacementFvPatchVectorField::rmap
(
const fvPatchVectorField& ptf,
const labelList& addr
)
{
fixedGradientFvPatchVectorField::rmap(ptf, addr);
const tractionDisplacementFvPatchVectorField& dmptf =
refCast<const tractionDisplacementFvPatchVectorField>(ptf);
traction_.rmap(dmptf.traction_, addr);
pressure_.rmap(dmptf.pressure_, addr);
}
// Update the coefficients associated with the patch field
void tractionDisplacementFvPatchVectorField::updateCoeffs()
{
if (updated())
{
return;
}
const dictionary& mechanicalProperties =
db().lookupObject<IOdictionary>("mechanicalProperties");
dimensionedScalar rho(mechanicalProperties.lookup("rho"));
dimensionedScalar rhoE(mechanicalProperties.lookup("E"));
dimensionedScalar nu(mechanicalProperties.lookup("nu"));
dimensionedScalar E = rhoE/rho;
dimensionedScalar mu = E/(2.0*(1.0 + nu));
dimensionedScalar lambda = nu*E/((1.0 + nu)*(1.0 - 2.0*nu));
dimensionedScalar threeK = E/(1.0 - 2.0*nu);
Switch planeStress(mechanicalProperties.lookup("planeStress"));
if (planeStress)
{
lambda = nu*E/((1.0 + nu)*(1.0 - nu));
threeK = E/(1.0 - nu);
}
vectorField n = patch().nf();
const fvPatchField<tensor>& gradU =
patch().lookupPatchField<volTensorField, tensor>("grad(U)");
gradient() =
(
(traction_ - pressure_*n)/rho.value()
- (n & (mu.value()*gradU.T() - (mu + lambda).value()*gradU))
- n*tr(gradU)*lambda.value()
)/(2.0*mu + lambda).value();
fixedGradientFvPatchVectorField::updateCoeffs();
}
// Write
void tractionDisplacementFvPatchVectorField::write(Ostream& os) const
{
fvPatchVectorField::write(os);
traction_.writeEntry("traction", os);
pressure_.writeEntry("pressure", os);
writeEntry("value", os);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePatchTypeField(fvPatchVectorField, tractionDisplacementFvPatchVectorField);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,188 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
tractionDisplacementFvPatchVectorField
Description
Fixed traction boundary condition for the standard linear elastic, fixed
coefficient displacement equation (stressedFoam).
SourceFiles
tractionDisplacementFvPatchVectorField.C
\*---------------------------------------------------------------------------*/
#ifndef tractionDisplacementFvPatchVectorField_H
#define tractionDisplacementFvPatchVectorField_H
#include "fvPatchFields.H"
#include "fixedGradientFvPatchFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class tractionDisplacementFvPatch Declaration
\*---------------------------------------------------------------------------*/
class tractionDisplacementFvPatchVectorField
:
public fixedGradientFvPatchVectorField
{
// Private Data
vectorField traction_;
scalarField pressure_;
public:
//- Runtime type information
TypeName("tractionDisplacement");
// Constructors
//- Construct from patch and internal field
tractionDisplacementFvPatchVectorField
(
const fvPatch&,
const DimensionedField<vector, volMesh>&
);
//- Construct from patch, internal field and dictionary
tractionDisplacementFvPatchVectorField
(
const fvPatch&,
const DimensionedField<vector, volMesh>&,
const dictionary&
);
//- Construct by mapping given
// tractionDisplacementFvPatchVectorField onto a new patch
tractionDisplacementFvPatchVectorField
(
const tractionDisplacementFvPatchVectorField&,
const fvPatch&,
const DimensionedField<vector, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
tractionDisplacementFvPatchVectorField
(
const tractionDisplacementFvPatchVectorField&
);
//- Construct and return a clone
virtual tmp<fvPatchVectorField> clone() const
{
return tmp<fvPatchVectorField>
(
new tractionDisplacementFvPatchVectorField(*this)
);
}
//- Construct as copy setting internal field reference
tractionDisplacementFvPatchVectorField
(
const tractionDisplacementFvPatchVectorField&,
const DimensionedField<vector, volMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchVectorField> clone
(
const DimensionedField<vector, volMesh>& iF
) const
{
return tmp<fvPatchVectorField>
(
new tractionDisplacementFvPatchVectorField(*this, iF)
);
}
// Member functions
// Access
virtual const vectorField& traction() const
{
return traction_;
}
virtual vectorField& traction()
{
return traction_;
}
virtual const scalarField& pressure() const
{
return pressure_;
}
virtual scalarField& pressure()
{
return pressure_;
}
// Mapping functions
//- Map (and resize as needed) from self given a mapping object
virtual void autoMap
(
const fvPatchFieldMapper&
);
//- Reverse map the given fvPatchField onto this fvPatchField
virtual void rmap
(
const fvPatchVectorField&,
const labelList&
);
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
//- Write
virtual void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,35 @@
rheologyModel/rheologyModel.C
rheologyLaws = rheologyModel/rheologyLaws
$(rheologyLaws)/rheologyLaw/rheologyLaw.C
$(rheologyLaws)/rheologyLaw/newRheologyLaw.C
$(rheologyLaws)/linearElastic/linearElastic.C
$(rheologyLaws)/multiMaterial/multiMaterial.C
$(rheologyLaws)/MaxwellViscoelastic/MaxwellViscoelastic.C
$(rheologyLaws)/BurgersViscoelastic/BurgersViscoelastic.C
$(rheologyLaws)/KelvinSLSViscoelastic/KelvinSLSViscoelastic.C
$(rheologyLaws)/MaxwellSLSViscoelastic/MaxwellSLSViscoelastic.C
$(rheologyLaws)/MaxwellElasticViscoelastic/MaxwellElasticViscoelastic.C
$(rheologyLaws)/PronyViscoelastic/PronyViscoelastic.C
thermalModel/thermalModel.C
thermalLaws = thermalModel/thermalLaws
$(thermalLaws)/thermalLaw/thermalLaw.C
$(thermalLaws)/thermalLaw/newThermalLaw.C
$(thermalLaws)/constantThermal/constantThermal.C
$(thermalLaws)/multiMaterialThermal/multiMaterialThermal.C
cohesiveLaws/cohesiveLaw/cohesiveLaw.C
cohesiveLaws/Dugdale/DugdaleCohesiveLaw.C
cohesiveLaws/linear/linearCohesiveLaw.C
fvPatchFields/tractionDisplacement/tractionDisplacementFvPatchVectorField.C
fvPatchFields/tractionDisplacementThermo/tractionDisplacementThermoFvPatchVectorField.C
fvPatchFields/nusselt/nusseltFvPatchScalarField.C
fvPatchFields/newDirectionMixed/newDirectionMixedFvPatchFields.C
fvPatchFields/cohesiveLaw/cohesiveLawFvPatchVectorField.C
fvPatchFields/cohesiveZone/cohesiveZoneFvPatchVectorField.C
LIB = $(FOAM_LIBBIN)/libmaterialModels

View file

@ -0,0 +1,5 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude
EXE_LIBS = \
-lfiniteVolume

View file

@ -0,0 +1,88 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Dugdale cohesive law.
\*---------------------------------------------------------------------------*/
#include "DugdaleCohesiveLaw.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(DugdaleCohesiveLaw, 0);
addToRunTimeSelectionTable(cohesiveLaw, DugdaleCohesiveLaw, dictionary);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::DugdaleCohesiveLaw::DugdaleCohesiveLaw
(
const word& cohesiveLawName,
const dictionary& dict
)
:
cohesiveLaw(cohesiveLawName, dict),
deltaC_(GIc()/sigmaMax())
{}
Foam::DugdaleCohesiveLaw::DugdaleCohesiveLaw
(
const DugdaleCohesiveLaw& dcl
)
:
cohesiveLaw(dcl),
deltaC_(dcl.deltaC_)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::DugdaleCohesiveLaw::~DugdaleCohesiveLaw()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
//- Return current holding traction
Foam::scalar Foam::DugdaleCohesiveLaw::traction(scalar delta) const
{
if (delta > deltaC().value())
{
return 0.0;
}
else if (delta < 0)
{
return sigmaMax().value();
}
return sigmaMax().value();
}
// ************************************************************************* //

View file

@ -0,0 +1,113 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
DugdaleCohesiveLaw
Description
Dugdale cohesive law.
SourceFiles
DugdaleCohesiveLaw.C
\*---------------------------------------------------------------------------*/
#ifndef DugdaleCohesiveLaw_H
#define DugdaleCohesiveLaw_H
#include "cohesiveLaw.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class DugdaleCohesiveLaw Declaration
\*---------------------------------------------------------------------------*/
class DugdaleCohesiveLaw
:
public cohesiveLaw
{
private:
// Private data
//- Critical separation distance
dimensionedScalar deltaC_;
public:
//- Runtime type information
TypeName("Dugdale");
// Constructors
//- Construct from components
DugdaleCohesiveLaw
(
const word& cohesiveLawName,
const dictionary& dict
);
//- Construct as copy
DugdaleCohesiveLaw(const DugdaleCohesiveLaw&);
//- Construct and return a clone
virtual autoPtr<cohesiveLaw> clone() const
{
return autoPtr<cohesiveLaw>(new DugdaleCohesiveLaw(*this));
}
// Destructor
virtual ~DugdaleCohesiveLaw();
// Member Functions
//- Return reference to critical separation distance
const dimensionedScalar& deltaC() const
{
return deltaC_;
}
//- Return current holding traction
scalar traction(scalar delta) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,112 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Virtual base class for cohesive law.
\*---------------------------------------------------------------------------*/
#include "cohesiveLaw.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(cohesiveLaw, 0);
defineRunTimeSelectionTable(cohesiveLaw, dictionary);
}
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
Foam::autoPtr<Foam::cohesiveLaw> Foam::cohesiveLaw::New
(
const word& cohesiveLawName,
const dictionary& dict
)
{
Info << "Selecting cohesive law: " << cohesiveLawName << endl;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(cohesiveLawName);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalErrorIn
(
"cohesiveLaw::New(const word& cohesiveLawName, "
"const dictionary& dict)"
) << "Unknown cohesive law " << cohesiveLawName
<< endl << endl
<< "Valid cohesive laws are :" << endl
<< dictionaryConstructorTablePtr_->toc()
<< exit(FatalError);
}
return autoPtr<cohesiveLaw>(cstrIter()(cohesiveLawName, dict));
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::cohesiveLaw::cohesiveLaw
(
const word& cohesiveLawName,
const dictionary& dict
)
:
cohesiveLawCoeffs_(dict.subDict(cohesiveLawName + "Coeffs")),
GIc_(cohesiveLawCoeffs_.lookup("GIc")),
sigmaMax_(cohesiveLawCoeffs_.lookup("sigmaMax"))
{}
Foam::cohesiveLaw::cohesiveLaw
(
const cohesiveLaw& cl
)
:
refCount(),
cohesiveLawCoeffs_(cl.cohesiveLawCoeffs_),
GIc_(cl.GIc_),
sigmaMax_(cl.sigmaMax_)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::cohesiveLaw::~cohesiveLaw()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::cohesiveLaw::writeDict(Ostream& os) const
{
os.writeKeyword(word(type() + "Coeffs"))
<< cohesiveLawCoeffs();
}
// ************************************************************************* //

View file

@ -0,0 +1,165 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
cohesiveLaw
Description
Virtual base class for cohesive zone model.
SourceFiles
cohesiveLaw.C
\*---------------------------------------------------------------------------*/
#ifndef cohesiveLaw_H
#define cohesiveLaw_H
#include "IOdictionary.H"
#include "autoPtr.H"
#include "runTimeSelectionTables.H"
#include "dimensionedTypes.H"
#include "tmp.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class cohesiveLaw Declaration
\*---------------------------------------------------------------------------*/
class cohesiveLaw
:
public refCount
{
private:
// Private data
//- Cohesive law coefficients
dictionary cohesiveLawCoeffs_;
//- Fracture energy
dimensionedScalar GIc_;
//- Maximum cohesive strength
dimensionedScalar sigmaMax_;
public:
//- Runtime type information
TypeName("cohesiveLaw");
// Declare run-time constructor selection tables
declareRunTimeSelectionTable
(
autoPtr,
cohesiveLaw,
dictionary,
(
const word& cohesiveLawName,
const dictionary& dict
),
(cohesiveLawName, dict)
);
// Selectors
//- Select null constructed
static autoPtr<cohesiveLaw> New
(
const word& cohesiveLawName,
const dictionary& dict
);
// Constructors
//- Construct from components
cohesiveLaw
(
const word& cohesiveLawName,
const dictionary& dict
);
//- Construct as copy
cohesiveLaw(const cohesiveLaw&);
//- Construct and return a clone
virtual autoPtr<cohesiveLaw> clone() const = 0;
// Destructor
virtual ~cohesiveLaw();
// Member Functions
//- Return cohesive law coefficients
const dictionary& cohesiveLawCoeffs() const
{
return cohesiveLawCoeffs_;
}
//- Return reference to fracture energy
const dimensionedScalar& GIc() const
{
return GIc_;
}
//- Return reference to maximum cohesive strength
const dimensionedScalar& sigmaMax() const
{
return sigmaMax_;
}
//- Return reference to critical separation distance
virtual const dimensionedScalar& deltaC() const = 0;
//- Return current holding traction
virtual scalar traction(scalar delta) const = 0;
//- Write dictionary
void writeDict(Ostream& os) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,88 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Linear cohesive law.
\*---------------------------------------------------------------------------*/
#include "linearCohesiveLaw.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(linearCohesiveLaw, 0);
addToRunTimeSelectionTable(cohesiveLaw, linearCohesiveLaw, dictionary);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::linearCohesiveLaw::linearCohesiveLaw
(
const word& cohesiveLawName,
const dictionary& dict
)
:
cohesiveLaw(cohesiveLawName, dict),
deltaC_(2.0*GIc()/sigmaMax())
{}
Foam::linearCohesiveLaw::linearCohesiveLaw
(
const linearCohesiveLaw& lcl
)
:
cohesiveLaw(lcl),
deltaC_(lcl.deltaC_)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::linearCohesiveLaw::~linearCohesiveLaw()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
//- Return current holding traction
Foam::scalar Foam::linearCohesiveLaw::traction(scalar delta) const
{
if (delta > deltaC().value())
{
return 0.0;
}
else if (delta < 0)
{
return sigmaMax().value();
}
return sigmaMax().value()*(1.0 - delta/deltaC().value());
}
// ************************************************************************* //

View file

@ -0,0 +1,113 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
linearCohesiveLaw
Description
Linear cohesive law.
SourceFiles
linearCohesiveLaw.C
\*---------------------------------------------------------------------------*/
#ifndef linearCohesiveLaw_H
#define linearCohesiveLaw_H
#include "cohesiveLaw.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class linearCohesiveLaw Declaration
\*---------------------------------------------------------------------------*/
class linearCohesiveLaw
:
public cohesiveLaw
{
private:
// Private data
//- Critical separation distance
dimensionedScalar deltaC_;
public:
//- Runtime type information
TypeName("linear");
// Constructors
//- Construct from components
linearCohesiveLaw
(
const word& cohesiveLawName,
const dictionary& dict
);
//- Construct as copy
linearCohesiveLaw(const linearCohesiveLaw&);
//- Construct and return a clone
virtual autoPtr<cohesiveLaw> clone() const
{
return autoPtr<cohesiveLaw>(new linearCohesiveLaw(*this));
}
// Destructor
virtual ~linearCohesiveLaw();
// Member Functions
//- Return reference to critical separation distance
const dimensionedScalar& deltaC() const
{
return deltaC_;
}
//- Return current holding traction
scalar traction(scalar delta) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,237 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2007 Hrvoje Jasak
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Class
componentReference
Description
Class contains data for a component reference as used in stress
analysis solvers.
SourceFiles
componentReferenceI.H
componentReference.C
componentReferenceIO.C
\*---------------------------------------------------------------------------*/
#ifndef componentReference_H
#define componentReference_H
#include "polyPatchID.H"
#include "fvMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class componentReference Declaration
\*---------------------------------------------------------------------------*/
class componentReference
{
// Private data
//- Patch ID
polyPatchID patchID_;
//- Face index
label faceIndex_;
//- Direction
direction dir_;
//- Value in direction
scalar value_;
// Private Member Functions
//- Create direction given a name
direction getDir(const dictionary& dict) const
{
word dirName(dict.lookup("direction"));
if (dirName == "x" || dirName == "X")
{
return vector::X;
}
else if (dirName == "y" || dirName == "Y")
{
return vector::Y;
}
else if (dirName == "z" || dirName == "Z")
{
return vector::Z;
}
else
{
FatalIOErrorIn
(
"vector::component componentReference::getComp("
"const word& dirName) const",
dict
) << "Direction " << dirName << " not recognised. Please "
<< "use x, y or z" << abort(FatalIOError);
// Dummy return to keep compiler happy
return vector::X;
}
}
//- Check if patch face is in range
void checkPatchFace(const fvMesh& mesh) const
{
if
(
!patchID_.active()
|| faceIndex_ >= mesh.boundaryMesh()[patchID_.index()].size()
)
{
FatalErrorIn
(
"void checkPatchFace(const componentReference::fvMesh&)"
"const"
) << "Non-existing patch or index out of range."
<< abort(FatalError);
}
}
public:
// Public classes
//- Class used for the read-construction of
// PtrLists of componentReference
class iNew
{
const fvMesh& mesh_;
public:
iNew(const fvMesh& mesh)
:
mesh_(mesh)
{}
autoPtr<componentReference> operator()(Istream& is) const
{
dictionary crDict(is);
autoPtr<componentReference> cr
(
new componentReference(mesh_, crDict)
);
return cr;
}
};
// Constructors
//- Construct from components
componentReference
(
const fvMesh& mesh,
const word& patchName,
const label faceIndex,
const direction dir,
const scalar value
)
:
patchID_(patchName, mesh.boundaryMesh()),
faceIndex_(faceIndex),
dir_(dir),
value_(value)
{
checkPatchFace(mesh);
}
//- Construct from dictionary
componentReference
(
const fvMesh& mesh,
const dictionary& dict
)
:
patchID_(dict.lookup("patch"), mesh.boundaryMesh()),
faceIndex_(readLabel(dict.lookup("face"))),
dir_(getDir(dict)),
value_(readScalar(dict.lookup("value")))
{
checkPatchFace(mesh);
}
//- Clone
autoPtr<componentReference> clone() const
{
return autoPtr<componentReference>(new componentReference(*this));
}
// Destructor - default
// Member Functions
//- Return patch index
label patchIndex() const
{
return patchID_.index();
}
//- Return face index
label faceIndex() const
{
return faceIndex_;
}
//- Return direction
direction dir() const
{
return dir_;
}
//- Return value
scalar value() const
{
return value_;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,56 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2007 Hrvoje Jasak
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Type
componentReferenceList
Description
container classes for componentReference
\*---------------------------------------------------------------------------*/
#ifndef componentReferenceList_H
#define componentReferenceList_H
#include "componentReference.H"
#include "PtrList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
typedef PtrList<componentReference> componentReferenceList;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,265 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2007 Hrvoje Jasak
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Description
\*---------------------------------------------------------------------------*/
#include "cohesiveLawFvPatchVectorField.H"
#include "addToRunTimeSelectionTable.H"
#include "volFields.H"
#include "rheologyModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
cohesiveLawFvPatchVectorField::cohesiveLawFvPatchVectorField
(
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF
)
:
fixedGradientFvPatchVectorField(p, iF),
cohesiveLawPtr_(NULL),
relaxationFactor_(1.0),
traction_(p.size(), vector::zero)
{}
cohesiveLawFvPatchVectorField::cohesiveLawFvPatchVectorField
(
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF,
const dictionary& dict
)
:
fixedGradientFvPatchVectorField(p, iF),
cohesiveLawPtr_
(
cohesiveLaw::New(dict.lookup("cohesiveLaw"), dict).ptr()
),
relaxationFactor_(readScalar(dict.lookup("relaxationFactor"))),
traction_(p.size(), vector::zero)
{
fvPatchVectorField::operator=(patchInternalField());
gradient() = vector::zero;
}
cohesiveLawFvPatchVectorField::cohesiveLawFvPatchVectorField
(
const cohesiveLawFvPatchVectorField& cpf
)
:
fixedGradientFvPatchVectorField(cpf),
cohesiveLawPtr_(cpf.cohesiveLawPtr_->clone().ptr()),
relaxationFactor_(cpf.relaxationFactor_),
traction_(cpf.traction_)
{}
cohesiveLawFvPatchVectorField::cohesiveLawFvPatchVectorField
(
const cohesiveLawFvPatchVectorField& cpf,
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
fixedGradientFvPatchVectorField(cpf, p, iF, mapper),
cohesiveLawPtr_(cpf.cohesiveLawPtr_->clone().ptr()),
relaxationFactor_(cpf.relaxationFactor_),
traction_(cpf.traction_, mapper)
{}
cohesiveLawFvPatchVectorField::cohesiveLawFvPatchVectorField
(
const cohesiveLawFvPatchVectorField& cpf,
const DimensionedField<vector, volMesh>& iF
)
:
fixedGradientFvPatchVectorField(cpf, iF),
cohesiveLawPtr_(cpf.cohesiveLawPtr_->clone().ptr()),
relaxationFactor_(cpf.relaxationFactor_),
traction_(cpf.traction_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const cohesiveLaw& cohesiveLawFvPatchVectorField::law() const
{
if (!cohesiveLawPtr_)
{
FatalErrorIn
(
"const cohesiveLaw& cohesiveLawFvPatchVectorField::law() const"
) << "Law pointer not set" << abort(FatalError);
}
return *cohesiveLawPtr_;
}
void cohesiveLawFvPatchVectorField::autoMap
(
const fvPatchFieldMapper& m
)
{
if (cohesiveLawPtr_ == NULL)
{
FatalErrorIn("cohesiveFvPatchVectorField::autoMap")
<< "NULL cohesive law"
<< abort(FatalError);
}
fixedGradientFvPatchVectorField::autoMap(m);
traction_.autoMap(m);
}
// Reverse-map the given fvPatchField onto this fvPatchField
void cohesiveLawFvPatchVectorField::rmap
(
const fvPatchVectorField& ptf,
const labelList& addr
)
{
fixedGradientFvPatchVectorField::rmap(ptf, addr);
const cohesiveLawFvPatchVectorField& dmptf =
refCast<const cohesiveLawFvPatchVectorField>(ptf);
// No need to grab the cohesive zone pointer more than once
if (!cohesiveLawPtr_)
{
cohesiveLawPtr_ = dmptf.cohesiveLawPtr_->clone().ptr();
relaxationFactor_ = dmptf.relaxationFactor_;
}
traction_.rmap(dmptf.traction_, addr);
}
// Update the coefficients associated with the patch field
void cohesiveLawFvPatchVectorField::updateCoeffs()
{
if (updated())
{
return;
}
// Looking up rheology
const fvPatchField<scalar>& mu =
patch().lookupPatchField<volScalarField, scalar>("mu");
const fvPatchField<scalar>& lambda =
patch().lookupPatchField<volScalarField, scalar>("lambda");
vectorField n = patch().nf();
const fvPatchField<tensor>& gradU =
patch().lookupPatchField<volTensorField, tensor>("grad(U)");
// Patch displacement
const vectorField& U = *this;
// Patch stress
tensorField sigma = mu*(gradU + gradU.T()) + I*(lambda*tr(gradU));
// Normal stress component
scalarField sigmaN = (n & (n & sigma));
scalarField delta = -(n & U);
label sizeByTwo = patch().size()/2;
for(label i = 0; i < sizeByTwo; i++)
{
scalar tmp = delta[i];
delta[i] += delta[sizeByTwo + i];
delta[sizeByTwo + i] += tmp;
}
forAll (traction_, faceI)
{
if (delta[faceI] < 0)
{
// Return from traction to symmetryPlane??
traction_[faceI] = law().sigmaMax().value()*n[faceI];
}
else if(delta[faceI] > law().deltaC().value())
{
// Traction free
traction_[faceI] = vector::zero;
}
else
{
// Calculate cohesive traction from cohesive zone model
traction_[faceI] = law().traction(delta[faceI])*n[faceI];
}
}
gradient() =
(
traction_
- (n & (mu*gradU.T() - (mu + lambda)*gradU))
- n*lambda*tr(gradU)
)/(2.0*mu + lambda);
fixedGradientFvPatchVectorField::updateCoeffs();
}
// Write
void cohesiveLawFvPatchVectorField::write(Ostream& os) const
{
fvPatchVectorField::write(os);
traction_.writeEntry("traction", os);
os.writeKeyword("cohesiveLaw") << law().type()
<< token::END_STATEMENT << nl;
os.writeKeyword("relaxationFactor") << relaxationFactor_
<< token::END_STATEMENT << nl;
law().writeDict(os);
writeEntry("value", os);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePatchTypeField(fvPatchVectorField, cohesiveLawFvPatchVectorField);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,183 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2007 Hrvoje Jasak
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Class
cohesiveLawFvPatchVectorField
Description
Cohesive law fv patch field
SourceFiles
cohesiveLawFvPatchVectorField.C
\*---------------------------------------------------------------------------*/
#ifndef cohesiveLawFvPatchVectorField_H
#define cohesiveLawFvPatchVectorField_H
#include "fvPatchFields.H"
#include "fixedGradientFvPatchFields.H"
#include "cohesiveFvPatch.H"
#include "cohesiveLaw.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class cohesiveLawFvPatch Declaration
\*---------------------------------------------------------------------------*/
class cohesiveLawFvPatchVectorField
:
public fixedGradientFvPatchVectorField
{
// Private Data
//- Cohesive law
cohesiveLaw* cohesiveLawPtr_;
//- Under-relaxation factor
scalar relaxationFactor_;
//- Traction
vectorField traction_;
public:
//- Runtime type information
TypeName("cohesiveLaw");
// Constructors
//- Construct from patch and internal field
cohesiveLawFvPatchVectorField
(
const fvPatch&,
const DimensionedField<vector, volMesh>&
);
//- Construct from patch, internal field and dictionary
cohesiveLawFvPatchVectorField
(
const fvPatch&,
const DimensionedField<vector, volMesh>&,
const dictionary&
);
//- Construct by mapping given
// cohesiveLawFvPatchVectorField onto a new patch
cohesiveLawFvPatchVectorField
(
const cohesiveLawFvPatchVectorField&,
const fvPatch&,
const DimensionedField<vector, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
cohesiveLawFvPatchVectorField
(
const cohesiveLawFvPatchVectorField&
);
//- Construct and return a clone
virtual tmp<fvPatchVectorField> clone() const
{
return tmp<fvPatchVectorField>
(
new cohesiveLawFvPatchVectorField(*this)
);
}
//- Construct as copy setting internal field reference
cohesiveLawFvPatchVectorField
(
const cohesiveLawFvPatchVectorField&,
const DimensionedField<vector, volMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchVectorField> clone
(
const DimensionedField<vector, volMesh>& iF
) const
{
return tmp<fvPatchVectorField>
(
new cohesiveLawFvPatchVectorField(*this, iF)
);
}
// Member functions
// Access
//- Return cohesive law
const cohesiveLaw& law() const;
// Mapping functions
//- Map (and resize as needed) from self given a mapping object
virtual void autoMap
(
const fvPatchFieldMapper&
);
//- Reverse map the given fvPatchField onto this fvPatchField
virtual void rmap
(
const fvPatchVectorField&,
const labelList&
);
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
//- Write
virtual void write(Ostream&) const;
// Member operators
virtual void operator=(const fvPatchVectorField&) {}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,325 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2007 Hrvoje Jasak
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Class
cohesiveZoneFvPatchVectorField
Description
\*---------------------------------------------------------------------------*/
#include "cohesiveZoneFvPatchVectorField.H"
#include "addToRunTimeSelectionTable.H"
#include "transformField.H"
#include "volFields.H"
#include "rheologyModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
cohesiveZoneFvPatchVectorField::cohesiveZoneFvPatchVectorField
(
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF
)
:
directionMixedFvPatchVectorField(p, iF),
UName_("undefined"),
rheologyName_("undefined"),
cohesiveLawPtr_(NULL),
relaxationFactor_(1.0)
{}
cohesiveZoneFvPatchVectorField::cohesiveZoneFvPatchVectorField
(
const cohesiveZoneFvPatchVectorField& ptf,
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
directionMixedFvPatchVectorField(ptf, p, iF, mapper),
UName_(ptf.UName_),
rheologyName_(ptf.rheologyName_),
cohesiveLawPtr_(ptf.cohesiveLawPtr_),
relaxationFactor_(ptf.relaxationFactor_)
{}
cohesiveZoneFvPatchVectorField::cohesiveZoneFvPatchVectorField
(
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF,
const dictionary& dict
)
:
directionMixedFvPatchVectorField(p, iF),
UName_(dict.lookup("U")),
rheologyName_(dict.lookup("rheology")),
cohesiveLawPtr_
(
cohesiveLaw::New(dict.lookup("cohesiveLaw"), dict).ptr()
),
relaxationFactor_(readScalar(dict.lookup("relaxationFactor")))
{
if (dict.found("refValue"))
{
this->refValue() = vectorField("refValue", dict, p.size());
}
else
{
this->refValue() = vector::zero;
}
if (dict.found("refGradient"))
{
this->refGrad() = vectorField("refGradient", dict, p.size());
}
else
{
this->refGrad() = vector::zero;
}
if (dict.found("valueFraction"))
{
this->valueFraction() =
symmTensorField("valueFraction", dict, p.size());
}
else
{
vectorField n = patch().nf();
this->valueFraction() = sqr(n);
}
if (dict.found("value"))
{
Field<vector>::operator=(vectorField("value", dict, p.size()));
}
else
{
Field<vector> normalValue = transform(valueFraction(), refValue());
Field<vector> gradValue =
this->patchInternalField() + refGrad()/this->patch().deltaCoeffs();
Field<vector> transformGradValue =
transform(I - valueFraction(), gradValue);
Field<vector>::operator=(normalValue + transformGradValue);
}
}
cohesiveZoneFvPatchVectorField::cohesiveZoneFvPatchVectorField
(
const cohesiveZoneFvPatchVectorField& ptf,
const DimensionedField<vector, volMesh>& iF
)
:
directionMixedFvPatchVectorField(ptf, iF),
UName_(ptf.UName_),
rheologyName_(ptf.rheologyName_),
cohesiveLawPtr_(ptf.cohesiveLawPtr_),
relaxationFactor_(ptf.relaxationFactor_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// Map from self
void cohesiveZoneFvPatchVectorField::autoMap
(
const fvPatchFieldMapper& m
)
{
if (cohesiveLawPtr_ == NULL)
{
FatalErrorIn("cohesiveZoneFvPatchVectorField::autoMap")
<< "NULL cohesive law"
<< abort(FatalError);
}
directionMixedFvPatchVectorField::autoMap(m);
}
// Reverse-map the given fvPatchField onto this fvPatchField
void cohesiveZoneFvPatchVectorField::rmap
(
const fvPatchField<vector>& ptf,
const labelList& addr
)
{
directionMixedFvPatchVectorField::rmap(ptf, addr);
const cohesiveZoneFvPatchVectorField& dmptf =
refCast<const cohesiveZoneFvPatchVectorField>(ptf);
// No need to grab the cohesive zone pointer more than once
if (!cohesiveLawPtr_)
{
cohesiveLawPtr_ = dmptf.cohesiveLawPtr_->clone().ptr();
relaxationFactor_ = dmptf.relaxationFactor_;
}
}
void cohesiveZoneFvPatchVectorField::updateCoeffs()
{
if (this->updated())
{
return;
}
// Looking up rheology
const rheologyModel& rheology =
this->db().objectRegistry::lookupObject<rheologyModel>(rheologyName_);
const scalarField mu =
rheology.mu()().boundaryField()[patch().index()];
const scalarField lambda =
rheology.lambda()().boundaryField()[patch().index()];
const fvPatchField<tensor>& gradU =
patch().lookupPatchField<volTensorField, tensor>
(
"grad(" +UName_ + ")"
);
// Patch displacement
const vectorField& U = *this;
// Patch stress
tensorField sigma = mu*(gradU + gradU.T()) + I*(lambda*tr(gradU));
// Patch normal
vectorField n = patch().nf();
// Normal stress component
scalarField sigmaN = (n&(n&sigma));
// Chech crack propagation
forAll(sigmaN, faceI)
{
vector cohesiveTraction = vector::zero;
if
(
(magSqr(valueFraction()[faceI]) > 1-SMALL)
&& (sigmaN[faceI] >= law().sigmaMax().value())
)
{
// Switch to full traction boundary condition
valueFraction()[faceI] = symmTensor::zero;
Info << "Crack started at face: " << faceI << endl;
// Cohesive traction
cohesiveTraction = n[faceI]*law().sigmaMax().value();
}
else if(magSqr(valueFraction()[faceI]) < SMALL)
{
// Normal displacement
scalar Un = -(n[faceI]&U[faceI]);
if(Un < 0)
{
// Return from traction to symmetryPlane
refValue()[faceI] = vector::zero;
refGrad() = vector::zero;
valueFraction()[faceI] = sqr(n[faceI]);
Info << "Face removed from crack: " << faceI << endl;
}
else if(Un > law().deltaC().value()/2)
{
// Traction free
cohesiveTraction = vector::zero;
}
else
{
// Calculate cohesive traction from cohesive zone model
cohesiveTraction = law().traction(2*Un)*n[faceI];
}
}
if(magSqr(valueFraction()[faceI]) < SMALL)
{
cohesiveTraction =
relaxationFactor_*cohesiveTraction
+ (1.0 - relaxationFactor_)*sigmaN[faceI]*n[faceI];
refGrad()[faceI] =
(
cohesiveTraction
- (
n[faceI]
& (
mu[faceI]*gradU[faceI].T()
- (mu[faceI] + lambda[faceI])*gradU[faceI]
)
)
- n[faceI]*lambda[faceI]*tr(gradU[faceI])
)
/(2.0*mu[faceI] + lambda[faceI]);
}
}
directionMixedFvPatchVectorField::updateCoeffs();
}
// Write
void cohesiveZoneFvPatchVectorField::write(Ostream& os) const
{
directionMixedFvPatchVectorField::write(os);
os.writeKeyword("U") << UName_ << token::END_STATEMENT << nl;
os.writeKeyword("rheology") << rheologyName_ << token::END_STATEMENT << nl;
os.writeKeyword("cohesiveLaw") << law().type()
<< token::END_STATEMENT << nl;
os.writeKeyword("relaxationFactor") << relaxationFactor_
<< token::END_STATEMENT << nl;
law().writeDict(os);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePatchTypeField(fvPatchVectorField, cohesiveZoneFvPatchVectorField);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,196 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2007 Hrvoje Jasak
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Class
cohesiveZoneFvPatchVectorField
Description
SourceFiles
cohesiveZoneFvPatchVectorField.C
\*---------------------------------------------------------------------------*/
#ifndef cohesiveZoneFvPatchVectorField_H
#define cohesiveZoneFvPatchVectorField_H
#include "fvPatchFields.H"
#include "directionMixedFvPatchFields.H"
#include "cohesiveLaw.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class directionMixedFvPatch Declaration
\*---------------------------------------------------------------------------*/
class cohesiveZoneFvPatchVectorField
:
public directionMixedFvPatchVectorField
{
// Private data
//- Name of the displacement field
const word UName_;
//- Name of rheology model
const word rheologyName_;
//- Cohesive law
cohesiveLaw* cohesiveLawPtr_;
//- Under-relaxation factor
scalar relaxationFactor_;
// Private Member Functions
public:
//- Runtime type information
TypeName("cohesiveZone");
// Constructors
//- Construct from patch and internal field
cohesiveZoneFvPatchVectorField
(
const fvPatch&,
const DimensionedField<vector, volMesh>&
);
//- Construct from patch, internal field and dictionary
cohesiveZoneFvPatchVectorField
(
const fvPatch&,
const DimensionedField<vector, volMesh>&,
const dictionary&
);
//- Construct by mapping given cohesiveZoneFvPatchVectorField onto
// a new patch
cohesiveZoneFvPatchVectorField
(
const cohesiveZoneFvPatchVectorField&,
const fvPatch&,
const DimensionedField<vector, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct and return a clone
virtual tmp<fvPatchField<vector> > clone() const
{
return tmp<fvPatchField<vector> >
(
new cohesiveZoneFvPatchVectorField(*this)
);
}
//- Construct as copy setting internal field reference
cohesiveZoneFvPatchVectorField
(
const cohesiveZoneFvPatchVectorField&,
const DimensionedField<vector, volMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchField<vector> > clone
(
const DimensionedField<vector, volMesh>& iF
) const
{
return tmp<fvPatchField<vector> >
(
new cohesiveZoneFvPatchVectorField(*this, iF)
);
}
// Destructor
// virtual ~cohesiveZoneFvPatchVectorField();
// Member functions
// Access
//- Return true if this patch field fixes a value.
// Needed to check if a level has to be specified while solving
// Poissons equations.
virtual bool fixesValue() const
{
return false;
}
//- Return cohesive law
const cohesiveLaw& law() const
{
return *cohesiveLawPtr_;
}
// Mapping functions
//- Map (and resize as needed) from self given a mapping object
virtual void autoMap
(
const fvPatchFieldMapper&
);
//- Reverse map the given fvPatchField onto this fvPatchField
virtual void rmap
(
const fvPatchField<vector>&,
const labelList&
);
// Evaluation functions
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
//- Write
virtual void write(Ostream&) const;
// Member operators
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,328 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2007 Hrvoje Jasak
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Class
newDirectionMixedFvPatchField
Description
Doubly mixed fixed value-fixed gradient boundary condition
separated into a normal and a tangential component given a
direction vector. The mixture is controlled by two separate
valueFraction coefficients in the normal and tangential direction.
\*---------------------------------------------------------------------------*/
#include "newDirectionMixedFvPatchField.H"
#include "transformField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type>
void newDirectionMixedFvPatchField<Type>::checkNHat()
{
scalarField magNHat(Foam::mag(nHat_));
if (min(magNHat) < SMALL)
{
FatalErrorIn("void newDirectionMixedFvPatchField<Type>::checkNHat()")
<< "Incorrectly defined normal direction. mag = "
<< min(magNHat)
<< abort(FatalError);
}
magNHat /= mag(magNHat);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
newDirectionMixedFvPatchField<Type>::newDirectionMixedFvPatchField
(
const fvPatch& p,
const DimensionedField<Type, volMesh>& iF
)
:
fvPatchField<Type>(p, iF),
refValue_(p.size()),
refGrad_(p.size()),
nHat_(p.size()),
normalValueFraction_(p.size()),
tangentialValueFraction_(p.size())
{}
template<class Type>
newDirectionMixedFvPatchField<Type>::newDirectionMixedFvPatchField
(
const newDirectionMixedFvPatchField<Type>& ptf,
const fvPatch& p,
const DimensionedField<Type, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
fvPatchField<Type>(ptf, p, iF, mapper),
refValue_(ptf.refValue_, mapper),
refGrad_(ptf.refGrad_, mapper),
nHat_(ptf.nHat_, mapper),
normalValueFraction_(ptf.normalValueFraction_, mapper),
tangentialValueFraction_(ptf.tangentialValueFraction_, mapper)
{
this->checkNHat();
}
template<class Type>
newDirectionMixedFvPatchField<Type>::newDirectionMixedFvPatchField
(
const fvPatch& p,
const DimensionedField<Type, volMesh>& iF,
const dictionary& dict
)
:
fvPatchField<Type>(p, iF, dict),
refValue_("refValue", dict, p.size()),
refGrad_("refGradient", dict, p.size()),
nHat_("nHat", dict, p.size()),
normalValueFraction_("normalValueFraction", dict, p.size()),
tangentialValueFraction_("tangentialValueFraction", dict, p.size())
{
this->checkNHat();
evaluate();
}
template<class Type>
newDirectionMixedFvPatchField<Type>::newDirectionMixedFvPatchField
(
const newDirectionMixedFvPatchField<Type>& ptf,
const DimensionedField<Type, volMesh>& iF
)
:
fvPatchField<Type>(ptf, iF),
refValue_(ptf.refValue_),
refGrad_(ptf.refGrad_),
nHat_(ptf.nHat_),
normalValueFraction_(ptf.normalValueFraction_),
tangentialValueFraction_(ptf.tangentialValueFraction_)
{
this->checkNHat();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// Map from self
template<class Type>
void newDirectionMixedFvPatchField<Type>::autoMap
(
const fvPatchFieldMapper& m
)
{
Field<Type>::autoMap(m);
refValue_.autoMap(m);
refGrad_.autoMap(m);
nHat_.autoMap(m);
normalValueFraction_.autoMap(m);
tangentialValueFraction_.autoMap(m);
}
// Reverse-map the given fvPatchField onto this fvPatchField
template<class Type>
void newDirectionMixedFvPatchField<Type>::rmap
(
const fvPatchField<Type>& ptf,
const labelList& addr
)
{
fvPatchField<Type>::rmap(ptf, addr);
const newDirectionMixedFvPatchField<Type>& dmptf =
refCast<const newDirectionMixedFvPatchField<Type> >(ptf);
refValue_.rmap(dmptf.refValue_, addr);
refGrad_.rmap(dmptf.refGrad_, addr);
nHat_.rmap(dmptf.nHat_, addr);
normalValueFraction_.rmap(dmptf.normalValueFraction_, addr);
tangentialValueFraction_.rmap(dmptf.tangentialValueFraction_, addr);
}
// Return gradient at boundary
template<class Type>
tmp<Field<Type> > newDirectionMixedFvPatchField<Type>::snGrad() const
{
Field<Type> pif = this->patchInternalField();
const scalarField& deltaCoeffs = this->patch().deltaCoeffs();
const tensorField nn= nHat_*nHat_;
Field<Type> normalValue =
normalValueFraction_*transform(nn, refValue_)
+ (1.0 - normalValueFraction_)*transform(nn, pif + refGrad_/deltaCoeffs);
Field<Type> tangentialValue =
tangentialValueFraction_*transform(I - nn, refValue_)
+ (1.0 - tangentialValueFraction_)*
transform(I - nn, pif + refGrad_/deltaCoeffs);
return (normalValue + tangentialValue - pif)*deltaCoeffs;
}
// Evaluate the field on the patch
template<class Type>
void newDirectionMixedFvPatchField<Type>::evaluate()
{
if (!this->updated())
{
this->updateCoeffs();
}
Field<Type> pif = this->patchInternalField();
const scalarField& deltaCoeffs = this->patch().deltaCoeffs();
const tensorField nn = nHat_*nHat_;
Field<Type> normalValue =
normalValueFraction_*transform(nn, refValue_)
+ (1.0 - normalValueFraction_)*transform(nn, pif + refGrad_/deltaCoeffs);
Field<Type> tangentialValue =
tangentialValueFraction_*transform(I - nn, refValue_)
+ (1.0 - tangentialValueFraction_)*
transform(I - nn, pif + refGrad_/deltaCoeffs);
Field<Type>::operator=(normalValue + tangentialValue);
fvPatchField<Type>::evaluate();
}
//- Return the matrix diagonal coefficients corresponding to the
// evaluation of the value of this patchField
template<class Type>
tmp<Field<Type> > newDirectionMixedFvPatchField<Type>::valueInternalCoeffs
(
const tmp<scalarField>&
) const
{
const Field<Type> one(this->size(), pTraits<Type>::one);
const tensorField nn= nHat_*nHat_;
return
transform(nn, one)*(1.0 - normalValueFraction_)
+ transform(I - nn, one)*(1.0 - tangentialValueFraction_);
}
//- Return the matrix source coefficients corresponding to the
// evaluation of the value of this patchField
template<class Type>
tmp<Field<Type> > newDirectionMixedFvPatchField<Type>::valueBoundaryCoeffs
(
const tmp<scalarField>&
) const
{
const scalarField& deltaCoeffs = this->patch().deltaCoeffs();
const tensorField nn= nHat_*nHat_;
return
normalValueFraction_*transform(nn, refValue_)
+ (1.0 - normalValueFraction_)*transform(nn, refGrad_)/deltaCoeffs
+ tangentialValueFraction_*transform(I - nn, refValue_)
+ (1.0 - tangentialValueFraction_)*
transform(I - nn, refGrad_)/deltaCoeffs;
// Alternative; allows fiddling internal/boundary split for value coeffs
// return
// *this
// - scale
// (
// valueInternalCoeffs(this->patch().weights()),
// this->patchInternalField()
// );
}
//- Return the matrix diagonal coefficients corresponding to the
// evaluation of the gradient of this patchField
template<class Type>
tmp<Field<Type> >
newDirectionMixedFvPatchField<Type>::gradientInternalCoeffs() const
{
const scalarField& deltaCoeffs = this->patch().deltaCoeffs();
const Field<Type> one(this->size(), pTraits<Type>::one);
const tensorField nn= nHat_*nHat_;
return
-transform(nn, one)*normalValueFraction_*deltaCoeffs
- transform(I - nn, one)*tangentialValueFraction_*deltaCoeffs;
}
//- Return the matrix source coefficients corresponding to the
// evaluation of the gradient of this patchField
template<class Type>
tmp<Field<Type> >
newDirectionMixedFvPatchField<Type>::gradientBoundaryCoeffs() const
{
const scalarField& deltaCoeffs = this->patch().deltaCoeffs();
const tensorField nn= nHat_*nHat_;
return
normalValueFraction_*deltaCoeffs*transform(nn, refValue_)
+ (1.0 - normalValueFraction_)*transform(nn, refGrad_)
+ tangentialValueFraction_*deltaCoeffs*transform(I - nn, refValue_)
+ (1.0 - tangentialValueFraction_)*transform(I - nn, refGrad_);
// Alternative; allows fiddling internal/boundary split for grad coeffs
// return
// snGrad()
// - scale(gradientInternalCoeffs(), this->patchInternalField());
}
// Write
template<class Type>
void newDirectionMixedFvPatchField<Type>::write(Ostream& os) const
{
fvPatchField<Type>::write(os);
refValue_.writeEntry("refValue", os);
refGrad_.writeEntry("refGradient", os);
nHat_.writeEntry("nHat", os);
normalValueFraction_.writeEntry("normalValueFraction", os);
tangentialValueFraction_.writeEntry("tangentialValueFraction", os);
this->writeEntry("value", os);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,302 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2007 Hrvoje Jasak
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Class
newDirectionMixedFvPatchField
Description
Doubly mixed fixed value-fixed gradient boundary condition
separated into a normal and a tangential component given a
direction vector. The mixture is controlled by two separate
valueFraction coefficients in the normal and tangential direction.
SourceFiles
newDirectionMixedFvPatchField.C
\*---------------------------------------------------------------------------*/
#ifndef newDirectionMixedFvPatchField_H
#define newDirectionMixedFvPatchField_H
#include "fvPatchField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class directionMixedFvPatch Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class newDirectionMixedFvPatchField
:
public fvPatchField<Type>
{
// Private data
//- Value field
Field<Type> refValue_;
//- Gradient field
Field<Type> refGrad_;
//- Normal direction
vectorField nHat_;
//- Fraction (0-1) of value used for normal component
scalarField normalValueFraction_;
//- Fraction (0-1) of value used for tangential component
scalarField tangentialValueFraction_;
// Private Member Functions
//- Check and normalize nHat
void checkNHat();
public:
//- Runtime type information
TypeName("newDirectionMixed");
// Constructors
//- Construct from patch and internal field
newDirectionMixedFvPatchField
(
const fvPatch&,
const DimensionedField<Type, volMesh>&
);
//- Construct from patch, internal field and dictionary
newDirectionMixedFvPatchField
(
const fvPatch&,
const DimensionedField<Type, volMesh>&,
const dictionary&
);
//- Construct by mapping given newDirectionMixedFvPatchField onto
// a new patch
newDirectionMixedFvPatchField
(
const newDirectionMixedFvPatchField<Type>&,
const fvPatch&,
const DimensionedField<Type, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct and return a clone
virtual tmp<fvPatchField<Type> > clone() const
{
return tmp<fvPatchField<Type> >
(
new newDirectionMixedFvPatchField<Type>(*this)
);
}
//- Construct as copy setting internal field reference
newDirectionMixedFvPatchField
(
const newDirectionMixedFvPatchField<Type>&,
const DimensionedField<Type, volMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchField<Type> > clone
(
const DimensionedField<Type, volMesh>& iF
) const
{
return tmp<fvPatchField<Type> >
(
new newDirectionMixedFvPatchField<Type>(*this, iF)
);
}
// Member functions
// Access
//- Return true if this patch field fixes a value.
// Needed to check if a level has to be specified while solving
// Poissons equations.
virtual bool fixesValue() const
{
return true;
}
// Mapping functions
//- Map (and resize as needed) from self given a mapping object
virtual void autoMap
(
const fvPatchFieldMapper&
);
//- Reverse map the given fvPatchField onto this fvPatchField
virtual void rmap
(
const fvPatchField<Type>&,
const labelList&
);
// Return defining fields
virtual Field<Type>& refValue()
{
return refValue_;
}
virtual const Field<Type>& refValue() const
{
return refValue_;
}
virtual Field<Type>& refGrad()
{
return refGrad_;
}
virtual const Field<Type>& refGrad() const
{
return refGrad_;
}
virtual vectorField& nHat()
{
return nHat_;
}
virtual const vectorField& nHat() const
{
return nHat_;
}
virtual scalarField& normalValueFraction()
{
return normalValueFraction_;
}
virtual const scalarField& normalValueFraction() const
{
return normalValueFraction_;
}
virtual scalarField& tangentialValueFraction()
{
return tangentialValueFraction_;
}
virtual const scalarField& tangentialValueFraction() const
{
return tangentialValueFraction_;
}
// Evaluation functions
//- Return gradient at boundary
virtual tmp<Field<Type> > snGrad() const;
//- Evaluate the patch field
virtual void evaluate();
//- Return the matrix diagonal coefficients corresponding to the
// evaluation of the value of this patchField with given weights
virtual tmp<Field<Type> > valueInternalCoeffs
(
const tmp<scalarField>&
) const;
//- Return the matrix source coefficients corresponding to the
// evaluation of the value of this patchField with given weights
virtual tmp<Field<Type> > valueBoundaryCoeffs
(
const tmp<scalarField>&
) const;
//- Return the matrix diagonal coefficients corresponding to the
// evaluation of the gradient of this patchField
virtual tmp<Field<Type> > gradientInternalCoeffs() const;
//- Return the matrix source coefficients corresponding to the
// evaluation of the gradient of this patchField
virtual tmp<Field<Type> > gradientBoundaryCoeffs() const;
//- Write
virtual void write(Ostream&) const;
// Member operators
virtual void operator=(const fvPatchField<Type>&) {}
virtual void operator+=(const fvPatchField<Type>&) {}
virtual void operator-=(const fvPatchField<Type>&) {}
virtual void operator*=(const fvPatchField<Type>&) {}
virtual void operator/=(const fvPatchField<Type>&) {}
virtual void operator=(const Field<Type>&) {}
virtual void operator+=(const Field<Type>&) {}
virtual void operator-=(const Field<Type>&) {}
virtual void operator*=(const Field<scalar>&) {}
virtual void operator/=(const Field<scalar>&) {}
virtual void operator=(const Type&) {}
virtual void operator+=(const Type&) {}
virtual void operator-=(const Type&) {}
virtual void operator*=(const scalar) {}
virtual void operator/=(const scalar) {}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "newDirectionMixedFvPatchField.C"
#else
# ifdef xlC
# pragma implementation("newDirectionMixedFvPatchField.C")
# endif
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,68 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2007 Hrvoje Jasak
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Class
directionMixedFvPatchField
Description
Doubly mixed fixed value-fixed gradient boundary condition
separated into a normal and a tangential component given a
direction vector. The mixture is controlled by two separate
valueFraction cuefficients in the normal and tangential direction.
\*---------------------------------------------------------------------------*/
#ifndef directionMixedFvPatchFieldsFwd_H
#define directionMixedFvPatchFieldsFwd_H
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type> class newDirectionMixedFvPatchField;
typedef newDirectionMixedFvPatchField<scalar>
newDirectionMixedFvPatchScalarField;
typedef newDirectionMixedFvPatchField<vector>
newDirectionMixedFvPatchVectorField;
typedef newDirectionMixedFvPatchField<tensor>
newDirectionMixedFvPatchTensorField;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,50 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2007 Hrvoje Jasak
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Description
Doubly mixed fixed value-fixed gradient boundary condition
separated into a normal and a tangential component given a
direction vector. The mixture is controlled by two separate
valueFraction cuefficients in the normal and tangential direction.
\*---------------------------------------------------------------------------*/
#include "newDirectionMixedFvPatchFields.H"
#include "addToRunTimeSelectionTable.H"
#include "volFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makePatchFields(newDirectionMixed);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,62 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2007 Hrvoje Jasak
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Class
newDirectionMixedFvPatchFields
Description
Doubly mixed fixed value-fixed gradient boundary condition
separated into a normal and a tangential component given a
direction vector. The mixture is controlled by two separate
valueFraction cuefficients in the normal and tangential direction.
SourceFiles
newDirectionMixedFvPatchFields.C
\*---------------------------------------------------------------------------*/
#ifndef newDirectionMixedFvPatchFields_H
#define newDirectionMixedFvPatchFields_H
#include "newDirectionMixedFvPatchField.H"
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePatchTypeFieldTypedefs(newDirectionMixed)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,243 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
\*---------------------------------------------------------------------------*/
#include "nusseltFvPatchScalarField.H"
#include "addToRunTimeSelectionTable.H"
#include "fvPatchFieldMapper.H"
#include "volFields.H"
#include "surfaceFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
nusseltFvPatchScalarField::nusseltFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF
)
:
mixedFvPatchScalarField(p, iF),
DTName_("undefined"),
Tinf_(0.0),
alpha_(p.size(), 0.0)
{
refValue() = 0.0;
refGrad() = 0.0;
valueFraction() = 0.0;
}
nusseltFvPatchScalarField::nusseltFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
)
:
mixedFvPatchScalarField(p, iF),
DTName_(dict.lookup("DT")),
Tinf_(readScalar(dict.lookup("Tinf"))),
alpha_("alpha", dict, p.size())
{
if (dict.found("value"))
{
fvPatchField<scalar>::operator=
(
scalarField("value", dict, p.size())
);
}
else
{
fvPatchField<scalar>::operator=(patchInternalField());
}
refValue() = *this;
refGrad() = 0.0;
valueFraction() = 0.0;
if (Tinf_ < SMALL)
{
FatalIOErrorIn
(
"nusseltFvPatchScalarField::nusseltFvPatchScalarField\n"
"(\n"
" const fvPatch&,\n"
" const DimensionedField<scalar, volMesh>&,\n"
" const dictionary&\n"
")",
dict
) << "unphysical Tinf specified (Tinf = 0 or negative)"
<< exit(FatalError);
}
if (min(alpha_) < -SMALL)
{
FatalIOErrorIn
(
"nusseltFvPatchScalarField::nusseltFvPatchScalarField\n"
"(\n"
" const fvPatch&,\n"
" const DimensionedField<scalar, volMesh>&,\n"
" const dictionary&\n"
")",
dict
) << "unphysical alpha specified (alpha = 0 or negative)" << endl
<< exit(FatalError);
}
}
nusseltFvPatchScalarField::nusseltFvPatchScalarField
(
const nusseltFvPatchScalarField& ptf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
mixedFvPatchScalarField(ptf, p, iF, mapper),
DTName_(ptf.DTName_),
Tinf_(ptf.Tinf_),
alpha_(ptf.alpha_)
{}
nusseltFvPatchScalarField::nusseltFvPatchScalarField
(
const nusseltFvPatchScalarField& ptf
)
:
mixedFvPatchScalarField(ptf),
DTName_(ptf.DTName_),
Tinf_(ptf.Tinf_),
alpha_(ptf.alpha_)
{}
nusseltFvPatchScalarField::nusseltFvPatchScalarField
(
const nusseltFvPatchScalarField& ptpsf,
const DimensionedField<scalar, volMesh>& iF
)
:
mixedFvPatchScalarField(ptpsf, iF),
DTName_(ptpsf.DTName_),
Tinf_(ptpsf.Tinf_),
alpha_(ptpsf.alpha_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// Map from self
void nusseltFvPatchScalarField::autoMap
(
const fvPatchFieldMapper& m
)
{
mixedFvPatchScalarField::autoMap(m);
alpha_.autoMap(m);
}
// Reverse-map the given fvPatchField onto this fvPatchField
void nusseltFvPatchScalarField::rmap
(
const fvPatchField<scalar>& ptf,
const labelList& addr
)
{
mixedFvPatchField<scalar>::rmap(ptf, addr);
const nusseltFvPatchScalarField& npsf =
refCast<const nusseltFvPatchScalarField>(ptf);
alpha_.rmap(npsf.alpha_, addr);
}
// Update the coefficients associated with the patch field
void nusseltFvPatchScalarField::updateCoeffs()
{
if (updated())
{
return;
}
scalarField Tinternal = patchInternalField();
// Lookup temperature diffusivity of the patch
const fvPatchField<scalar>& DT =
this->patch().lookupPatchField<volScalarField, scalar>(DTName_);
// Calculate flux
scalarField tempFlux = alpha_*(Tinternal - Tinf_);
refValue() =
neg(tempFlux)*
min
(
Tinternal - tempFlux/(DT*patch().deltaCoeffs()),
Tinf_
)
+ pos(tempFlux)*
max
(
Tinternal - tempFlux/(DT*patch().deltaCoeffs()),
Tinf_
);
refGrad() = -tempFlux;
valueFraction() = pos(tempFlux);
mixedFvPatchScalarField::updateCoeffs();
}
// Write
void nusseltFvPatchScalarField::write(Ostream& os) const
{
fvPatchScalarField::write(os);
os.writeKeyword("DT") << DTName_ << token::END_STATEMENT << nl;
os.writeKeyword("Tinf") << Tinf_ << token::END_STATEMENT << endl;
alpha_.writeEntry("alpha", os);
writeEntry("value", os);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePatchTypeField(fvPatchScalarField, nusseltFvPatchScalarField);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,201 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Class
nusseltFvPatchScalarField
Description
Nusselt boundary condition for temperature
SourceFiles
nusseltFvPatchScalarField.C
\*---------------------------------------------------------------------------*/
#ifndef nusseltFvPatchScalarFields_H
#define nusseltFvPatchScalarFields_H
#include "mixedFvPatchFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class nusseltFvPatch Declaration
\*---------------------------------------------------------------------------*/
class nusseltFvPatchScalarField
:
public mixedFvPatchScalarField
{
// Private data
//- Name of the displacement field
const word DTName_;
//- Reference temperature at infinity
scalar Tinf_;
//- Heat transfer coefficient
scalarField alpha_;
public:
//- Runtime type information
TypeName("nusselt");
// Constructors
//- Construct from patch and internal field
nusseltFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&
);
//- Construct from patch, internal field and dictionary
nusseltFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const dictionary&
);
//- Construct by mapping given nusseltFvPatchScalarField
// onto a new patch
nusseltFvPatchScalarField
(
const nusseltFvPatchScalarField&,
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
nusseltFvPatchScalarField
(
const nusseltFvPatchScalarField&
);
//- Construct and return a clone
virtual tmp<fvPatchScalarField> clone() const
{
return tmp<fvPatchScalarField>
(
new nusseltFvPatchScalarField(*this)
);
}
//- Construct as copy setting internal field reference
nusseltFvPatchScalarField
(
const nusseltFvPatchScalarField&,
const DimensionedField<scalar, volMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchScalarField> clone
(
const DimensionedField<scalar, volMesh>& iF
) const
{
return tmp<fvPatchScalarField>
(
new nusseltFvPatchScalarField(*this, iF)
);
}
// Member functions
// Access
//- Return the temperature at infinity
scalar Tinf() const
{
return Tinf_;
}
//- Return reference to the temperature at infinity
// to allow adjustment
scalar& Tinf()
{
return Tinf_;
}
//- Return the heat transfer coefficient
const scalarField& alpha() const
{
return alpha_;
}
//- Return reference to the heat transfer coefficient
// to allow adjustment
scalarField& alpha()
{
return alpha_;
}
// Mapping functions
//- Map (and resize as needed) from self given a mapping object
virtual void autoMap
(
const fvPatchFieldMapper&
);
//- Reverse map the given fvPatchField onto this fvPatchField
virtual void rmap
(
const fvPatchField<scalar>&,
const labelList&
);
// Evaluation functions
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
//- Write
virtual void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,205 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
\*---------------------------------------------------------------------------*/
#include "tractionDisplacementFvPatchVectorField.H"
#include "addToRunTimeSelectionTable.H"
#include "volFields.H"
#include "rheologyModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
tractionDisplacementFvPatchVectorField::
tractionDisplacementFvPatchVectorField
(
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF
)
:
fixedGradientFvPatchVectorField(p, iF),
UName_("undefined"),
rheologyName_("undefined"),
traction_(p.size(), vector::zero),
pressure_(p.size(), 0.0)
{
fvPatchVectorField::operator=(patchInternalField());
gradient() = vector::zero;
}
tractionDisplacementFvPatchVectorField::
tractionDisplacementFvPatchVectorField
(
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF,
const dictionary& dict
)
:
fixedGradientFvPatchVectorField(p, iF),
UName_(dict.lookup("U")),
rheologyName_(dict.lookup("rheology")),
traction_("traction", dict, p.size()),
pressure_("pressure", dict, p.size())
{
fvPatchVectorField::operator=(patchInternalField());
gradient() = vector::zero;
Info << "rf: " << rheologyName_ << endl;
}
tractionDisplacementFvPatchVectorField::
tractionDisplacementFvPatchVectorField
(
const tractionDisplacementFvPatchVectorField& tdpvf,
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
fixedGradientFvPatchVectorField(tdpvf, p, iF, mapper),
UName_(tdpvf.UName_),
rheologyName_(tdpvf.rheologyName_),
traction_(tdpvf.traction_, mapper),
pressure_(tdpvf.pressure_, mapper)
{}
tractionDisplacementFvPatchVectorField::
tractionDisplacementFvPatchVectorField
(
const tractionDisplacementFvPatchVectorField& tdpvf
)
:
fixedGradientFvPatchVectorField(tdpvf),
UName_(tdpvf.UName_),
rheologyName_(tdpvf.rheologyName_),
traction_(tdpvf.traction_),
pressure_(tdpvf.pressure_)
{}
tractionDisplacementFvPatchVectorField::
tractionDisplacementFvPatchVectorField
(
const tractionDisplacementFvPatchVectorField& tdpvf,
const DimensionedField<vector, volMesh>& iF
)
:
fixedGradientFvPatchVectorField(tdpvf, iF),
UName_(tdpvf.UName_),
rheologyName_(tdpvf.rheologyName_),
traction_(tdpvf.traction_),
pressure_(tdpvf.pressure_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void tractionDisplacementFvPatchVectorField::autoMap
(
const fvPatchFieldMapper& m
)
{
fixedGradientFvPatchVectorField::autoMap(m);
traction_.autoMap(m);
pressure_.autoMap(m);
}
// Reverse-map the given fvPatchField onto this fvPatchField
void tractionDisplacementFvPatchVectorField::rmap
(
const fvPatchVectorField& ptf,
const labelList& addr
)
{
fixedGradientFvPatchVectorField::rmap(ptf, addr);
const tractionDisplacementFvPatchVectorField& dmptf =
refCast<const tractionDisplacementFvPatchVectorField>(ptf);
traction_.rmap(dmptf.traction_, addr);
pressure_.rmap(dmptf.pressure_, addr);
}
// Update the coefficients associated with the patch field
void tractionDisplacementFvPatchVectorField::updateCoeffs()
{
if (updated())
{
return;
}
// Looking up rheology
const rheologyModel& rheology =
this->db().objectRegistry::lookupObject<rheologyModel>(rheologyName_);
const scalarField mu = rheology.mu()().boundaryField()[patch().index()];
const scalarField lambda =
rheology.lambda()().boundaryField()[patch().index()];
vectorField n = patch().nf();
const fvPatchField<tensor>& gradU =
patch().lookupPatchField<volTensorField, tensor>("grad(" +UName_ + ")");
gradient() =
(
(traction_ - (pressure_)*n)
- (n & (mu*gradU.T() - (mu + lambda)*gradU))
- n*lambda*tr(gradU)
)/(2.0*mu + lambda);
fixedGradientFvPatchVectorField::updateCoeffs();
}
// Write
void tractionDisplacementFvPatchVectorField::write(Ostream& os) const
{
fvPatchVectorField::write(os);
os.writeKeyword("U") << UName_ << token::END_STATEMENT << nl;
os.writeKeyword("rheology") << rheologyName_ << token::END_STATEMENT << nl;
traction_.writeEntry("traction", os);
pressure_.writeEntry("pressure", os);
writeEntry("value", os);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePatchTypeField(fvPatchVectorField, tractionDisplacementFvPatchVectorField);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,199 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Class
tractionDisplacementFvPatchVectorField
Description
Fixed traction boundary condition for the standard linear elastic, fixed
coefficient displacement equation (stressedFoam).
Author
Hrvoje Jasak, Wikki Ltd. All rights reserved
SourceFiles
tractionDisplacementFvPatchVectorField.C
\*---------------------------------------------------------------------------*/
#ifndef tractionDisplacementFvPatchVectorField_H
#define tractionDisplacementFvPatchVectorField_H
#include "fvPatchFields.H"
#include "fixedGradientFvPatchFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class tractionDisplacementFvPatchVectorField Declaration
\*---------------------------------------------------------------------------*/
class tractionDisplacementFvPatchVectorField
:
public fixedGradientFvPatchVectorField
{
// Private Data
//- Name of the displacement field
const word UName_;
//- Name of rheology model
const word rheologyName_;
//- Traction
vectorField traction_;
//- Pressure
scalarField pressure_;
public:
//- Runtime type information
TypeName("tractionDisplacement");
// Constructors
//- Construct from patch and internal field
tractionDisplacementFvPatchVectorField
(
const fvPatch&,
const DimensionedField<vector, volMesh>&
);
//- Construct from patch, internal field and dictionary
tractionDisplacementFvPatchVectorField
(
const fvPatch&,
const DimensionedField<vector, volMesh>&,
const dictionary&
);
//- Construct by mapping given
// tractionDisplacementFvPatchVectorField onto a new patch
tractionDisplacementFvPatchVectorField
(
const tractionDisplacementFvPatchVectorField&,
const fvPatch&,
const DimensionedField<vector, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
tractionDisplacementFvPatchVectorField
(
const tractionDisplacementFvPatchVectorField&
);
//- Construct and return a clone
virtual tmp<fvPatchVectorField> clone() const
{
return tmp<fvPatchVectorField>
(
new tractionDisplacementFvPatchVectorField(*this)
);
}
//- Construct as copy setting internal field reference
tractionDisplacementFvPatchVectorField
(
const tractionDisplacementFvPatchVectorField&,
const DimensionedField<vector, volMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchVectorField> clone
(
const DimensionedField<vector, volMesh>& iF
) const
{
return tmp<fvPatchVectorField>
(
new tractionDisplacementFvPatchVectorField(*this, iF)
);
}
// Member functions
// Access
virtual const vectorField& traction() const
{
return traction_;
}
virtual vectorField& traction()
{
return traction_;
}
virtual const scalarField& pressure() const
{
return pressure_;
}
virtual scalarField& pressure()
{
return pressure_;
}
// Mapping functions
//- Map (and resize as needed) from self given a mapping object
virtual void autoMap
(
const fvPatchFieldMapper&
);
//- Reverse map the given fvPatchField onto this fvPatchField
virtual void rmap
(
const fvPatchVectorField&,
const labelList&
);
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
//- Write
virtual void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,243 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
\*---------------------------------------------------------------------------*/
#include "tractionDisplacementThermoFvPatchVectorField.H"
#include "addToRunTimeSelectionTable.H"
#include "volFields.H"
#include "rheologyModel.H"
#include "thermalModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
tractionDisplacementThermoFvPatchVectorField::
tractionDisplacementThermoFvPatchVectorField
(
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF
)
:
fixedGradientFvPatchVectorField(p, iF),
UName_("undefined"),
TName_("undefined"),
rheologyName_("undefined"),
thermoName_("undefined"),
traction_(p.size(), vector::zero),
pressure_(p.size(), 0.0)
{
fvPatchVectorField::operator=(patchInternalField());
gradient() = vector::zero;
}
tractionDisplacementThermoFvPatchVectorField::
tractionDisplacementThermoFvPatchVectorField
(
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF,
const dictionary& dict
)
:
fixedGradientFvPatchVectorField(p, iF),
UName_(dict.lookup("U")),
TName_(dict.lookup("T")),
rheologyName_(dict.lookup("rheology")),
thermoName_(dict.lookup("thermo")),
traction_("traction", dict, p.size()),
pressure_("pressure", dict, p.size())
{
fvPatchVectorField::operator=(patchInternalField());
gradient() = vector::zero;
}
tractionDisplacementThermoFvPatchVectorField::
tractionDisplacementThermoFvPatchVectorField
(
const tractionDisplacementThermoFvPatchVectorField& tdpvf,
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
fixedGradientFvPatchVectorField(tdpvf, p, iF, mapper),
UName_(tdpvf.UName_),
TName_(tdpvf.TName_),
rheologyName_(tdpvf.rheologyName_),
thermoName_(tdpvf.thermoName_),
traction_(tdpvf.traction_, mapper),
pressure_(tdpvf.pressure_, mapper)
{}
tractionDisplacementThermoFvPatchVectorField::
tractionDisplacementThermoFvPatchVectorField
(
const tractionDisplacementThermoFvPatchVectorField& tdpvf
)
:
fixedGradientFvPatchVectorField(tdpvf),
UName_(tdpvf.UName_),
TName_(tdpvf.TName_),
rheologyName_(tdpvf.rheologyName_),
thermoName_(tdpvf.thermoName_),
traction_(tdpvf.traction_),
pressure_(tdpvf.pressure_)
{}
tractionDisplacementThermoFvPatchVectorField::
tractionDisplacementThermoFvPatchVectorField
(
const tractionDisplacementThermoFvPatchVectorField& tdpvf,
const DimensionedField<vector, volMesh>& iF
)
:
fixedGradientFvPatchVectorField(tdpvf, iF),
UName_(tdpvf.UName_),
TName_(tdpvf.TName_),
rheologyName_(tdpvf.rheologyName_),
thermoName_(tdpvf.thermoName_),
traction_(tdpvf.traction_),
pressure_(tdpvf.pressure_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void tractionDisplacementThermoFvPatchVectorField::autoMap
(
const fvPatchFieldMapper& m
)
{
fixedGradientFvPatchVectorField::autoMap(m);
traction_.autoMap(m);
pressure_.autoMap(m);
}
// Reverse-map the given fvPatchField onto this fvPatchField
void tractionDisplacementThermoFvPatchVectorField::rmap
(
const fvPatchVectorField& ptf,
const labelList& addr
)
{
fixedGradientFvPatchVectorField::rmap(ptf, addr);
const tractionDisplacementThermoFvPatchVectorField& dmptf =
refCast<const tractionDisplacementThermoFvPatchVectorField>(ptf);
traction_.rmap(dmptf.traction_, addr);
pressure_.rmap(dmptf.pressure_, addr);
}
// Update the coefficients associated with the patch field
void tractionDisplacementThermoFvPatchVectorField::updateCoeffs()
{
if (updated())
{
return;
}
// Looking up rheology
const rheologyModel& rheology =
this->db().objectRegistry::
lookupObject<rheologyModel>(rheologyName_);
const scalarField mu = rheology.mu()().boundaryField()[patch().index()];
const scalarField lambda =
rheology.lambda()().boundaryField()[patch().index()];
vectorField n = patch().nf();
const fvPatchField<tensor>& gradU =
patch().lookupPatchField<volTensorField, tensor>("grad(" +UName_ + ")");
// Thermal component
// Looking up thermo
const thermalModel& thermo =
this->db().objectRegistry::lookupObject<thermalModel>(thermoName_);
const fvPatchField<scalar>& T =
patch().lookupPatchField<volScalarField, scalar>(TName_);
const scalarField rhoThreeKalpha =
rheology.rho()().boundaryField()[patch().index()]*
rheology.threeK()().boundaryField()[patch().index()]*
thermo.alpha()().boundaryField()[patch().index()];
const scalarField T0 = thermo.T0()().boundaryField()[patch().index()];
gradient() =
(
(traction_ - (pressure_)*n)
- (n & (mu*gradU.T() - (mu + lambda)*gradU))
- n*lambda*tr(gradU)
+ n*rhoThreeKalpha*(T - T0)
)/(2.0*mu + lambda);
fixedGradientFvPatchVectorField::updateCoeffs();
}
// Write
void tractionDisplacementThermoFvPatchVectorField::write
(
Ostream& os
) const
{
fvPatchVectorField::write(os);
os.writeKeyword("U") << UName_ << token::END_STATEMENT << nl;
os.writeKeyword("T") << TName_ << token::END_STATEMENT << nl;
os.writeKeyword("rheology") << rheologyName_ << token::END_STATEMENT << nl;
os.writeKeyword("thermo") << thermoName_ << token::END_STATEMENT << nl;
traction_.writeEntry("traction", os);
pressure_.writeEntry("pressure", os);
writeEntry("value", os);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePatchTypeField
(
fvPatchVectorField,
tractionDisplacementThermoFvPatchVectorField
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,201 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Class
tractionDisplacementThermoFvPatchVectorField
Author
Hrvoje Jasak, Wikki Ltd. All rights reserved
SourceFiles
tractionDisplacementThermoFvPatchVectorField.C
\*---------------------------------------------------------------------------*/
#ifndef tractionDisplacementThermoFvPatchVectorField_H
#define tractionDisplacementThermoFvPatchVectorField_H
#include "fvPatchFields.H"
#include "fixedGradientFvPatchFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class tractionDisplacementThermoFvPatchVectorField Declaration
\*---------------------------------------------------------------------------*/
class tractionDisplacementThermoFvPatchVectorField
:
public fixedGradientFvPatchVectorField
{
// Private Data
//- Name of the displacement field
const word UName_;
//- Name of the temperature field
const word TName_;
//- Name of rheology model
const word rheologyName_;
//- Name of thermal model
const word thermoName_;
//- Traction
vectorField traction_;
//- Pressure
scalarField pressure_;
public:
//- Runtime type information
TypeName("tractionDisplacementThermo");
// Constructors
//- Construct from patch and internal field
tractionDisplacementThermoFvPatchVectorField
(
const fvPatch&,
const DimensionedField<vector, volMesh>&
);
//- Construct from patch, internal field and dictionary
tractionDisplacementThermoFvPatchVectorField
(
const fvPatch&,
const DimensionedField<vector, volMesh>&,
const dictionary&
);
//- Construct by mapping given
// tractionDisplacementThermoFvPatchVectorField onto a new patch
tractionDisplacementThermoFvPatchVectorField
(
const tractionDisplacementThermoFvPatchVectorField&,
const fvPatch&,
const DimensionedField<vector, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
tractionDisplacementThermoFvPatchVectorField
(
const tractionDisplacementThermoFvPatchVectorField&
);
//- Construct and return a clone
virtual tmp<fvPatchVectorField> clone() const
{
return tmp<fvPatchVectorField>
(
new tractionDisplacementThermoFvPatchVectorField(*this)
);
}
//- Construct as copy setting internal field reference
tractionDisplacementThermoFvPatchVectorField
(
const tractionDisplacementThermoFvPatchVectorField&,
const DimensionedField<vector, volMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchVectorField> clone
(
const DimensionedField<vector, volMesh>& iF
) const
{
return tmp<fvPatchVectorField>
(
new tractionDisplacementThermoFvPatchVectorField(*this, iF)
);
}
// Member functions
// Access
virtual const vectorField& traction() const
{
return traction_;
}
virtual vectorField& traction()
{
return traction_;
}
virtual const scalarField& pressure() const
{
return pressure_;
}
virtual scalarField& pressure()
{
return pressure_;
}
// Mapping functions
//- Map (and resize as needed) from self given a mapping object
virtual void autoMap
(
const fvPatchFieldMapper&
);
//- Reverse map the given fvPatchField onto this fvPatchField
virtual void rmap
(
const fvPatchVectorField&,
const labelList&
);
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
//- Write
virtual void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,210 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2007 Hrvoje Jasak
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Description
\*---------------------------------------------------------------------------*/
#include "BurgersViscoelastic.H"
#include "addToRunTimeSelectionTable.H"
#include "zeroGradientFvPatchFields.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(BurgersViscoelastic, 0);
addToRunTimeSelectionTable(rheologyLaw, BurgersViscoelastic, dictionary);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from dictionary
Foam::BurgersViscoelastic::BurgersViscoelastic
(
const word& name,
const volSymmTensorField& sigma,
const dictionary& dict
)
:
rheologyLaw(name, sigma, dict),
rho_(dict.lookup("rho")),
k1_(dict.lookup("k1")),
eta1_(dict.lookup("eta1")),
k2_(dict.lookup("k2")),
eta2_(dict.lookup("eta2")),
nu_(dict.lookup("nu"))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::BurgersViscoelastic::~BurgersViscoelastic()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::tmp<Foam::volScalarField> Foam::BurgersViscoelastic::rho(scalar t) const
{
tmp<volScalarField> tresult
(
new volScalarField
(
IOobject
(
"rho",
mesh().time().timeName(),
mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh(),
rho_,
zeroGradientFvPatchScalarField::typeName
)
);
tresult().correctBoundaryConditions();
return tresult;
}
Foam::tmp<Foam::volScalarField> Foam::BurgersViscoelastic::E(scalar t) const
{
scalar E = 0.0;
if(t>=0)
{
scalar p1 = eta1_.value()/k1_.value()
+ eta1_.value()/k2_.value()
+ eta2_.value()/k2_.value();
scalar p2 = eta1_.value()*eta2_.value()/(k1_.value()*k2_.value());
scalar q1 = eta1_.value();
scalar q2 = eta1_.value()*eta2_.value()/k2_.value();
scalar A = sqrt(sqr(p1) - 4*p2);
scalar r1 = (p1 - A)/(2*p2);
scalar r2 = (p1 + A)/(2*p2);
E = (q1 - q2*r1)*exp(-r1*t)/A - (q1 - q2*r2)*exp(-r2*t)/A;
}
tmp<volScalarField> tresult
(
new volScalarField
(
IOobject
(
"E",
mesh().time().timeName(),
mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh(),
dimensionedScalar("E", k1_.dimensions(), E),
zeroGradientFvPatchScalarField::typeName
)
);
tresult().correctBoundaryConditions();
return tresult;
}
Foam::tmp<Foam::volScalarField> Foam::BurgersViscoelastic::nu(scalar t) const
{
tmp<volScalarField> tresult
(
new volScalarField
(
IOobject
(
"nu",
mesh().time().timeName(),
mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh(),
nu_,
zeroGradientFvPatchScalarField::typeName
)
);
tresult().correctBoundaryConditions();
return tresult;
}
Foam::tmp<Foam::volScalarField> Foam::BurgersViscoelastic::J(scalar t) const
{
scalar J = 0.0;
if(t >= 0)
{
J = 1.0/k1_.value()
+ (1 - exp(-k2_.value()*t/eta2_.value()))/k2_.value()
+ t/eta1_.value();
}
tmp<volScalarField> tresult
(
new volScalarField
(
IOobject
(
"J",
mesh().time().timeName(),
mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh(),
dimensionedScalar("J", dimless/k1_.dimensions(), J),
zeroGradientFvPatchScalarField::typeName
)
);
tresult().correctBoundaryConditions();
return tresult;
}
// ************************************************************************* //

View file

@ -0,0 +1,154 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2007 Hrvoje Jasak
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Class
BurgersViscoelastic
Description
Linear elastic rheology
SourceFiles
BurgersViscoelastic.C
\*---------------------------------------------------------------------------*/
#ifndef BurgersViscoelastic_H
#define BurgersViscoelastic_H
#include "rheologyLaw.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class BurgersViscoelastic Declaration
\*---------------------------------------------------------------------------*/
class BurgersViscoelastic
:
public rheologyLaw
{
// Private data
//- Density
dimensionedScalar rho_;
//- Linear spring constant of Maxwell model
dimensionedScalar k1_;
//- Coefficient of viscosity of Maxwell model
dimensionedScalar eta1_;
//- Linear spring constant of Kelvin model
dimensionedScalar k2_;
//- Coefficient of viscosity of Kelvin model
dimensionedScalar eta2_;
//- Poisson's ratio
dimensionedScalar nu_;
// Private Member Functions
//- Disallow default bitwise copy construct
BurgersViscoelastic(const BurgersViscoelastic&);
//- Disallow default bitwise assignment
void operator=(const BurgersViscoelastic&);
public:
//- Runtime type information
TypeName("BurgersViscoelastic");
// Static data members
// Constructors
//- Construct from dictionary
BurgersViscoelastic
(
const word& name,
const volSymmTensorField& sigma,
const dictionary& dict
);
// Destructor
virtual ~BurgersViscoelastic();
// Member Functions
//- Return density
virtual tmp<volScalarField> rho() const
{
return rho(0);
}
//- Return modulus of elasticity
virtual tmp<volScalarField> E() const
{
return E(0);
}
//- Return Poisson's ratio
virtual tmp<volScalarField> nu() const
{
return nu(0);
}
//- Return density
virtual tmp<volScalarField> rho(scalar t) const;
//- Return modulus of elasticity
virtual tmp<volScalarField> E(scalar t) const;
//- Return Poisson's ratio
virtual tmp<volScalarField> nu(scalar t) const;
//- Return creep compliance
virtual tmp<volScalarField> J(scalar t) const;
//- Correct the rheological model
virtual void correct()
{}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,203 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2007 Hrvoje Jasak
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Description
\*---------------------------------------------------------------------------*/
#include "KelvinSLSViscoelastic.H"
#include "addToRunTimeSelectionTable.H"
#include "zeroGradientFvPatchFields.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(KelvinSLSViscoelastic, 0);
addToRunTimeSelectionTable(rheologyLaw, KelvinSLSViscoelastic, dictionary);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from dictionary
Foam::KelvinSLSViscoelastic::KelvinSLSViscoelastic
(
const word& name,
const volSymmTensorField& sigma,
const dictionary& dict
)
:
rheologyLaw(name, sigma, dict),
rho_(dict.lookup("rho")),
k1_(dict.lookup("k1")),
k2_(dict.lookup("k2")),
eta2_(dict.lookup("eta2")),
nu_(dict.lookup("nu"))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::KelvinSLSViscoelastic::~KelvinSLSViscoelastic()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::tmp<Foam::volScalarField> Foam::KelvinSLSViscoelastic::rho(scalar t) const
{
tmp<volScalarField> tresult
(
new volScalarField
(
IOobject
(
"rho",
mesh().time().timeName(),
mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh(),
rho_,
zeroGradientFvPatchScalarField::typeName
)
);
tresult().correctBoundaryConditions();
return tresult;
}
Foam::tmp<Foam::volScalarField> Foam::KelvinSLSViscoelastic::E(scalar t) const
{
scalar E = 0.0;
if(t>=0)
{
scalar p1 = eta2_.value()/(k1_.value() + k2_.value());
scalar q0 = k1_.value()*k2_.value()/(k1_.value() + k2_.value());
scalar q1 = k1_.value()*eta2_.value()/(k1_.value() + k2_.value());
E = q0 + (q1/p1 - q0)*exp(-t/p1);
}
tmp<volScalarField> tresult
(
new volScalarField
(
IOobject
(
"E",
mesh().time().timeName(),
mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh(),
dimensionedScalar("E", k1_.dimensions(), E),
zeroGradientFvPatchScalarField::typeName
)
);
tresult().correctBoundaryConditions();
return tresult;
}
Foam::tmp<Foam::volScalarField> Foam::KelvinSLSViscoelastic::nu(scalar t) const
{
tmp<volScalarField> tresult
(
new volScalarField
(
IOobject
(
"nu",
mesh().time().timeName(),
mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh(),
nu_,
zeroGradientFvPatchScalarField::typeName
)
);
tresult().correctBoundaryConditions();
return tresult;
}
Foam::tmp<Foam::volScalarField> Foam::KelvinSLSViscoelastic::J(scalar t) const
{
scalar J = 0.0;
if(t >= 0)
{
scalar p1 = eta2_.value()/(k1_.value() + k2_.value());
scalar q0 = k1_.value()*k2_.value()/(k1_.value() + k2_.value());
scalar q1 = k1_.value()*eta2_.value()/(k1_.value() + k2_.value());
J = 1.0/q0 + (p1/q1 - 1.0/q0)*exp(-q0*t/q1);
}
tmp<volScalarField> tresult
(
new volScalarField
(
IOobject
(
"J",
mesh().time().timeName(),
mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh(),
dimensionedScalar("J", dimless/k1_.dimensions(), J),
zeroGradientFvPatchScalarField::typeName
)
);
tresult().correctBoundaryConditions();
return tresult;
}
// ************************************************************************* //

View file

@ -0,0 +1,150 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2007 Hrvoje Jasak
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Class
KelvinSLSViscoelastic
Description
Linear elastic rheology
SourceFiles
KelvinSLSViscoelastic.C
\*---------------------------------------------------------------------------*/
#ifndef KelvinSLSViscoelastic_H
#define KelvinSLSViscoelastic_H
#include "rheologyLaw.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class KelvinSLSViscoelastic Declaration
\*---------------------------------------------------------------------------*/
class KelvinSLSViscoelastic
:
public rheologyLaw
{
// Private data
//- Density
dimensionedScalar rho_;
//- Linear spring constant
dimensionedScalar k1_;
//- Linear spring constant of Kelvin model
dimensionedScalar k2_;
//- Coefficient of viscosity of Kelvin model
dimensionedScalar eta2_;
//- Poisson's ratio
dimensionedScalar nu_;
// Private Member Functions
//- Disallow default bitwise copy construct
KelvinSLSViscoelastic(const KelvinSLSViscoelastic&);
//- Disallow default bitwise assignment
void operator=(const KelvinSLSViscoelastic&);
public:
//- Runtime type information
TypeName("KelvinSLSViscoelastic");
// Static data members
// Constructors
//- Construct from dictionary
KelvinSLSViscoelastic
(
const word& name,
const volSymmTensorField& sigma,
const dictionary& dict
);
// Destructor
virtual ~KelvinSLSViscoelastic();
// Member Functions
//- Return density
virtual tmp<volScalarField> rho() const
{
return rho(0);
}
//- Return modulus of elasticity
virtual tmp<volScalarField> E() const
{
return E(0);
}
//- Return Poisson's ratio
virtual tmp<volScalarField> nu() const
{
return nu(0);
}
//- Return density
virtual tmp<volScalarField> rho(scalar t) const;
//- Return modulus of elasticity
virtual tmp<volScalarField> E(scalar t) const;
//- Return Poisson's ratio
virtual tmp<volScalarField> nu(scalar t) const;
//- Return creep compliance
virtual tmp<volScalarField> J(scalar t) const;
//- Correct the rheological model
virtual void correct()
{}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,204 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2007 Hrvoje Jasak
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Description
\*---------------------------------------------------------------------------*/
#include "MaxwellElasticViscoelastic.H"
#include "addToRunTimeSelectionTable.H"
#include "zeroGradientFvPatchFields.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(MaxwellElasticViscoelastic, 0);
addToRunTimeSelectionTable
(
rheologyLaw,
MaxwellElasticViscoelastic,
dictionary
);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from dictionary
Foam::MaxwellElasticViscoelastic::MaxwellElasticViscoelastic
(
const word& name,
const volSymmTensorField& sigma,
const dictionary& dict
)
:
rheologyLaw(name, sigma, dict),
rho_(dict.lookup("rho")),
k_(dict.lookup("k")),
eta_(dict.lookup("eta")),
nu_(dict.lookup("nu"))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::MaxwellElasticViscoelastic::~MaxwellElasticViscoelastic()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::tmp<Foam::volScalarField>
Foam::MaxwellElasticViscoelastic::rho(scalar t) const
{
tmp<volScalarField> tresult
(
new volScalarField
(
IOobject
(
"rho",
mesh().time().timeName(),
mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh(),
rho_,
zeroGradientFvPatchScalarField::typeName
)
);
tresult().correctBoundaryConditions();
return tresult;
}
Foam::tmp<Foam::volScalarField>
Foam::MaxwellElasticViscoelastic::E(scalar t) const
{
scalar tau = eta_.value()/k_.value();
tmp<volScalarField> tE
(
new volScalarField
(
IOobject
(
"E",
mesh().time().timeName(),
mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh(),
k_*exp(-t/tau),
zeroGradientFvPatchScalarField::typeName
)
);
if (t < 0)
{
tE().internalField() = 0.0;
tE().correctBoundaryConditions();
}
return tE;
}
Foam::tmp<Foam::volScalarField>
Foam::MaxwellElasticViscoelastic::nu(scalar t) const
{
scalar tau = eta_.value()/k_.value();
scalar E0 = k_.value();
scalar Et = k_.value()*exp(-t/tau);
scalar nu = 0.5 - Et/(6*E0);
tmp<volScalarField> tresult
(
new volScalarField
(
IOobject
(
"nu",
mesh().time().timeName(),
mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh(),
dimensionedScalar("nu", dimless, nu),
zeroGradientFvPatchScalarField::typeName
)
);
tresult().correctBoundaryConditions();
return tresult;
}
Foam::tmp<Foam::volScalarField>
Foam::MaxwellElasticViscoelastic::J(scalar t) const
{
tmp<volScalarField> tJ
(
new volScalarField
(
IOobject
(
"J",
mesh().time().timeName(),
mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh(),
dimensionedScalar
(
"J",
dimless/k_.dimensions(),
1.0/k_.value() + t/eta_.value()
),
zeroGradientFvPatchScalarField::typeName
)
);
if (t < 0)
{
tJ().internalField() = 0.0;
tJ().correctBoundaryConditions();
}
return tJ;
}
// ************************************************************************* //

View file

@ -0,0 +1,148 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2007 Hrvoje Jasak
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Class
MaxwellElasticViscoelastic
Description
Linear elastic rheology
SourceFiles
MaxwellElasticViscoelastic.C
\*---------------------------------------------------------------------------*/
#ifndef MaxwellElasticViscoelastic_H
#define MaxwellElasticViscoelastic_H
#include "rheologyLaw.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class MaxwellElasticViscoelastic Declaration
\*---------------------------------------------------------------------------*/
class MaxwellElasticViscoelastic
:
public rheologyLaw
{
// Private data
//- Density
dimensionedScalar rho_;
//- Linear spring constant
dimensionedScalar k_;
//- Coefficient of viscosity
dimensionedScalar eta_;
//- Poisson's ratio
dimensionedScalar nu_;
// Private Member Functions
//- Disallow default bitwise copy construct
MaxwellElasticViscoelastic(const MaxwellElasticViscoelastic&);
//- Disallow default bitwise assignment
void operator=(const MaxwellElasticViscoelastic&);
public:
//- Runtime type information
TypeName("MaxwellElasticViscoelastic");
// Static data members
// Constructors
//- Construct from dictionary
MaxwellElasticViscoelastic
(
const word& name,
const volSymmTensorField& sigma,
const dictionary& dict
);
// Destructor
virtual ~MaxwellElasticViscoelastic();
// Member Functions
//- Return density
virtual tmp<volScalarField> rho() const
{
return rho(0);
}
//- Return modulus of elasticity
virtual tmp<volScalarField> E() const
{
return E(0);
}
//- Return Poisson's ratio
virtual tmp<volScalarField> nu() const
{
return nu(0);
}
//- Return density
virtual tmp<volScalarField> rho(scalar t) const;
//- Return modulus of elasticity
virtual tmp<volScalarField> E(scalar t) const;
//- Return Poisson's ratio
virtual tmp<volScalarField> nu(scalar t) const;
//- Return creep compliance
virtual tmp<volScalarField> J(scalar t) const;
//- Correct the rheological model
virtual void correct()
{}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,197 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2007 Hrvoje Jasak
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Description
\*---------------------------------------------------------------------------*/
#include "MaxwellSLSViscoelastic.H"
#include "addToRunTimeSelectionTable.H"
#include "zeroGradientFvPatchFields.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(MaxwellSLSViscoelastic, 0);
addToRunTimeSelectionTable(rheologyLaw, MaxwellSLSViscoelastic, dictionary);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from dictionary
Foam::MaxwellSLSViscoelastic::MaxwellSLSViscoelastic
(
const word& name,
const volSymmTensorField& sigma,
const dictionary& dict
)
:
rheologyLaw(name, sigma, dict),
rho_(dict.lookup("rho")),
k1_(dict.lookup("k1")),
eta1_(dict.lookup("eta1")),
k2_(dict.lookup("k2")),
nu_(dict.lookup("nu"))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::MaxwellSLSViscoelastic::~MaxwellSLSViscoelastic()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::tmp<Foam::volScalarField>
Foam::MaxwellSLSViscoelastic::rho(scalar t) const
{
tmp<volScalarField> tresult
(
new volScalarField
(
IOobject
(
"rho",
mesh().time().timeName(),
mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh(),
rho_,
zeroGradientFvPatchScalarField::typeName
)
);
tresult().correctBoundaryConditions();
return tresult;
}
Foam::tmp<Foam::volScalarField> Foam::MaxwellSLSViscoelastic::E(scalar t) const
{
scalar E = 0.0;
if(t>=0)
{
E = k2_.value() + k1_.value()*exp(-k1_.value()*t/eta1_.value());
}
tmp<volScalarField> tresult
(
new volScalarField
(
IOobject
(
"E",
mesh().time().timeName(),
mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh(),
dimensionedScalar("E", k1_.dimensions(), E),
zeroGradientFvPatchScalarField::typeName
)
);
tresult().correctBoundaryConditions();
return tresult;
}
Foam::tmp<Foam::volScalarField> Foam::MaxwellSLSViscoelastic::nu(scalar t) const
{
tmp<volScalarField> tresult
(
new volScalarField
(
IOobject
(
"nu",
mesh().time().timeName(),
mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh(),
nu_,
zeroGradientFvPatchScalarField::typeName
)
);
tresult().correctBoundaryConditions();
return tresult;
}
Foam::tmp<Foam::volScalarField> Foam::MaxwellSLSViscoelastic::J(scalar t) const
{
scalar J = 0.0;
if(t>=0)
{
scalar Jg = 1.0/(k2_.value() + k1_.value());
scalar Jr = 1.0/k2_.value();
scalar tau = eta1_.value()/k1_.value();
scalar tauC = tau*(k1_.value() + k2_.value())/k2_.value();
J = Jg + (Jr - Jg)*(1.0 - exp(-t/tauC));
}
tmp<volScalarField> tresult
(
new volScalarField
(
IOobject
(
"J",
mesh().time().timeName(),
mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh(),
dimensionedScalar("J", dimless/k1_.dimensions(), J),
zeroGradientFvPatchScalarField::typeName
)
);
tresult().correctBoundaryConditions();
return tresult;
}
// ************************************************************************* //

View file

@ -0,0 +1,150 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2007 Hrvoje Jasak
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Class
MaxwellSLSViscoelastic
Description
Linear elastic rheology
SourceFiles
MaxwellSLSViscoelastic.C
\*---------------------------------------------------------------------------*/
#ifndef MaxwellSLSViscoelastic_H
#define MaxwellSLSViscoelastic_H
#include "rheologyLaw.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class MaxwellSLSViscoelastic Declaration
\*---------------------------------------------------------------------------*/
class MaxwellSLSViscoelastic
:
public rheologyLaw
{
// Private data
//- Density
dimensionedScalar rho_;
//- Linear spring constant of Maxwell model
dimensionedScalar k1_;
//- Coefficient of viscosity of Maxwell model
dimensionedScalar eta1_;
//- Linear spring constant
dimensionedScalar k2_;
//- Poisson's ratio
dimensionedScalar nu_;
// Private Member Functions
//- Disallow default bitwise copy construct
MaxwellSLSViscoelastic(const MaxwellSLSViscoelastic&);
//- Disallow default bitwise assignment
void operator=(const MaxwellSLSViscoelastic&);
public:
//- Runtime type information
TypeName("MaxwellSLSViscoelastic");
// Static data members
// Constructors
//- Construct from dictionary
MaxwellSLSViscoelastic
(
const word& name,
const volSymmTensorField& sigma,
const dictionary& dict
);
// Destructor
virtual ~MaxwellSLSViscoelastic();
// Member Functions
//- Return density
virtual tmp<volScalarField> rho() const
{
return rho(0);
}
//- Return modulus of elasticity
virtual tmp<volScalarField> E() const
{
return E(0);
}
//- Return Poisson's ratio
virtual tmp<volScalarField> nu() const
{
return nu(0);
}
//- Return density
virtual tmp<volScalarField> rho(scalar t) const;
//- Return modulus of elasticity
virtual tmp<volScalarField> E(scalar t) const;
//- Return Poisson's ratio
virtual tmp<volScalarField> nu(scalar t) const;
//- Return creep compliance
virtual tmp<volScalarField> J(scalar t) const;
//- Correct the rheological model
virtual void correct()
{}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,190 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2007 Hrvoje Jasak
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Description
\*---------------------------------------------------------------------------*/
#include "MaxwellViscoelastic.H"
#include "addToRunTimeSelectionTable.H"
#include "zeroGradientFvPatchFields.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(MaxwellViscoelastic, 0);
addToRunTimeSelectionTable(rheologyLaw, MaxwellViscoelastic, dictionary);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from dictionary
Foam::MaxwellViscoelastic::MaxwellViscoelastic
(
const word& name,
const volSymmTensorField& sigma,
const dictionary& dict
)
:
rheologyLaw(name, sigma, dict),
rho_(dict.lookup("rho")),
k_(dict.lookup("k")),
eta_(dict.lookup("eta")),
nu_(dict.lookup("nu"))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::MaxwellViscoelastic::~MaxwellViscoelastic()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::tmp<Foam::volScalarField> Foam::MaxwellViscoelastic::rho(scalar t) const
{
tmp<volScalarField> tresult
(
new volScalarField
(
IOobject
(
"rho",
mesh().time().timeName(),
mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh(),
rho_,
zeroGradientFvPatchScalarField::typeName
)
);
tresult().correctBoundaryConditions();
return tresult;
}
Foam::tmp<Foam::volScalarField> Foam::MaxwellViscoelastic::E(scalar t) const
{
scalar tau = eta_.value()/k_.value();
tmp<volScalarField> tE
(
new volScalarField
(
IOobject
(
"E",
mesh().time().timeName(),
mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh(),
k_*exp(-t/tau),
zeroGradientFvPatchScalarField::typeName
)
);
if (t < 0)
{
tE().internalField() = 0.0;
tE().correctBoundaryConditions();
}
return tE;
}
Foam::tmp<Foam::volScalarField> Foam::MaxwellViscoelastic::nu(scalar t) const
{
tmp<volScalarField> tresult
(
new volScalarField
(
IOobject
(
"nu",
mesh().time().timeName(),
mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh(),
nu_,
zeroGradientFvPatchScalarField::typeName
)
);
tresult().correctBoundaryConditions();
return tresult;
}
Foam::tmp<Foam::volScalarField> Foam::MaxwellViscoelastic::J(scalar t) const
{
tmp<volScalarField> tJ
(
new volScalarField
(
IOobject
(
"J",
mesh().time().timeName(),
mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh(),
dimensionedScalar
(
"J",
dimless/k_.dimensions(),
1.0/k_.value() + t/eta_.value()
),
zeroGradientFvPatchScalarField::typeName
)
);
if (t < 0)
{
tJ().internalField() = 0.0;
tJ().correctBoundaryConditions();
}
return tJ;
}
// ************************************************************************* //

View file

@ -0,0 +1,148 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2007 Hrvoje Jasak
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Class
MaxwellViscoelastic
Description
Linear elastic rheology
SourceFiles
MaxwellViscoelastic.C
\*---------------------------------------------------------------------------*/
#ifndef MaxwellViscoelastic_H
#define MaxwellViscoelastic_H
#include "rheologyLaw.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class MaxwellViscoelastic Declaration
\*---------------------------------------------------------------------------*/
class MaxwellViscoelastic
:
public rheologyLaw
{
// Private data
//- Density
dimensionedScalar rho_;
//- Linear spring constant
dimensionedScalar k_;
//- Coefficient of viscosity
dimensionedScalar eta_;
//- Poisson's ratio
dimensionedScalar nu_;
// Private Member Functions
//- Disallow default bitwise copy construct
MaxwellViscoelastic(const MaxwellViscoelastic&);
//- Disallow default bitwise assignment
void operator=(const MaxwellViscoelastic&);
public:
//- Runtime type information
TypeName("MaxwellViscoelastic");
// Static data members
// Constructors
//- Construct from dictionary
MaxwellViscoelastic
(
const word& name,
const volSymmTensorField& sigma,
const dictionary& dict
);
// Destructor
virtual ~MaxwellViscoelastic();
// Member Functions
//- Return density
virtual tmp<volScalarField> rho() const
{
return rho(0);
}
//- Return modulus of elasticity
virtual tmp<volScalarField> E() const
{
return E(0);
}
//- Return Poisson's ratio
virtual tmp<volScalarField> nu() const
{
return nu();
}
//- Return density
virtual tmp<volScalarField> rho(scalar t) const;
//- Return modulus of elasticity
virtual tmp<volScalarField> E(scalar t) const;
//- Return Poisson's ratio
virtual tmp<volScalarField> nu(scalar t) const;
//- Return creep compliance
virtual tmp<volScalarField> J(scalar t) const;
//- Correct the rheological model
virtual void correct()
{}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,170 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2007 Hrvoje Jasak
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Description
\*---------------------------------------------------------------------------*/
#include "PronyViscoelastic.H"
#include "addToRunTimeSelectionTable.H"
#include "zeroGradientFvPatchFields.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(PronyViscoelastic, 0);
addToRunTimeSelectionTable(rheologyLaw, PronyViscoelastic, dictionary);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from dictionary
Foam::PronyViscoelastic::PronyViscoelastic
(
const word& name,
const volSymmTensorField& sigma,
const dictionary& dict
)
:
rheologyLaw(name, sigma, dict),
rho_(dict.lookup("rho")),
k_("k", dict, readInt(dict.lookup("size"))),
kDimensions_(dict.lookup("kDimensions")),
tau_("tau", dict, readInt(dict.lookup("size"))),
tauDimensions_(dict.lookup("tauDimensions")),
nu_(dict.lookup("nu"))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::PronyViscoelastic::~PronyViscoelastic()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::tmp<Foam::volScalarField> Foam::PronyViscoelastic::rho(scalar t) const
{
tmp<volScalarField> tresult
(
new volScalarField
(
IOobject
(
"rho",
mesh().time().timeName(),
mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh(),
rho_,
zeroGradientFvPatchScalarField::typeName
)
);
tresult().correctBoundaryConditions();
return tresult;
}
Foam::tmp<Foam::volScalarField> Foam::PronyViscoelastic::E(scalar t) const
{
scalar E = 0.0;
E = k_[0];
for(int i=1; i<k_.size(); i++)
{
E += k_[i]*exp(-t/tau_[i]);
}
if(t < 0)
{
E = 0;
}
tmp<volScalarField> tresult
(
new volScalarField
(
IOobject
(
"E",
mesh().time().timeName(),
mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh(),
dimensionedScalar("E", kDimensions_, E),
zeroGradientFvPatchScalarField::typeName
)
);
tresult().correctBoundaryConditions();
return tresult;
}
Foam::tmp<Foam::volScalarField> Foam::PronyViscoelastic::nu(scalar t) const
{
tmp<volScalarField> tresult
(
new volScalarField
(
IOobject
(
"nu",
mesh().time().timeName(),
mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh(),
nu_,
zeroGradientFvPatchScalarField::typeName
)
);
tresult().correctBoundaryConditions();
return tresult;
}
Foam::tmp<Foam::volScalarField> Foam::PronyViscoelastic::J(scalar t) const
{
notImplemented(type() + "::J(scalar t)");
return 1.0/E(t);
}
// ************************************************************************* //

View file

@ -0,0 +1,153 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2007 Hrvoje Jasak
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Class
PronyViscoelastic
Description
Linear elastic rheology
SourceFiles
PronyViscoelastic.C
\*---------------------------------------------------------------------------*/
#ifndef PronyViscoelastic_H
#define PronyViscoelastic_H
#include "rheologyLaw.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class PronyViscoelastic Declaration
\*---------------------------------------------------------------------------*/
class PronyViscoelastic
:
public rheologyLaw
{
// Private data
//- Density
dimensionedScalar rho_;
//- Linear spring constants of generalised Maxwell model
Field<scalar> k_;
//- Dimension set for k field
dimensionSet kDimensions_;
//- Relaxation times of generalised Maxwell model
Field<scalar> tau_;
//- Dimension set for tau field
dimensionSet tauDimensions_;
//- Poisson's ratio
dimensionedScalar nu_;
// Private Member Functions
//- Disallow default bitwise copy construct
PronyViscoelastic(const PronyViscoelastic&);
//- Disallow default bitwise assignment
void operator=(const PronyViscoelastic&);
public:
//- Runtime type information
TypeName("PronyViscoelastic");
// Static data members
// Constructors
//- Construct from dictionary
PronyViscoelastic
(
const word& name,
const volSymmTensorField& sigma,
const dictionary& dict
);
// Destructor
virtual ~PronyViscoelastic();
// Member Functions
//- Return density
virtual tmp<volScalarField> rho() const
{
return rho(0);
}
//- Return modulus of elasticity
virtual tmp<volScalarField> E() const
{
return E(0);
}
//- Return Poisson's ratio
virtual tmp<volScalarField> nu() const
{
return nu(0);
}
//- Return density
virtual tmp<volScalarField> rho(scalar t) const;
//- Return modulus of elasticity
virtual tmp<volScalarField> E(scalar t) const;
//- Return Poisson's ratio
virtual tmp<volScalarField> nu(scalar t) const;
//- Return creep compliance
virtual tmp<volScalarField> J(scalar t) const;
//- Correct the rheological model
virtual void correct()
{}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,148 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2007 Hrvoje Jasak
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Description
\*---------------------------------------------------------------------------*/
#include "linearElastic.H"
#include "addToRunTimeSelectionTable.H"
#include "zeroGradientFvPatchFields.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(linearElastic, 0);
addToRunTimeSelectionTable(rheologyLaw, linearElastic, dictionary);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from dictionary
Foam::linearElastic::linearElastic
(
const word& name,
const volSymmTensorField& sigma,
const dictionary& dict
)
:
rheologyLaw(name, sigma, dict),
rho_(dict.lookup("rho")),
E_(dict.lookup("E")),
nu_(dict.lookup("nu"))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::linearElastic::~linearElastic()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::tmp<Foam::volScalarField> Foam::linearElastic::rho() const
{
tmp<volScalarField> tresult
(
new volScalarField
(
IOobject
(
"rho",
mesh().time().timeName(),
mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh(),
rho_,
zeroGradientFvPatchScalarField::typeName
)
);
tresult().correctBoundaryConditions();
return tresult;
}
Foam::tmp<Foam::volScalarField> Foam::linearElastic::E() const
{
tmp<volScalarField> tresult
(
new volScalarField
(
IOobject
(
"E",
mesh().time().timeName(),
mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh(),
E_,
zeroGradientFvPatchScalarField::typeName
)
);
tresult().correctBoundaryConditions();
return tresult;
}
Foam::tmp<Foam::volScalarField> Foam::linearElastic::nu() const
{
tmp<volScalarField> tresult
(
new volScalarField
(
IOobject
(
"nu",
mesh().time().timeName(),
mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh(),
nu_,
zeroGradientFvPatchScalarField::typeName
)
);
tresult().correctBoundaryConditions();
return tresult;
}
// ************************************************************************* //

View file

@ -0,0 +1,150 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2007 Hrvoje Jasak
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Class
linearElastic
Description
Linear elastic rheology
SourceFiles
linearElastic.C
\*---------------------------------------------------------------------------*/
#ifndef linearElastic_H
#define linearElastic_H
#include "rheologyLaw.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class linearElastic Declaration
\*---------------------------------------------------------------------------*/
class linearElastic
:
public rheologyLaw
{
// Private data
//- Density
dimensionedScalar rho_;
//- Modulus of elasticity
dimensionedScalar E_;
//- Poisson's ratio
dimensionedScalar nu_;
// Private Member Functions
//- Disallow default bitwise copy construct
linearElastic(const linearElastic&);
//- Disallow default bitwise assignment
void operator=(const linearElastic&);
public:
//- Runtime type information
TypeName("linearElastic");
// Static data members
// Constructors
//- Construct from dictionary
linearElastic
(
const word& name,
const volSymmTensorField& sigma,
const dictionary& dict
);
// Destructor
virtual ~linearElastic();
// Member Functions
//- Return density
virtual tmp<volScalarField> rho() const;
//- Return modulus of elasticity
virtual tmp<volScalarField> E() const;
//- Return Poisson's ratio
virtual tmp<volScalarField> nu() const;
//- Return density
virtual tmp<volScalarField> rho(scalar t) const
{
return rho();
}
//- Return modulus of elasticity
virtual tmp<volScalarField> E(scalar t) const
{
return E();
}
//- Return Poisson's ratio
virtual tmp<volScalarField> nu(scalar t) const
{
return nu();
}
//- Return creep compliance
virtual tmp<volScalarField> J(scalar t) const
{
notImplemented(type() + "::J(scalar t)");
return 1.0/E(t);
}
//- Correct the rheological model
virtual void correct()
{}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,261 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2007 Hrvoje Jasak
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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();
}
}
// ************************************************************************* //

View file

@ -0,0 +1,146 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2007 Hrvoje Jasak
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Class
multiMaterial
Description
Zoned multi-material rheology controlled by an indicator field.
SourceFiles
multiMaterial.C
\*---------------------------------------------------------------------------*/
#ifndef multiMaterial_H
#define multiMaterial_H
#include "rheologyLaw.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class multiMaterial Declaration
\*---------------------------------------------------------------------------*/
class multiMaterial
:
public rheologyLaw,
public PtrList<rheologyLaw>
{
// Private data
//- Material indicator field
volScalarField materials_;
// Private Member Functions
//- Disallow default bitwise copy construct
multiMaterial(const multiMaterial&);
//- Disallow default bitwise assignment
void operator=(const multiMaterial&);
//- Calculate indicator field given index
tmp<scalarField> indicator(const label index) const;
public:
//- Runtime type information
TypeName("multiMaterial");
// Static data members
// Constructors
//- Construct from dictionary
multiMaterial
(
const word& name,
const volSymmTensorField& sigma,
const dictionary& dict
);
// Destructor
virtual ~multiMaterial();
// Member Functions
//- Return density
virtual tmp<volScalarField> rho() const;
//- Return modulus of elasticity
virtual tmp<volScalarField> E() const;
//- Return Poisson's ratio
virtual tmp<volScalarField> nu() const;
//- Return density
virtual tmp<volScalarField> rho(scalar t) const
{
return rho();
}
//- Return modulus of elasticity
virtual tmp<volScalarField> E(scalar t) const
{
return E();
}
//- Return Poisson's ratio
virtual tmp<volScalarField> nu(scalar) const
{
return nu();
}
//- Return creep compliance
virtual tmp<volScalarField> J(scalar t) const
{
notImplemented(type() + "::J(scalar t)");
return 1.0/E(t);
}
//- Correct the rheological model
virtual void correct();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,82 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2007 Hrvoje Jasak
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Class
rheologyLaw
Description
\*---------------------------------------------------------------------------*/
#include "rheologyLaw.H"
#include "volFields.H"
#include "surfaceFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
autoPtr<rheologyLaw> rheologyLaw::New
(
const word& name,
const volSymmTensorField& sigma,
const dictionary& dict
)
{
word rheoTypeName = dict.lookup("type");
Info<< "Selecting rheology model " << rheoTypeName << endl;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(rheoTypeName);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalIOErrorIn
(
"rheologyLaw::New(\n"
" const word& name,\n"
" const volSymmTensorField& sigma,\n"
" const dictionary& dict\n"
")",
dict
) << "Unknown rheologyLaw type "
<< rheoTypeName << endl << endl
<< "Valid rheologyLaws are : " << endl
<< dictionaryConstructorTablePtr_->toc()
<< exit(FatalIOError);
}
return autoPtr<rheologyLaw>(cstrIter()(name, sigma, dict));
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,66 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2007 Hrvoje Jasak
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Class
rheologyLaw
Description
Material rheology for solids.
\*---------------------------------------------------------------------------*/
#include "rheologyLaw.H"
#include "volFields.H"
#include "fvc.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(rheologyLaw, 0);
defineRunTimeSelectionTable(rheologyLaw, dictionary);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
rheologyLaw::rheologyLaw
(
const word& name,
const volSymmTensorField& sigma,
const dictionary& dict
)
:
name_(name),
sigma_(sigma)
{}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,184 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2007 Hrvoje Jasak
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Class
rheologyLaw
Description
Material rheology for solids.
SourceFiles
rheologyLaw.C
newRheologyLaw.C
\*---------------------------------------------------------------------------*/
#ifndef rheologyLaw_H
#define rheologyLaw_H
#include "IOdictionary.H"
#include "typeInfo.H"
#include "runTimeSelectionTables.H"
#include "volFields.H"
#include "tmp.H"
#include "autoPtr.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class rheologyLaw Declaration
\*---------------------------------------------------------------------------*/
class rheologyLaw
{
// Private data
//- Name
const word name_;
//- Reference to stress field
const volSymmTensorField& sigma_;
// Private Member Functions
//- Disallow copy construct
rheologyLaw(const rheologyLaw&);
//- Disallow default bitwise assignment
void operator=(const rheologyLaw&);
protected:
//- Return reference to mesh
const fvMesh& mesh() const
{
return sigma_.mesh();
}
//- Return reference to stress field
const volSymmTensorField& sigma() const
{
return sigma_;
}
public:
//- Runtime type information
TypeName("rheologyLaw");
// Declare run-time constructor selection table
declareRunTimeSelectionTable
(
autoPtr,
rheologyLaw,
dictionary,
(
const word name,
const volSymmTensorField& sigma,
const dictionary& dict
),
(name, sigma, dict)
);
// Selectors
//- Return a reference to the selected rheology model
static autoPtr<rheologyLaw> New
(
const word& name,
const volSymmTensorField& sigma,
const dictionary& dict
);
// Constructors
//- Construct from dictionary
rheologyLaw
(
const word& name,
const volSymmTensorField& sigma,
const dictionary& dict
);
// Destructor
virtual ~rheologyLaw()
{}
// Member Functions
//- Return name
const word& name() const
{
return name_;
}
//- Return density
virtual tmp<volScalarField> rho() const = 0;
//- Return modulus of elasticity
virtual tmp<volScalarField> E() const = 0;
//- Return Poisson's ratio
virtual tmp<volScalarField> nu() const = 0;
//- Return density
virtual tmp<volScalarField> rho(scalar t) const = 0;
//- Return modulus of elasticity
virtual tmp<volScalarField> E(scalar t) const = 0;
//- Return Poisson's ratio
virtual tmp<volScalarField> nu(scalar t) const = 0;
//- Return creep compliance
virtual tmp<volScalarField> J(scalar t) const = 0;
//- Correct the rheological model
virtual void correct() = 0;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,282 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2008 Hrvoje Jasak
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Class
rheologyModel
Description
Material rheology for solids.
\*---------------------------------------------------------------------------*/
#include "rheologyModel.H"
#include "volFields.H"
#include "fvc.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(rheologyModel, 0);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
rheologyModel::rheologyModel
(
const volSymmTensorField& sigma
)
:
IOdictionary
(
IOobject
(
"rheologyProperties",
sigma.time().constant(),
sigma.db(),
IOobject::MUST_READ,
IOobject::NO_WRITE
)
),
sigma_(sigma),
planeStress_(lookup("planeStress")),
lawPtr_(rheologyLaw::New("law", sigma_, subDict("rheology")))
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
// Return first Lame's coefficient
tmp<volScalarField> rheologyModel::mu() const
{
volScalarField lawE = lawPtr_->E();
volScalarField lawNu = lawPtr_->nu();
return tmp<volScalarField>
(
new volScalarField
(
IOobject
(
"mu",
sigma_.time().timeName(),
sigma_.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
lawE/(2.0*(1.0 + lawNu))
)
);
}
// Return second Lame's coefficient
tmp<volScalarField> rheologyModel::lambda() const
{
volScalarField lawE = lawPtr_->E();
volScalarField lawNu = lawPtr_->nu();
if (planeStress())
{
return tmp<volScalarField>
(
new volScalarField
(
IOobject
(
"lambda",
sigma_.time().timeName(),
sigma_.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
lawNu*lawE/((1.0 + lawNu)*(1.0 - lawNu))
)
);
}
else
{
return tmp<volScalarField>
(
new volScalarField
(
IOobject
(
"lambda",
sigma_.time().timeName(),
sigma_.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
lawNu*lawE/((1.0 + lawNu)*(1.0 - 2.0*lawNu))
)
);
}
}
// Return threeK
tmp<volScalarField> rheologyModel::threeK() const
{
volScalarField lawRho = lawPtr_->rho();
volScalarField lawE = lawPtr_->E();
volScalarField lawNu = lawPtr_->nu();
if (planeStress())
{
return tmp<volScalarField>
(
new volScalarField
(
IOobject
(
"threeK",
sigma_.time().timeName(),
sigma_.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
lawE/(lawRho*(1 - lawNu))
)
);
}
else
{
return tmp<volScalarField>
(
new volScalarField
(
IOobject
(
"threeK",
sigma_.time().timeName(),
sigma_.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
lawE/(lawRho*(1 - 2*lawNu))
)
);
}
}
// Return first Lame's coefficient
tmp<volScalarField> rheologyModel::mu(scalar t) const
{
volScalarField lawE = lawPtr_->E(t);
volScalarField lawNu = lawPtr_->nu(t);
return tmp<volScalarField>
(
new volScalarField
(
IOobject
(
"mu",
sigma_.time().timeName(),
sigma_.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
lawE/(2.0*(1.0 + lawNu))
)
);
}
// Return second Lame's coefficient
tmp<volScalarField> rheologyModel::lambda(scalar t) const
{
volScalarField lawE = lawPtr_->E(t);
volScalarField lawNu = lawPtr_->nu(t);
if (planeStress())
{
return tmp<volScalarField>
(
new volScalarField
(
IOobject
(
"lambda",
sigma_.time().timeName(),
sigma_.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
lawNu*lawE/((1.0 + lawNu)*(1.0 - lawNu))
)
);
}
else
{
return tmp<volScalarField>
(
new volScalarField
(
IOobject
(
"lambda",
sigma_.time().timeName(),
sigma_.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
lawNu*lawE/((1.0 + lawNu)*(1.0 - 2.0*lawNu))
)
);
}
}
void rheologyModel::correct()
{
lawPtr_->correct();
}
bool rheologyModel::read()
{
if (regIOobject::read())
{
lookup("planeStress") >> planeStress_;
lawPtr_ = rheologyLaw::New("law", sigma_, subDict("rheology"));
return true;
}
else
{
return false;
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,158 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2007 Hrvoje Jasak
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Class
rheologyModel
Description
Material rheology for solids.
SourceFiles
rheologyModel.C
\*---------------------------------------------------------------------------*/
#ifndef rheologyModel_H
#define rheologyModel_H
#include "IOdictionary.H"
#include "typeInfo.H"
#include "runTimeSelectionTables.H"
#include "volFields.H"
#include "tmp.H"
#include "rheologyLaw.H"
#include "Switch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class rheologyModel Declaration
\*---------------------------------------------------------------------------*/
class rheologyModel
:
public IOdictionary
{
// Private data
//- Reference to stress field
const volSymmTensorField& sigma_;
//- Plane stress
Switch planeStress_;
//- Rheology law
autoPtr<rheologyLaw> lawPtr_;
// Private Member Functions
//- Disallow copy construct
rheologyModel(const rheologyModel&);
//- Disallow default bitwise assignment
void operator=(const rheologyModel&);
public:
//- Runtime type information
TypeName("rheologyModel");
// Constructors
//- Construct from dictionary
rheologyModel
(
const volSymmTensorField& sigma
);
// Destructor
virtual ~rheologyModel()
{}
// Member Functions
//- Return true for plane stress
const Switch& planeStress() const
{
return planeStress_;
}
//- Return rheology law
const rheologyLaw& law() const
{
return lawPtr_();
}
//- Return density
tmp<volScalarField> rho() const
{
return lawPtr_->rho();
}
//- Return first Lame's coefficient
tmp<volScalarField> mu() const;
//- Return second Lame's coefficient
tmp<volScalarField> lambda() const;
//- Return threeK
tmp<volScalarField> threeK() const;
//- Return density
tmp<volScalarField> rho(scalar t) const
{
return lawPtr_->rho(t);
}
//- Return first Lame's coefficient
tmp<volScalarField> mu(scalar t) const;
//- Return second Lame's coefficient
tmp<volScalarField> lambda(scalar t) const;
//- Correct the rheological model
void correct();
//- Read rheologyProperties dictionary
virtual bool read();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,170 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2008 Hrvoje Jasak
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
\*---------------------------------------------------------------------------*/
#include "constantThermal.H"
#include "addToRunTimeSelectionTable.H"
#include "zeroGradientFvPatchFields.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(constantThermal, 0);
addToRunTimeSelectionTable(thermalLaw, constantThermal, dictionary);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from dictionary
Foam::constantThermal::constantThermal
(
const word& name,
const volScalarField& T,
const dictionary& dict
)
:
thermalLaw(name, T, dict),
C_(dict.lookup("C")),
k_(dict.lookup("k")),
alpha_(dict.lookup("alpha")),
T0_(dict.lookup("T0"))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::constantThermal::~constantThermal()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::tmp<Foam::volScalarField> Foam::constantThermal::C() const
{
tmp<volScalarField> tresult
(
new volScalarField
(
IOobject
(
"C",
mesh().time().timeName(),
mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh(),
C_,
zeroGradientFvPatchScalarField::typeName
)
);
tresult().correctBoundaryConditions();
return tresult;
}
Foam::tmp<Foam::volScalarField> Foam::constantThermal::k() const
{
tmp<volScalarField> tresult
(
new volScalarField
(
IOobject
(
"k",
mesh().time().timeName(),
mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh(),
k_,
zeroGradientFvPatchScalarField::typeName
)
);
tresult().correctBoundaryConditions();
return tresult;
}
Foam::tmp<Foam::volScalarField> Foam::constantThermal::alpha() const
{
tmp<volScalarField> tresult
(
new volScalarField
(
IOobject
(
"alpha",
mesh().time().timeName(),
mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh(),
alpha_,
zeroGradientFvPatchScalarField::typeName
)
);
tresult().correctBoundaryConditions();
return tresult;
}
Foam::tmp<Foam::volScalarField> Foam::constantThermal::T0() const
{
tmp<volScalarField> tresult
(
new volScalarField
(
IOobject
(
"T0",
mesh().time().timeName(),
mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh(),
T0_,
zeroGradientFvPatchScalarField::typeName
)
);
tresult().correctBoundaryConditions();
return tresult;
}
// ************************************************************************* //

View file

@ -0,0 +1,132 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2008 Hrvoje Jasak
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Class
constantThermal
Description
Constant thermal properties
Author
Hrvoje Jasak, Wikki Ltd. All rights reserved.
SourceFiles
constantThermal.C
\*---------------------------------------------------------------------------*/
#ifndef constantThermal_H
#define constantThermal_H
#include "thermalLaw.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class constantThermal Declaration
\*---------------------------------------------------------------------------*/
class constantThermal
:
public thermalLaw
{
// Private data
//- Specific heat capacity
dimensionedScalar C_;
//- Thermal conductivity
dimensionedScalar k_;
//- Thermal expansion coefficient
dimensionedScalar alpha_;
//- Reference temperature
dimensionedScalar T0_;
// Private Member Functions
//- Disallow default bitwise copy construct
constantThermal(const constantThermal&);
//- Disallow default bitwise assignment
void operator=(const constantThermal&);
public:
//- Runtime type information
TypeName("constant");
// Static data members
// Constructors
//- Construct from dictionary
constantThermal
(
const word& name,
const volScalarField& T,
const dictionary& dict
);
// Destructor
virtual ~constantThermal();
// Member Functions
//- Return specific heat capacity
virtual tmp<volScalarField> C() const;
//- Return thermal conductivity
virtual tmp<volScalarField> k() const;
//- Return thermal expansion coefficient
virtual tmp<volScalarField> alpha() const;
//- Return reference temperature
virtual tmp<volScalarField> T0() const;
virtual void correct()
{}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,294 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2008 Hrvoje Jasak
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
\*---------------------------------------------------------------------------*/
#include "multiMaterialThermal.H"
#include "addToRunTimeSelectionTable.H"
#include "zeroGradientFvPatchFields.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(multiMaterialThermal, 0);
addToRunTimeSelectionTable(thermalLaw, multiMaterialThermal, dictionary);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::tmp<Foam::scalarField> Foam::multiMaterialThermal::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::multiMaterialThermal::multiMaterialThermal
(
const word& name,
const volScalarField& T,
const dictionary& dict
)
:
thermalLaw(name, T, dict),
PtrList<thermalLaw>(),
materials_
(
IOobject
(
"materials",
mesh().time().timeName(),
mesh(),
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh()
)
{
PtrList<thermalLaw>& laws = *this;
PtrList<entry> lawEntries(dict.lookup("laws"));
laws.setSize(lawEntries.size());
forAll (laws, lawI)
{
laws.set
(
lawI,
thermalLaw::New
(
lawEntries[lawI].keyword(),
T,
lawEntries[lawI].dict()
)
);
}
if
(
min(materials_).value() < 0
|| max(materials_).value() > laws.size() + SMALL
)
{
FatalErrorIn
(
"multiMaterialThermal::multiMaterialThermal\n"
"(\n"
" const word& name,\n"
" const volScalarField& T,\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::multiMaterialThermal::~multiMaterialThermal()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::tmp<Foam::volScalarField> Foam::multiMaterialThermal::C() const
{
tmp<volScalarField> tresult
(
new volScalarField
(
IOobject
(
"C",
mesh().time().timeName(),
mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh(),
dimensionedScalar("zeroC", dimSpecificHeatCapacity, 0),
zeroGradientFvPatchScalarField::typeName
)
);
volScalarField& result = tresult();
// Accumulate data for all fields
const PtrList<thermalLaw>& laws = *this;
forAll (laws, lawI)
{
result.internalField() +=
indicator(lawI)*laws[lawI].C()().internalField();
}
result.correctBoundaryConditions();
return tresult;
}
Foam::tmp<Foam::volScalarField> Foam::multiMaterialThermal::k() const
{
tmp<volScalarField> tresult
(
new volScalarField
(
IOobject
(
"k",
mesh().time().timeName(),
mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh(),
dimensionedScalar("zerok", dimThermalConductivity, 0),
zeroGradientFvPatchScalarField::typeName
)
);
volScalarField& result = tresult();
// Accumulate data for all fields
const PtrList<thermalLaw>& laws = *this;
forAll (laws, lawI)
{
result.internalField() +=
indicator(lawI)*laws[lawI].k()().internalField();
}
result.correctBoundaryConditions();
return tresult;
}
Foam::tmp<Foam::volScalarField> Foam::multiMaterialThermal::alpha() const
{
tmp<volScalarField> tresult
(
new volScalarField
(
IOobject
(
"alpha",
mesh().time().timeName(),
mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh(),
dimensionedScalar("zeroE", dimless/dimTemperature, 0),
zeroGradientFvPatchScalarField::typeName
)
);
volScalarField& result = tresult();
// Accumulate data for all fields
const PtrList<thermalLaw>& laws = *this;
forAll (laws, lawI)
{
result.internalField() +=
indicator(lawI)*laws[lawI].alpha()().internalField();
}
result.correctBoundaryConditions();
return tresult;
}
Foam::tmp<Foam::volScalarField> Foam::multiMaterialThermal::T0() const
{
tmp<volScalarField> tresult
(
new volScalarField
(
IOobject
(
"T0",
mesh().time().timeName(),
mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh(),
dimensionedScalar("zeroT0", dimTemperature, 0),
zeroGradientFvPatchScalarField::typeName
)
);
volScalarField& result = tresult();
// Accumulate data for all fields
const PtrList<thermalLaw>& laws = *this;
forAll (laws, lawI)
{
result.internalField() +=
indicator(lawI)*laws[lawI].T0()().internalField();
}
result.correctBoundaryConditions();
return tresult;
}
void Foam::multiMaterialThermal::correct()
{
PtrList<thermalLaw>& laws = *this;
forAll (laws, lawI)
{
laws[lawI].correct();
}
}
// ************************************************************************* //

View file

@ -0,0 +1,126 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2008 Hrvoje Jasak
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Class
multiMaterialThermal
Description
Zoned multi-material thermal model controlled by an indicator field.
Author
Hrvoje Jasak, Wikki Ltd. All rights reserved.
SourceFiles
multiMaterialThermal.C
\*---------------------------------------------------------------------------*/
#ifndef multiMaterialThermal_H
#define multiMaterialThermal_H
#include "thermalLaw.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class multiMaterialThermal Declaration
\*---------------------------------------------------------------------------*/
class multiMaterialThermal
:
public thermalLaw,
public PtrList<thermalLaw>
{
// Private data
//- Material indicator field
volScalarField materials_;
// Private Member Functions
//- Disallow default bitwise copy construct
multiMaterialThermal(const multiMaterialThermal&);
//- Disallow default bitwise assignment
void operator=(const multiMaterialThermal&);
//- Calculate indicator field given index
tmp<scalarField> indicator(const label index) const;
public:
//- Runtime type information
TypeName("multiMaterial");
// Static data members
// Constructors
//- Construct from dictionary
multiMaterialThermal
(
const word& name,
const volScalarField& T,
const dictionary& dict
);
// Destructor
virtual ~multiMaterialThermal();
// Member Functions
//- Return specific heat capacity
virtual tmp<volScalarField> C() const;
//- Return thermal conductivity
virtual tmp<volScalarField> k() const;
//- Return thermal expansion coefficient
virtual tmp<volScalarField> alpha() const;
//- Return reference temperature
virtual tmp<volScalarField> T0() const;
//- Correct the rheological model
virtual void correct();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,80 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2007 Hrvoje Jasak
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Class
thermalLaw
\*---------------------------------------------------------------------------*/
#include "thermalLaw.H"
#include "volFields.H"
#include "surfaceFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
autoPtr<thermalLaw> thermalLaw::New
(
const word& name,
const volScalarField& T,
const dictionary& dict
)
{
word rheoTypeName = dict.lookup("type");
Info<< "Selecting thermal model " << rheoTypeName << endl;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(rheoTypeName);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalIOErrorIn
(
"thermalLaw::New(\n"
" const word& name,\n"
" const volScalarField& T,\n"
" const dictionary& dict\n"
")",
dict
) << "Unknown thermalLaw type "
<< rheoTypeName << endl << endl
<< "Valid thermalLaws are : " << endl
<< dictionaryConstructorTablePtr_->toc()
<< exit(FatalIOError);
}
return autoPtr<thermalLaw>(cstrIter()(name, T, dict));
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,63 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2007 Hrvoje Jasak
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Class
thermalLaw
\*---------------------------------------------------------------------------*/
#include "thermalLaw.H"
#include "volFields.H"
#include "fvc.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(thermalLaw, 0);
defineRunTimeSelectionTable(thermalLaw, dictionary);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
thermalLaw::thermalLaw
(
const word& name,
const volScalarField& T,
const dictionary& dict
)
:
name_(name),
T_(T)
{}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,171 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2008 Hrvoje Jasak
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Class
thermalLaw
Description
Thermal material properties for solids.
Author
Hrvoje Jasak, Wikki Ltd. All rights reserved.
SourceFiles
thermalLaw.C
newThermalLaw.C
\*---------------------------------------------------------------------------*/
#ifndef thermalLaw_H
#define thermalLaw_H
#include "IOdictionary.H"
#include "typeInfo.H"
#include "runTimeSelectionTables.H"
#include "volFields.H"
#include "tmp.H"
#include "autoPtr.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class thermalLaw Declaration
\*---------------------------------------------------------------------------*/
class thermalLaw
{
// Private data
//- Name
const word name_;
//- Reference to stress field
const volScalarField& T_;
// Private Member Functions
//- Disallow copy construct
thermalLaw(const thermalLaw&);
//- Disallow default bitwise assignment
void operator=(const thermalLaw&);
protected:
//- Return reference to mesh
const fvMesh& mesh() const
{
return T_.mesh();
}
public:
//- Runtime type information
TypeName("thermalLaw");
// Declare run-time constructor selection table
declareRunTimeSelectionTable
(
autoPtr,
thermalLaw,
dictionary,
(
const word name,
const volScalarField& T,
const dictionary& dict
),
(name, T, dict)
);
// Selectors
//- Return a reference to the selected thermal model
static autoPtr<thermalLaw> New
(
const word& name,
const volScalarField& T,
const dictionary& dict
);
// Constructors
//- Construct from dictionary
thermalLaw
(
const word& name,
const volScalarField& T,
const dictionary& dict
);
// Destructor
virtual ~thermalLaw()
{}
// Member Functions
//- Return name
const word& name() const
{
return name_;
}
//- Return specific heat capacity
virtual tmp<volScalarField> C() const = 0;
//- Return thermal conductivity
virtual tmp<volScalarField> k() const = 0;
//- Return thermal expansion coefficient
virtual tmp<volScalarField> alpha() const = 0;
//- Return reference temperature
virtual tmp<volScalarField> T0() const = 0;
//- Correct the rheological model
virtual void correct() = 0;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,91 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2007 Hrvoje Jasak
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Class
thermalModel
Description
Thermal material properties for solids.
Author
Hrvoje Jasak, Wikki Ltd. All rights reserved.
\*---------------------------------------------------------------------------*/
#include "thermalModel.H"
#include "volFields.H"
#include "fvc.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(thermalModel, 0);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
thermalModel::thermalModel(const volScalarField& T)
:
IOdictionary
(
IOobject
(
"thermalProperties",
T.time().constant(),
T.db(),
IOobject::MUST_READ,
IOobject::NO_WRITE
)
),
T_(T),
lawPtr_(thermalLaw::New("law", T_, subDict("thermal")))
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
bool thermalModel::read()
{
if (regIOobject::read())
{
lawPtr_ = thermalLaw::New("law", T_, subDict("thermal"));
return true;
}
else
{
return false;
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,149 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2008 Hrvoje Jasak
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Class
thermalModel
Description
Thermal material properties for solids.
Author
Hrvoje Jasak, Wikki Ltd. All rights reserved.
SourceFiles
thermalModel.C
\*---------------------------------------------------------------------------*/
#ifndef thermalModel_H
#define thermalModel_H
#include "IOdictionary.H"
#include "typeInfo.H"
#include "runTimeSelectionTables.H"
#include "volFields.H"
#include "tmp.H"
#include "thermalLaw.H"
#include "Switch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class thermalModel Declaration
\*---------------------------------------------------------------------------*/
class thermalModel
:
public IOdictionary
{
// Private data
//- Reference to temperature field
const volScalarField& T_;
//- Thermal law
autoPtr<thermalLaw> lawPtr_;
// Private Member Functions
//- Disallow copy construct
thermalModel(const thermalModel&);
//- Disallow default bitwise assignment
void operator=(const thermalModel&);
public:
//- Runtime type information
TypeName("thermalModel");
// Constructors
//- Construct from dictionary
thermalModel(const volScalarField& T);
// Destructor
virtual ~thermalModel()
{}
// Member Functions
//- Return thermal law
const thermalLaw& law() const
{
return lawPtr_();
}
//- Return specific heat capacity
tmp<volScalarField> C() const
{
return lawPtr_->C();
}
//- Return thermal conductivity
tmp<volScalarField> k() const
{
return lawPtr_->k();
}
//- Return thermal expansion coefficient
tmp<volScalarField> alpha() const
{
return lawPtr_->alpha();
}
//- Return reference temperature
tmp<volScalarField> T0() const
{
return lawPtr_->T0();
}
//- Correct the thermal model
void correct()
{
lawPtr_->correct();
}
//- Read thermalProperties dictionary
virtual bool read();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,5 @@
contactProblem.C
contactPatchPair.C
newContactStressFoam.C
EXE = $(FOAM_APPBIN)/newContactStressFoam

View file

@ -0,0 +1,11 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I../materialModels/lnInclude \
-I../newStressedFoam/
EXE_LIBS = \
-lfiniteVolume \
-lmaterialModels \
-llduSolvers

View file

@ -0,0 +1,5 @@
if (runTime.outputTime())
{
volScalarField ca = contact.contactArea();
ca.write();
}

View file

@ -0,0 +1,447 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2007 Hrvoje Jasak
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Description
\*---------------------------------------------------------------------------*/
#include "contactPatchPair.H"
#include "contactProblem.H"
#include "surfaceFields.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::contactPatchPair::contactPatchPair
(
const word& name,
const contactProblem& cp,
const word& masterPatchName,
const word& slavePatchName,
const dimensionedScalar& frictionCoeff,
const scalar contactTol,
const intersection::algorithm alg,
const intersection::direction dir
)
:
name_(name),
cp_(cp),
masterPatch_(masterPatchName, cp.mesh().boundaryMesh()),
slavePatch_(slavePatchName, cp.mesh().boundaryMesh()),
frictionCoeff_(frictionCoeff),
contactTol_(contactTol),
masterInterpolate_
(
cp.mesh().boundaryMesh()[masterPatch_.index()]
),
slaveInterpolate_
(
cp.mesh().boundaryMesh()[slavePatch_.index()]
),
masterToSlaveInterpolate_
(
cp.mesh().boundaryMesh()[masterPatch_.index()], // from patch
cp.mesh().boundaryMesh()[slavePatch_.index()], // to patch
alg,
dir
),
slaveToMasterInterpolate_
(
cp.mesh().boundaryMesh()[slavePatch_.index()], // from patch
cp.mesh().boundaryMesh()[masterPatch_.index()], // to patch
alg,
dir
)
{}
// Construct from dictionary
Foam::contactPatchPair::contactPatchPair
(
const word& name,
const contactProblem& cp,
const dictionary& dict
)
:
name_(name),
cp_(cp),
masterPatch_(dict.lookup("masterPatch"), cp.mesh().boundaryMesh()),
slavePatch_(dict.lookup("slavePatch"), cp.mesh().boundaryMesh()),
frictionCoeff_(dict.lookup("frictionCoeff")),
contactTol_(readScalar(dict.lookup("contactTol"))),
masterInterpolate_
(
cp.mesh().boundaryMesh()[masterPatch_.index()]
),
slaveInterpolate_
(
cp.mesh().boundaryMesh()[slavePatch_.index()]
),
masterToSlaveInterpolate_
(
cp.mesh().boundaryMesh()[masterPatch_.index()], // from patch
cp.mesh().boundaryMesh()[slavePatch_.index()], // to patch
intersection::algorithmNames_.read(dict.lookup("projectionAlgo")),
intersection::directionNames_.read(dict.lookup("projectionDir"))
),
slaveToMasterInterpolate_
(
cp.mesh().boundaryMesh()[slavePatch_.index()], // from patch
cp.mesh().boundaryMesh()[masterPatch_.index()], // to patch
intersection::algorithmNames_.read(dict.lookup("projectionAlgo")),
intersection::directionNames_.read(dict.lookup("projectionDir"))
)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::tmp<Foam::scalarField>
Foam::contactPatchPair::masterTouchFraction() const
{
// Get reference to displacement field and mesh
const volVectorField& U = cp_.U();
const fvMesh& mesh = cp_.mesh();
// Interpolate slave displacement into master vertices
vectorField masterVertexU =
slaveToMasterInterpolate_.pointInterpolate<vector>
(
slaveInterpolate_.faceToPointInterpolate
(
U.boundaryField()[slavePatch_.index()]
)
);
const vectorField& projectionDir =
mesh.boundaryMesh()[masterPatch_.index()].pointNormals();
// Calculate master gap function
scalarField vertexMasterGap =
(
(
masterVertexU
- masterInterpolate_.faceToPointInterpolate
(
U.boundaryField()[masterPatch_.index()]
)
)
& projectionDir
) + slaveToMasterInterpolate_.pointDistanceToIntersection() - contactTol_;
// Calculate area in contact
const faceList& masterPatchLocalFaces =
mesh.boundaryMesh()[masterPatch_.index()].localFaces();
const pointField& masterPatchLocalPoints =
mesh.boundaryMesh()[masterPatch_.index()].localPoints();
tmp<scalarField> ttouchFrac
(
new scalarField(masterPatchLocalFaces.size(), 0)
);
scalarField& touchFrac = ttouchFrac();
forAll (masterPatchLocalFaces, faceI)
{
touchFrac[faceI] =
masterPatchLocalFaces[faceI].areaInContact
(
masterPatchLocalPoints,
vertexMasterGap
);
}
return ttouchFrac;
}
Foam::tmp<Foam::scalarField>
Foam::contactPatchPair::slaveTouchFraction() const
{
// Get reference to displacement field and mesh
const volVectorField& U = cp_.U();
const fvMesh& mesh = cp_.mesh();
// Interpolate master displacement into slave vertices
vectorField slaveVertexU =
masterToSlaveInterpolate_.pointInterpolate<vector>
(
masterInterpolate_.faceToPointInterpolate
(
U.boundaryField()[masterPatch_.index()]
)
);
const vectorField& projectionDir =
mesh.boundaryMesh()[slavePatch_.index()].pointNormals();
// Calculate slave gap function
scalarField vertexSlaveGap =
(
(
slaveVertexU
- slaveInterpolate_.faceToPointInterpolate
(
U.boundaryField()[slavePatch_.index()]
)
)
& projectionDir
) + masterToSlaveInterpolate_.pointDistanceToIntersection() - contactTol_;
// Calculate area in contact
const faceList& slavePatchLocalFaces =
mesh.boundaryMesh()[slavePatch_.index()].localFaces();
const pointField& slavePatchLocalPoints =
mesh.boundaryMesh()[slavePatch_.index()].localPoints();
tmp<scalarField> ttouchFrac
(
new scalarField(slavePatchLocalFaces.size(), 0)
);
scalarField& touchFrac = ttouchFrac();
forAll (slavePatchLocalFaces, faceI)
{
touchFrac[faceI] =
slavePatchLocalFaces[faceI].areaInContact
(
slavePatchLocalPoints,
vertexSlaveGap
);
}
return ttouchFrac;
}
void Foam::contactPatchPair::correct
(
const FieldField<Field, vector>& curTraction,
FieldField<Field, vector>& newTraction,
FieldField<Field, vector>& refValue,
FieldField<Field, scalar>& valueFraction
)
{
// Get reference to displacement field and mesh
const volVectorField::GeometricBoundaryField& Upatches =
cp_.U().boundaryField();
const fvMesh& mesh = cp_.mesh();
const surfaceVectorField::GeometricBoundaryField& Apatches =
mesh.Sf().boundaryField();
const surfaceScalarField::GeometricBoundaryField& magApatches =
mesh.magSf().boundaryField();
// Get patch indices
const label masterIndex = masterPatch_.index();
const label slaveIndex = slavePatch_.index();
// Calculate patch normals
vectorField nMasterPatch = Apatches[masterIndex]/magApatches[masterIndex];
vectorField nSlavePatch = Apatches[slaveIndex]/magApatches[slaveIndex];
// Calculate slave pressure and tangential force
scalarField slavePressure = -( nSlavePatch & curTraction[slaveIndex]);
// Enforce gradient condition on the master patch
// Calculate relative tangential velocity for master patch
vectorField relUmaster =
slaveToMasterInterpolate_.faceInterpolate<vector>
(
Upatches[slaveIndex]
)
- Upatches[masterIndex];
relUmaster -= nMasterPatch*(nMasterPatch & relUmaster);
relUmaster /= mag(relUmaster) + VSMALL;
// Calculate tangential master traction
scalarField magMasterTangential =
Foam::mag((I - nMasterPatch*nMasterPatch) & curTraction[masterIndex]);
// Calculate master pressure
scalarField masterPressure =
max
(
slaveToMasterInterpolate_.faceInterpolate<scalar>
(
slavePressure
),
0.0
);
// Calculate master traction, using the positive part of
// slave pressure and tangential fricton
// Mind the signs: pressure = negative gradient (minus master normal)
// friction = positive pressure
newTraction[masterIndex] +=
masterTouchFraction()*
(
-nMasterPatch*masterPressure
+ relUmaster*
min
(
frictionCoeff_.value()*masterPressure,
magMasterTangential
)
);
// Enforce direction mixed condition on the slave patch
// Calculate slave fraction. Correct for negative pressure
// (if the pressure is negative, the contact is released)
//HJ, fiddle pos pressure!!!
scalarField slaveFrac = slaveTouchFraction();
// Calculate slave displacement
vectorField slaveVertexU =
masterToSlaveInterpolate_.pointInterpolate<vector>
(
masterInterpolate_.faceToPointInterpolate
(
Upatches[masterIndex]
)
);
const vectorField& projectionDir =
mesh.boundaryMesh()[slaveIndex].pointNormals();
// Calculate slave displacement
vectorField slaveDisp =
slaveInterpolate_.pointToFaceInterpolate
(
slaveVertexU
+ masterToSlaveInterpolate_.pointDistanceToIntersection()
*projectionDir
);
// Accumulate normal of slave displacement
refValue[slaveIndex] +=
nSlavePatch*
min
(
pos(slaveFrac)*
(
(nSlavePatch & Upatches[slaveIndex])
+ slaveFrac*contactTol_
),
(nSlavePatch & slaveDisp)
);
// Accumulate slave friction
// Calculate relative tangential velocity for slave patch
vectorField relUslave =
masterToSlaveInterpolate_.faceInterpolate<vector>
(
Upatches[masterIndex]
)
- Upatches[slaveIndex];
relUslave -= nSlavePatch*(nSlavePatch & relUslave);
relUslave /= mag(relUslave) + VSMALL;
// Take out normal component out of slave traction and find the
// magnitude of the tangential traction.
scalarField magSlaveTangential =
Foam::mag((I - nSlavePatch*nSlavePatch) & curTraction[slaveIndex]);
// Calculate slave traction
newTraction[slaveIndex] +=
slaveFrac*relUslave*
min
(
frictionCoeff_.value()*max(slavePressure, scalar(0)),
magSlaveTangential
);
// Accumulate slave touch fraction
valueFraction[slaveIndex] += slaveFrac;
/*
Info << "slavePressure: " << slavePressure << nl
<< "slaveTouchFrac: " << slaveTouchFraction() << nl
// << "slaveFrac: " << slaveFrac << nl
<< "refValueSlave: " << refValue[slaveIndex].component(vector::Y) << nl
// << "slaveTraction: " << newTraction[slaveIndex] << nl
<< "masterTouchFrac: " << masterTouchFraction() << nl
// << "interpolated slave pressure: "
// << slaveToMasterInterpolate_.faceInterpolate<scalar>
// (
// slavePressure
// )
// << nl
// << "masterTraction: "
// << newTraction[masterIndex].component(vector::Y)
<< endl;
*/
}
void Foam::contactPatchPair::writeDict(Ostream& os) const
{
os << nl << name() << nl << token::BEGIN_BLOCK;
os << "masterPatch " << masterPatch_.name() << token::END_STATEMENT << nl
<< "slavePatch " << slavePatch_.name() << token::END_STATEMENT << nl
<< "frictionCoeff " << frictionCoeff_ << token::END_STATEMENT << nl
<< "contactTol " << contactTol_ << token::END_STATEMENT << nl
<< "projectionAlgo "
<< intersection::algorithmNames_
[masterToSlaveInterpolate_.projectionAlgo()]
<< token::END_STATEMENT << nl
<< "projectionDir "
<< intersection::directionNames_
[masterToSlaveInterpolate_.projectionDir()]
<< token::END_STATEMENT << nl
<< token::END_BLOCK << endl;
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
// ************************************************************************* //

View file

@ -0,0 +1,178 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2007 Hrvoje Jasak
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Class
contactPatchPair
Description
A pair of surfaces in contact.
SourceFiles
contactPatchPair.C
\*---------------------------------------------------------------------------*/
#ifndef contactPatchPair_H
#define contactPatchPair_H
#include "polyPatchID.H"
#include "dimensionedTypes.H"
#include "volFieldsFwd.H"
#include "primitivePatchInterpolation.H"
#include "patchToPatchInterpolation.H"
#include "FieldFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class contactProblem;
/*---------------------------------------------------------------------------*\
Class contactPatchPair Declaration
\*---------------------------------------------------------------------------*/
class contactPatchPair
{
private:
// Private data
//- Name
const word name_;
//- Reference to contact problem
const contactProblem& cp_;
//- Master patch ID. Gradient condition will be enforced
const polyPatchID masterPatch_;
//- Slave patch ID. Direction mixed condition will be enforced
const polyPatchID slavePatch_;
//- Friction coefficient
dimensionedScalar frictionCoeff_;
//- Contact tolerance
const scalar contactTol_;
//- Master patch interpolator
primitivePatchInterpolation masterInterpolate_;
//- Slave patch interpolator
primitivePatchInterpolation slaveInterpolate_;
//- Master to slave patch interpolator
patchToPatchInterpolation masterToSlaveInterpolate_;
//- Master to slave patch interpolator
patchToPatchInterpolation slaveToMasterInterpolate_;
// Private Member Functions
//- Disallow default bitwise copy construct
contactPatchPair(const contactPatchPair&);
//- Disallow default bitwise assignment
void operator=(const contactPatchPair&);
public:
// Constructors
//- Construct from components
contactPatchPair
(
const word& name,
const contactProblem& cp,
const word& masterPatchName,
const word& slavePatchName,
const dimensionedScalar& frictionCoeff,
const scalar contactTol,
const intersection::algorithm alg = intersection::FULL_RAY,
const intersection::direction dir = intersection::CONTACT_SPHERE
);
//- Construct from components
contactPatchPair
(
const word& name,
const contactProblem& cp,
const dictionary& dict
);
// Member Functions
//- Return name
const word& name() const
{
return name_;
}
//- Return master patch ID
const polyPatchID masterPatch() const
{
return masterPatch_;
}
//- Return slave patch ID
const polyPatchID& slavePatch() const
{
return slavePatch_;
}
//- Return master touch fraction
tmp<scalarField> masterTouchFraction() const;
//- Return slave touch fraction
tmp<scalarField> slaveTouchFraction() const;
//- Correct contact data
void correct
(
const FieldField<Field, vector>& curTraction,
FieldField<Field, vector>& newTraction,
FieldField<Field, vector>& refValue,
FieldField<Field, scalar>& normalValueFraction
);
//- Write dictionary
void writeDict(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,56 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2007 Hrvoje Jasak
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Type
contactPatchPairList
Description
Container classes for contactPatchPair
\*---------------------------------------------------------------------------*/
#ifndef contactPatchPairList_H
#define contactPatchPairList_H
#include "contactPatchPair.H"
#include "PtrList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
typedef PtrList<contactPatchPair> contactPatchPairList;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,336 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2007 Hrvoje Jasak
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Description
Class describes a multiple body contact problem. Each individual contact
is described by a contactPatchPair. contactProblem handles
multiple contact updates and sets the boundary conditions on the
displacement field.
\*---------------------------------------------------------------------------*/
#include "contactProblem.H"
#include "fvMesh.H"
#include "FieldFields.H"
#include "directionMixedFvPatchFields.H"
#include "surfaceFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(contactProblem, 0);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Read constructor given IOobject
contactProblem::contactProblem
(
volVectorField& U,
const volTensorField& gradU
)
:
IOdictionary
(
IOobject
(
"contactProperties",
U.time().constant(),
U.db(),
IOobject::MUST_READ,
IOobject::NO_WRITE
)
),
contactPatchPairList(),
U_(U),
gradU_(gradU),
urfValue_(readScalar(lookup("urfValue"))),
urfTraction_(readScalar(lookup("urfTraction"))),
urfFraction_(readScalar(lookup("urfFraction")))
{
// Read contactPatchPairList
Istream& is = lookup("contacts");
PtrList<entry> contactEntries(is);
contactPatchPairList& contacts = *this;
contacts.setSize(contactEntries.size());
forAll(contacts, contactI)
{
contacts.set
(
contactI,
new contactPatchPair
(
contactEntries[contactI].keyword(),
*this,
contactEntries[contactI].dict()
)
);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void contactProblem::correct()
{
contactPatchPairList& contacts = *this;
// Create fields for accumulation
volVectorField::GeometricBoundaryField& Upatches = U().boundaryField();
FieldField<Field, vector> curTraction(Upatches.size());
FieldField<Field, vector> newTraction(Upatches.size());
FieldField<Field, vector> refValue(Upatches.size());
FieldField<Field, scalar> valueFraction(Upatches.size());
forAll (Upatches, patchI)
{
curTraction.set
(
patchI,
new vectorField(Upatches[patchI].size(), vector::zero)
);
newTraction.set
(
patchI,
new vectorField(Upatches[patchI].size(), vector::zero)
);
refValue.set
(
patchI,
new vectorField(Upatches[patchI].size(), vector::zero)
);
valueFraction.set
(
patchI,
new scalarField(Upatches[patchI].size(), 0)
);
}
// Collect patches involved in contact
boolList contactPatches(Upatches.size(), false);
forAll (contacts, contactI)
{
contactPatches[contacts[contactI].masterPatch().index()] = true;
contactPatches[contacts[contactI].slavePatch().index()] = true;
}
// Calculate the traction for all involved patches
// Collect fields
const volTensorField::GeometricBoundaryField& gradUpatches =
gradU().boundaryField();
const surfaceVectorField::GeometricBoundaryField& Apatches =
mesh().Sf().boundaryField();
const surfaceScalarField::GeometricBoundaryField& magApatches =
mesh().magSf().boundaryField();
// Lookup mu and lambda form object registry
const volScalarField& mu =
mesh().objectRegistry::lookupObject<volScalarField>("mu");
const volScalarField::GeometricBoundaryField& muPatches =
mu.boundaryField();
const volScalarField& lambda =
mesh().objectRegistry::lookupObject<volScalarField>("lambda");
const volScalarField::GeometricBoundaryField& lambdaPatches =
lambda.boundaryField();
forAll (Upatches, patchI)
{
if (contactPatches[patchI])
{
vectorField nPatch = Apatches[patchI]/magApatches[patchI];
curTraction[patchI] =
nPatch &
(
muPatches[patchI]*
(
gradUpatches[patchI]
+ gradUpatches[patchI].T()
)
+ I*(lambdaPatches[patchI]*tr(gradUpatches[patchI]))
);
}
}
// Accumulate contact data and active patches
forAll (contacts, contactI)
{
contacts[contactI].correct
(
curTraction,
newTraction,
refValue,
valueFraction
);
}
// Enforce accumulated contact onto the patches
forAll (Upatches, patchI)
{
if (contactPatches[patchI])
{
// Cast the patch into direction mixed type
directionMixedFvPatchVectorField& curUPatch =
refCast<directionMixedFvPatchVectorField>(Upatches[patchI]);
// Set the values using under-relaxation
curUPatch.refValue() =
(1.0 - urfValue_)*curUPatch.refValue()
+ urfValue_*refValue[patchI];
// Calculate the gradient from under-relaxad accumulated traction
vectorField nPatch = Apatches[patchI]/magApatches[patchI];
curUPatch.refGrad() =
(
(1.0 - urfTraction_)*curTraction[patchI]
+ urfTraction_*newTraction[patchI]
- (nPatch &
(
muPatches[patchI]*gradUpatches[patchI].T()
- (
muPatches[patchI]
+ lambdaPatches[patchI]
)*gradUpatches[patchI]
)
)
- nPatch*
(
lambdaPatches[patchI]*tr(gradUpatches[patchI])
)
)/(2.0*muPatches[patchI] + lambdaPatches[patchI]);
// Set the value fractions
curUPatch.valueFraction() =
(1.0 - urfFraction_)*curUPatch.valueFraction()
+ I*urfFraction_*valueFraction[patchI];
}
}
}
tmp<volScalarField> contactProblem::contactArea() const
{
tmp<volScalarField> tca
(
new volScalarField
(
IOobject
(
"contactArea",
U().time().timeName(),
U().db(),
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh(),
dimensionedScalar(0)
)
);
volScalarField& ca = tca();
// Set contact area boundary
const contactPatchPairList& contacts = *this;
forAll (contacts, contactI)
{
// Get master contact
ca.boundaryField()[contacts[contactI].masterPatch().index()] +=
contacts[contactI].masterTouchFraction();
// Get slave contact
ca.boundaryField()[contacts[contactI].slavePatch().index()] +=
contacts[contactI].slaveTouchFraction();
}
return tca;
}
// Return a list of contactPatchPair names
wordList contactProblem::names() const
{
const contactPatchPairList& contacts = *this;
wordList t(contacts.size());
forAll (contacts, contactI)
{
t[contactI] = contacts[contactI].name();
}
return t;
}
bool contactProblem::read()
{
if (regIOobject::read())
{
urfValue_ = readScalar(lookup("urfValue"));
urfTraction_ = readScalar(lookup("urfTraction"));
urfFraction_ = readScalar(lookup("urfFraction"));
// Decided not to re-read contactPatchPairList. HJ, 10/Jul/2004
return true;
}
else
{
return false;
}
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,161 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2007 Hrvoje Jasak
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Class
contactProblem
Description
Class describes a multiple body contact problem. Each individual contact
is described by a contactPatchPair. contactProblem handles
multiple contact updates and sets the boundary conditions on the
displacement field.
SourceFiles
contactProblem.C
\*---------------------------------------------------------------------------*/
#ifndef contactProblem_H
#define contactProblem_H
#include "contactPatchPairList.H"
#include "IOdictionary.H"
#include "volFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class fvMesh;
/*---------------------------------------------------------------------------*\
Class contactProblem Declaration
\*---------------------------------------------------------------------------*/
class contactProblem
:
public IOdictionary,
public contactPatchPairList
{
private:
// Private data
//- Reference to displacement field
volVectorField& U_;
//- Reference to displacement gradient field
const volTensorField& gradU_;
//- Value under-relaxation
scalar urfValue_;
//- Gradient under-relaxation
scalar urfTraction_;
//- Fraction under-relaxation
scalar urfFraction_;
// Private Member Functions
//- Disallow default bitwise copy construct
contactProblem(const contactProblem&);
//- Disallow default bitwise assignment
void operator=(const contactProblem&);
public:
//- Runtime type information
TypeName("contactProblem");
// Constructors
//- Read constructor
contactProblem
(
volVectorField& U,
const volTensorField& gradU
);
// Destructor
virtual ~contactProblem()
{}
// Member Functions
//- Return const reference to displacement field
const volVectorField& U() const
{
return U_;
}
//- Return reference to displacement field
volVectorField& U()
{
return U_;
}
//- Return const reference to displacement gradient field
const volTensorField& gradU() const
{
return gradU_;
}
//- Return reference to displacement field
const fvMesh& mesh() const
{
return U_.mesh();
}
//- Return contact area field
tmp<volScalarField> contactArea() const;
//- Return a list of contact patch pair names
wordList names() const;
//- Correct contact conditions
void correct();
//- Read rheologyProperties dictionary
virtual bool read();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,38 @@
mesh.weights();
Info<< "Reading field U\n" << endl;
volVectorField U
(
IOobject
(
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
// Create gradient field
volTensorField gradU = fvc::grad(U);
volSymmTensorField sigma
(
IOobject
(
"sigma",
runTime.timeName(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
mesh,
dimensionedSymmTensor("zero", dimForce/dimArea, symmTensor::zero)
);
// Create rheology model
rheologyModel rheology(sigma);
// Create contact problem
contactProblem contact(U, gradU);

View file

@ -0,0 +1,120 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2007 Hrvoje Jasak
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM 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
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Application
stressedFoam
Description
Transient/steady-state solver for solid bodies in contact.
Solves for the displacement vector field U, also generating the
stress tensor field sigma.
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "rheologyModel.H"
#include "contactProblem.H"
#include "componentReferenceList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
# include "setRootCase.H"
# include "createTime.H"
# include "createMesh.H"
# include "createFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< "\nCalculating displacement field\n" << endl;
volScalarField rho = rheology.rho();
// Force n-sqaured projection
// polyPatch::setNSquaredProjection(true);
while (runTime.loop())
{
Info<< "Iteration: " << runTime.timeName() << nl << endl;
# include "readStressedFoamControls.H"
volScalarField mu = rheology.mu();
volScalarField lambda = rheology.lambda();
int iCorr=0;
scalar initialResidual=0;
contact.correct();
do
{
fvVectorMatrix UEqn
(
fvm::d2dt2(rho, U)
==
fvm::laplacian(2*mu + lambda, U, "laplacian(DU,U)")
+ fvc::div
(
mu*gradU.T() + lambda*(I*tr(gradU)) - (mu + lambda)*gradU,
"div(sigma)"
)
);
# include "setComponentReference.H"
initialResidual = UEqn.solve().initialResidual();
gradU = fvc::grad(U);
# include "calculateSigma.H"
rheology.correct();
rho = rheology.rho();
mu = rheology.mu();
lambda = rheology.lambda();
} while (initialResidual > convergenceTolerance && ++iCorr < nCorr);
# include "calculateStress.H"
# include "calculateContactArea.H"
Info<< "ExecutionTime = "
<< runTime.elapsedCpuTime()
<< " s\n\n" << endl;
}
Info<< "End\n" << endl;
return(0);
}
// ************************************************************************* //

View file

@ -0,0 +1,3 @@
newStressedFoam.C
EXE = $(FOAM_APPBIN)/newStressedFoam

View file

@ -0,0 +1,8 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I../materialModels/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lmaterialModels \
-llduSolvers

View file

@ -0,0 +1 @@
sigma = 2*mu*symm(gradU) + lambda*(I*tr(gradU));

View file

@ -0,0 +1,101 @@
if (runTime.outputTime())
{
volScalarField sigmaEq
(
IOobject
(
"sigmaEq",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
sqrt((3.0/2.0)*magSqr(dev(sigma)))
);
Info<< "Max sigmaEq = " << max(sigmaEq).value()
<< endl;
volScalarField sigmaxx
(
IOobject
(
"sigmaxx",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
sigma.component(symmTensor::XX)
);
volScalarField sigmayy
(
IOobject
(
"sigmayy",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
sigma.component(symmTensor::YY)
);
volScalarField sigmazz
(
IOobject
(
"sigmazz",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
sigma.component(symmTensor::ZZ)
);
Info<< "Max sigmazz = " << max(sigmazz).value()
<< endl;
volScalarField sigmaxy
(
IOobject
(
"sigmaxy",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
sigma.component(symmTensor::XY)
);
volScalarField sigmaxz
(
IOobject
(
"sigmaxz",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
sigma.component(symmTensor::XZ)
);
volScalarField sigmayz
(
IOobject
(
"sigmayz",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
sigma.component(symmTensor::YZ)
);
runTime.write();
}

View file

@ -0,0 +1,29 @@
Info<< "Reading field U\n" << endl;
volVectorField U
(
IOobject
(
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
volSymmTensorField sigma
(
IOobject
(
"sigma",
runTime.timeName(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
mesh,
dimensionedSymmTensor("zero", dimForce/dimArea, symmTensor::zero)
);
rheologyModel rheology(sigma);

Some files were not shown because too many files have changed in this diff Show more