ENH: Updated utilities using lagrangian classes

This commit is contained in:
andy
2011-02-24 16:47:54 +00:00
parent bf172bbf57
commit af115c5d01
20 changed files with 223 additions and 427 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -61,7 +61,7 @@ void Foam::streamLine::track()
(
new streamLineParticle
(
particles,
mesh,
seedPoints[i],
seedPoints.cells()[i],
lifeTime_ // lifetime
@ -215,7 +215,7 @@ void Foam::streamLine::track()
}
// additional particle info
streamLineParticle::trackData td
streamLineParticle::trackingData td
(
particles,
vsInterp,

View File

@ -30,16 +30,15 @@ License
namespace Foam
{
defineParticleTypeNameAndDebug(streamLineParticle, 0);
// defineParticleTypeNameAndDebug(streamLineParticle, 0);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// Estimate dt to cross cell in a few steps
Foam::scalar Foam::streamLineParticle::calcSubCycleDeltaT
(
streamLineParticle::trackData& td,
trackingData& td,
const scalar dt,
const vector& U
) const
@ -58,7 +57,7 @@ Foam::scalar Foam::streamLineParticle::calcSubCycleDeltaT
Foam::vector Foam::streamLineParticle::interpolateFields
(
const streamLineParticle::trackData& td,
const trackingData& td,
const point& position,
const label cellI
)
@ -103,29 +102,27 @@ Foam::vector Foam::streamLineParticle::interpolateFields
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
//- Construct from components
Foam::streamLineParticle::streamLineParticle
(
const Cloud<streamLineParticle>& c,
const polyMesh& mesh,
const vector& position,
const label cellI,
const label lifeTime
)
:
Particle<streamLineParticle>(c, position, cellI),
particle(mesh, position, cellI),
lifeTime_(lifeTime)
{}
//- Construct from Istream
Foam::streamLineParticle::streamLineParticle
(
const Cloud<streamLineParticle>& c,
const polyMesh& mesh,
Istream& is,
bool readFields
)
:
Particle<streamLineParticle>(c, is, readFields)
particle(mesh, is, readFields)
{
if (readFields)
{
@ -157,16 +154,15 @@ Foam::streamLineParticle::streamLineParticle
}
// Construct copy
Foam::streamLineParticle::streamLineParticle
(
const streamLineParticle& c
const streamLineParticle& p
)
:
Particle<streamLineParticle>(c),
lifeTime_(c.lifeTime_),
sampledPositions_(c.sampledPositions_),
sampledScalars_(c.sampledScalars_)
particle(p),
lifeTime_(p.lifeTime_),
sampledPositions_(p.sampledPositions_),
sampledScalars_(p.sampledScalars_)
{}
@ -174,15 +170,17 @@ Foam::streamLineParticle::streamLineParticle
bool Foam::streamLineParticle::move
(
streamLineParticle::trackData& td,
trackingData& td,
const scalar trackTime
)
{
streamLineParticle& p = static_cast<streamLineParticle&>(*this);
td.switchProcessor = false;
td.keepParticle = true;
scalar tEnd = (1.0 - stepFraction())*trackTime;
scalar maxDt = cloud_.pMesh().bounds().mag();
scalar maxDt = mesh_.bounds().mag();
while
(
@ -266,8 +264,7 @@ bool Foam::streamLineParticle::move
if (debug)
{
Pout<< "streamLineParticle : Removing stagnant particle:"
<< static_cast<Particle<streamLineParticle> >(*this)
<< " sampled positions:" << sampledPositions_.size()
<< p << " sampled positions:" << sampledPositions_.size()
<< endl;
}
td.keepParticle = false;
@ -281,13 +278,12 @@ bool Foam::streamLineParticle::move
if (debug)
{
Pout<< "streamLineParticle : Removing particle:"
<< static_cast<Particle<streamLineParticle> >(*this)
<< " sampled positions:" << sampledPositions_.size()
<< p << " sampled positions:" << sampledPositions_.size()
<< endl;
}
}
// Transfer particle data into trackData.
// Transfer particle data into trackingData.
//td.allPositions_.append(sampledPositions_);
td.allPositions_.append(vectorList());
vectorList& top = td.allPositions_.last();
@ -316,7 +312,7 @@ bool Foam::streamLineParticle::move
bool Foam::streamLineParticle::hitPatch
(
const polyPatch&,
streamLineParticle::trackData& td,
trackingData& td,
const label patchI,
const scalar trackFraction,
const tetIndices& tetIs
@ -327,24 +323,10 @@ bool Foam::streamLineParticle::hitPatch
}
bool Foam::streamLineParticle::hitPatch
(
const polyPatch&,
int&,
const label,
const scalar,
const tetIndices&
)
{
// Disable generic patch interaction
return false;
}
void Foam::streamLineParticle::hitWedgePatch
(
const wedgePolyPatch& pp,
streamLineParticle::trackData& td
trackingData& td
)
{
// Remove particle
@ -352,18 +334,10 @@ void Foam::streamLineParticle::hitWedgePatch
}
void Foam::streamLineParticle::hitWedgePatch
(
const wedgePolyPatch&,
int&
)
{}
void Foam::streamLineParticle::hitSymmetryPatch
(
const symmetryPolyPatch& pp,
streamLineParticle::trackData& td
trackingData& td
)
{
// Remove particle
@ -371,18 +345,10 @@ void Foam::streamLineParticle::hitSymmetryPatch
}
void Foam::streamLineParticle::hitSymmetryPatch
(
const symmetryPolyPatch&,
int&
)
{}
void Foam::streamLineParticle::hitCyclicPatch
(
const cyclicPolyPatch& pp,
streamLineParticle::trackData& td
trackingData& td
)
{
// Remove particle
@ -390,18 +356,10 @@ void Foam::streamLineParticle::hitCyclicPatch
}
void Foam::streamLineParticle::hitCyclicPatch
(
const cyclicPolyPatch&,
int&
)
{}
void Foam::streamLineParticle::hitProcessorPatch
(
const processorPolyPatch&,
streamLineParticle::trackData& td
trackingData& td
)
{
// Switch particle
@ -409,18 +367,10 @@ void Foam::streamLineParticle::hitProcessorPatch
}
void Foam::streamLineParticle::hitProcessorPatch
(
const processorPolyPatch&,
int&
)
{}
void Foam::streamLineParticle::hitWallPatch
(
const wallPolyPatch& wpp,
streamLineParticle::trackData& td,
trackingData& td,
const tetIndices&
)
{
@ -429,32 +379,15 @@ void Foam::streamLineParticle::hitWallPatch
}
void Foam::streamLineParticle::hitWallPatch
(
const wallPolyPatch& wpp,
int&,
const tetIndices&
)
{}
void Foam::streamLineParticle::hitPatch
(
const polyPatch& wpp,
streamLineParticle::trackData& td
)
{
// Remove particle
td.keepParticle = false;
}
void Foam::streamLineParticle::hitPatch
(
const polyPatch& wpp,
int&
trackingData& td
)
{}
{
// Remove particle
td.keepParticle = false;
}
void Foam::streamLineParticle::readFields(Cloud<streamLineParticle>& c)
@ -464,6 +397,8 @@ void Foam::streamLineParticle::readFields(Cloud<streamLineParticle>& c)
return;
}
particle::readFields(c);
IOField<label> lifeTime
(
c.fieldIOobject("lifeTime", IOobject::MUST_READ)
@ -495,7 +430,7 @@ void Foam::streamLineParticle::readFields(Cloud<streamLineParticle>& c)
void Foam::streamLineParticle::writeFields(const Cloud<streamLineParticle>& c)
{
Particle<streamLineParticle>::writeFields(c);
particle::writeFields(c);
label np = c.size();
@ -534,7 +469,7 @@ void Foam::streamLineParticle::writeFields(const Cloud<streamLineParticle>& c)
Foam::Ostream& Foam::operator<<(Ostream& os, const streamLineParticle& p)
{
os << static_cast<const Particle<streamLineParticle>&>(p)
os << static_cast<const particle&>(p)
<< token::SPACE << p.lifeTime_
<< token::SPACE << p.sampledPositions_
<< token::SPACE << p.sampledScalars_

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -36,7 +36,7 @@ SourceFiles
#ifndef streamLineParticle_H
#define streamLineParticle_H
#include "Particle.H"
#include "particle.H"
#include "autoPtr.H"
#include "interpolationCellPoint.H"
#include "vectorList.H"
@ -49,20 +49,20 @@ namespace Foam
class streamLineParticleCloud;
/*---------------------------------------------------------------------------*\
Class streamLineParticle Declaration
Class streamLineParticle Declaration
\*---------------------------------------------------------------------------*/
class streamLineParticle
:
public Particle<streamLineParticle>
public particle
{
public:
//- Class used to pass tracking data to the trackToFace function
class trackData
class trackingData
:
public Particle<streamLineParticle>::trackData
public particle::TrackingData<Cloud<streamLineParticle> >
{
public:
@ -81,7 +81,7 @@ public:
// Constructors
trackData
trackingData
(
Cloud<streamLineParticle>& cloud,
const PtrList<interpolationCellPoint<scalar> >& vsInterp,
@ -94,7 +94,7 @@ public:
List<DynamicList<vectorList> >& allVectors
)
:
Particle<streamLineParticle>::trackData(cloud),
particle::TrackingData<Cloud<streamLineParticle> >(cloud),
vsInterp_(vsInterp),
vvInterp_(vvInterp),
UIndex_(UIndex),
@ -130,7 +130,7 @@ private:
// steps.
scalar calcSubCycleDeltaT
(
streamLineParticle::trackData& td,
trackingData& td,
const scalar dt,
const vector& U
) const;
@ -138,7 +138,7 @@ private:
//- Interpolate all quantities; return interpolated velocity.
vector interpolateFields
(
const streamLineParticle::trackData&,
const trackingData&,
const point&,
const label cellI
);
@ -151,7 +151,7 @@ public:
//- Construct from components
streamLineParticle
(
const Cloud<streamLineParticle>& c,
const polyMesh& c,
const vector& position,
const label cellI,
const label lifeTime
@ -160,32 +160,49 @@ public:
//- Construct from Istream
streamLineParticle
(
const Cloud<streamLineParticle>& c,
const polyMesh& c,
Istream& is,
bool readFields = true
);
//- Construct copy
streamLineParticle(const streamLineParticle& c);
streamLineParticle(const streamLineParticle& p);
//- Construct and return a clone
autoPtr<Particle<streamLineParticle> > clone() const
autoPtr<particle> clone() const
{
return autoPtr<Particle<streamLineParticle> >
(
new streamLineParticle(*this)
);
return autoPtr<particle>(new streamLineParticle(*this));
}
//- Factory class to read-construct particles used for
// parallel transfer
class iNew
{
const polyMesh& mesh_;
public:
iNew(const polyMesh& mesh)
:
mesh_(mesh)
{}
autoPtr<streamLineParticle> operator()(Istream& is) const
{
return autoPtr<streamLineParticle>
(
new streamLineParticle(mesh_, is, true)
);
}
};
// Member Functions
// Tracking
//- Track all particles to their end point
bool move(trackData&, const scalar trackTime);
bool move(trackingData&, const scalar trackTime);
//- Overridable function to handle the particle hitting a patch
@ -193,31 +210,17 @@ public:
bool hitPatch
(
const polyPatch&,
streamLineParticle::trackData& td,
trackingData& td,
const label patchI,
const scalar trackFraction,
const tetIndices& tetIs
);
bool hitPatch
(
const polyPatch&,
int&,
const label,
const scalar,
const tetIndices&
);
//- Overridable function to handle the particle hitting a wedge
void hitWedgePatch
(
const wedgePolyPatch&,
streamLineParticle::trackData& td
);
void hitWedgePatch
(
const wedgePolyPatch&,
int&
trackingData& td
);
//- Overridable function to handle the particle hitting a
@ -225,24 +228,14 @@ public:
void hitSymmetryPatch
(
const symmetryPolyPatch&,
streamLineParticle::trackData& td
);
void hitSymmetryPatch
(
const symmetryPolyPatch&,
int&
trackingData& td
);
//- Overridable function to handle the particle hitting a cyclic
void hitCyclicPatch
(
const cyclicPolyPatch&,
streamLineParticle::trackData& td
);
void hitCyclicPatch
(
const cyclicPolyPatch&,
int&
trackingData& td
);
//- Overridable function to handle the particle hitting a
@ -250,25 +243,14 @@ public:
void hitProcessorPatch
(
const processorPolyPatch&,
streamLineParticle::trackData& td
);
void hitProcessorPatch
(
const processorPolyPatch&,
int&
trackingData& td
);
//- Overridable function to handle the particle hitting a wallPatch
void hitWallPatch
(
const wallPolyPatch&,
streamLineParticle::trackData& td,
const tetIndices&
);
void hitWallPatch
(
const wallPolyPatch&,
int&,
trackingData& td,
const tetIndices&
);
@ -276,12 +258,7 @@ public:
void hitPatch
(
const polyPatch&,
streamLineParticle::trackData& td
);
void hitPatch
(
const polyPatch&,
int&
trackingData& td
);
@ -297,8 +274,6 @@ public:
// Ostream Operator
friend Ostream& operator<<(Ostream&, const streamLineParticle&);
};