mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Re-worked lagrangian/molecularDynamics
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
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 * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
bool Foam::molecule::move(molecule::trackData& td, const scalar trackTime)
|
||||
bool Foam::molecule::move(molecule::trackingData& td, const scalar trackTime)
|
||||
{
|
||||
td.switchProcessor = false;
|
||||
td.keepParticle = true;
|
||||
|
||||
const constantProperties& constProps(td.molCloud().constProps(id_));
|
||||
const constantProperties& constProps(td.cloud().constProps(id_));
|
||||
|
||||
if (td.part() == 0)
|
||||
{
|
||||
@ -195,9 +180,8 @@ bool Foam::molecule::move(molecule::trackData& td, const scalar trackTime)
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorIn("molecule::move(molecule::trackData& td)") << nl
|
||||
<< td.part()
|
||||
<< " is an invalid part of the integration method."
|
||||
FatalErrorIn("molecule::move(trackingData&, const scalar)") << nl
|
||||
<< td.part() << " is an invalid part of the integration method."
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
@ -207,7 +191,7 @@ bool Foam::molecule::move(molecule::trackData& td, const scalar trackTime)
|
||||
|
||||
void Foam::molecule::transformProperties(const tensor& T)
|
||||
{
|
||||
Particle<molecule>::transformProperties(T);
|
||||
particle::transformProperties(T);
|
||||
|
||||
Q_ = T & Q_;
|
||||
|
||||
@ -229,7 +213,7 @@ void Foam::molecule::transformProperties(const tensor& T)
|
||||
|
||||
void Foam::molecule::transformProperties(const vector& separation)
|
||||
{
|
||||
Particle<molecule>::transformProperties(separation);
|
||||
particle::transformProperties(separation);
|
||||
|
||||
if (special_ == SPECIAL_TETHERED)
|
||||
{
|
||||
@ -257,20 +241,7 @@ void Foam::molecule::setSiteSizes(label size)
|
||||
bool Foam::molecule::hitPatch
|
||||
(
|
||||
const polyPatch&,
|
||||
molecule::trackData&,
|
||||
const label,
|
||||
const scalar,
|
||||
const tetIndices&
|
||||
)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::molecule::hitPatch
|
||||
(
|
||||
const polyPatch&,
|
||||
int&,
|
||||
trackingData&,
|
||||
const label,
|
||||
const scalar,
|
||||
const tetIndices&
|
||||
@ -283,25 +254,17 @@ bool Foam::molecule::hitPatch
|
||||
void Foam::molecule::hitProcessorPatch
|
||||
(
|
||||
const processorPolyPatch&,
|
||||
molecule::trackData& td
|
||||
trackingData& td
|
||||
)
|
||||
{
|
||||
td.switchProcessor = true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::molecule::hitProcessorPatch
|
||||
(
|
||||
const processorPolyPatch&,
|
||||
int&
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
void Foam::molecule::hitWallPatch
|
||||
(
|
||||
const wallPolyPatch& wpp,
|
||||
molecule::trackData& td,
|
||||
trackingData& td,
|
||||
const tetIndices& tetIs
|
||||
)
|
||||
{
|
||||
@ -320,31 +283,14 @@ void Foam::molecule::hitWallPatch
|
||||
}
|
||||
|
||||
|
||||
void Foam::molecule::hitWallPatch
|
||||
(
|
||||
const wallPolyPatch&,
|
||||
int&,
|
||||
const tetIndices&
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
void Foam::molecule::hitPatch
|
||||
(
|
||||
const polyPatch&,
|
||||
molecule::trackData& td
|
||||
trackingData& td
|
||||
)
|
||||
{
|
||||
td.keepParticle = false;
|
||||
}
|
||||
|
||||
|
||||
void Foam::molecule::hitPatch
|
||||
(
|
||||
const polyPatch&,
|
||||
int&
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -37,7 +37,7 @@ SourceFiles
|
||||
#ifndef molecule_H
|
||||
#define molecule_H
|
||||
|
||||
#include "Particle.H"
|
||||
#include "particle.H"
|
||||
#include "IOstream.H"
|
||||
#include "autoPtr.H"
|
||||
#include "diagTensor.H"
|
||||
@ -56,7 +56,7 @@ class moleculeCloud;
|
||||
|
||||
class molecule
|
||||
:
|
||||
public Particle<molecule>
|
||||
public particle
|
||||
{
|
||||
|
||||
public:
|
||||
@ -76,7 +76,6 @@ public:
|
||||
//- Class to hold molecule constant properties
|
||||
class constantProperties
|
||||
{
|
||||
|
||||
// Private data
|
||||
|
||||
Field<vector> siteReferencePositions_;
|
||||
@ -95,6 +94,7 @@ public:
|
||||
|
||||
scalar mass_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
void checkSiteListSizes() const;
|
||||
@ -150,12 +150,10 @@ public:
|
||||
|
||||
|
||||
//- 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 part_;
|
||||
|
||||
@ -164,17 +162,18 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
trackData
|
||||
(
|
||||
moleculeCloud& molCloud,
|
||||
label part
|
||||
);
|
||||
trackingData(moleculeCloud& cloud, label part)
|
||||
:
|
||||
particle::TrackingData<moleculeCloud>(cloud),
|
||||
part_(part)
|
||||
{}
|
||||
|
||||
// Member functions
|
||||
|
||||
inline moleculeCloud& molCloud();
|
||||
|
||||
inline label part() const;
|
||||
inline label part() const
|
||||
{
|
||||
return part_;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -226,7 +225,7 @@ public:
|
||||
//- Construct from components
|
||||
inline molecule
|
||||
(
|
||||
const Cloud<molecule>& c,
|
||||
const polyMesh& mesh,
|
||||
const vector& position,
|
||||
const label cellI,
|
||||
const label tetFaceI,
|
||||
@ -245,23 +244,42 @@ public:
|
||||
//- Construct from Istream
|
||||
molecule
|
||||
(
|
||||
const Cloud<molecule>& c,
|
||||
const polyMesh& mesh,
|
||||
Istream& is,
|
||||
bool readFields = true
|
||||
);
|
||||
|
||||
//- 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
|
||||
|
||||
// Tracking
|
||||
|
||||
bool move(trackData&, const scalar trackTime);
|
||||
bool move(trackingData&, const scalar trackTime);
|
||||
|
||||
void transformProperties(const tensor& T);
|
||||
|
||||
@ -318,18 +336,7 @@ public:
|
||||
bool hitPatch
|
||||
(
|
||||
const polyPatch&,
|
||||
molecule::trackData& 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,
|
||||
trackingData& td,
|
||||
const label patchI,
|
||||
const scalar trackFraction,
|
||||
const tetIndices& tetIs
|
||||
@ -339,31 +346,14 @@ public:
|
||||
void hitProcessorPatch
|
||||
(
|
||||
const processorPolyPatch&,
|
||||
molecule::trackData& td
|
||||
);
|
||||
|
||||
//- Overridable function to handle the particle hitting a processorPatch
|
||||
// without trackData
|
||||
void hitProcessorPatch
|
||||
(
|
||||
const processorPolyPatch&,
|
||||
int&
|
||||
trackingData& td
|
||||
);
|
||||
|
||||
//- Overridable function to handle the particle hitting a wallPatch
|
||||
void hitWallPatch
|
||||
(
|
||||
const wallPolyPatch&,
|
||||
molecule::trackData& td,
|
||||
const tetIndices&
|
||||
);
|
||||
|
||||
//- Overridable function to handle the particle hitting a wallPatch
|
||||
// without trackData
|
||||
void hitWallPatch
|
||||
(
|
||||
const wallPolyPatch&,
|
||||
int&,
|
||||
trackingData& td,
|
||||
const tetIndices&
|
||||
);
|
||||
|
||||
@ -371,15 +361,7 @@ public:
|
||||
void hitPatch
|
||||
(
|
||||
const polyPatch&,
|
||||
molecule::trackData& td
|
||||
);
|
||||
|
||||
//- Overridable function to handle the particle hitting a polyPatch
|
||||
// without trackData
|
||||
void hitPatch
|
||||
(
|
||||
const polyPatch&,
|
||||
int&
|
||||
trackingData& td
|
||||
);
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -219,7 +219,7 @@ inline Foam::molecule::constantProperties::constantProperties
|
||||
|
||||
inline Foam::molecule::molecule
|
||||
(
|
||||
const Cloud<molecule>& c,
|
||||
const polyMesh& mesh,
|
||||
const vector& position,
|
||||
const label cellI,
|
||||
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),
|
||||
v_(v),
|
||||
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
|
||||
{
|
||||
@ -394,6 +393,7 @@ Foam::molecule::constantProperties::electrostaticSites() const
|
||||
return electrostaticSites_;
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::molecule::constantProperties::electrostaticSite
|
||||
(
|
||||
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 * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -31,12 +31,12 @@ License
|
||||
|
||||
Foam::molecule::molecule
|
||||
(
|
||||
const Cloud<molecule>& cloud,
|
||||
const polyMesh& mesh,
|
||||
Istream& is,
|
||||
bool readFields
|
||||
)
|
||||
:
|
||||
Particle<molecule>(cloud, is, readFields),
|
||||
particle(mesh, is, readFields),
|
||||
Q_(tensor::zero),
|
||||
v_(vector::zero),
|
||||
a_(vector::zero),
|
||||
@ -104,7 +104,7 @@ void Foam::molecule::readFields(Cloud<molecule>& mC)
|
||||
return;
|
||||
}
|
||||
|
||||
Particle<molecule>::readFields(mC);
|
||||
particle::readFields(mC);
|
||||
|
||||
IOField<tensor> Q(mC.fieldIOobject("Q", IOobject::MUST_READ));
|
||||
mC.checkFieldIOobject(mC, Q);
|
||||
@ -153,7 +153,7 @@ void Foam::molecule::readFields(Cloud<molecule>& mC)
|
||||
|
||||
void Foam::molecule::writeFields(const Cloud<molecule>& mC)
|
||||
{
|
||||
Particle<molecule>::writeFields(mC);
|
||||
particle::writeFields(mC);
|
||||
|
||||
label np = mC.size();
|
||||
|
||||
@ -262,7 +262,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const molecule& mol)
|
||||
{
|
||||
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.stepFraction()
|
||||
<< token::SPACE << mol.Q_
|
||||
@ -280,7 +280,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const molecule& mol)
|
||||
}
|
||||
else
|
||||
{
|
||||
os << static_cast<const Particle<molecule>&>(mol);
|
||||
os << static_cast<const particle&>(mol);
|
||||
os.write
|
||||
(
|
||||
reinterpret_cast<const char*>(&mol.Q_),
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -33,7 +33,6 @@ using namespace Foam::constant::mathematical;
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineParticleTypeNameAndDebug(molecule, 0);
|
||||
defineTemplateTypeNameAndDebug(Cloud<molecule>, 0);
|
||||
}
|
||||
|
||||
@ -746,7 +745,7 @@ void Foam::moleculeCloud::initialiseMolecules
|
||||
label tetFace = -1;
|
||||
label tetPt = -1;
|
||||
|
||||
findCellFacePt
|
||||
mesh_.findCellFacePt
|
||||
(
|
||||
globalPosition,
|
||||
cell,
|
||||
@ -834,7 +833,7 @@ void Foam::moleculeCloud::initialiseMolecules
|
||||
label tetFace = -1;
|
||||
label tetPt = -1;
|
||||
|
||||
findCellFacePt
|
||||
mesh_.findCellFacePt
|
||||
(
|
||||
globalPosition,
|
||||
cell,
|
||||
@ -913,7 +912,7 @@ void Foam::moleculeCloud::initialiseMolecules
|
||||
label tetFace = -1;
|
||||
label tetPt = -1;
|
||||
|
||||
findCellFacePt
|
||||
mesh_.findCellFacePt
|
||||
(
|
||||
globalPosition,
|
||||
cell,
|
||||
@ -1000,11 +999,9 @@ void Foam::moleculeCloud::createMolecule
|
||||
const vector& bulkVelocity
|
||||
)
|
||||
{
|
||||
const Cloud<molecule>& cloud = *this;
|
||||
|
||||
if (cell == -1)
|
||||
{
|
||||
findCellFacePt(position, cell, tetFace, tetPt);
|
||||
mesh_.findCellFacePt(position, cell, tetFace, tetPt);
|
||||
}
|
||||
|
||||
if (cell == -1)
|
||||
@ -1063,7 +1060,7 @@ void Foam::moleculeCloud::createMolecule
|
||||
(
|
||||
new molecule
|
||||
(
|
||||
cloud,
|
||||
mesh_,
|
||||
position,
|
||||
cell,
|
||||
tetFace,
|
||||
@ -1159,18 +1156,18 @@ Foam::moleculeCloud::moleculeCloud
|
||||
|
||||
void Foam::moleculeCloud::evolve()
|
||||
{
|
||||
molecule::trackData td0(*this, 0);
|
||||
molecule::trackingData td0(*this, 0);
|
||||
Cloud<molecule>::move(td0, mesh_.time().deltaTValue());
|
||||
|
||||
molecule::trackData td1(*this, 1);
|
||||
molecule::trackingData td1(*this, 1);
|
||||
Cloud<molecule>::move(td1, mesh_.time().deltaTValue());
|
||||
|
||||
molecule::trackData td2(*this, 2);
|
||||
molecule::trackingData td2(*this, 2);
|
||||
Cloud<molecule>::move(td2, mesh_.time().deltaTValue());
|
||||
|
||||
calculateForce();
|
||||
|
||||
molecule::trackData td3(*this, 3);
|
||||
molecule::trackingData td3(*this, 3);
|
||||
Cloud<molecule>::move(td3, mesh_.time().deltaTValue());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user