mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
BUG: redistributePar: transfer particles correctly. Fixes #605.
This commit is contained in:
@ -1,3 +1,4 @@
|
|||||||
|
passivePositionParticleCloud.C
|
||||||
parLagrangianRedistributor.C
|
parLagrangianRedistributor.C
|
||||||
parFvFieldReconstructor.C
|
parFvFieldReconstructor.C
|
||||||
loadOrCreateMesh.C
|
loadOrCreateMesh.C
|
||||||
|
|||||||
@ -25,7 +25,7 @@ License
|
|||||||
|
|
||||||
#include "ListOps.H"
|
#include "ListOps.H"
|
||||||
#include "parLagrangianRedistributor.H"
|
#include "parLagrangianRedistributor.H"
|
||||||
#include "passiveParticleCloud.H"
|
#include "passivePositionParticleCloud.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -133,7 +133,7 @@ void Foam::parLagrangianRedistributor::findClouds
|
|||||||
Foam::autoPtr<Foam::mapDistributeBase>
|
Foam::autoPtr<Foam::mapDistributeBase>
|
||||||
Foam::parLagrangianRedistributor::redistributeLagrangianPositions
|
Foam::parLagrangianRedistributor::redistributeLagrangianPositions
|
||||||
(
|
(
|
||||||
passiveParticleCloud& lpi
|
passivePositionParticleCloud& lpi
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
//Debug(lpi.size());
|
//Debug(lpi.size());
|
||||||
@ -147,7 +147,7 @@ Foam::parLagrangianRedistributor::redistributeLagrangianPositions
|
|||||||
{
|
{
|
||||||
// List of lists of particles to be transferred for all of the
|
// List of lists of particles to be transferred for all of the
|
||||||
// neighbour processors
|
// neighbour processors
|
||||||
List<IDLList<passiveParticle>> particleTransferLists
|
List<IDLList<passivePositionParticle>> particleTransferLists
|
||||||
(
|
(
|
||||||
Pstream::nProcs()
|
Pstream::nProcs()
|
||||||
);
|
);
|
||||||
@ -156,17 +156,15 @@ Foam::parLagrangianRedistributor::redistributeLagrangianPositions
|
|||||||
labelList destProc(lpi.size());
|
labelList destProc(lpi.size());
|
||||||
|
|
||||||
label particleI = 0;
|
label particleI = 0;
|
||||||
forAllIter(passiveParticleCloud, lpi, iter)
|
forAllIter(passivePositionParticleCloud, lpi, iter)
|
||||||
{
|
{
|
||||||
passiveParticle& ppi = iter();
|
passivePositionParticle& ppi = iter();
|
||||||
|
|
||||||
label destProcI = destinationProcID_[ppi.cell()];
|
label destProcI = destinationProcID_[ppi.cell()];
|
||||||
label destCellI = destinationCell_[ppi.cell()];
|
label destCellI = destinationCell_[ppi.cell()];
|
||||||
|
|
||||||
ppi.cell() = destCellI;
|
ppi.cell() = destCellI;
|
||||||
destProc[particleI++] = destProcI;
|
destProc[particleI++] = destProcI;
|
||||||
//Pout<< "Sending particle:" << ppi << " to processor " << destProcI
|
|
||||||
// << " to cell " << destCellI << endl;
|
|
||||||
particleTransferLists[destProcI].append(lpi.remove(&ppi));
|
particleTransferLists[destProcI].append(lpi.remove(&ppi));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,11 +200,11 @@ Foam::parLagrangianRedistributor::redistributeLagrangianPositions
|
|||||||
lpi.rename(cloudName + "_old");
|
lpi.rename(cloudName + "_old");
|
||||||
|
|
||||||
// New cloud on tgtMesh
|
// New cloud on tgtMesh
|
||||||
passiveParticleCloud lagrangianPositions
|
passivePositionParticleCloud lagrangianPositions
|
||||||
(
|
(
|
||||||
tgtMesh_,
|
tgtMesh_,
|
||||||
cloudName,
|
cloudName,
|
||||||
IDLList<passiveParticle>()
|
IDLList<passivePositionParticle>()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@ -222,32 +220,28 @@ Foam::parLagrangianRedistributor::redistributeLagrangianPositions
|
|||||||
{
|
{
|
||||||
UIPstream particleStream(procI, pBufs);
|
UIPstream particleStream(procI, pBufs);
|
||||||
|
|
||||||
IDLList<passiveParticle> newParticles
|
// Receive particles and locate them
|
||||||
|
IDLList<passivePositionParticle> newParticles
|
||||||
(
|
(
|
||||||
particleStream,
|
particleStream,
|
||||||
passiveParticle::iNew(tgtMesh_)
|
passivePositionParticle::iNew(tgtMesh_)
|
||||||
);
|
);
|
||||||
|
|
||||||
forAllIter
|
forAllIter
|
||||||
(
|
(
|
||||||
IDLList<passiveParticle>,
|
IDLList<passivePositionParticle>,
|
||||||
newParticles,
|
newParticles,
|
||||||
newpIter
|
newpIter
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
passiveParticle& newp = newpIter();
|
passivePositionParticle& newp = newpIter();
|
||||||
newp.relocate();
|
|
||||||
|
|
||||||
lagrangianPositions.addParticle(newParticles.remove(&newp));
|
lagrangianPositions.addParticle(newParticles.remove(&newp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//OFstream::debug = 1;
|
IOPosition<passivePositionParticleCloud>(lagrangianPositions).write();
|
||||||
//Debug(lagrangianPositions.size());
|
|
||||||
IOPosition<passiveParticleCloud>(lagrangianPositions).write();
|
|
||||||
//OFstream::debug = 0;
|
|
||||||
|
|
||||||
// Restore cloud name
|
// Restore cloud name
|
||||||
lpi.rename(cloudName);
|
lpi.rename(cloudName);
|
||||||
@ -300,7 +294,7 @@ Foam::parLagrangianRedistributor::redistributeLagrangianPositions
|
|||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
// Load cloud and send particle
|
// Load cloud and send particle
|
||||||
passiveParticleCloud lpi(srcMesh_, cloudName, false);
|
passivePositionParticleCloud lpi(srcMesh_, cloudName, false);
|
||||||
|
|
||||||
return redistributeLagrangianPositions(lpi);
|
return redistributeLagrangianPositions(lpi);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -49,7 +49,7 @@ namespace Foam
|
|||||||
class mapDistributePolyMesh;
|
class mapDistributePolyMesh;
|
||||||
class mapDistributeBase;
|
class mapDistributeBase;
|
||||||
class IOobjectList;
|
class IOobjectList;
|
||||||
class passiveParticleCloud;
|
class passivePositionParticleCloud;
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class parLagrangianRedistributor Declaration
|
Class parLagrangianRedistributor Declaration
|
||||||
@ -112,7 +112,7 @@ public:
|
|||||||
//- Redistribute and write lagrangian positions
|
//- Redistribute and write lagrangian positions
|
||||||
autoPtr<mapDistributeBase> redistributeLagrangianPositions
|
autoPtr<mapDistributeBase> redistributeLagrangianPositions
|
||||||
(
|
(
|
||||||
passiveParticleCloud& cloud
|
passivePositionParticleCloud& cloud
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Read, redistribute and write lagrangian positions
|
//- Read, redistribute and write lagrangian positions
|
||||||
@ -153,7 +153,7 @@ public:
|
|||||||
template<class Container>
|
template<class Container>
|
||||||
static void readLagrangianFields
|
static void readLagrangianFields
|
||||||
(
|
(
|
||||||
const passiveParticleCloud& cloud,
|
const passivePositionParticleCloud& cloud,
|
||||||
const IOobjectList& objects,
|
const IOobjectList& objects,
|
||||||
const HashSet<word>& selectedFields
|
const HashSet<word>& selectedFields
|
||||||
);
|
);
|
||||||
@ -163,7 +163,7 @@ public:
|
|||||||
void redistributeStoredLagrangianFields
|
void redistributeStoredLagrangianFields
|
||||||
(
|
(
|
||||||
const mapDistributeBase& map,
|
const mapDistributeBase& map,
|
||||||
passiveParticleCloud& cloud
|
passivePositionParticleCloud& cloud
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -29,7 +29,7 @@ License
|
|||||||
#include "mapDistributePolyMesh.H"
|
#include "mapDistributePolyMesh.H"
|
||||||
#include "cloud.H"
|
#include "cloud.H"
|
||||||
#include "CompactIOField.H"
|
#include "CompactIOField.H"
|
||||||
#include "passiveParticleCloud.H"
|
#include "passivePositionParticleCloud.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -223,7 +223,7 @@ void Foam::parLagrangianRedistributor::redistributeLagrangianFieldFields
|
|||||||
template<class Container>
|
template<class Container>
|
||||||
void Foam::parLagrangianRedistributor::readLagrangianFields
|
void Foam::parLagrangianRedistributor::readLagrangianFields
|
||||||
(
|
(
|
||||||
const passiveParticleCloud& cloud,
|
const passivePositionParticleCloud& cloud,
|
||||||
const IOobjectList& objects,
|
const IOobjectList& objects,
|
||||||
const HashSet<word>& selectedFields
|
const HashSet<word>& selectedFields
|
||||||
)
|
)
|
||||||
@ -272,7 +272,7 @@ template<class Container>
|
|||||||
void Foam::parLagrangianRedistributor::redistributeStoredLagrangianFields
|
void Foam::parLagrangianRedistributor::redistributeStoredLagrangianFields
|
||||||
(
|
(
|
||||||
const mapDistributeBase& map,
|
const mapDistributeBase& map,
|
||||||
passiveParticleCloud& cloud
|
passivePositionParticleCloud& cloud
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
HashTable<Container*> fields
|
HashTable<Container*> fields
|
||||||
|
|||||||
@ -0,0 +1,183 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2017 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::passivePositionParticle
|
||||||
|
|
||||||
|
Description
|
||||||
|
Passive particle, transferring in old format (i.e. position instead of
|
||||||
|
coordinates). Used for e.g. redistributePar.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
passivePositionParticle.H
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef passivePositionParticle_H
|
||||||
|
#define passivePositionParticle_H
|
||||||
|
|
||||||
|
#include "passiveParticle.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class passivePositionParticle Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class passivePositionParticle
|
||||||
|
:
|
||||||
|
public passiveParticle
|
||||||
|
{
|
||||||
|
// Private member data
|
||||||
|
|
||||||
|
//- Cached position
|
||||||
|
point position_;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from Istream in old format
|
||||||
|
passivePositionParticle
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream& is,
|
||||||
|
bool readFields,
|
||||||
|
bool newFormat
|
||||||
|
)
|
||||||
|
:
|
||||||
|
passiveParticle(mesh, is, readFields, newFormat),
|
||||||
|
position_(position())
|
||||||
|
{}
|
||||||
|
|
||||||
|
//- Construct as copy
|
||||||
|
passivePositionParticle(const passivePositionParticle& p)
|
||||||
|
:
|
||||||
|
passiveParticle(p),
|
||||||
|
position_(p.position_)
|
||||||
|
{}
|
||||||
|
|
||||||
|
//- Construct and return a clone
|
||||||
|
virtual autoPtr<particle> clone() const
|
||||||
|
{
|
||||||
|
return autoPtr<particle>(new passivePositionParticle(*this));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//- Factory class to read-construct particles used for
|
||||||
|
// parallel transfer
|
||||||
|
class iNew
|
||||||
|
{
|
||||||
|
const polyMesh& mesh_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
iNew(const polyMesh& mesh)
|
||||||
|
:
|
||||||
|
mesh_(mesh)
|
||||||
|
{}
|
||||||
|
|
||||||
|
autoPtr<passivePositionParticle> operator()(Istream& is) const
|
||||||
|
{
|
||||||
|
return autoPtr<passivePositionParticle>
|
||||||
|
(
|
||||||
|
// Read in old format
|
||||||
|
new passivePositionParticle(mesh_, is, true, false)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Friend Operators
|
||||||
|
|
||||||
|
friend Ostream& operator<<
|
||||||
|
(
|
||||||
|
Ostream& os,
|
||||||
|
const passivePositionParticle& ppi
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// Copy data into old format structure. Exact opposite of
|
||||||
|
// particleIO.C reading old format.
|
||||||
|
struct oldParticle
|
||||||
|
{
|
||||||
|
vector position;
|
||||||
|
label celli;
|
||||||
|
label facei;
|
||||||
|
scalar stepFraction;
|
||||||
|
label tetFacei;
|
||||||
|
label tetPti;
|
||||||
|
label origProc;
|
||||||
|
label origId;
|
||||||
|
} p;
|
||||||
|
|
||||||
|
p.position = ppi.position_;
|
||||||
|
p.celli = ppi.cell();
|
||||||
|
p.facei = ppi.face();
|
||||||
|
p.stepFraction = ppi.stepFraction();
|
||||||
|
p.tetFacei = ppi.tetFace();
|
||||||
|
p.tetPti = ppi.tetPt();
|
||||||
|
p.origProc = ppi.origProc();
|
||||||
|
p.origId = ppi.origId();
|
||||||
|
|
||||||
|
if (os.format() == IOstream::ASCII)
|
||||||
|
{
|
||||||
|
os << p.position
|
||||||
|
<< token::SPACE << p.celli
|
||||||
|
<< token::SPACE << p.facei
|
||||||
|
<< token::SPACE << p.stepFraction
|
||||||
|
<< token::SPACE << p.tetFacei
|
||||||
|
<< token::SPACE << p.tetPti
|
||||||
|
<< token::SPACE << p.origProc
|
||||||
|
<< token::SPACE << p.origId;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const std::size_t sizeofFields
|
||||||
|
(
|
||||||
|
sizeof(oldParticle) - offsetof(oldParticle, position)
|
||||||
|
);
|
||||||
|
|
||||||
|
os.write
|
||||||
|
(
|
||||||
|
reinterpret_cast<const char*>(&p.position),
|
||||||
|
sizeofFields
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,64 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2017 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 "passivePositionParticleCloud.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
defineTemplateTypeNameAndDebug(Cloud<passivePositionParticle>, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::passivePositionParticleCloud::passivePositionParticleCloud
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const word& cloudName,
|
||||||
|
bool readFields
|
||||||
|
)
|
||||||
|
:
|
||||||
|
Cloud<passivePositionParticle>(mesh, cloudName, false)
|
||||||
|
{
|
||||||
|
if (readFields)
|
||||||
|
{
|
||||||
|
passivePositionParticle::readFields(*this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::passivePositionParticleCloud::passivePositionParticleCloud
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const word& cloudName,
|
||||||
|
const IDLList<passivePositionParticle>& particles
|
||||||
|
)
|
||||||
|
:
|
||||||
|
Cloud<passivePositionParticle>(mesh, cloudName, particles)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,93 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2017 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::passivePositionParticleCloud
|
||||||
|
|
||||||
|
Description
|
||||||
|
A Cloud of passive position particles
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
passivePositionParticleCloud.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef passivePositionParticleCloud_H
|
||||||
|
#define passivePositionParticleCloud_H
|
||||||
|
|
||||||
|
#include "Cloud.H"
|
||||||
|
#include "passivePositionParticle.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class passivePositionParticleCloud Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class passivePositionParticleCloud
|
||||||
|
:
|
||||||
|
public Cloud<passivePositionParticle>
|
||||||
|
{
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
passivePositionParticleCloud(const passivePositionParticleCloud&);
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const passivePositionParticleCloud&);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct given mesh
|
||||||
|
passivePositionParticleCloud
|
||||||
|
(
|
||||||
|
const polyMesh&,
|
||||||
|
const word& cloudName = "defaultCloud",
|
||||||
|
bool readFields = true
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from mesh, cloud name, and a list of particles
|
||||||
|
passivePositionParticleCloud
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const word& cloudName,
|
||||||
|
const IDLList<passivePositionParticle>& particles
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -80,7 +80,7 @@ Usage
|
|||||||
|
|
||||||
#include "parFvFieldReconstructor.H"
|
#include "parFvFieldReconstructor.H"
|
||||||
#include "parLagrangianRedistributor.H"
|
#include "parLagrangianRedistributor.H"
|
||||||
#include "unmappedPassiveParticleCloud.H"
|
#include "unmappedPassivePositionParticleCloud.H"
|
||||||
#include "hexRef8Data.H"
|
#include "hexRef8Data.H"
|
||||||
#include "meshRefinement.H"
|
#include "meshRefinement.H"
|
||||||
#include "pointFields.H"
|
#include "pointFields.H"
|
||||||
@ -1908,7 +1908,7 @@ void readLagrangian
|
|||||||
const fvMesh& mesh,
|
const fvMesh& mesh,
|
||||||
const wordList& cloudNames,
|
const wordList& cloudNames,
|
||||||
const HashSet<word>& selectedLagrangianFields,
|
const HashSet<word>& selectedLagrangianFields,
|
||||||
PtrList<unmappedPassiveParticleCloud>& clouds
|
PtrList<unmappedPassivePositionParticleCloud>& clouds
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
(void)mesh.tetBasePtIs();
|
(void)mesh.tetBasePtIs();
|
||||||
@ -1919,13 +1919,13 @@ void readLagrangian
|
|||||||
clouds.set
|
clouds.set
|
||||||
(
|
(
|
||||||
i,
|
i,
|
||||||
new unmappedPassiveParticleCloud(mesh, cloudNames[i], false)
|
new unmappedPassivePositionParticleCloud(mesh, cloudNames[i], false)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
//forAllConstIter
|
//forAllConstIter
|
||||||
//(
|
//(
|
||||||
// unmappedPassiveParticleCloud,
|
// unmappedPassivePositionParticleCloud,
|
||||||
// clouds[i],
|
// clouds[i],
|
||||||
// iter
|
// iter
|
||||||
//)
|
//)
|
||||||
@ -2087,7 +2087,7 @@ void redistributeLagrangian
|
|||||||
const fvMesh& mesh,
|
const fvMesh& mesh,
|
||||||
const label nOldCells,
|
const label nOldCells,
|
||||||
const mapDistributePolyMesh& distMap,
|
const mapDistributePolyMesh& distMap,
|
||||||
PtrList<unmappedPassiveParticleCloud>& clouds
|
PtrList<unmappedPassivePositionParticleCloud>& clouds
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (clouds.size())
|
if (clouds.size())
|
||||||
@ -2958,7 +2958,7 @@ int main(int argc, char *argv[])
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Read lagrangian fields and store on cloud (objectRegistry)
|
// Read lagrangian fields and store on cloud (objectRegistry)
|
||||||
PtrList<unmappedPassiveParticleCloud> clouds(cloudNames.size());
|
PtrList<unmappedPassivePositionParticleCloud> clouds(cloudNames.size());
|
||||||
readLagrangian
|
readLagrangian
|
||||||
(
|
(
|
||||||
mesh,
|
mesh,
|
||||||
|
|||||||
@ -22,21 +22,21 @@ License
|
|||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
Class
|
Class
|
||||||
Foam::unmappedPassiveParticleCloud
|
Foam::unmappedPassivePositionParticleCloud
|
||||||
|
|
||||||
Description
|
Description
|
||||||
passiveParticleCloud but with autoMap and writing disabled. Only used
|
passivePositionParticleCloud but with autoMap and writing disabled.
|
||||||
for its objectRegistry to store lagrangian fields
|
Only used for its objectRegistry to store lagrangian fields
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
unmappedPassiveParticleCloud.C
|
unmappedPassivePositionParticleCloud.C
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef unmappedPassiveParticleCloud_H
|
#ifndef unmappedPassivePositionParticleCloud_H
|
||||||
#define unmappedPassiveParticleCloud_H
|
#define unmappedPassivePositionParticleCloud_H
|
||||||
|
|
||||||
#include "passiveParticleCloud.H"
|
#include "passivePositionParticleCloud.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -47,9 +47,9 @@ namespace Foam
|
|||||||
Class unmappedPassiveParticleCloud Declaration
|
Class unmappedPassiveParticleCloud Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
class unmappedPassiveParticleCloud
|
class unmappedPassivePositionParticleCloud
|
||||||
:
|
:
|
||||||
public passiveParticleCloud
|
public passivePositionParticleCloud
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -57,29 +57,29 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct given mesh
|
//- Construct given mesh
|
||||||
unmappedPassiveParticleCloud
|
unmappedPassivePositionParticleCloud
|
||||||
(
|
(
|
||||||
const polyMesh& mesh,
|
const polyMesh& mesh,
|
||||||
const word& cloudName = "defaultCloud",
|
const word& cloudName = "defaultCloud",
|
||||||
bool readFields = true
|
bool readFields = true
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
passiveParticleCloud(mesh, cloudName, readFields)
|
passivePositionParticleCloud(mesh, cloudName, readFields)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//- Construct from mesh, cloud name, and a list of particles
|
//- Construct from mesh, cloud name, and a list of particles
|
||||||
unmappedPassiveParticleCloud
|
unmappedPassivePositionParticleCloud
|
||||||
(
|
(
|
||||||
const polyMesh& mesh,
|
const polyMesh& mesh,
|
||||||
const word& cloudName,
|
const word& cloudName,
|
||||||
const IDLList<passiveParticle>& particles
|
const IDLList<passivePositionParticle>& particles
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
passiveParticleCloud(mesh, cloudName, particles)
|
passivePositionParticleCloud(mesh, cloudName, particles)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
virtual ~unmappedPassiveParticleCloud()
|
virtual ~unmappedPassivePositionParticleCloud()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//- Switch off remapping of cells of particles when
|
//- Switch off remapping of cells of particles when
|
||||||
@ -98,7 +98,6 @@ public:
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -512,7 +512,10 @@ void Foam::particle::locate
|
|||||||
// We hit a boundary ...
|
// We hit a boundary ...
|
||||||
if (boundaryFail)
|
if (boundaryFail)
|
||||||
{
|
{
|
||||||
FatalErrorInFunction << boundaryMsg << exit(FatalError);
|
FatalErrorInFunction << boundaryMsg
|
||||||
|
<< " when tracking from centre " << mesh_.cellCentres()[celli_]
|
||||||
|
<< " of cell " << celli_ << " to position " << position
|
||||||
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1210,11 +1213,11 @@ void Foam::particle::autoMap
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::particle::relocate()
|
void Foam::particle::relocate(const point& position)
|
||||||
{
|
{
|
||||||
locate
|
locate
|
||||||
(
|
(
|
||||||
position(),
|
position,
|
||||||
nullptr,
|
nullptr,
|
||||||
celli_,
|
celli_,
|
||||||
true,
|
true,
|
||||||
|
|||||||
@ -662,9 +662,9 @@ public:
|
|||||||
//- Map after a topology change
|
//- Map after a topology change
|
||||||
void autoMap(const vector& position, const mapPolyMesh& mapper);
|
void autoMap(const vector& position, const mapPolyMesh& mapper);
|
||||||
|
|
||||||
//- Set the addressing based on the current position and cell
|
//- Set the addressing based on the provided position and current cell
|
||||||
// Used for e.g. redistributePar
|
// Used for e.g. redistributePar
|
||||||
void relocate();
|
void relocate(const point& position);
|
||||||
|
|
||||||
|
|
||||||
// I-O
|
// I-O
|
||||||
|
|||||||
@ -114,17 +114,20 @@ Foam::particle::particle
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const size_t s =
|
|
||||||
offsetof(oldParticle, facei) - offsetof(oldParticle, position);
|
|
||||||
|
|
||||||
is.read(reinterpret_cast<char*>(&p.position), s);
|
|
||||||
|
|
||||||
if (readFields)
|
if (readFields)
|
||||||
{
|
{
|
||||||
|
// Read whole struct
|
||||||
const size_t s =
|
const size_t s =
|
||||||
sizeof(oldParticle) - offsetof(oldParticle, facei);
|
sizeof(oldParticle) - offsetof(oldParticle, position);
|
||||||
|
is.read(reinterpret_cast<char*>(&p.position), s);
|
||||||
is.read(reinterpret_cast<char*>(&p.facei), s);
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Read only position and cell
|
||||||
|
const size_t s =
|
||||||
|
offsetof(oldParticle, facei)
|
||||||
|
- offsetof(oldParticle, position);
|
||||||
|
is.read(reinterpret_cast<char*>(&p.position), s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user