Commit af115c5d authored by andy's avatar andy
Browse files

ENH: Updated utilities using lagrangian classes

parent bf172bbf
......@@ -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
......@@ -100,7 +100,7 @@ Foam::lagrangianFieldDecomposer::lagrangianFieldDecomposer
(
new passiveParticle
(
positions_,
procMesh,
ppi.position(),
procCelli,
false
......@@ -112,7 +112,7 @@ Foam::lagrangianFieldDecomposer::lagrangianFieldDecomposer
particleIndices_.setSize(pi);
IOPosition<passiveParticle>(positions_).write();
IOPosition<Cloud<passiveParticle> >(positions_).write();
}
......
......@@ -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
......@@ -24,8 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "MapLagrangianFields.H"
#include "Cloud.H"
#include "passiveParticle.H"
#include "passiveParticleCloud.H"
#include "meshSearch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -44,7 +43,9 @@ static label findCell(const Cloud<passiveParticle>& cloud, const point& pt)
label tetFaceI = -1;
label tetPtI = -1;
cloud.findCellFacePt(pt, cellI, tetFaceI, tetPtI);
const polyMesh& mesh = cloud.pMesh();
mesh.findCellFacePt(pt, cellI, tetFaceI, tetPtI);
if (cellI >= 0)
{
......@@ -55,8 +56,6 @@ static label findCell(const Cloud<passiveParticle>& cloud, const point& pt)
// See if particle on face by finding nearest face and shifting
// particle.
const polyMesh& mesh = cloud.pMesh();
meshSearch meshSearcher(mesh, false);
label faceI = meshSearcher.findNearestBoundaryFace(pt);
......@@ -67,7 +66,7 @@ static label findCell(const Cloud<passiveParticle>& cloud, const point& pt)
const point perturbPt = (1-perturbFactor)*pt+perturbFactor*cc;
cloud.findCellFacePt(perturbPt, cellI, tetFaceI, tetPtI);
mesh.findCellFacePt(perturbPt, cellI, tetFaceI, tetPtI);
return cellI;
}
......@@ -124,7 +123,7 @@ void mapLagrangian(const meshToMesh& meshToMeshInterp)
Info<< nl << " processing cloud " << cloudDirs[cloudI] << endl;
// Read positions & cell
Cloud<passiveParticle> sourceParcels
passiveParticleCloud sourceParcels
(
meshSource,
cloudDirs[cloudI],
......@@ -134,13 +133,15 @@ void mapLagrangian(const meshToMesh& meshToMeshInterp)
<< " parcels from source mesh." << endl;
// Construct empty target cloud
Cloud<passiveParticle> targetParcels
passiveParticleCloud targetParcels
(
meshTarget,
cloudDirs[cloudI],
IDLList<passiveParticle>()
);
particle::TrackingData<passiveParticleCloud> td(targetParcels);
label sourceParticleI = 0;
// Indices of source particles that get added to targetParcels
......@@ -176,15 +177,14 @@ void mapLagrangian(const meshToMesh& meshToMeshInterp)
(
new passiveParticle
(
targetParcels,
meshTarget,
targetCc[targetCells[i]],
targetCells[i]
)
);
passiveParticle& newP = newPtr();
scalar fraction = 0;
label faceI = newP.track(iter().position(), fraction);
label faceI = newP.track(iter().position(), td);
if (faceI < 0 && newP.cell() >= 0)
{
......@@ -246,7 +246,7 @@ void mapLagrangian(const meshToMesh& meshToMeshInterp)
if (addParticles.size())
{
IOPosition<passiveParticle>(targetParcels).write();
IOPosition<passiveParticleCloud>(targetParcels).write();
// addParticles now contains the indices of the sourceMesh
// particles that were appended to the target mesh.
......
......@@ -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
......@@ -283,7 +283,7 @@ Foam::label Foam::meshRefinement::markFeatureRefinement
label tetFaceI = -1;
label tetPtI = -1;
cloud.findCellFacePt(keepPoint, cellI, tetFaceI, tetPtI);
mesh_.findCellFacePt(keepPoint, cellI, tetFaceI, tetPtI);
if (cellI != -1)
{
......@@ -309,7 +309,7 @@ Foam::label Foam::meshRefinement::markFeatureRefinement
(
new trackedParticle
(
cloud,
mesh_,
keepPoint,
cellI,
tetFaceI,
......@@ -330,7 +330,7 @@ Foam::label Foam::meshRefinement::markFeatureRefinement
labelList maxFeatureLevel(mesh_.nCells(), -1);
// Database to pass into trackedParticle::move
trackedParticle::trackData td(cloud, maxFeatureLevel);
trackedParticle::trackingData td(cloud, maxFeatureLevel);
// Track all particles to their end position (= starting feature point)
cloud.move(td, GREAT);
......
......@@ -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
......@@ -29,7 +29,7 @@ License
Foam::trackedParticle::trackedParticle
(
const Cloud<trackedParticle>& c,
const polyMesh& mesh,
const vector& position,
const label cellI,
const label tetFaceI,
......@@ -40,7 +40,7 @@ Foam::trackedParticle::trackedParticle
const label j
)
:
Particle<trackedParticle>(c, position, cellI, tetFaceI, tetPtI),
particle(mesh, position, cellI, tetFaceI, tetPtI),
end_(end),
level_(level),
i_(i),
......@@ -50,12 +50,12 @@ Foam::trackedParticle::trackedParticle
Foam::trackedParticle::trackedParticle
(
const Cloud<trackedParticle>& c,
const polyMesh& mesh,
Istream& is,
bool readFields
)
:
Particle<trackedParticle>(c, is, readFields)
particle(mesh, is, readFields)
{
if (readFields)
{
......@@ -89,7 +89,7 @@ Foam::trackedParticle::trackedParticle
bool Foam::trackedParticle::move
(
trackedParticle::trackData& td,
trackingData& td,
const scalar trackedParticle
)
{
......@@ -120,7 +120,7 @@ bool Foam::trackedParticle::move
bool Foam::trackedParticle::hitPatch
(
const polyPatch&,
trackedParticle::trackData& td,
trackingData& td,
const label patchI,
const scalar trackFraction,
const tetIndices& tetIs
......@@ -130,23 +130,10 @@ bool Foam::trackedParticle::hitPatch
}
bool Foam::trackedParticle::hitPatch
(
const polyPatch&,
int&,
const label,
const scalar trackFraction,
const tetIndices& tetIs
)
{
return false;
}
void Foam::trackedParticle::hitWedgePatch
(
const wedgePolyPatch&,
trackedParticle::trackData& td
trackingData& td
)
{
// Remove particle
......@@ -154,18 +141,10 @@ void Foam::trackedParticle::hitWedgePatch
}
void Foam::trackedParticle::hitWedgePatch
(
const wedgePolyPatch&,
int&
)
{}
void Foam::trackedParticle::hitSymmetryPatch
(
const symmetryPolyPatch&,
trackedParticle::trackData& td
trackingData& td
)
{
// Remove particle
......@@ -173,18 +152,10 @@ void Foam::trackedParticle::hitSymmetryPatch
}
void Foam::trackedParticle::hitSymmetryPatch
(
const symmetryPolyPatch&,
int&
)
{}
void Foam::trackedParticle::hitCyclicPatch
(
const cyclicPolyPatch&,
trackedParticle::trackData& td
trackingData& td
)
{
// Remove particle
......@@ -192,18 +163,10 @@ void Foam::trackedParticle::hitCyclicPatch
}
void Foam::trackedParticle::hitCyclicPatch
(
const cyclicPolyPatch&,
int&
)
{}
void Foam::trackedParticle::hitProcessorPatch
(
const processorPolyPatch&,
trackedParticle::trackData& td
trackingData& td
)
{
// Remove particle
......@@ -211,18 +174,10 @@ void Foam::trackedParticle::hitProcessorPatch
}
void Foam::trackedParticle::hitProcessorPatch
(
const processorPolyPatch&,
int&
)
{}
void Foam::trackedParticle::hitWallPatch
(
const wallPolyPatch& wpp,
trackedParticle::trackData& td,
trackingData& td,
const tetIndices&
)
{
......@@ -231,19 +186,10 @@ void Foam::trackedParticle::hitWallPatch
}
void Foam::trackedParticle::hitWallPatch
(
const wallPolyPatch& wpp,
int&,
const tetIndices&
)
{}
void Foam::trackedParticle::hitPatch
(
const polyPatch& wpp,
trackedParticle::trackData& td
trackingData& td
)
{
// Remove particle
......@@ -251,21 +197,13 @@ void Foam::trackedParticle::hitPatch
}
void Foam::trackedParticle::hitPatch
(
const polyPatch& wpp,
int&
)
{}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<(Ostream& os, const trackedParticle& p)
{
if (os.format() == IOstream::ASCII)
{
os << static_cast<const Particle<trackedParticle>&>(p)
os << static_cast<const particle&>(p)
<< token::SPACE << p.end_
<< token::SPACE << p.level_
<< token::SPACE << p.i_
......@@ -273,7 +211,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const trackedParticle& p)
}
else
{
os << static_cast<const Particle<trackedParticle>&>(p);
os << static_cast<const particle&>(p);
os.write
(
reinterpret_cast<const char*>(&p.end_),
......
......@@ -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 trackedParticle_H
#define trackedParticle_H
#include "Particle.H"
#include "particle.H"
#include "autoPtr.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -52,7 +52,7 @@ class trackedParticleCloud;
class trackedParticle
:
public Particle<trackedParticle>
public particle
{
// Private data
......@@ -74,35 +74,26 @@ public:
friend class Cloud<trackedParticle>;
//- Class used to pass tracking data to the trackToFace function
class trackData
class trackingData
:
public particle::TrackingData<Cloud<trackedParticle> >
{
//- Reference to the cloud containing this particle
Cloud<trackedParticle>& cloud_;
labelList& maxLevel_;
public:
bool switchProcessor;
bool keepParticle;
// Constructors
trackData(Cloud<trackedParticle>& cloud, labelList& maxLevel)
trackingData(Cloud<trackedParticle>& cloud, labelList& maxLevel)
:
cloud_(cloud),
particle::TrackingData<Cloud<trackedParticle> >(cloud),
maxLevel_(maxLevel)
{}
// Member functions
Cloud<trackedParticle>& cloud()
{
return cloud_;
}
labelList& maxLevel()
{
return maxLevel_;
......@@ -116,7 +107,7 @@ public:
//- Construct from components
trackedParticle
(
const Cloud<trackedParticle>& c,
const polyMesh& mesh,
const vector& position,
const label cellI,
const label tetFaceI,
......@@ -130,20 +121,39 @@ public:
//- Construct from Istream
trackedParticle
(
const Cloud<trackedParticle>& c,
const polyMesh& mesh,
Istream& is,
bool readFields = true
);
//- Construct and return a clone
autoPtr<Particle<trackedParticle> > clone() const
autoPtr<particle> clone() const
{
return autoPtr<Particle<trackedParticle> >
(
new trackedParticle(*this)
);
return autoPtr<particle>(new trackedParticle(*this));
}
//- Factory class to read-construct particles used for
// parallel transfer
class iNew
{
const polyMesh& mesh_;
public:
iNew(const polyMesh& mesh)
:
mesh_(mesh)
{}
autoPtr<trackedParticle> operator()(Istream& is) const
{
return autoPtr<trackedParticle>
(
new trackedParticle(mesh_, is, true)
);
}
};
// Member Functions
......@@ -170,7 +180,7 @@ public:
// Tracking
//- Track all particles to their end point
bool move(trackData&, const scalar);
bool move(trackingData&, const scalar);
//- Overridable function to handle the particle hitting a patch
......@@ -178,30 +188,17 @@ public:
bool hitPatch
(
const polyPatch&,
trackedParticle::trackData& td,
trackingData& td,
const label patchI,
const scalar trackFraction,
const tetIndices& tetIs
);
bool hitPatch
(
const polyPatch&,
int&,
const label patchI,
const scalar trackFraction,
const tetIndices& tetIs
);
//- Overridable function to handle the particle hitting a wedge
void hitWedgePatch
(
const wedgePolyPatch&,
trackedParticle::trackData& td
);
void hitWedgePatch
(
const wedgePolyPatch&,
int&
trackingData& td
);
//- Overridable function to handle the particle hitting a
......@@ -209,24 +206,14 @@ public:
void hitSymmetryPatch
(
const symmetryPolyPatch&,
trackedParticle::trackData& td
);
void hitSymmetryPatch
(
const symmetryPolyPatch&,
int&
trackingData& td
);
//- Overridable function to handle the particle hitting a cyclic
void hitCyclicPatch
(
const cyclicPolyPatch&,
trackedParticle::trackData& td
);
void hitCyclicPatch
(
const cyclicPolyPatch&,
int&
trackingData& td
);
//- Overridable function to handle the particle hitting a
......@@ -234,25 +221,14 @@ public:
void hitProcessorPatch
(
const processorPolyPatch&,
trackedParticle::trackData& td
);
void hitProcessorPatch
(
const processorPolyPatch&,
int&
trackingData& td
);
//- Overridable function to handle the particle hitting a wallPatch
void hitWallPatch
(
const wallPolyPatch&,
trackedParticle::trackData& td,
const tetIndices&
);
void hitWallPatch
(
const wallPolyPatch&,
int&,
trackingData& td,
const tetIndices&
);
......@@ -260,20 +236,13 @@ public:
void hitPatch
(
const polyPatch&,
trackedParticle::trackData& td
);
void hitPatch
(
const polyPatch&,
int&
trackingData& td
);
// Ostream Operator
friend Ostream& operator<<(Ostream&, const trackedParticle&);
};
......