STYLE: consistency update

- handling of cloud coordinates/positions between mapFields, mapFieldsPar
This commit is contained in:
Mark Olesen
2018-09-19 23:11:31 +02:00
parent eda13117e4
commit 39c1fbedcd
2 changed files with 50 additions and 48 deletions

View File

@ -3,7 +3,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) 2011-2017 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -85,13 +85,13 @@ void mapLagrangian(const meshToMesh0& meshToMesh0Interp)
// Determine which particles are in meshTarget // Determine which particles are in meshTarget
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// target to source cell map // Target to source cell map
const labelList& cellAddressing = meshToMesh0Interp.cellAddressing(); const labelList& cellAddressing = meshToMesh0Interp.cellAddressing();
// Invert celladdressing to get source to target(s). // Invert celladdressing to get source to target(s).
// Note: could use sparse addressing but that is too storage inefficient // Note: could use sparse addressing but that is too storage inefficient
// (Map<labelList>) // (Map<labelList>)
labelListList sourceToTargets const labelListList sourceToTargets
( (
invertOneToMany(meshToMesh0Interp.fromMesh().nCells(), cellAddressing) invertOneToMany(meshToMesh0Interp.fromMesh().nCells(), cellAddressing)
); );
@ -99,8 +99,7 @@ void mapLagrangian(const meshToMesh0& meshToMesh0Interp)
const fvMesh& meshSource = meshToMesh0Interp.fromMesh(); const fvMesh& meshSource = meshToMesh0Interp.fromMesh();
const fvMesh& meshTarget = meshToMesh0Interp.toMesh(); const fvMesh& meshTarget = meshToMesh0Interp.toMesh();
const fileNameList cloudDirs
fileNameList cloudDirs
( (
readDir readDir
( (
@ -109,25 +108,26 @@ void mapLagrangian(const meshToMesh0& meshToMesh0Interp)
) )
); );
forAll(cloudDirs, cloudI) for (const fileName& cloudDir : cloudDirs)
{ {
// Search for list of lagrangian objects for this time // Search for list of lagrangian objects for this time
IOobjectList objects IOobjectList objects
( (
meshSource, meshSource,
meshSource.time().timeName(), meshSource.time().timeName(),
cloud::prefix/cloudDirs[cloudI] cloud::prefix/cloudDir
); );
if (objects.found("coordinates") || objects.found("positions")) if (objects.found("coordinates") || objects.found("positions"))
{ {
Info<< nl << " processing cloud " << cloudDirs[cloudI] << endl; // Has coordinates/positions - so must be a valid cloud
Info<< nl << " processing cloud " << cloudDir << endl;
// Read positions & cell // Read positions & cell
passiveParticleCloud sourceParcels passiveParticleCloud sourceParcels
( (
meshSource, meshSource,
cloudDirs[cloudI], cloudDir,
false false
); );
Info<< " read " << sourceParcels.size() Info<< " read " << sourceParcels.size()
@ -137,7 +137,7 @@ void mapLagrangian(const meshToMesh0& meshToMesh0Interp)
passiveParticleCloud targetParcels passiveParticleCloud targetParcels
( (
meshTarget, meshTarget,
cloudDirs[cloudI], cloudDir,
IDLList<passiveParticle>() IDLList<passiveParticle>()
); );
@ -157,7 +157,7 @@ void mapLagrangian(const meshToMesh0& meshToMesh0Interp)
// This requires there to be no boundary in the way. // This requires there to be no boundary in the way.
forAllConstIter(Cloud<passiveParticle>, sourceParcels, iter) forAllConstIters(sourceParcels, iter)
{ {
bool foundCell = false; bool foundCell = false;
@ -171,7 +171,7 @@ void mapLagrangian(const meshToMesh0& meshToMesh0Interp)
// all by tracking from their cell centre to the parcel // all by tracking from their cell centre to the parcel
// position. // position.
forAll(targetCells, i) for (const label targetCell : targetCells)
{ {
// Track from its cellcentre to position to make sure. // Track from its cellcentre to position to make sure.
autoPtr<passiveParticle> newPtr autoPtr<passiveParticle> newPtr
@ -180,8 +180,8 @@ void mapLagrangian(const meshToMesh0& meshToMesh0Interp)
( (
meshTarget, meshTarget,
barycentric(1, 0, 0, 0), barycentric(1, 0, 0, 0),
targetCells[i], targetCell,
meshTarget.cells()[targetCells[i]][0], meshTarget.cells()[targetCell][0],
1 1
) )
); );
@ -221,11 +221,11 @@ void mapLagrangian(const meshToMesh0& meshToMesh0Interp)
{ {
sourceParticleI = 0; sourceParticleI = 0;
forAllIter(Cloud<passiveParticle>, sourceParcels, iter) forAllIters(sourceParcels, iter)
{ {
if (unmappedSource.found(sourceParticleI)) if (unmappedSource.found(sourceParticleI))
{ {
label targetCell = const label targetCell =
findCell(targetParcels, iter().position()); findCell(targetParcels, iter().position());
if (targetCell >= 0) if (targetCell >= 0)
@ -263,17 +263,17 @@ void mapLagrangian(const meshToMesh0& meshToMesh0Interp)
// ~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~
MapLagrangianFields<label> MapLagrangianFields<label>
(cloudDirs[cloudI], objects, meshToMesh0Interp, addParticles); (cloudDir, objects, meshToMesh0Interp, addParticles);
MapLagrangianFields<scalar> MapLagrangianFields<scalar>
(cloudDirs[cloudI], objects, meshToMesh0Interp, addParticles); (cloudDir, objects, meshToMesh0Interp, addParticles);
MapLagrangianFields<vector> MapLagrangianFields<vector>
(cloudDirs[cloudI], objects, meshToMesh0Interp, addParticles); (cloudDir, objects, meshToMesh0Interp, addParticles);
MapLagrangianFields<sphericalTensor> MapLagrangianFields<sphericalTensor>
(cloudDirs[cloudI], objects, meshToMesh0Interp, addParticles); (cloudDir, objects, meshToMesh0Interp, addParticles);
MapLagrangianFields<symmTensor> MapLagrangianFields<symmTensor>
(cloudDirs[cloudI], objects, meshToMesh0Interp, addParticles); (cloudDir, objects, meshToMesh0Interp, addParticles);
MapLagrangianFields<tensor> MapLagrangianFields<tensor>
(cloudDirs[cloudI], objects, meshToMesh0Interp, addParticles); (cloudDir, objects, meshToMesh0Interp, addParticles);
} }
} }
} }

View File

@ -3,7 +3,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) 2011-2017 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -89,7 +89,7 @@ void mapLagrangian(const meshToMesh& interp)
const polyMesh& meshTarget = interp.tgtRegion(); const polyMesh& meshTarget = interp.tgtRegion();
const labelListList& sourceToTarget = interp.srcToTgtCellAddr(); const labelListList& sourceToTarget = interp.srcToTgtCellAddr();
fileNameList cloudDirs const fileNameList cloudDirs
( (
readDir readDir
( (
@ -98,31 +98,33 @@ void mapLagrangian(const meshToMesh& interp)
) )
); );
forAll(cloudDirs, cloudI) for (const fileName& cloudDir : cloudDirs)
{ {
// Search for list of lagrangian objects for this time // Search for list of lagrangian objects for this time
IOobjectList objects IOobjectList objects
( (
meshSource, meshSource,
meshSource.time().timeName(), meshSource.time().timeName(),
cloud::prefix/cloudDirs[cloudI] cloud::prefix/cloudDir
); );
bool foundPositions = if
returnReduce(objects.found("positions"), orOp<bool>());; (
returnReduce
bool foundCoordinates = (
returnReduce(objects.found("coordinates"), orOp<bool>());; (objects.found("coordinates") || objects.found("positions")),
orOp<bool>()
if (foundPositions || foundCoordinates) )
)
{ {
Info<< nl << " processing cloud " << cloudDirs[cloudI] << endl; // Has coordinates/positions - so must be a valid cloud
Info<< nl << " processing cloud " << cloudDir << endl;
// Read positions & cell // Read positions & cell
passiveParticleCloud sourceParcels passiveParticleCloud sourceParcels
( (
meshSource, meshSource,
cloudDirs[cloudI], cloudDir,
false false
); );
Info<< " read " << sourceParcels.size() Info<< " read " << sourceParcels.size()
@ -132,7 +134,7 @@ void mapLagrangian(const meshToMesh& interp)
passiveParticleCloud targetParcels passiveParticleCloud targetParcels
( (
meshTarget, meshTarget,
cloudDirs[cloudI], cloudDir,
IDLList<passiveParticle>() IDLList<passiveParticle>()
); );
@ -152,7 +154,7 @@ void mapLagrangian(const meshToMesh& interp)
// This requires there to be no boundary in the way. // This requires there to be no boundary in the way.
forAllConstIter(Cloud<passiveParticle>, sourceParcels, iter) forAllConstIters(sourceParcels, iter)
{ {
bool foundCell = false; bool foundCell = false;
@ -166,7 +168,7 @@ void mapLagrangian(const meshToMesh& interp)
// all by tracking from their cell centre to the parcel // all by tracking from their cell centre to the parcel
// position. // position.
forAll(targetCells, i) for (const label targetCell : targetCells)
{ {
// Track from its cellcentre to position to make sure. // Track from its cellcentre to position to make sure.
autoPtr<passiveParticle> newPtr autoPtr<passiveParticle> newPtr
@ -175,8 +177,8 @@ void mapLagrangian(const meshToMesh& interp)
( (
meshTarget, meshTarget,
barycentric(1, 0, 0, 0), barycentric(1, 0, 0, 0),
targetCells[i], targetCell,
meshTarget.cells()[targetCells[i]][0], meshTarget.cells()[targetCell][0],
1 1
) )
); );
@ -216,11 +218,11 @@ void mapLagrangian(const meshToMesh& interp)
{ {
sourceParticleI = 0; sourceParticleI = 0;
forAllIter(Cloud<passiveParticle>, sourceParcels, iter) forAllIters(sourceParcels, iter)
{ {
if (unmappedSource.found(sourceParticleI)) if (unmappedSource.found(sourceParticleI))
{ {
label targetCell = const label targetCell =
findCell(targetParcels, iter().position()); findCell(targetParcels, iter().position());
if (targetCell >= 0) if (targetCell >= 0)
@ -259,42 +261,42 @@ void mapLagrangian(const meshToMesh& interp)
MapLagrangianFields<label> MapLagrangianFields<label>
( (
cloudDirs[cloudI], cloudDir,
objects, objects,
meshTarget, meshTarget,
addParticles addParticles
); );
MapLagrangianFields<scalar> MapLagrangianFields<scalar>
( (
cloudDirs[cloudI], cloudDir,
objects, objects,
meshTarget, meshTarget,
addParticles addParticles
); );
MapLagrangianFields<vector> MapLagrangianFields<vector>
( (
cloudDirs[cloudI], cloudDir,
objects, objects,
meshTarget, meshTarget,
addParticles addParticles
); );
MapLagrangianFields<sphericalTensor> MapLagrangianFields<sphericalTensor>
( (
cloudDirs[cloudI], cloudDir,
objects, objects,
meshTarget, meshTarget,
addParticles addParticles
); );
MapLagrangianFields<symmTensor> MapLagrangianFields<symmTensor>
( (
cloudDirs[cloudI], cloudDir,
objects, objects,
meshTarget, meshTarget,
addParticles addParticles
); );
MapLagrangianFields<tensor> MapLagrangianFields<tensor>
( (
cloudDirs[cloudI], cloudDir,
objects, objects,
meshTarget, meshTarget,
addParticles addParticles