ENH: Re-worked lagrangian/molecularDynamics

This commit is contained in:
andy
2011-02-24 16:44:46 +00:00
parent f5da7edfe4
commit e8ea1f031d
5 changed files with 76 additions and 164 deletions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd. \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -63,29 +63,14 @@ Foam::tensor Foam::molecule::rotationTensorZ(scalar phi) const
} }
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::molecule::trackData::trackData
(
moleculeCloud& molCloud,
label part
)
:
Particle<molecule>::trackData(molCloud),
molCloud_(molCloud),
part_(part)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::molecule::move(molecule::trackingData& td, const scalar trackTime)
bool Foam::molecule::move(molecule::trackData& td, const scalar trackTime)
{ {
td.switchProcessor = false; td.switchProcessor = false;
td.keepParticle = true; td.keepParticle = true;
const constantProperties& constProps(td.molCloud().constProps(id_)); const constantProperties& constProps(td.cloud().constProps(id_));
if (td.part() == 0) if (td.part() == 0)
{ {
@ -195,9 +180,8 @@ bool Foam::molecule::move(molecule::trackData& td, const scalar trackTime)
} }
else else
{ {
FatalErrorIn("molecule::move(molecule::trackData& td)") << nl FatalErrorIn("molecule::move(trackingData&, const scalar)") << nl
<< td.part() << td.part() << " is an invalid part of the integration method."
<< " is an invalid part of the integration method."
<< abort(FatalError); << abort(FatalError);
} }
@ -207,7 +191,7 @@ bool Foam::molecule::move(molecule::trackData& td, const scalar trackTime)
void Foam::molecule::transformProperties(const tensor& T) void Foam::molecule::transformProperties(const tensor& T)
{ {
Particle<molecule>::transformProperties(T); particle::transformProperties(T);
Q_ = T & Q_; Q_ = T & Q_;
@ -229,7 +213,7 @@ void Foam::molecule::transformProperties(const tensor& T)
void Foam::molecule::transformProperties(const vector& separation) void Foam::molecule::transformProperties(const vector& separation)
{ {
Particle<molecule>::transformProperties(separation); particle::transformProperties(separation);
if (special_ == SPECIAL_TETHERED) if (special_ == SPECIAL_TETHERED)
{ {
@ -257,20 +241,7 @@ void Foam::molecule::setSiteSizes(label size)
bool Foam::molecule::hitPatch bool Foam::molecule::hitPatch
( (
const polyPatch&, const polyPatch&,
molecule::trackData&, trackingData&,
const label,
const scalar,
const tetIndices&
)
{
return false;
}
bool Foam::molecule::hitPatch
(
const polyPatch&,
int&,
const label, const label,
const scalar, const scalar,
const tetIndices& const tetIndices&
@ -283,25 +254,17 @@ bool Foam::molecule::hitPatch
void Foam::molecule::hitProcessorPatch void Foam::molecule::hitProcessorPatch
( (
const processorPolyPatch&, const processorPolyPatch&,
molecule::trackData& td trackingData& td
) )
{ {
td.switchProcessor = true; td.switchProcessor = true;
} }
void Foam::molecule::hitProcessorPatch
(
const processorPolyPatch&,
int&
)
{}
void Foam::molecule::hitWallPatch void Foam::molecule::hitWallPatch
( (
const wallPolyPatch& wpp, const wallPolyPatch& wpp,
molecule::trackData& td, trackingData& td,
const tetIndices& tetIs const tetIndices& tetIs
) )
{ {
@ -320,31 +283,14 @@ void Foam::molecule::hitWallPatch
} }
void Foam::molecule::hitWallPatch
(
const wallPolyPatch&,
int&,
const tetIndices&
)
{}
void Foam::molecule::hitPatch void Foam::molecule::hitPatch
( (
const polyPatch&, const polyPatch&,
molecule::trackData& td trackingData& td
) )
{ {
td.keepParticle = false; td.keepParticle = false;
} }
void Foam::molecule::hitPatch
(
const polyPatch&,
int&
)
{}
// ************************************************************************* // // ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd. \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -37,7 +37,7 @@ SourceFiles
#ifndef molecule_H #ifndef molecule_H
#define molecule_H #define molecule_H
#include "Particle.H" #include "particle.H"
#include "IOstream.H" #include "IOstream.H"
#include "autoPtr.H" #include "autoPtr.H"
#include "diagTensor.H" #include "diagTensor.H"
@ -56,7 +56,7 @@ class moleculeCloud;
class molecule class molecule
: :
public Particle<molecule> public particle
{ {
public: public:
@ -76,7 +76,6 @@ public:
//- Class to hold molecule constant properties //- Class to hold molecule constant properties
class constantProperties class constantProperties
{ {
// Private data // Private data
Field<vector> siteReferencePositions_; Field<vector> siteReferencePositions_;
@ -95,6 +94,7 @@ public:
scalar mass_; scalar mass_;
// Private Member Functions // Private Member Functions
void checkSiteListSizes() const; void checkSiteListSizes() const;
@ -150,12 +150,10 @@ public:
//- Class used to pass tracking data to the trackToFace function //- Class used to pass tracking data to the trackToFace function
class trackData class trackingData
: :
public Particle<molecule>::trackData public particle::TrackingData<moleculeCloud>
{ {
moleculeCloud& molCloud_;
// label specifying which part of the integration algorithm is taking // label specifying which part of the integration algorithm is taking
label part_; label part_;
@ -164,17 +162,18 @@ public:
// Constructors // Constructors
trackData trackingData(moleculeCloud& cloud, label part)
( :
moleculeCloud& molCloud, particle::TrackingData<moleculeCloud>(cloud),
label part part_(part)
); {}
// Member functions // Member functions
inline moleculeCloud& molCloud(); inline label part() const
{
inline label part() const; return part_;
}
}; };
@ -226,7 +225,7 @@ public:
//- Construct from components //- Construct from components
inline molecule inline molecule
( (
const Cloud<molecule>& c, const polyMesh& mesh,
const vector& position, const vector& position,
const label cellI, const label cellI,
const label tetFaceI, const label tetFaceI,
@ -245,23 +244,42 @@ public:
//- Construct from Istream //- Construct from Istream
molecule molecule
( (
const Cloud<molecule>& c, const polyMesh& mesh,
Istream& is, Istream& is,
bool readFields = true bool readFields = true
); );
//- Construct and return a clone //- Construct and return a clone
autoPtr<Particle<molecule> > clone() const autoPtr<particle> clone() const
{ {
return autoPtr<Particle<molecule> >(new molecule(*this)); return autoPtr<particle>(new molecule(*this));
} }
//- Factory class to read-construct particles used for
// parallel transfer
class iNew
{
const polyMesh& mesh_;
public:
iNew(const polyMesh& mesh)
:
mesh_(mesh)
{}
autoPtr<molecule> operator()(Istream& is) const
{
return autoPtr<molecule>(new molecule(mesh_, is, true));
}
};
// Member Functions // Member Functions
// Tracking // Tracking
bool move(trackData&, const scalar trackTime); bool move(trackingData&, const scalar trackTime);
void transformProperties(const tensor& T); void transformProperties(const tensor& T);
@ -318,18 +336,7 @@ public:
bool hitPatch bool hitPatch
( (
const polyPatch&, const polyPatch&,
molecule::trackData& td, trackingData& td,
const label patchI,
const scalar trackFraction,
const tetIndices& tetIs
);
//- Overridable function to handle the particle hitting a patch
// Executed before other patch-hitting functions without trackData
bool hitPatch
(
const polyPatch& p,
int& td,
const label patchI, const label patchI,
const scalar trackFraction, const scalar trackFraction,
const tetIndices& tetIs const tetIndices& tetIs
@ -339,31 +346,14 @@ public:
void hitProcessorPatch void hitProcessorPatch
( (
const processorPolyPatch&, const processorPolyPatch&,
molecule::trackData& td trackingData& td
);
//- Overridable function to handle the particle hitting a processorPatch
// without trackData
void hitProcessorPatch
(
const processorPolyPatch&,
int&
); );
//- Overridable function to handle the particle hitting a wallPatch //- Overridable function to handle the particle hitting a wallPatch
void hitWallPatch void hitWallPatch
( (
const wallPolyPatch&, const wallPolyPatch&,
molecule::trackData& td, trackingData& td,
const tetIndices&
);
//- Overridable function to handle the particle hitting a wallPatch
// without trackData
void hitWallPatch
(
const wallPolyPatch&,
int&,
const tetIndices& const tetIndices&
); );
@ -371,15 +361,7 @@ public:
void hitPatch void hitPatch
( (
const polyPatch&, const polyPatch&,
molecule::trackData& td trackingData& td
);
//- Overridable function to handle the particle hitting a polyPatch
// without trackData
void hitPatch
(
const polyPatch&,
int&
); );

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd. \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -219,7 +219,7 @@ inline Foam::molecule::constantProperties::constantProperties
inline Foam::molecule::molecule inline Foam::molecule::molecule
( (
const Cloud<molecule>& c, const polyMesh& mesh,
const vector& position, const vector& position,
const label cellI, const label cellI,
const label tetFaceI, const label tetFaceI,
@ -236,7 +236,7 @@ inline Foam::molecule::molecule
) )
: :
Particle<molecule>(c, position, cellI, tetFaceI, tetPtI), particle(mesh, position, cellI, tetFaceI, tetPtI),
Q_(Q), Q_(Q),
v_(v), v_(v),
a_(a), a_(a),
@ -254,8 +254,7 @@ inline Foam::molecule::molecule
} }
// * * * constantProperties Private Member Functions * * * * * * * * * * * * // // * * * * * * * constantProperties Private Member Functions * * * * * * * * //
inline void Foam::molecule::constantProperties::checkSiteListSizes() const inline void Foam::molecule::constantProperties::checkSiteListSizes() const
{ {
@ -394,6 +393,7 @@ Foam::molecule::constantProperties::electrostaticSites() const
return electrostaticSites_; return electrostaticSites_;
} }
inline bool Foam::molecule::constantProperties::electrostaticSite inline bool Foam::molecule::constantProperties::electrostaticSite
( (
label sId label sId
@ -462,19 +462,6 @@ inline Foam::label Foam::molecule::constantProperties::nSites() const
} }
// * * * * * * * * * * * trackData Member Functions * * * * * * * * * * * * //
inline Foam::moleculeCloud& Foam::molecule::trackData::molCloud()
{
return molCloud_;
}
inline Foam::label Foam::molecule::trackData::part() const
{
return part_;
}
// * * * * * * * * * * * * molecule Member Functions * * * * * * * * * * * * // // * * * * * * * * * * * * molecule Member Functions * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd. \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -31,12 +31,12 @@ License
Foam::molecule::molecule Foam::molecule::molecule
( (
const Cloud<molecule>& cloud, const polyMesh& mesh,
Istream& is, Istream& is,
bool readFields bool readFields
) )
: :
Particle<molecule>(cloud, is, readFields), particle(mesh, is, readFields),
Q_(tensor::zero), Q_(tensor::zero),
v_(vector::zero), v_(vector::zero),
a_(vector::zero), a_(vector::zero),
@ -104,7 +104,7 @@ void Foam::molecule::readFields(Cloud<molecule>& mC)
return; return;
} }
Particle<molecule>::readFields(mC); particle::readFields(mC);
IOField<tensor> Q(mC.fieldIOobject("Q", IOobject::MUST_READ)); IOField<tensor> Q(mC.fieldIOobject("Q", IOobject::MUST_READ));
mC.checkFieldIOobject(mC, Q); mC.checkFieldIOobject(mC, Q);
@ -153,7 +153,7 @@ void Foam::molecule::readFields(Cloud<molecule>& mC)
void Foam::molecule::writeFields(const Cloud<molecule>& mC) void Foam::molecule::writeFields(const Cloud<molecule>& mC)
{ {
Particle<molecule>::writeFields(mC); particle::writeFields(mC);
label np = mC.size(); label np = mC.size();
@ -262,7 +262,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const molecule& mol)
{ {
if (os.format() == IOstream::ASCII) if (os.format() == IOstream::ASCII)
{ {
os << token::SPACE << static_cast<const Particle<molecule>&>(mol) os << token::SPACE << static_cast<const particle&>(mol)
<< token::SPACE << mol.face() << token::SPACE << mol.face()
<< token::SPACE << mol.stepFraction() << token::SPACE << mol.stepFraction()
<< token::SPACE << mol.Q_ << token::SPACE << mol.Q_
@ -280,7 +280,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const molecule& mol)
} }
else else
{ {
os << static_cast<const Particle<molecule>&>(mol); os << static_cast<const particle&>(mol);
os.write os.write
( (
reinterpret_cast<const char*>(&mol.Q_), reinterpret_cast<const char*>(&mol.Q_),

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd. \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -33,7 +33,6 @@ using namespace Foam::constant::mathematical;
namespace Foam namespace Foam
{ {
defineParticleTypeNameAndDebug(molecule, 0);
defineTemplateTypeNameAndDebug(Cloud<molecule>, 0); defineTemplateTypeNameAndDebug(Cloud<molecule>, 0);
} }
@ -746,7 +745,7 @@ void Foam::moleculeCloud::initialiseMolecules
label tetFace = -1; label tetFace = -1;
label tetPt = -1; label tetPt = -1;
findCellFacePt mesh_.findCellFacePt
( (
globalPosition, globalPosition,
cell, cell,
@ -834,7 +833,7 @@ void Foam::moleculeCloud::initialiseMolecules
label tetFace = -1; label tetFace = -1;
label tetPt = -1; label tetPt = -1;
findCellFacePt mesh_.findCellFacePt
( (
globalPosition, globalPosition,
cell, cell,
@ -913,7 +912,7 @@ void Foam::moleculeCloud::initialiseMolecules
label tetFace = -1; label tetFace = -1;
label tetPt = -1; label tetPt = -1;
findCellFacePt mesh_.findCellFacePt
( (
globalPosition, globalPosition,
cell, cell,
@ -1000,11 +999,9 @@ void Foam::moleculeCloud::createMolecule
const vector& bulkVelocity const vector& bulkVelocity
) )
{ {
const Cloud<molecule>& cloud = *this;
if (cell == -1) if (cell == -1)
{ {
findCellFacePt(position, cell, tetFace, tetPt); mesh_.findCellFacePt(position, cell, tetFace, tetPt);
} }
if (cell == -1) if (cell == -1)
@ -1063,7 +1060,7 @@ void Foam::moleculeCloud::createMolecule
( (
new molecule new molecule
( (
cloud, mesh_,
position, position,
cell, cell,
tetFace, tetFace,
@ -1159,18 +1156,18 @@ Foam::moleculeCloud::moleculeCloud
void Foam::moleculeCloud::evolve() void Foam::moleculeCloud::evolve()
{ {
molecule::trackData td0(*this, 0); molecule::trackingData td0(*this, 0);
Cloud<molecule>::move(td0, mesh_.time().deltaTValue()); Cloud<molecule>::move(td0, mesh_.time().deltaTValue());
molecule::trackData td1(*this, 1); molecule::trackingData td1(*this, 1);
Cloud<molecule>::move(td1, mesh_.time().deltaTValue()); Cloud<molecule>::move(td1, mesh_.time().deltaTValue());
molecule::trackData td2(*this, 2); molecule::trackingData td2(*this, 2);
Cloud<molecule>::move(td2, mesh_.time().deltaTValue()); Cloud<molecule>::move(td2, mesh_.time().deltaTValue());
calculateForce(); calculateForce();
molecule::trackData td3(*this, 3); molecule::trackingData td3(*this, 3);
Cloud<molecule>::move(td3, mesh_.time().deltaTValue()); Cloud<molecule>::move(td3, mesh_.time().deltaTValue());
} }