ENH: add regular expressions for reconstructPar, mapFieldsPar -fields option

- improved flexibility

- reconstruction of Lagrangian positions/fields now handled as a class
  for better modularity
This commit is contained in:
Mark Olesen
2018-11-28 08:36:17 +01:00
parent b81420e524
commit 41a03f3790
19 changed files with 862 additions and 613 deletions

View File

@ -42,7 +42,7 @@ Description
#include "regionProperties.H"
#include "fvFieldReconstructor.H"
#include "pointFieldReconstructor.H"
#include "reconstructLagrangian.H"
#include "lagrangianReconstructor.H"
#include "faCFD.H"
#include "faMesh.H"
@ -95,9 +95,9 @@ int main(int argc, char *argv[])
argList::addOption
(
"fields",
"list",
"Specify a list of fields to be reconstructed. Eg, '(U T p)' - "
"regular expressions not currently supported"
"wordRes",
"Specify single or multiple fields to reconstruct (all by default)."
" Eg, 'T' or '(p T U \"alpha.*\")'"
);
argList::addBoolOption
(
@ -107,16 +107,18 @@ int main(int argc, char *argv[])
argList::addOption
(
"lagrangianFields",
"list",
"Specify a list of lagrangian fields to be reconstructed. Eg, '(U d)' -"
"regular expressions not currently supported, "
"positions always included."
"wordRes",
"Specify single or multiple lagrangian fields to reconstruct"
" (all by default)."
" Eg, '(U d)'"
" - Positions are always included."
);
argList::addBoolOption
(
"noLagrangian",
"Skip reconstructing lagrangian positions and fields"
);
argList::addBoolOption
(
"noSets",
@ -131,48 +133,40 @@ int main(int argc, char *argv[])
#include "setRootCase.H"
#include "createTime.H"
wordHashSet selectedFields;
args.readIfPresent("fields", selectedFields);
const bool noFields = args.found("noFields");
wordRes selectedFields;
args.readListIfPresent<wordRe>("fields", selectedFields);
if (noFields)
const bool doFields = !args.found("noFields");
if (!doFields)
{
Info<< "Skipping reconstructing fields"
<< nl << endl;
}
const bool noLagrangian = args.found("noLagrangian");
wordRes selectedLagrangianFields;
args.readListIfPresent<wordRe>
(
"lagrangianFields", selectedLagrangianFields
);
if (noLagrangian)
const bool doLagrangian = !args.found("noLagrangian");
if (!doLagrangian)
{
Info<< "Skipping reconstructing lagrangian positions and fields"
<< nl << endl;
}
const bool doReconstructSets = !args.found("noSets");
const bool noReconstructSets = args.found("noSets");
if (noReconstructSets)
if (!doReconstructSets)
{
Info<< "Skipping reconstructing cellSets, faceSets and pointSets"
<< nl << endl;
}
wordHashSet selectedLagrangianFields;
if (args.readIfPresent("lagrangianFields", selectedLagrangianFields))
{
if (noLagrangian)
{
FatalErrorInFunction
<< "Cannot specify noLagrangian and lagrangianFields "
<< "options together."
<< exit(FatalError);
}
}
const bool newTimes = args.found("newTimes");
const bool allRegions = args.found("allRegions");
@ -367,12 +361,12 @@ int main(int argc, char *argv[])
databases[0].timeName()
);
if (!noFields)
if (doFields)
{
// If there are any FV fields, reconstruct them
Info<< "Reconstructing FV fields" << nl << endl;
fvFieldReconstructor fvReconstructor
fvFieldReconstructor reconstructor
(
mesh,
procMeshes.meshes(),
@ -381,92 +375,91 @@ int main(int argc, char *argv[])
procMeshes.boundaryProcAddressing()
);
fvReconstructor.reconstructFvVolumeInternalFields<scalar>
reconstructor.reconstructFvVolumeInternalFields<scalar>
(
objects,
selectedFields
);
fvReconstructor.reconstructFvVolumeInternalFields<vector>
reconstructor.reconstructFvVolumeInternalFields<vector>
(
objects,
selectedFields
);
fvReconstructor.reconstructFvVolumeInternalFields
<sphericalTensor>
reconstructor.reconstructFvVolumeInternalFields<sphericalTensor>
(
objects,
selectedFields
);
fvReconstructor.reconstructFvVolumeInternalFields<symmTensor>
reconstructor.reconstructFvVolumeInternalFields<symmTensor>
(
objects,
selectedFields
);
fvReconstructor.reconstructFvVolumeInternalFields<tensor>
reconstructor.reconstructFvVolumeInternalFields<tensor>
(
objects,
selectedFields
);
fvReconstructor.reconstructFvVolumeFields<scalar>
reconstructor.reconstructFvVolumeFields<scalar>
(
objects,
selectedFields
);
fvReconstructor.reconstructFvVolumeFields<vector>
reconstructor.reconstructFvVolumeFields<vector>
(
objects,
selectedFields
);
fvReconstructor.reconstructFvVolumeFields<sphericalTensor>
reconstructor.reconstructFvVolumeFields<sphericalTensor>
(
objects,
selectedFields
);
fvReconstructor.reconstructFvVolumeFields<symmTensor>
reconstructor.reconstructFvVolumeFields<symmTensor>
(
objects,
selectedFields
);
fvReconstructor.reconstructFvVolumeFields<tensor>
reconstructor.reconstructFvVolumeFields<tensor>
(
objects,
selectedFields
);
fvReconstructor.reconstructFvSurfaceFields<scalar>
reconstructor.reconstructFvSurfaceFields<scalar>
(
objects,
selectedFields
);
fvReconstructor.reconstructFvSurfaceFields<vector>
reconstructor.reconstructFvSurfaceFields<vector>
(
objects,
selectedFields
);
fvReconstructor.reconstructFvSurfaceFields<sphericalTensor>
reconstructor.reconstructFvSurfaceFields<sphericalTensor>
(
objects,
selectedFields
);
fvReconstructor.reconstructFvSurfaceFields<symmTensor>
reconstructor.reconstructFvSurfaceFields<symmTensor>
(
objects,
selectedFields
);
fvReconstructor.reconstructFvSurfaceFields<tensor>
reconstructor.reconstructFvSurfaceFields<tensor>
(
objects,
selectedFields
);
if (fvReconstructor.nReconstructed() == 0)
if (reconstructor.nReconstructed() == 0)
{
Info<< "No FV fields" << nl << endl;
}
}
if (!noFields)
if (doFields)
{
Info<< "Reconstructing point fields" << nl << endl;
@ -482,7 +475,7 @@ int main(int argc, char *argv[])
);
}
pointFieldReconstructor pointReconstructor
pointFieldReconstructor reconstructor
(
pMesh,
pMeshes,
@ -490,33 +483,33 @@ int main(int argc, char *argv[])
procMeshes.boundaryProcAddressing()
);
pointReconstructor.reconstructFields<scalar>
reconstructor.reconstructFields<scalar>
(
objects,
selectedFields
);
pointReconstructor.reconstructFields<vector>
reconstructor.reconstructFields<vector>
(
objects,
selectedFields
);
pointReconstructor.reconstructFields<sphericalTensor>
reconstructor.reconstructFields<sphericalTensor>
(
objects,
selectedFields
);
pointReconstructor.reconstructFields<symmTensor>
reconstructor.reconstructFields<symmTensor>
(
objects,
selectedFields
);
pointReconstructor.reconstructFields<tensor>
reconstructor.reconstructFields<tensor>
(
objects,
selectedFields
);
if (pointReconstructor.nReconstructed() == 0)
if (reconstructor.nReconstructed() == 0)
{
Info<< "No point fields" << nl << endl;
}
@ -530,7 +523,7 @@ int main(int argc, char *argv[])
// the first processor that has them. They are in pass2 only used
// for name and type (scalar, vector etc).
if (!noLagrangian)
if (doLagrangian)
{
HashTable<IOobjectList> allCloudObjects;
@ -585,6 +578,14 @@ int main(int argc, char *argv[])
if (allCloudObjects.size())
{
lagrangianReconstructor reconstructor
(
mesh,
procMeshes.meshes(),
procMeshes.faceProcAddressing(),
procMeshes.cellProcAddressing()
);
// Pass2: reconstruct the cloud
forAllConstIters(allCloudObjects, iter)
{
@ -596,107 +597,82 @@ int main(int argc, char *argv[])
Info<< "Reconstructing lagrangian fields for cloud "
<< cloudName << nl << endl;
reconstructLagrangianPositions
(
mesh,
cloudName,
procMeshes.meshes(),
procMeshes.faceProcAddressing(),
procMeshes.cellProcAddressing()
);
reconstructLagrangianFields<label>
reconstructor.reconstructPositions(cloudName);
reconstructor.reconstructFields<label>
(
cloudName,
mesh,
procMeshes.meshes(),
cloudObjs,
selectedLagrangianFields
);
reconstructLagrangianFieldFields<label>
reconstructor.reconstructFieldFields<label>
(
cloudName,
mesh,
procMeshes.meshes(),
cloudObjs,
selectedLagrangianFields
);
reconstructLagrangianFields<scalar>
reconstructor.reconstructFields<scalar>
(
cloudName,
mesh,
procMeshes.meshes(),
cloudObjs,
selectedLagrangianFields
);
reconstructLagrangianFieldFields<scalar>
reconstructor.reconstructFieldFields<scalar>
(
cloudName,
mesh,
procMeshes.meshes(),
cloudObjs,
selectedLagrangianFields
);
reconstructLagrangianFields<vector>
reconstructor.reconstructFields<vector>
(
cloudName,
mesh,
procMeshes.meshes(),
cloudObjs,
selectedLagrangianFields
);
reconstructLagrangianFieldFields<vector>
reconstructor.reconstructFieldFields<vector>
(
cloudName,
mesh,
procMeshes.meshes(),
cloudObjs,
selectedLagrangianFields
);
reconstructLagrangianFields<sphericalTensor>
reconstructor.reconstructFields<sphericalTensor>
(
cloudName,
mesh,
procMeshes.meshes(),
cloudObjs,
selectedLagrangianFields
);
reconstructLagrangianFieldFields<sphericalTensor>
reconstructor.reconstructFieldFields<sphericalTensor>
(
cloudName,
mesh,
procMeshes.meshes(),
cloudObjs,
selectedLagrangianFields
);
reconstructLagrangianFields<symmTensor>
reconstructor.reconstructFields<symmTensor>
(
cloudName,
mesh,
procMeshes.meshes(),
cloudObjs,
selectedLagrangianFields
);
reconstructLagrangianFieldFields<symmTensor>
reconstructor.reconstructFieldFields<symmTensor>
(
cloudName,
mesh,
procMeshes.meshes(),
cloudObjs,
selectedLagrangianFields
);
reconstructLagrangianFields<tensor>
reconstructor.reconstructFields<tensor>
(
cloudName,
mesh,
procMeshes.meshes(),
cloudObjs,
selectedLagrangianFields
);
reconstructLagrangianFieldFields<tensor>
reconstructor.reconstructFieldFields<tensor>
(
cloudName,
mesh,
procMeshes.meshes(),
cloudObjs,
selectedLagrangianFields
);
@ -727,7 +703,7 @@ int main(int argc, char *argv[])
processorFaMeshes procFaMeshes(procMeshes.meshes());
faFieldReconstructor faReconstructor
faFieldReconstructor reconstructor
(
aMesh,
procFaMeshes.meshes(),
@ -736,21 +712,20 @@ int main(int argc, char *argv[])
procFaMeshes.boundaryProcAddressing()
);
faReconstructor.reconstructFaAreaFields<scalar>(objects);
faReconstructor.reconstructFaAreaFields<vector>(objects);
faReconstructor
.reconstructFaAreaFields<sphericalTensor>(objects);
faReconstructor.reconstructFaAreaFields<symmTensor>(objects);
faReconstructor.reconstructFaAreaFields<tensor>(objects);
reconstructor.reconstructFaAreaFields<scalar>(objects);
reconstructor.reconstructFaAreaFields<vector>(objects);
reconstructor.reconstructFaAreaFields<sphericalTensor>(objects);
reconstructor.reconstructFaAreaFields<symmTensor>(objects);
reconstructor.reconstructFaAreaFields<tensor>(objects);
faReconstructor.reconstructFaEdgeFields<scalar>(objects);
reconstructor.reconstructFaEdgeFields<scalar>(objects);
}
else
{
Info << "No FA fields" << nl << endl;
}
if (!noReconstructSets)
if (doReconstructSets)
{
// Scan to find all sets
HashTable<label> cSetNames;

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -32,7 +32,7 @@ Description
SourceFiles
parFvFieldReconstructor.C
parFvFieldReconstructorReconstructFields.C
parFvFieldReconstructorFields.C
\*---------------------------------------------------------------------------*/
@ -47,6 +47,7 @@ SourceFiles
namespace Foam
{
// Forward declarations
class mapDistributePolyMesh;
class mapDistributeBase;
class IOobjectList;
@ -149,26 +150,26 @@ public:
//- Read, reconstruct and write all/selected volume internal fields
template<class Type>
void reconstructFvVolumeInternalFields
label reconstructFvVolumeInternalFields
(
const IOobjectList& objects,
const wordHashSet& selectedFields
const wordRes& selectedFields = wordRes()
) const;
//- Read, reconstruct and write all/selected volume fields
template<class Type>
void reconstructFvVolumeFields
label reconstructFvVolumeFields
(
const IOobjectList& objects,
const wordHashSet& selectedFields
const wordRes& selectedFields = wordRes()
) const;
//- Read, reconstruct and write all/selected surface fields
template<class Type>
void reconstructFvSurfaceFields
label reconstructFvSurfaceFields
(
const IOobjectList& objects,
const wordHashSet& selectedFields
const wordRes& selectedFields = wordRes()
) const;
//- Helper: reconstruct and write mesh points
@ -184,7 +185,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "parFvFieldReconstructorReconstructFields.C"
# include "parFvFieldReconstructorFields.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -408,33 +408,34 @@ Foam::parFvFieldReconstructor::reconstructFvSurfaceField
template<class Type>
void Foam::parFvFieldReconstructor::reconstructFvVolumeInternalFields
Foam::label Foam::parFvFieldReconstructor::reconstructFvVolumeInternalFields
(
const IOobjectList& objects,
const wordHashSet& selectedFields
const wordRes& selectedFields
) const
{
typedef DimensionedField<Type, volMesh> FieldType;
const word& clsName = FieldType::typeName;
typedef DimensionedField<Type, volMesh> fieldType;
// Available fields, sorted order
const wordList fieldNames =
(
selectedFields.empty()
? objects.sortedNames(clsName)
: objects.sortedNames(clsName, selectedFields)
? objects.sortedNames<fieldType>()
: objects.sortedNames<fieldType>(selectedFields)
);
if (fieldNames.size())
{
Info<< " Reconstructing " << clsName << "s\n" << endl;
}
label nFields = 0;
for (const word& fieldName : fieldNames)
{
Info<< " " << fieldName << endl;
if (!nFields++)
{
Info<< " Reconstructing "
<< fieldType::typeName << "s\n" << nl;
}
tmp<FieldType> tfld
Info<< " " << fieldName << nl;
tmp<fieldType> tfld
(
reconstructFvVolumeInternalField<Type>(*(objects[fieldName]))
);
@ -444,42 +445,43 @@ void Foam::parFvFieldReconstructor::reconstructFvVolumeInternalFields
}
}
if (fieldNames.size()) Info<< endl;
if (nFields) Info<< endl;
return nFields;
}
template<class Type>
void Foam::parFvFieldReconstructor::reconstructFvVolumeFields
Foam::label Foam::parFvFieldReconstructor::reconstructFvVolumeFields
(
const IOobjectList& objects,
const wordHashSet& selectedFields
const wordRes& selectedFields
) const
{
typedef GeometricField<Type, fvPatchField, volMesh> FieldType;
const word& clsName = FieldType::typeName;
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
// Available fields, sorted order
const wordList fieldNames =
(
selectedFields.empty()
? objects.sortedNames(clsName)
: objects.sortedNames(clsName, selectedFields)
? objects.sortedNames<fieldType>()
: objects.sortedNames<fieldType>(selectedFields)
);
if (fieldNames.size())
{
Info<< " Reconstructing " << clsName << "s\n" << endl;
}
label nFields = 0;
for (const word& fieldName : fieldNames)
{
if ("cellDist" == fieldName)
{
continue;
}
Info<< " " << fieldName << endl;
if (!nFields++)
{
Info<< " Reconstructing "
<< fieldType::typeName << "s\n" << nl;
}
Info<< " " << fieldName << nl;
tmp<FieldType> tfld
tmp<fieldType> tfld
(
reconstructFvVolumeField<Type>(*(objects[fieldName]))
);
@ -489,38 +491,39 @@ void Foam::parFvFieldReconstructor::reconstructFvVolumeFields
}
}
if (fieldNames.size()) Info<< endl;
if (nFields) Info<< endl;
return nFields;
}
template<class Type>
void Foam::parFvFieldReconstructor::reconstructFvSurfaceFields
Foam::label Foam::parFvFieldReconstructor::reconstructFvSurfaceFields
(
const IOobjectList& objects,
const wordHashSet& selectedFields
const wordRes& selectedFields
) const
{
typedef GeometricField<Type, fvsPatchField, surfaceMesh> FieldType;
const word& clsName = FieldType::typeName;
typedef GeometricField<Type, fvsPatchField, surfaceMesh> fieldType;
// Available fields, sorted order
const wordList fieldNames =
(
selectedFields.empty()
? objects.sortedNames(clsName)
: objects.sortedNames(clsName, selectedFields)
? objects.sortedNames<fieldType>()
: objects.sortedNames<fieldType>(selectedFields)
);
if (fieldNames.size())
{
Info<< " Reconstructing " << clsName << "s\n" << endl;
}
label nFields = 0;
for (const word& fieldName : fieldNames)
{
Info<< " " << fieldName << endl;
if (!nFields++)
{
Info<< " Reconstructing "
<< fieldType::typeName << "s\n" << nl;
}
Info<< " " << fieldName << nl;
tmp<FieldType> tfld
tmp<fieldType> tfld
(
reconstructFvSurfaceField<Type>(*(objects[fieldName]))
);
@ -530,7 +533,8 @@ void Foam::parFvFieldReconstructor::reconstructFvSurfaceFields
}
}
if (fieldNames.size()) Info<< endl;
if (nFields) Info<< endl;
return nFields;
}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -31,7 +31,7 @@ Description
SourceFiles
parLagrangianRedistributor.C
parLagrangianRedistributorRedistributeFields.C
parLagrangianRedistributorFields.C
\*---------------------------------------------------------------------------*/
@ -46,6 +46,7 @@ SourceFiles
namespace Foam
{
// Forward declarations
class mapDistributePolyMesh;
class mapDistributeBase;
class IOobjectList;
@ -126,41 +127,41 @@ public:
static wordList filterObjects
(
const IOobjectList& objects,
const wordHashSet& selectedFields
const wordRes& selectedFields = wordRes()
);
//- Read, redistribute and write all/selected lagrangian fields
template<class Type>
void redistributeLagrangianFields
label redistributeFields
(
const mapDistributeBase& map,
const word& cloudName,
const IOobjectList& objects,
const wordHashSet& selectedFields
const wordRes& selectedFields = wordRes()
) const;
//- Read, redistribute and write all/selected lagrangian fieldFields
template<class Type>
void redistributeLagrangianFieldFields
label redistributeFieldFields
(
const mapDistributeBase& map,
const word& cloudName,
const IOobjectList& objects,
const wordHashSet& selectedFields
const wordRes& selectedFields = wordRes()
) const;
//- Read and store all fields of a cloud
template<class Container>
static void readLagrangianFields
static label readFields
(
const passivePositionParticleCloud& cloud,
const IOobjectList& objects,
const wordHashSet& selectedFields
const wordRes& selectedFields = wordRes()
);
//- Redistribute and write stored lagrangian fields
template<class Container>
void redistributeStoredLagrangianFields
label redistributeStoredFields
(
const mapDistributeBase& map,
passivePositionParticleCloud& cloud
@ -176,7 +177,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "parLagrangianRedistributorRedistributeFields.C"
# include "parLagrangianRedistributorFields.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -37,21 +37,23 @@ template<class Container>
Foam::wordList Foam::parLagrangianRedistributor::filterObjects
(
const IOobjectList& objects,
const wordHashSet& selectedFields
const wordRes& selectedFields
)
{
// Parallel synchronise
wordList fieldNames =
(
selectedFields.empty()
? objects.names(Container::typeName)
: objects.names(Container::typeName, selectedFields)
? objects.names<Container>()
: objects.names<Container>(selectedFields)
);
// Parallel synchronise
// - Combine names from all processors
Pstream::combineGather(fieldNames, ListOps::uniqueEqOp<word>());
Pstream::combineScatter(fieldNames);
// Ensure order is consistent
// Sort for consistent order on all processors
Foam::sort(fieldNames);
return fieldNames;
@ -59,17 +61,17 @@ Foam::wordList Foam::parLagrangianRedistributor::filterObjects
template<class Type>
void Foam::parLagrangianRedistributor::redistributeLagrangianFields
Foam::label Foam::parLagrangianRedistributor::redistributeFields
(
const mapDistributeBase& map,
const word& cloudName,
const IOobjectList& objects,
const wordHashSet& selectedFields
const wordRes& selectedFields
) const
{
const word fieldClassName(IOField<Type>::typeName);
typedef IOField<Type> fieldType;
const wordList objectNames
const wordList fieldNames
(
filterObjects<IOField<Type>>
(
@ -78,14 +80,14 @@ void Foam::parLagrangianRedistributor::redistributeLagrangianFields
)
);
if (objectNames.size())
label nFields = 0;
for (const word& objectName : fieldNames)
{
if (!nFields)
{
Info<< " Redistributing lagrangian "
<< fieldClassName << "s\n" << endl;
<< fieldType::typeName << "s\n" << endl;
}
for (const word& objectName : objectNames)
{
Info<< " " << objectName << endl;
// Read if present
@ -126,24 +128,24 @@ void Foam::parLagrangianRedistributor::redistributeLagrangianFields
}
}
if (objectNames.size()) Info<< endl;
return nFields;
}
template<class Type>
void Foam::parLagrangianRedistributor::redistributeLagrangianFieldFields
Foam::label Foam::parLagrangianRedistributor::redistributeFieldFields
(
const mapDistributeBase& map,
const word& cloudName,
const IOobjectList& objects,
const wordHashSet& selectedFields
const wordRes& selectedFields
) const
{
const word fieldClassName(CompactIOField<Field<Type>, Type>::typeName);
typedef CompactIOField<Field<Type>, Type> fieldType;
wordList objectNames
wordList fieldNames
(
filterObjects<CompactIOField<Field<Type>, Type>>
filterObjects<fieldType>
(
objects,
selectedFields
@ -160,19 +162,18 @@ void Foam::parLagrangianRedistributor::redistributeLagrangianFieldFields
selectedFields
)
);
objectNames.append(ioFieldNames);
fieldNames.append(ioFieldNames);
}
if (objectNames.size())
label nFields = 0;
for (const word& objectName : fieldNames)
{
if (!nFields++)
{
Info<< " Redistributing lagrangian "
<< fieldClassName << "s\n" << endl;
<< fieldType::typeName << "s\n" << nl;
}
for (const word& objectName : objectNames)
{
Info<< " " << objectName << endl;
Info<< " " << objectName << nl;
// Read if present
CompactIOField<Field<Type>, Type> field
@ -212,20 +213,23 @@ void Foam::parLagrangianRedistributor::redistributeLagrangianFieldFields
).write();
}
}
if (nFields) Info<< endl;
return nFields;
}
template<class Container>
void Foam::parLagrangianRedistributor::readLagrangianFields
Foam::label Foam::parLagrangianRedistributor::readFields
(
const passivePositionParticleCloud& cloud,
const IOobjectList& objects,
const wordHashSet& selectedFields
const wordRes& selectedFields
)
{
const word fieldClassName(Container::typeName);
const wordList objectNames
const wordList fieldNames
(
filterObjects<Container>
(
@ -234,15 +238,15 @@ void Foam::parLagrangianRedistributor::readLagrangianFields
)
);
if (objectNames.size())
label nFields = 0;
for (const word& objectName : fieldNames)
{
if (!nFields++)
{
Info<< " Reading lagrangian "
<< fieldClassName << "s\n" << endl;
<< Container::typeName << "s\n" << nl;
}
for (const word& objectName : objectNames)
{
Info<< " " << objectName << endl;
Info<< " " << objectName << nl;
// Read if present
Container* fieldPtr = new Container
@ -260,33 +264,33 @@ void Foam::parLagrangianRedistributor::readLagrangianFields
fieldPtr->store();
}
return nFields;
}
template<class Container>
void Foam::parLagrangianRedistributor::redistributeStoredLagrangianFields
Foam::label Foam::parLagrangianRedistributor::redistributeStoredFields
(
const mapDistributeBase& map,
passivePositionParticleCloud& cloud
) const
{
const word fieldClassName(Container::typeName);
HashTable<Container*> fields
(
cloud.lookupClass<Container>()
);
if (fields.size())
{
Info<< " Redistributing lagrangian "
<< fieldClassName << "s\n" << endl;
}
label nFields = 0;
forAllIters(fields, iter)
{
Container& field = *(*iter);
Container& field = *(iter.object());
if (!nFields++)
{
Info<< " Redistributing lagrangian "
<< Container::typeName << "s\n" << endl;
}
Info<< " " << field.name() << endl;
map.distribute(field);
@ -309,6 +313,8 @@ void Foam::parLagrangianRedistributor::redistributeStoredLagrangianFields
).write();
}
}
return nFields;
}

View File

@ -1687,7 +1687,7 @@ void reconstructMeshFields
(
const parFvFieldReconstructor& fvReconstructor,
const IOobjectList& objects,
const wordHashSet& selectedFields
const wordRes& selectedFields
)
{
// Dimensioned fields
@ -1784,7 +1784,7 @@ void reconstructLagrangian
const fvMesh& baseMesh,
const fvMesh& mesh,
const mapDistributePolyMesh& distMap,
const wordHashSet& selectedLagrangianFields
const wordRes& selectedLagrangianFields
)
{
// Clouds (note: might not be present on all processors)
@ -1832,49 +1832,49 @@ void reconstructLagrangian
cloud::prefix/cloudName
);
lagrangianReconstructor.redistributeLagrangianFields<label>
lagrangianReconstructor.redistributeFields<label>
(
lagrangianMap,
cloudName,
cloudObjs,
selectedLagrangianFields
);
lagrangianReconstructor.redistributeLagrangianFieldFields<label>
lagrangianReconstructor.redistributeFieldFields<label>
(
lagrangianMap,
cloudName,
cloudObjs,
selectedLagrangianFields
);
lagrangianReconstructor.redistributeLagrangianFields<scalar>
lagrangianReconstructor.redistributeFields<scalar>
(
lagrangianMap,
cloudName,
cloudObjs,
selectedLagrangianFields
);
lagrangianReconstructor.redistributeLagrangianFieldFields<scalar>
lagrangianReconstructor.redistributeFieldFields<scalar>
(
lagrangianMap,
cloudName,
cloudObjs,
selectedLagrangianFields
);
lagrangianReconstructor.redistributeLagrangianFields<vector>
lagrangianReconstructor.redistributeFields<vector>
(
lagrangianMap,
cloudName,
cloudObjs,
selectedLagrangianFields
);
lagrangianReconstructor.redistributeLagrangianFieldFields<vector>
lagrangianReconstructor.redistributeFieldFields<vector>
(
lagrangianMap,
cloudName,
cloudObjs,
selectedLagrangianFields
);
lagrangianReconstructor.redistributeLagrangianFields
lagrangianReconstructor.redistributeFields
<sphericalTensor>
(
lagrangianMap,
@ -1882,7 +1882,7 @@ void reconstructLagrangian
cloudObjs,
selectedLagrangianFields
);
lagrangianReconstructor.redistributeLagrangianFieldFields
lagrangianReconstructor.redistributeFieldFields
<sphericalTensor>
(
lagrangianMap,
@ -1890,14 +1890,14 @@ void reconstructLagrangian
cloudObjs,
selectedLagrangianFields
);
lagrangianReconstructor.redistributeLagrangianFields<symmTensor>
lagrangianReconstructor.redistributeFields<symmTensor>
(
lagrangianMap,
cloudName,
cloudObjs,
selectedLagrangianFields
);
lagrangianReconstructor.redistributeLagrangianFieldFields
lagrangianReconstructor.redistributeFieldFields
<symmTensor>
(
lagrangianMap,
@ -1905,14 +1905,14 @@ void reconstructLagrangian
cloudObjs,
selectedLagrangianFields
);
lagrangianReconstructor.redistributeLagrangianFields<tensor>
lagrangianReconstructor.redistributeFields<tensor>
(
lagrangianMap,
cloudName,
cloudObjs,
selectedLagrangianFields
);
lagrangianReconstructor.redistributeLagrangianFieldFields<tensor>
lagrangianReconstructor.redistributeFieldFields<tensor>
(
lagrangianMap,
cloudName,
@ -1929,7 +1929,7 @@ void readLagrangian
(
const fvMesh& mesh,
const wordList& cloudNames,
const wordHashSet& selectedLagrangianFields,
const wordRes& selectedLagrangianFields,
PtrList<unmappedPassivePositionParticleCloud>& clouds
)
{
@ -1963,21 +1963,21 @@ void readLagrangian
//Pout<< "Found clould objects:" << cloudObjs.names() << endl;
parLagrangianRedistributor::readLagrangianFields
parLagrangianRedistributor::readFields
<IOField<label>>
(
clouds[i],
cloudObjs,
selectedLagrangianFields
);
parLagrangianRedistributor::readLagrangianFields
parLagrangianRedistributor::readFields
<IOField<Field<label>>>
(
clouds[i],
cloudObjs,
selectedLagrangianFields
);
parLagrangianRedistributor::readLagrangianFields
parLagrangianRedistributor::readFields
<CompactIOField<Field<label>, label>>
(
clouds[i],
@ -1986,21 +1986,21 @@ void readLagrangian
);
parLagrangianRedistributor::readLagrangianFields
parLagrangianRedistributor::readFields
<IOField<scalar>>
(
clouds[i],
cloudObjs,
selectedLagrangianFields
);
parLagrangianRedistributor::readLagrangianFields
parLagrangianRedistributor::readFields
<IOField<Field<scalar>>>
(
clouds[i],
cloudObjs,
selectedLagrangianFields
);
parLagrangianRedistributor::readLagrangianFields
parLagrangianRedistributor::readFields
<CompactIOField<Field<scalar>, scalar>>
(
clouds[i],
@ -2009,21 +2009,21 @@ void readLagrangian
);
parLagrangianRedistributor::readLagrangianFields
parLagrangianRedistributor::readFields
<IOField<vector>>
(
clouds[i],
cloudObjs,
selectedLagrangianFields
);
parLagrangianRedistributor::readLagrangianFields
parLagrangianRedistributor::readFields
<IOField<Field<vector>>>
(
clouds[i],
cloudObjs,
selectedLagrangianFields
);
parLagrangianRedistributor::readLagrangianFields
parLagrangianRedistributor::readFields
<CompactIOField<Field<vector>, vector>>
(
clouds[i],
@ -2032,21 +2032,21 @@ void readLagrangian
);
parLagrangianRedistributor::readLagrangianFields
parLagrangianRedistributor::readFields
<IOField<sphericalTensor>>
(
clouds[i],
cloudObjs,
selectedLagrangianFields
);
parLagrangianRedistributor::readLagrangianFields
parLagrangianRedistributor::readFields
<IOField<Field<sphericalTensor>>>
(
clouds[i],
cloudObjs,
selectedLagrangianFields
);
parLagrangianRedistributor::readLagrangianFields
parLagrangianRedistributor::readFields
<CompactIOField<Field<sphericalTensor>, sphericalTensor>>
(
clouds[i],
@ -2055,21 +2055,21 @@ void readLagrangian
);
parLagrangianRedistributor::readLagrangianFields
parLagrangianRedistributor::readFields
<IOField<symmTensor>>
(
clouds[i],
cloudObjs,
selectedLagrangianFields
);
parLagrangianRedistributor::readLagrangianFields
parLagrangianRedistributor::readFields
<IOField<Field<symmTensor>>>
(
clouds[i],
cloudObjs,
selectedLagrangianFields
);
parLagrangianRedistributor::readLagrangianFields
parLagrangianRedistributor::readFields
<CompactIOField<Field<symmTensor>, symmTensor>>
(
clouds[i],
@ -2078,21 +2078,21 @@ void readLagrangian
);
parLagrangianRedistributor::readLagrangianFields
parLagrangianRedistributor::readFields
<IOField<tensor>>
(
clouds[i],
cloudObjs,
selectedLagrangianFields
);
parLagrangianRedistributor::readLagrangianFields
parLagrangianRedistributor::readFields
<IOField<Field<tensor>>>
(
clouds[i],
cloudObjs,
selectedLagrangianFields
);
parLagrangianRedistributor::readLagrangianFields
parLagrangianRedistributor::readFields
<CompactIOField<Field<tensor>, tensor>>
(
clouds[i],
@ -2136,19 +2136,19 @@ void redistributeLagrangian
distributor.redistributeLagrangianPositions(clouds[i]);
const mapDistributeBase& lagrangianMap = *lagrangianMapPtr;
distributor.redistributeStoredLagrangianFields
distributor.redistributeStoredFields
<IOField<label>>
(
lagrangianMap,
clouds[i]
);
distributor.redistributeStoredLagrangianFields
distributor.redistributeStoredFields
<IOField<Field<label>>>
(
lagrangianMap,
clouds[i]
);
distributor.redistributeStoredLagrangianFields
distributor.redistributeStoredFields
<CompactIOField<Field<label>, label>>
(
lagrangianMap,
@ -2156,19 +2156,19 @@ void redistributeLagrangian
);
distributor.redistributeStoredLagrangianFields
distributor.redistributeStoredFields
<IOField<scalar>>
(
lagrangianMap,
clouds[i]
);
distributor.redistributeStoredLagrangianFields
distributor.redistributeStoredFields
<IOField<Field<scalar>>>
(
lagrangianMap,
clouds[i]
);
distributor.redistributeStoredLagrangianFields
distributor.redistributeStoredFields
<CompactIOField<Field<scalar>, scalar>>
(
lagrangianMap,
@ -2176,19 +2176,19 @@ void redistributeLagrangian
);
distributor.redistributeStoredLagrangianFields
distributor.redistributeStoredFields
<IOField<vector>>
(
lagrangianMap,
clouds[i]
);
distributor.redistributeStoredLagrangianFields
distributor.redistributeStoredFields
<IOField<Field<vector>>>
(
lagrangianMap,
clouds[i]
);
distributor.redistributeStoredLagrangianFields
distributor.redistributeStoredFields
<CompactIOField<Field<vector>, vector>>
(
lagrangianMap,
@ -2196,19 +2196,19 @@ void redistributeLagrangian
);
distributor.redistributeStoredLagrangianFields
distributor.redistributeStoredFields
<IOField<sphericalTensor>>
(
lagrangianMap,
clouds[i]
);
distributor.redistributeStoredLagrangianFields
distributor.redistributeStoredFields
<IOField<Field<sphericalTensor>>>
(
lagrangianMap,
clouds[i]
);
distributor.redistributeStoredLagrangianFields
distributor.redistributeStoredFields
<CompactIOField<Field<sphericalTensor>, sphericalTensor>>
(
lagrangianMap,
@ -2216,19 +2216,19 @@ void redistributeLagrangian
);
distributor.redistributeStoredLagrangianFields
distributor.redistributeStoredFields
<IOField<symmTensor>>
(
lagrangianMap,
clouds[i]
);
distributor.redistributeStoredLagrangianFields
distributor.redistributeStoredFields
<IOField<Field<symmTensor>>>
(
lagrangianMap,
clouds[i]
);
distributor.redistributeStoredLagrangianFields
distributor.redistributeStoredFields
<CompactIOField<Field<symmTensor>, symmTensor>>
(
lagrangianMap,
@ -2236,19 +2236,19 @@ void redistributeLagrangian
);
distributor.redistributeStoredLagrangianFields
distributor.redistributeStoredFields
<IOField<tensor>>
(
lagrangianMap,
clouds[i]
);
distributor.redistributeStoredLagrangianFields
distributor.redistributeStoredFields
<IOField<Field<tensor>>>
(
lagrangianMap,
clouds[i]
);
distributor.redistributeStoredLagrangianFields
distributor.redistributeStoredFields
<CompactIOField<Field<tensor>, tensor>>
(
lagrangianMap,
@ -2323,8 +2323,8 @@ int main(int argc, char *argv[])
}
const wordHashSet selectedFields(0);
const wordHashSet selectedLagrangianFields(0);
const wordRes selectedFields;
const wordRes selectedLagrangianFields;
if (decompose)

View File

@ -40,7 +40,7 @@ template<template<class> class CombineOp>
void MapMesh
(
const meshToMesh& interp,
const wordHashSet& selectedFields,
const wordRes& selectedFields,
const bool noLagrangian
)
{

View File

@ -121,7 +121,7 @@ template<class Type, class CombineOp>
void MapVolFields
(
const IOobjectList& objects,
const wordHashSet& selectedFields,
const wordRes& selectedFields,
const meshToMesh& interp,
const CombineOp& cop
)
@ -135,8 +135,8 @@ void MapVolFields
const wordList fieldNames =
(
selectedFields.empty()
? objects.sortedNames(fieldType::typeName)
: objects.sortedNames(fieldType::typeName, selectedFields)
? objects.sortedNames<fieldType>()
: objects.sortedNames<fieldType>(selectedFields)
);
for (const word& fieldName : fieldNames)

View File

@ -48,7 +48,7 @@ void mapConsistentMesh
const word& AMIMapMethod,
const word& procMapMethod,
const bool subtract,
const wordHashSet& selectedFields,
const wordRes& selectedFields,
const bool noLagrangian
)
{
@ -95,7 +95,7 @@ void mapSubMesh
const word& AMIMapMethod,
const word& procMapMethod,
const bool subtract,
const wordHashSet& selectedFields,
const wordRes& selectedFields,
const bool noLagrangian
)
{
@ -195,9 +195,9 @@ int main(int argc, char *argv[])
argList::addOption
(
"fields",
"list",
"Specify a list of fields to be mapped. Eg, '(U T p)' - "
"regular expressions not currently supported"
"wordRes",
"Specify single or multiple fields to reconstruct (all by default)."
" Eg, 'T' or '(p T U \"alpha.*\")'"
);
argList::addBoolOption
(
@ -288,8 +288,8 @@ int main(int argc, char *argv[])
Info<< "Subtracting mapped source field from target" << endl;
}
wordHashSet selectedFields;
args.readIfPresent("fields", selectedFields);
wordRes selectedFields;
args.readListIfPresent<wordRe>("fields", selectedFields);
const bool noLagrangian = args.found("noLagrangian");

View File

@ -1,6 +1,6 @@
processorMeshes.C
fvFieldReconstructor.C
pointFieldReconstructor.C
reconstructLagrangianPositions.C
lagrangianReconstructor.C
LIB = $(FOAM_LIBBIN)/libreconstruct

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -29,7 +29,7 @@ Description
SourceFiles
fvFieldReconstructor.C
fvFieldReconstructorReconstructFields.C
fvFieldReconstructorFields.C
\*---------------------------------------------------------------------------*/
@ -47,7 +47,6 @@ SourceFiles
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class fvFieldReconstructor Declaration
\*---------------------------------------------------------------------------*/
@ -193,25 +192,83 @@ public:
tmp<GeometricField<Type, fvsPatchField, surfaceMesh>>
reconstructFvSurfaceField(const IOobject& fieldIoObject) const;
//- Read, reconstruct and write all/selected volume internal fields
//- Read, reconstruct and write specified volume internal fields
template<class Type>
void reconstructFvVolumeInternalFields
label reconstructFvVolumeInternalFields
(
const IOobjectList& objects,
const UList<word>& fieldNames
);
//- Read, reconstruct and write specified volume fields
template<class Type>
label reconstructFvVolumeFields
(
const IOobjectList& objects,
const UList<word>& fieldNames
);
//- Read, reconstruct and write specified surface fields
template<class Type>
label reconstructFvSurfaceFields
(
const IOobjectList& objects,
const UList<word>& fieldNames
);
//- Read, reconstruct and write all/selected volume internal fields
// An empty wordRes corresponds to select ALL.
template<class Type>
label reconstructFvVolumeInternalFields
(
const IOobjectList& objects,
const wordRes& selectedFields = wordRes()
);
//- Read, reconstruct and write all/selected volume fields
// An empty wordRes corresponds to select ALL.
template<class Type>
label reconstructFvVolumeFields
(
const IOobjectList& objects,
const wordRes& selectedFields = wordRes()
);
//- Read, reconstruct and write all/selected surface fields
// An empty wordRes corresponds to select ALL.
template<class Type>
label reconstructFvSurfaceFields
(
const IOobjectList& objects,
const wordRes& selectedFields = wordRes()
);
//- Read, reconstruct and write all/selected volume internal fields
// An empty wordHashSet corresponds to select ALL.
// \note this may be removed in the future (2018-11)
template<class Type>
label reconstructFvVolumeInternalFields
(
const IOobjectList& objects,
const wordHashSet& selectedFields
);
//- Read, reconstruct and write all/selected volume fields
// An empty wordHashSet corresponds to select ALL.
// \note this may be removed in the future (2018-11)
template<class Type>
void reconstructFvVolumeFields
label reconstructFvVolumeFields
(
const IOobjectList& objects,
const wordHashSet& selectedFields
);
//- Read, reconstruct and write all/selected surface fields
// An empty wordHashSet corresponds to select ALL.
// \note this may be removed in the future (2018-11)
template<class Type>
void reconstructFvSurfaceFields
label reconstructFvSurfaceFields
(
const IOobjectList& objects,
const wordHashSet& selectedFields
@ -226,7 +283,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "fvFieldReconstructorReconstructFields.C"
#include "fvFieldReconstructorFields.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -588,106 +588,218 @@ Foam::fvFieldReconstructor::reconstructFvSurfaceField
template<class Type>
void Foam::fvFieldReconstructor::reconstructFvVolumeInternalFields
Foam::label Foam::fvFieldReconstructor::reconstructFvVolumeInternalFields
(
const IOobjectList& objects,
const wordHashSet& selectedFields
const UList<word>& fieldNames
)
{
const word& clsName = DimensionedField<Type, volMesh>::typeName;
const wordList fieldNames =
(
selectedFields.empty()
? objects.sortedNames(clsName)
: objects.sortedNames(clsName, selectedFields)
);
if (fieldNames.size())
{
Info<< " Reconstructing " << clsName << "s\n" << nl;
}
typedef DimensionedField<Type, volMesh> fieldType;
label nFields = 0;
for (const word& fieldName : fieldNames)
{
const IOobject* io = objects.cfindObject<fieldType>(fieldName);
if (io)
{
if (!nFields++)
{
Info<< " Reconstructing "
<< fieldType::typeName << "s\n" << nl;
}
Info<< " " << fieldName << endl;
reconstructFvVolumeInternalField<Type>(*(objects[fieldName]))().write();
reconstructFvVolumeInternalField<Type>(*io)().write();
++nReconstructed_;
}
}
if (fieldNames.size()) Info<< endl;
if (nFields) Info<< endl;
return nFields;
}
template<class Type>
void Foam::fvFieldReconstructor::reconstructFvVolumeFields
Foam::label Foam::fvFieldReconstructor::reconstructFvVolumeFields
(
const IOobjectList& objects,
const wordHashSet& selectedFields
const UList<word>& fieldNames
)
{
const word& clsName =
GeometricField<Type, fvPatchField, volMesh>::typeName;
const wordList fieldNames =
(
selectedFields.empty()
? objects.sortedNames(clsName)
: objects.sortedNames(clsName, selectedFields)
);
if (fieldNames.size())
{
Info<< " Reconstructing " << clsName << "s\n" << nl;
}
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
label nFields = 0;
for (const word& fieldName : fieldNames)
{
const IOobject* io = objects.cfindObject<fieldType>(fieldName);
if (io)
{
if (!nFields++)
{
Info<< " Reconstructing "
<< fieldType::typeName << "s\n" << nl;
}
Info<< " " << fieldName << endl;
reconstructFvVolumeField<Type>(*(objects[fieldName]))().write();
reconstructFvVolumeField<Type>(*io)().write();
++nReconstructed_;
}
}
if (fieldNames.size()) Info<< endl;
if (nFields) Info<< endl;
return nFields;
}
template<class Type>
void Foam::fvFieldReconstructor::reconstructFvSurfaceFields
Foam::label Foam::fvFieldReconstructor::reconstructFvSurfaceFields
(
const IOobjectList& objects,
const UList<word>& fieldNames
)
{
typedef GeometricField<Type, fvsPatchField, surfaceMesh> fieldType;
label nFields = 0;
for (const word& fieldName : fieldNames)
{
const IOobject* io = objects.cfindObject<fieldType>(fieldName);
if (io)
{
if (!nFields++)
{
Info<< " Reconstructing "
<< fieldType::typeName << "s\n" << nl;
}
Info<< " " << fieldName << endl;
reconstructFvSurfaceField<Type>(*io)().write();
++nReconstructed_;
}
}
if (nFields) Info<< endl;
return nFields;
}
template<class Type>
Foam::label Foam::fvFieldReconstructor::reconstructFvVolumeInternalFields
(
const IOobjectList& objects,
const wordRes& selectedFields
)
{
typedef DimensionedField<Type, volMesh> fieldType;
const wordList fieldNames =
(
selectedFields.empty()
? objects.sortedNames<fieldType>()
: objects.sortedNames<fieldType>(selectedFields)
);
return reconstructFvVolumeInternalFields<Type>(objects, fieldNames);
}
template<class Type>
Foam::label Foam::fvFieldReconstructor::reconstructFvVolumeFields
(
const IOobjectList& objects,
const wordRes& selectedFields
)
{
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
const wordList fieldNames =
(
selectedFields.empty()
? objects.sortedNames<fieldType>()
: objects.sortedNames<fieldType>(selectedFields)
);
return reconstructFvVolumeFields<Type>(objects, fieldNames);
}
template<class Type>
Foam::label Foam::fvFieldReconstructor::reconstructFvSurfaceFields
(
const IOobjectList& objects,
const wordRes& selectedFields
)
{
typedef GeometricField<Type, fvsPatchField, surfaceMesh> fieldType;
const wordList fieldNames =
(
selectedFields.empty()
? objects.sortedNames<fieldType>()
: objects.sortedNames<fieldType>(selectedFields)
);
return reconstructFvSurfaceFields<Type>(objects, fieldNames);
}
template<class Type>
Foam::label Foam::fvFieldReconstructor::reconstructFvVolumeInternalFields
(
const IOobjectList& objects,
const wordHashSet& selectedFields
)
{
const word& clsName =
GeometricField<Type, fvsPatchField, surfaceMesh>::typeName;
typedef DimensionedField<Type, volMesh> fieldType;
const wordList fieldNames =
(
selectedFields.empty()
? objects.sortedNames(clsName)
: objects.sortedNames(clsName, selectedFields)
? objects.sortedNames<fieldType>()
: objects.sortedNames<fieldType>(selectedFields)
);
if (fieldNames.size())
{
Info<< " Reconstructing " << clsName << "s\n" << nl;
return reconstructFvVolumeInternalFields<Type>(objects, fieldNames);
}
for (const word& fieldName : fieldNames)
template<class Type>
Foam::label Foam::fvFieldReconstructor::reconstructFvVolumeFields
(
const IOobjectList& objects,
const wordHashSet& selectedFields
)
{
Info<< " " << fieldName << endl;
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
reconstructFvSurfaceField<Type>(*(objects[fieldName]))().write();
const wordList fieldNames =
(
selectedFields.empty()
? objects.sortedNames<fieldType>()
: objects.sortedNames<fieldType>(selectedFields)
);
++nReconstructed_;
return reconstructFvVolumeField<Type>(objects, fieldNames);
}
if (fieldNames.size()) Info<< endl;
template<class Type>
Foam::label Foam::fvFieldReconstructor::reconstructFvSurfaceFields
(
const IOobjectList& objects,
const wordHashSet& selectedFields
)
{
typedef GeometricField<Type, fvsPatchField, surfaceMesh> fieldType;
const wordList fieldNames =
(
selectedFields.empty()
? objects.sortedNames<fieldType>()
: objects.sortedNames<fieldType>(selectedFields)
);
return reconstructFvSurfaceFields<Type>(objects, fieldNames);
}

View File

@ -23,38 +23,51 @@ License
\*---------------------------------------------------------------------------*/
#include "reconstructLagrangian.H"
#include "lagrangianReconstructor.H"
#include "labelIOList.H"
#include "passiveParticleCloud.H"
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
void Foam::reconstructLagrangianPositions
Foam::lagrangianReconstructor::lagrangianReconstructor
(
const polyMesh& mesh,
const word& cloudName,
const PtrList<fvMesh>& meshes,
const fvMesh& mesh,
const PtrList<fvMesh>& procMeshes,
const PtrList<labelIOList>& faceProcAddressing,
const PtrList<labelIOList>& cellProcAddressing
)
:
mesh_(mesh),
procMeshes_(procMeshes),
faceProcAddressing_(faceProcAddressing),
cellProcAddressing_(cellProcAddressing)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::label Foam::lagrangianReconstructor::reconstructPositions
(
const word& cloudName
) const
{
passiveParticleCloud lagrangianPositions
(
mesh,
mesh_,
cloudName,
IDLList<passiveParticle>()
);
forAll(meshes, meshi)
forAll(procMeshes_, meshi)
{
const labelList& cellMap = cellProcAddressing[meshi];
const labelList& faceMap = faceProcAddressing[meshi];
const labelList& cellMap = cellProcAddressing_[meshi];
const labelList& faceMap = faceProcAddressing_[meshi];
Cloud<passiveParticle> lpi(meshes[meshi], cloudName, false);
Cloud<passiveParticle> lpi(procMeshes_[meshi], cloudName, false);
forAllConstIter(Cloud<passiveParticle>, lpi, iter)
forAllConstIters(lpi, iter)
{
const passiveParticle& ppi = iter();
const passiveParticle& ppi = *iter;
const label mappedCell = cellMap[ppi.cell()];
@ -66,11 +79,11 @@ void Foam::reconstructLagrangianPositions
(
new passiveParticle
(
mesh,
mesh_,
ppi.coordinates(),
mappedCell,
mappedTetFace,
ppi.procTetPt(mesh, mappedCell, mappedTetFace)
ppi.procTetPt(mesh_, mappedCell, mappedTetFace)
)
);
}
@ -87,6 +100,8 @@ void Foam::reconstructLagrangianPositions
cloud::geometryType::POSITIONS
).write();
}
return lagrangianPositions.size();
}

View File

@ -0,0 +1,158 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
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::lagrangianReconstructor
Description
Reconstructor for lagrangian positions and fields
SourceFiles
lagrangianReconstructor.C
lagrangianReconstructorFields.C
\*---------------------------------------------------------------------------*/
#ifndef lagrangianReconstructor_H
#define lagrangianReconstructor_H
#include "cloud.H"
#include "polyMesh.H"
#include "IOobjectList.H"
#include "CompactIOField.H"
#include "fvMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class lagrangianReconstructor Declaration
\*---------------------------------------------------------------------------*/
class lagrangianReconstructor
{
// Private data
//- Mesh reference
const fvMesh& mesh_;
//- List of processor meshes
const PtrList<fvMesh>& procMeshes_;
//- List of processor face addressing lists
const PtrList<labelIOList>& faceProcAddressing_;
//- List of processor cell addressing lists
const PtrList<labelIOList>& cellProcAddressing_;
// Private Member Functions
//- No copy construct
lagrangianReconstructor(const lagrangianReconstructor&) = delete;
//- No copy assignment
void operator=(const lagrangianReconstructor&) = delete;
public:
// Constructors
//- Construct from components
lagrangianReconstructor
(
const fvMesh& mesh,
const PtrList<fvMesh>& procMeshes,
const PtrList<labelIOList>& faceProcAddressing,
const PtrList<labelIOList>& cellProcAddressing
);
// Member Functions
//- Reconstruct positions for given cloud
label reconstructPositions(const word& cloudName) const;
//- Reconstruct a single field for given cloud
template<class Type>
tmp<IOField<Type>> reconstructField
(
const word& cloudName,
const word& fieldName
);
//- Reconstruct a single field-field for given cloud
template<class Type>
tmp<CompactIOField<Field<Type>, Type>> reconstructFieldField
(
const word& cloudName,
const word& fieldName
);
//- Reconstruct multiple fields for given cloud
template<class Type>
label reconstructFields
(
const word& cloudName,
const IOobjectList& objects,
const UList<word>& fieldNames
);
//- Reconstruct multiple fields for given cloud
template<class Type>
label reconstructFields
(
const word& cloudName,
const IOobjectList& objects,
const wordRes& selectedFields = wordRes()
);
//- Reconstruct multiple field-field for given cloud
template<class Type>
label reconstructFieldFields
(
const word& cloudName,
const IOobjectList& objects,
const wordRes& selectedFields = wordRes()
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "lagrangianReconstructorFields.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -27,14 +27,13 @@ License
#include "CompactIOField.H"
#include "Time.H"
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
Foam::tmp<Foam::IOField<Type>> Foam::reconstructLagrangianField
Foam::tmp<Foam::IOField<Type>>
Foam::lagrangianReconstructor::reconstructField
(
const word& cloudName,
const polyMesh& mesh,
const PtrList<fvMesh>& meshes,
const word& fieldName
)
{
@ -44,17 +43,17 @@ Foam::tmp<Foam::IOField<Type>> Foam::reconstructLagrangianField
IOobject
(
fieldName,
mesh.time().timeName(),
mesh_.time().timeName(),
cloud::prefix/cloudName,
mesh,
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
Field<Type>(0)
Field<Type>()
);
auto& field = tfield.ref();
for (const fvMesh& localMesh : meshes)
for (const fvMesh& localMesh : procMeshes_)
{
// Check object on local mesh
IOobject localIOobject
@ -87,11 +86,9 @@ Foam::tmp<Foam::IOField<Type>> Foam::reconstructLagrangianField
template<class Type>
Foam::tmp<Foam::CompactIOField<Foam::Field<Type>, Type>>
Foam::reconstructLagrangianFieldField
Foam::lagrangianReconstructor::reconstructFieldField
(
const word& cloudName,
const polyMesh& mesh,
const PtrList<fvMesh>& meshes,
const word& fieldName
)
{
@ -101,17 +98,17 @@ Foam::reconstructLagrangianFieldField
IOobject
(
fieldName,
mesh.time().timeName(),
mesh_.time().timeName(),
cloud::prefix/cloudName,
mesh,
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
Field<Field<Type>>(0)
Field<Field<Type>>()
);
auto& field = tfield.ref();
for (const fvMesh& localMesh : meshes)
for (const fvMesh& localMesh : procMeshes_)
{
// Check object on local mesh
IOobject localIOobject
@ -150,117 +147,100 @@ Foam::reconstructLagrangianFieldField
template<class Type>
void Foam::reconstructLagrangianFields
Foam::label Foam::lagrangianReconstructor::reconstructFields
(
const word& cloudName,
const polyMesh& mesh,
const PtrList<fvMesh>& meshes,
const IOobjectList& objects,
const wordHashSet& selectedFields
const UList<word>& fieldNames
)
{
const word& clsName = IOField<Type>::typeName;
const wordList fieldNames =
(
selectedFields.empty()
? objects.sortedNames(clsName)
: objects.sortedNames(clsName, selectedFields)
);
if (fieldNames.size())
{
Info<< " Reconstructing lagrangian " << clsName << "s\n" << nl;
}
typedef IOField<Type> fieldType;
label nFields = 0;
for (const word& fieldName : fieldNames)
{
const IOobject* io = objects.cfindObject<fieldType>(fieldName);
if (io)
{
if (nFields++)
{
Info<< " Reconstructing lagrangian "
<< fieldType::typeName << "s\n" << nl;
}
Info<< " " << fieldName << endl;
reconstructLagrangianField<Type>
(
cloudName,
mesh,
meshes,
fieldName
)().write();
reconstructField<Type>(cloudName, fieldName)().write();
}
}
if (fieldNames.size()) Info<< endl;
if (nFields) Info<< endl;
return nFields;
}
template<class Type>
void Foam::reconstructLagrangianFieldFields
Foam::label Foam::lagrangianReconstructor::reconstructFields
(
const word& cloudName,
const polyMesh& mesh,
const PtrList<fvMesh>& meshes,
const IOobjectList& objects,
const wordHashSet& selectedFields
const wordRes& selectedFields
)
{
{
const word& clsName = CompactIOField<Field<Type>,Type>::typeName;
typedef IOField<Type> fieldType;
const wordList fieldNames =
(
selectedFields.empty()
? objects.sortedNames(clsName)
: objects.sortedNames(clsName, selectedFields)
? objects.sortedNames<fieldType>()
: objects.sortedNames<fieldType>(selectedFields)
);
if (fieldNames.size())
{
Info<< " Reconstructing lagrangian " << clsName << "s\n" << nl;
return reconstructFields<Type>(cloudName, objects, fieldNames);
}
for (const word& fieldName : fieldNames)
{
Info<< " " << fieldName << endl;
reconstructLagrangianFieldField<Type>
template<class Type>
Foam::label Foam::lagrangianReconstructor::reconstructFieldFields
(
cloudName,
mesh,
meshes,
fieldName
)().write();
}
if (fieldNames.size()) Info<< endl;
}
const word& cloudName,
const IOobjectList& objects,
const wordRes& selectedFields
)
{
const word& clsName = IOField<Field<Type>>::typeName;
typedef CompactIOField<Field<Type>, Type> fieldType;
const wordList fieldNames =
wordList fieldNames =
(
selectedFields.empty()
? objects.sortedNames(clsName)
: objects.sortedNames(clsName, selectedFields)
? objects.names<fieldType>()
: objects.names<fieldType>(selectedFields)
);
if (fieldNames.size())
{
Info<< " Reconstructing lagrangian " << clsName << "s\n" << nl;
}
// Append IOField Field names
fieldNames.append
(
objects.empty()
? objects.names<IOField<Field<Type>>>()
: objects.names<IOField<Field<Type>>>(selectedFields)
);
Foam::sort(fieldNames);
label nFields = 0;
for (const word& fieldName : fieldNames)
{
if (!nFields++)
{
Info<< " Reconstructing lagrangian "
<< fieldType::typeName << "s\n" << nl;
}
Info<< " " << fieldName << endl;
reconstructLagrangianFieldField<Type>
(
cloudName,
mesh,
meshes,
fieldName
)().write();
reconstructFieldField<Type>(cloudName, fieldName)().write();
}
if (fieldNames.size()) Info<< endl;
}
if (nFields) Info<< endl;
return nFields;
}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -29,6 +29,7 @@ Description
SourceFiles
pointFieldReconstructor.C
pointFieldReconstructorFields.C
\*---------------------------------------------------------------------------*/
@ -149,9 +150,28 @@ public:
tmp<GeometricField<Type, pointPatchField, pointMesh>>
reconstructField(const IOobject& fieldIoObject);
//- Reconstruct and write all fields
//- Reconstruct and write specified fields
template<class Type>
void reconstructFields
label reconstructFields
(
const IOobjectList& objects,
const UList<word>& fieldNames
);
//- Reconstruct and write all or selected fields
// An empty wordRes corresponds to select ALL.
template<class Type>
label reconstructFields
(
const IOobjectList& objects,
const wordRes& selectedFields = wordRes()
);
//- Reconstruct and write all or selected fields
// An empty wordHashSet corresponds to select ALL.
// \note this may be removed in the future (2018-11)
template<class Type>
label reconstructFields
(
const IOobjectList& objects,
const wordHashSet& selectedFields
@ -166,7 +186,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "pointFieldReconstructorReconstructFields.C"
#include "pointFieldReconstructorFields.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -135,37 +135,75 @@ Foam::pointFieldReconstructor::reconstructField(const IOobject& fieldIoObject)
}
// Reconstruct and write all point fields
template<class Type>
void Foam::pointFieldReconstructor::reconstructFields
Foam::label Foam::pointFieldReconstructor::reconstructFields
(
const IOobjectList& objects,
const UList<word>& fieldNames
)
{
typedef GeometricField<Type, pointPatchField, pointMesh> fieldType;
label nFields = 0;
for (const word& fieldName : fieldNames)
{
const IOobject* io = objects.cfindObject<fieldType>(fieldName);
if (io)
{
if (!nFields++)
{
Info<< " Reconstructing "
<< fieldType::typeName << "s\n" << nl;
}
Info<< " " << fieldName << endl;
reconstructField<Type>(*io)().write();
++nReconstructed_;
}
}
if (nFields) Info<< endl;
return nFields;
}
template<class Type>
Foam::label Foam::pointFieldReconstructor::reconstructFields
(
const IOobjectList& objects,
const wordRes& selectedFields
)
{
typedef GeometricField<Type, pointPatchField, pointMesh> fieldType;
const wordList fieldNames =
(
selectedFields.empty()
? objects.sortedNames<fieldType>()
: objects.sortedNames<fieldType>(selectedFields)
);
return reconstructFields<Type>(objects, fieldNames);
}
template<class Type>
Foam::label Foam::pointFieldReconstructor::reconstructFields
(
const IOobjectList& objects,
const wordHashSet& selectedFields
)
{
const word& clsName =
GeometricField<Type, pointPatchField, pointMesh>::typeName;
typedef GeometricField<Type, pointPatchField, pointMesh> fieldType;
const wordList fieldNames =
(
selectedFields.empty()
? objects.sortedNames(clsName)
: objects.sortedNames(clsName, selectedFields)
? objects.sortedNames<fieldType>()
: objects.sortedNames<fieldType>(selectedFields)
);
if (fieldNames.size())
{
Info<< " Reconstructing " << clsName << "s\n" << nl;
}
for (const word& fieldName : fieldNames)
{
Info<< " " << fieldName << endl;
reconstructField<Type>(*(objects[fieldName]))().write();
}
if (fieldNames.size()) Info<< endl;
return reconstructFields<Type>(objects, fieldNames);
}

View File

@ -45,7 +45,6 @@ SourceFiles
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class processorMeshes Declaration
\*---------------------------------------------------------------------------*/

View File

@ -1,117 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
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/>.
InClass
Foam::reconstructLagrangian
Description
SourceFiles
reconstructLagrangianFields.C
reconstructLagrangianPositions.C
\*---------------------------------------------------------------------------*/
#ifndef reconstructLagrangian_H
#define reconstructLagrangian_H
#include "cloud.H"
#include "polyMesh.H"
#include "IOobjectList.H"
#include "CompactIOField.H"
#include "fvMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void reconstructLagrangianPositions
(
const polyMesh& mesh,
const word& cloudName,
const PtrList<fvMesh>& meshes,
const PtrList<labelIOList>& faceProcAddressing,
const PtrList<labelIOList>& cellProcAddressing
);
template<class Type>
tmp<IOField<Type>> reconstructLagrangianField
(
const word& cloudName,
const polyMesh& mesh,
const PtrList<fvMesh>& meshes,
const word& fieldName
);
template<class Type>
tmp<CompactIOField<Field<Type>, Type>> reconstructLagrangianFieldField
(
const word& cloudName,
const polyMesh& mesh,
const PtrList<fvMesh>& meshes,
const word& fieldName
);
template<class Type>
void reconstructLagrangianFields
(
const word& cloudName,
const polyMesh& mesh,
const PtrList<fvMesh>& meshes,
const IOobjectList& objects,
const wordHashSet& selectedFields
);
template<class Type>
void reconstructLagrangianFieldFields
(
const word& cloudName,
const polyMesh& mesh,
const PtrList<fvMesh>& meshes,
const IOobjectList& objects,
const wordHashSet& selectedFields
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "reconstructLagrangianFields.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //