ENH: Non-inertial reference frame particle force.

This commit is contained in:
graham 2011-03-04 13:45:25 +00:00
parent 41951c6f9f
commit a9d0a6d02b
12 changed files with 637 additions and 37 deletions

View File

@ -89,30 +89,17 @@
"H", "H",
runTime.timeName(), runTime.timeName(),
mesh, mesh,
IOobject::NO_READ IOobject::MUST_READ,
IOobject::AUTO_WRITE
); );
autoPtr<volVectorField> HPtr_; autoPtr<volVectorField> HPtr;
if (Hheader.headerOk()) if (Hheader.headerOk())
{ {
Info<< "\nReading field H\n" << endl; Info<< "\nReading field H\n" << endl;
HPtr_.reset HPtr.reset(new volVectorField (Hheader, mesh));
(
new volVectorField
(
IOobject
(
"H",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
)
);
} }
IOobject HdotGradHheader IOobject HdotGradHheader
@ -120,28 +107,17 @@
"HdotGradH", "HdotGradH",
runTime.timeName(), runTime.timeName(),
mesh, mesh,
IOobject::NO_READ IOobject::MUST_READ,
IOobject::AUTO_WRITE
); );
autoPtr<volVectorField> HdotGradHPtr_; autoPtr<volVectorField> HdotGradHPtr;
if (HdotGradHheader.headerOk()) if (HdotGradHheader.headerOk())
{ {
Info<< "Reading field HdotGradH" << endl; Info<< "Reading field HdotGradH" << endl;
HdotGradHPtr_.reset HdotGradHPtr.reset(new volVectorField(HdotGradHheader, mesh));
(
new volVectorField
(
IOobject
(
"HdotGradH",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
)
);
} }
#include "createNonInertialFrameFields.H"

View File

@ -0,0 +1,110 @@
Info<< "Reading non-inertial frame fields" << endl;
IOobject linearAccelerationHeader
(
"linearAcceleration",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
);
autoPtr<uniformDimensionedVectorField> linearAccelerationPtr;
if (linearAccelerationHeader.headerOk())
{
Info<< " Reading " << linearAccelerationHeader.name() << endl;
linearAccelerationPtr.reset
(
new uniformDimensionedVectorField(linearAccelerationHeader)
);
}
IOobject angularVelocityMagHeader
(
"angularVelocityMag",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
);
autoPtr<uniformDimensionedScalarField> angularVelocityMagPtr;
if (angularVelocityMagHeader.headerOk())
{
Info<< " Reading " << angularVelocityMagHeader.name() << endl;
angularVelocityMagPtr.reset
(
new uniformDimensionedScalarField(angularVelocityMagHeader)
);
}
IOobject angularAccelerationHeader
(
"angularAcceleration",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
);
autoPtr<uniformDimensionedVectorField> angularAccelerationPtr;
if (angularAccelerationHeader.headerOk())
{
Info<< " Reading " << angularAccelerationHeader.name() << endl;
angularAccelerationPtr.reset
(
new uniformDimensionedVectorField(angularAccelerationHeader)
);
}
IOobject axisHeader
(
"axis",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
);
autoPtr<uniformDimensionedVectorField> axisPtr;
if (axisHeader.headerOk())
{
Info<< " Reading " << axisHeader.name() << endl;
axisPtr.reset
(
new uniformDimensionedVectorField(axisHeader)
);
}
IOobject axisRefPointHeader
(
"axisRefPoint",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
);
autoPtr<uniformDimensionedVectorField> axisRefPointPtr;
if (axisRefPointHeader.headerOk())
{
Info<< " Reading " << axisRefPointHeader.name() << endl;
axisRefPointPtr.reset
(
new uniformDimensionedVectorField(axisRefPointHeader)
);
}

View File

@ -61,7 +61,7 @@ Foam::UniformDimensionedField<Type>::UniformDimensionedField
{ {
dictionary dict(readStream(typeName)); dictionary dict(readStream(typeName));
this->dimensions().reset(dict.lookup("dimensions")); this->dimensions().reset(dict.lookup("dimensions"));
this->value() = dict.lookup("value"); dict.lookup("value") >> this->value();
} }

View File

@ -304,6 +304,8 @@ public:
//- Return a reference to the cloud copy //- Return a reference to the cloud copy
inline const KinematicCloud& cloudCopy() const; inline const KinematicCloud& cloudCopy() const;
inline bool hasWallImpactDistance() const;
// References to the mesh and databases // References to the mesh and databases

View File

@ -35,6 +35,13 @@ Foam::KinematicCloud<CloudType>::cloudCopy() const
} }
template<class CloudType>
inline bool Foam::KinematicCloud<CloudType>::hasWallImpactDistance() const
{
return true;
}
template<class CloudType> template<class CloudType>
inline const Foam::fvMesh& Foam::KinematicCloud<CloudType>::mesh() const inline const Foam::fvMesh& Foam::KinematicCloud<CloudType>::mesh() const
{ {

View File

@ -32,6 +32,7 @@ License
#include "NonSphereDragForce.H" #include "NonSphereDragForce.H"
#include "GravityForce.H" #include "GravityForce.H"
#include "NonInertialFrameForce.H"
#include "ParamagneticForce.H" #include "ParamagneticForce.H"
#include "PressureGradientForce.H" #include "PressureGradientForce.H"
#include "SRFForce.H" #include "SRFForce.H"
@ -44,6 +45,7 @@ License
makeParticleForceModelType(SphereDragForce, CloudType); \ makeParticleForceModelType(SphereDragForce, CloudType); \
makeParticleForceModelType(NonSphereDragForce, CloudType); \ makeParticleForceModelType(NonSphereDragForce, CloudType); \
makeParticleForceModelType(GravityForce, CloudType); \ makeParticleForceModelType(GravityForce, CloudType); \
makeParticleForceModelType(NonInertialFrameForce, CloudType); \
makeParticleForceModelType(ParamagneticForce, CloudType); \ makeParticleForceModelType(ParamagneticForce, CloudType); \
makeParticleForceModelType(PressureGradientForce, CloudType); \ makeParticleForceModelType(PressureGradientForce, CloudType); \
makeParticleForceModelType(SRFForce, CloudType); makeParticleForceModelType(SRFForce, CloudType);

View File

@ -33,6 +33,7 @@ License
#include "BrownianMotionForce.H" #include "BrownianMotionForce.H"
#include "GravityForce.H" #include "GravityForce.H"
#include "NonInertialFrameForce.H"
#include "ParamagneticForce.H" #include "ParamagneticForce.H"
#include "PressureGradientForce.H" #include "PressureGradientForce.H"
#include "SRFForce.H" #include "SRFForce.H"
@ -46,6 +47,7 @@ License
makeParticleForceModelType(NonSphereDragForce, CloudType); \ makeParticleForceModelType(NonSphereDragForce, CloudType); \
makeParticleForceModelType(BrownianMotionForce, CloudType); \ makeParticleForceModelType(BrownianMotionForce, CloudType); \
makeParticleForceModelType(GravityForce, CloudType); \ makeParticleForceModelType(GravityForce, CloudType); \
makeParticleForceModelType(NonInertialFrameForce, CloudType); \
makeParticleForceModelType(ParamagneticForce, CloudType); \ makeParticleForceModelType(ParamagneticForce, CloudType); \
makeParticleForceModelType(PressureGradientForce, CloudType); \ makeParticleForceModelType(PressureGradientForce, CloudType); \
makeParticleForceModelType(SRFForce, CloudType); makeParticleForceModelType(SRFForce, CloudType);

View File

@ -98,7 +98,7 @@ public:
// Access // Access
//- Return the the acceleration due to gravity //- Return the acceleration due to gravity
inline const vector& g() const; inline const vector& g() const;

View File

@ -0,0 +1,243 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd.
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "NonInertialFrameForce.H"
#include "uniformDimensionedFields.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class CloudType>
Foam::NonInertialFrameForce<CloudType>::NonInertialFrameForce
(
CloudType& owner,
const fvMesh& mesh,
const dictionary& dict,
const word& forceType
)
:
ParticleForce<CloudType>(owner, mesh, dict),
WName_
(
this->coeffs().template lookupOrDefault<word>
(
"linearAccelerationName",
"linearAcceleration"
)
),
W_(vector::zero),
omegaMagName_
(
this->coeffs().template lookupOrDefault<word>
(
"angularVelocityMagName",
"angularVelocityMag"
)
),
omegaMag_(0.0),
omegaDotName_
(
this->coeffs().template lookupOrDefault<word>
(
"angularAccelerationName",
"angularAcceleration"
)
),
omegaDot_(vector::zero),
axisName_
(
this->coeffs().template lookupOrDefault<word>
(
"axisName",
"axis"
)
),
axis_(vector::zero),
hasAxis_(false),
axisRefPointName_
(
this->coeffs().template lookupOrDefault<word>
(
"axisRefPointName",
"axisRefPoint"
)
),
axisRefPoint_(vector::zero)
{}
template<class CloudType>
Foam::NonInertialFrameForce<CloudType>::NonInertialFrameForce
(
const NonInertialFrameForce& niff
)
:
ParticleForce<CloudType>(niff),
WName_(niff.WName_),
W_(niff.W_),
omegaMagName_(niff.omegaMagName_),
omegaMag_(niff.omegaMag_),
omegaDotName_(niff.omegaDotName_),
omegaDot_(niff.omegaDot_),
axisName_(niff.axisName_),
axis_(niff.axis_),
hasAxis_(niff.hasAxis_),
axisRefPointName_(niff.axisRefPointName_),
axisRefPoint_(niff.axisRefPoint_)
{}
// * * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * //
template<class CloudType>
Foam::NonInertialFrameForce<CloudType>::~NonInertialFrameForce()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CloudType>
void Foam::NonInertialFrameForce<CloudType>::cacheFields(const bool store)
{
W_ = vector::zero;
omegaMag_ = 0.0;
omegaDot_ = vector::zero;
axis_ = vector::zero;
hasAxis_ = false;
axisRefPoint_ = vector::zero;
if (store)
{
if
(
this->mesh().template
foundObject<uniformDimensionedScalarField>(omegaMagName_)
)
{
uniformDimensionedScalarField omegaMag = this->mesh().template
lookupObject<uniformDimensionedScalarField>(omegaMagName_);
omegaMag_ = omegaMag.value();
// If omegaMag is found, require that the axis and axisRefPoint is
// found.
uniformDimensionedVectorField a = this->mesh().template
lookupObject<uniformDimensionedVectorField>(axisName_);
axis_ = a.value();
hasAxis_ = true;
scalar axisMag = mag(axis_);
if (mag(axis_) < SMALL)
{
FatalErrorIn
(
"void Foam::NonInertialFrameForce<CloudType>::"
"cacheFields(const bool store)"
) << axisName_ << " " << axis_ << " too small."
<< abort(FatalError);
}
axis_ /= axisMag;
uniformDimensionedVectorField axisRefPoint = this->mesh().template
lookupObject<uniformDimensionedVectorField>(axisRefPointName_);
axisRefPoint_ = axisRefPoint.value();
// Only look for omegaDot is omegaMag is found, optional.
if
(
this->mesh().template
foundObject<uniformDimensionedVectorField>(omegaDotName_)
)
{
uniformDimensionedVectorField omegaDot = this->mesh().template
lookupObject<uniformDimensionedVectorField>(omegaDotName_);
omegaDot_ = omegaDot.value();
}
}
if
(
this->mesh().template
foundObject<uniformDimensionedVectorField>(WName_)
)
{
uniformDimensionedVectorField W = this->mesh().template
lookupObject<uniformDimensionedVectorField>(WName_);
W_ = W.value();
}
else if (!hasAxis_)
{
WarningIn
(
"void Foam::NonInertialFrameForce<CloudType>::"
"cacheFields(const bool store)"
) << "No " << typeName << " variables found." << endl;
}
}
}
template<class CloudType>
Foam::forceSuSp Foam::NonInertialFrameForce<CloudType>::calcNonCoupled
(
const typename CloudType::parcelType& p,
const scalar dt,
const scalar mass,
const scalar Re,
const scalar muc
) const
{
forceSuSp value(vector::zero, 0.0);
value.Su() += -mass*W_;
if (hasAxis_)
{
const vector pRel = p.position() - axisRefPoint_;
const vector r = pRel - axis_*(axis_ & pRel);
vector omega = axis_*omegaMag_;
value.Su() +=
mass
*(
(r ^ omegaDot_)
+ 2.0*(p.U() ^ omega)
+ (omega ^ (r ^ omega))
);
}
return value;
}
// ************************************************************************* //

View File

@ -0,0 +1,186 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd.
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
Class
Foam::NonInertialFrameForce
Description
Calculates particle non-inertial reference frame force. Variable names as
from Landau and Lifshitz, Mechanics, 3rd Ed, p126-129.
SourceFiles
NonInertialFrameForce.C
\*---------------------------------------------------------------------------*/
#ifndef NonInertialFrameForce_H
#define NonInertialFrameForce_H
#include "ParticleForce.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class fvMesh;
/*---------------------------------------------------------------------------*\
Class NonInertialFrameForce Declaration
\*---------------------------------------------------------------------------*/
template<class CloudType>
class NonInertialFrameForce
:
public ParticleForce<CloudType>
{
// Private data
//- Name of the linear acceleration field
word WName_;
//- The linear acceleration of the reference frame
vector W_;
//- Name of the angular velocity magnitude field
word omegaMagName_;
//- The magnitude of the angular velocity of the reference frame,
// combines with axis to give omega
scalar omegaMag_;
//- Name of the angular acceleration field
word omegaDotName_;
//- Pointer to the angular acceleration of the reference frame
vector omegaDot_;
//- Name of the axis field
word axisName_;
//- Pointer to the axis of rotation - assumed to be a unit vector.
// duplication of omega to allow situations where omega = 0 and
// omegaDot != 0.
vector axis_;
// Boolean flag for whether rotational motion is active
bool hasAxis_;
//- Name of the axisRefPoint field
word axisRefPointName_;
//- Pointer to a point in non-inertial space on the axis of rotation
// (omega), used to calculate r.
vector axisRefPoint_;
public:
//- Runtime type information
TypeName("nonInertialFrame");
// Constructors
//- Construct from mesh
NonInertialFrameForce
(
CloudType& owner,
const fvMesh& mesh,
const dictionary& dict,
const word& forceType
);
//- Construct copy
NonInertialFrameForce(const NonInertialFrameForce& niff);
//- Construct and return a clone
virtual autoPtr<ParticleForce<CloudType> > clone() const
{
return autoPtr<ParticleForce<CloudType> >
(
new ParticleForce<CloudType>(*this)
);
}
//- Destructor
virtual ~NonInertialFrameForce();
// Member Functions
// Access
//- Return the linear acceleration of the reference frame
inline const vector& W() const;
//- Return the angular velocity of the reference frame
inline const vector& omega() const;
//- Return the angular acceleration of the reference frame
inline const vector& omegaDot() const;
//- Return the axis of rotation
inline const vector& axis() const;
//- Return bool stating if the frame is rotating
inline bool hasAxis() const;
//- Return the point in non-inertial space on the axis of rotation
inline const vector& axisRefPoint() const;
// Evaluation
//- Cache fields
virtual void cacheFields(const bool store);
//- Calculate the non-coupled force
virtual forceSuSp calcNonCoupled
(
const typename CloudType::parcelType& p,
const scalar dt,
const scalar mass,
const scalar Re,
const scalar muc
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "NonInertialFrameForceI.H"
#ifdef NoRepository
#include "NonInertialFrameForce.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,73 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd.
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class CloudType>
inline const Foam::vector& Foam::NonInertialFrameForce<CloudType>::W() const
{
return W_;
}
template<class CloudType>
inline const Foam::vector& Foam::NonInertialFrameForce<CloudType>::omega() const
{
return omegaMag_*axis_;
}
template<class CloudType>
inline const Foam::vector&
Foam::NonInertialFrameForce<CloudType>::omegaDot() const
{
return omegaDot_;
}
template<class CloudType>
inline const Foam::vector&
Foam::NonInertialFrameForce<CloudType>::axis() const
{
return axis_;
}
template<class CloudType>
inline bool Foam::NonInertialFrameForce<CloudType>::hasAxis() const
{
return hasAxis_;
}
template<class CloudType>
inline const Foam::vector&
Foam::NonInertialFrameForce<CloudType>::axisRefPoint() const
{
return axisRefPoint_;
}
// ************************************************************************* //

View File

@ -28,7 +28,6 @@ Description
Calculates particle SRF reference frame force Calculates particle SRF reference frame force
SourceFiles SourceFiles
SRFForceI.H
SRFForce.C SRFForce.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/