mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: allow wordHashSet filter for IOobjectList::names
- simplifies usage. Support syncPar check on names() to detect inconsistencies. - simplify readFields, ReadFields and other routines by using these new methods.
This commit is contained in:
@ -54,7 +54,7 @@ void RotateFields
|
||||
// Objects of field type
|
||||
IOobjectList fields(objects.lookupClass(GeometricField::typeName));
|
||||
|
||||
forAllIter(IOobjectList, fields, fieldIter)
|
||||
forAllConstIters(fields, fieldIter)
|
||||
{
|
||||
Info<< " Rotating " << fieldIter()->name() << endl;
|
||||
|
||||
|
||||
@ -193,7 +193,7 @@ void printAllSets(const polyMesh& mesh, Ostream& os)
|
||||
if (cellSets.size())
|
||||
{
|
||||
os << "cellSets:" << endl;
|
||||
forAllConstIter(IOobjectList, cellSets, iter)
|
||||
forAllConstIters(cellSets, iter)
|
||||
{
|
||||
cellSet set(*iter());
|
||||
os << '\t' << set.name() << "\tsize:" << set.size() << endl;
|
||||
@ -203,7 +203,7 @@ void printAllSets(const polyMesh& mesh, Ostream& os)
|
||||
if (faceSets.size())
|
||||
{
|
||||
os << "faceSets:" << endl;
|
||||
forAllConstIter(IOobjectList, faceSets, iter)
|
||||
forAllConstIters(faceSets, iter)
|
||||
{
|
||||
faceSet set(*iter());
|
||||
os << '\t' << set.name() << "\tsize:" << set.size() << endl;
|
||||
@ -213,7 +213,7 @@ void printAllSets(const polyMesh& mesh, Ostream& os)
|
||||
if (pointSets.size())
|
||||
{
|
||||
os << "pointSets:" << endl;
|
||||
forAllConstIter(IOobjectList, pointSets, iter)
|
||||
forAllConstIters(pointSets, iter)
|
||||
{
|
||||
pointSet set(*iter());
|
||||
os << '\t' << set.name() << "\tsize:" << set.size() << endl;
|
||||
@ -224,9 +224,8 @@ void printAllSets(const polyMesh& mesh, Ostream& os)
|
||||
if (cellZones.size())
|
||||
{
|
||||
os << "cellZones:" << endl;
|
||||
forAll(cellZones, i)
|
||||
for (const cellZone& zone : cellZones)
|
||||
{
|
||||
const cellZone& zone = cellZones[i];
|
||||
os << '\t' << zone.name() << "\tsize:" << zone.size() << endl;
|
||||
}
|
||||
}
|
||||
@ -234,9 +233,8 @@ void printAllSets(const polyMesh& mesh, Ostream& os)
|
||||
if (faceZones.size())
|
||||
{
|
||||
os << "faceZones:" << endl;
|
||||
forAll(faceZones, i)
|
||||
for (const faceZone& zone : faceZones)
|
||||
{
|
||||
const faceZone& zone = faceZones[i];
|
||||
os << '\t' << zone.name() << "\tsize:" << zone.size() << endl;
|
||||
}
|
||||
}
|
||||
@ -244,9 +242,8 @@ void printAllSets(const polyMesh& mesh, Ostream& os)
|
||||
if (pointZones.size())
|
||||
{
|
||||
os << "pointZones:" << endl;
|
||||
forAll(pointZones, i)
|
||||
for (const pointZone& zone : pointZones)
|
||||
{
|
||||
const pointZone& zone = pointZones[i];
|
||||
os << '\t' << zone.name() << "\tsize:" << zone.size() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,7 +107,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
//Pout<< "pointSets:" << pointObjects.names() << endl;
|
||||
|
||||
forAllConstIter(IOobjectList, pointObjects, iter)
|
||||
forAllConstIters(pointObjects, iter)
|
||||
{
|
||||
// Not in memory. Load it.
|
||||
pointSet set(*iter());
|
||||
@ -143,7 +143,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
//Pout<< "faceSets:" << faceObjects.names() << endl;
|
||||
|
||||
forAllConstIter(IOobjectList, faceObjects, iter)
|
||||
forAllConstIters(faceObjects, iter)
|
||||
{
|
||||
// Not in memory. Load it.
|
||||
faceSet set(*iter());
|
||||
@ -269,7 +269,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
//Pout<< "cellSets:" << cellObjects.names() << endl;
|
||||
|
||||
forAllConstIter(IOobjectList, cellObjects, iter)
|
||||
forAllConstIters(cellObjects, iter)
|
||||
{
|
||||
if (!slaveCellSets.found(iter.key()))
|
||||
{
|
||||
|
||||
@ -286,7 +286,7 @@ template<class TopoSet>
|
||||
void subsetTopoSets
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const IOobjectList& objectsList,
|
||||
const IOobjectList& objects,
|
||||
const labelList& map,
|
||||
const fvMesh& subMesh,
|
||||
PtrList<TopoSet>& subSets
|
||||
@ -294,7 +294,7 @@ void subsetTopoSets
|
||||
{
|
||||
// Read original sets
|
||||
PtrList<TopoSet> sets;
|
||||
ReadFields<TopoSet>(objectsList, sets);
|
||||
ReadFields<TopoSet>(objects, sets);
|
||||
|
||||
subSets.setSize(sets.size());
|
||||
forAll(sets, i)
|
||||
|
||||
@ -351,7 +351,7 @@ int main(int argc, char *argv[])
|
||||
// Get list of objects from the database
|
||||
IOobjectList objects(runTime, runTime.timeName(), regionPrefix);
|
||||
|
||||
forAllConstIter(IOobjectList, objects, iter)
|
||||
forAllConstIters(objects, iter)
|
||||
{
|
||||
const word& headerClassName = iter()->headerClassName();
|
||||
|
||||
|
||||
@ -81,9 +81,10 @@ int main(int argc, char *argv[])
|
||||
<< endl;
|
||||
}
|
||||
|
||||
|
||||
const IOobjectList fieldObjs(mesh, runTime.timeName());
|
||||
const wordList objNames = fieldObjs.names();
|
||||
const wordList objNames
|
||||
(
|
||||
IOobjectList(mesh, runTime.timeName()).sortedNames()
|
||||
);
|
||||
|
||||
PtrList<volScalarField> vsf(objNames.size());
|
||||
PtrList<volVectorField> vvf(objNames.size());
|
||||
|
||||
@ -173,21 +173,21 @@ bool Foam::domainDecomposition::writeDecomposition(const bool decomposeSets)
|
||||
IOobjectList objects(*this, facesInstance(), "polyMesh/sets");
|
||||
{
|
||||
IOobjectList cSets(objects.lookupClass(cellSet::typeName));
|
||||
forAllConstIter(IOobjectList, cSets, iter)
|
||||
forAllConstIters(cSets, iter)
|
||||
{
|
||||
cellSets.append(new cellSet(*iter()));
|
||||
}
|
||||
}
|
||||
{
|
||||
IOobjectList fSets(objects.lookupClass(faceSet::typeName));
|
||||
forAllConstIter(IOobjectList, fSets, iter)
|
||||
forAllConstIters(fSets, iter)
|
||||
{
|
||||
faceSets.append(new faceSet(*iter()));
|
||||
}
|
||||
}
|
||||
{
|
||||
IOobjectList pSets(objects.lookupClass(pointSet::typeName));
|
||||
forAllConstIter(IOobjectList, pSets, iter)
|
||||
forAllConstIters(pSets, iter)
|
||||
{
|
||||
pointSets.append(new pointSet(*iter()));
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ void Foam::lagrangianFieldDecomposer::readFields
|
||||
);
|
||||
|
||||
label lagrangianFieldi = 0;
|
||||
forAllIter(IOobjectList, lagrangianTypeObjects, iter)
|
||||
forAllConstIters(lagrangianTypeObjects, iter)
|
||||
{
|
||||
lagrangianFields[cloudI].set
|
||||
(
|
||||
@ -97,7 +97,7 @@ void Foam::lagrangianFieldDecomposer::readFieldFields
|
||||
|
||||
label lagrangianFieldi = 0;
|
||||
|
||||
forAllIter(IOobjectList, lagrangianTypeObjectsA, iter)
|
||||
forAllConstIters(lagrangianTypeObjectsA, iter)
|
||||
{
|
||||
lagrangianFields[cloudI].set
|
||||
(
|
||||
@ -106,7 +106,7 @@ void Foam::lagrangianFieldDecomposer::readFieldFields
|
||||
);
|
||||
}
|
||||
|
||||
forAllIter(IOobjectList, lagrangianTypeObjectsB, iter)
|
||||
forAllConstIters(lagrangianTypeObjectsB, iter)
|
||||
{
|
||||
lagrangianFields[cloudI].set
|
||||
(
|
||||
@ -129,22 +129,19 @@ Foam::lagrangianFieldDecomposer::decomposeField
|
||||
Field<Type> procField(field, particleIndices_);
|
||||
|
||||
// Create the field for the processor
|
||||
return tmp<IOField<Type>>
|
||||
return tmp<IOField<Type>>::New
|
||||
(
|
||||
new IOField<Type>
|
||||
IOobject
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
field.name(),
|
||||
procMesh_.time().timeName(),
|
||||
cloud::prefix/cloudName,
|
||||
procMesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
procField
|
||||
)
|
||||
field.name(),
|
||||
procMesh_.time().timeName(),
|
||||
cloud::prefix/cloudName,
|
||||
procMesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
procField
|
||||
);
|
||||
}
|
||||
|
||||
@ -161,22 +158,19 @@ Foam::lagrangianFieldDecomposer::decomposeFieldField
|
||||
Field<Field<Type>> procField(field, particleIndices_);
|
||||
|
||||
// Create the field for the processor
|
||||
return tmp<CompactIOField<Field<Type>, Type>>
|
||||
return tmp<CompactIOField<Field<Type>, Type>>::New
|
||||
(
|
||||
new CompactIOField<Field<Type>, Type>
|
||||
IOobject
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
field.name(),
|
||||
procMesh_.time().timeName(),
|
||||
cloud::prefix/cloudName,
|
||||
procMesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
procField
|
||||
)
|
||||
field.name(),
|
||||
procMesh_.time().timeName(),
|
||||
cloud::prefix/cloudName,
|
||||
procMesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
procField
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -39,14 +39,14 @@ void Foam::readFields
|
||||
{
|
||||
typedef GeometricField<Type, PatchField, GeoMesh> GeoField;
|
||||
|
||||
// Search list of objects for fields of type GeomField
|
||||
// Search list of objects for fields of type GeoField
|
||||
IOobjectList fieldObjects(objects.lookupClass(GeoField::typeName));
|
||||
|
||||
// Remove the cellDist field
|
||||
IOobjectList::iterator celDistIter = fieldObjects.find("cellDist");
|
||||
if (celDistIter != fieldObjects.end())
|
||||
auto iter = fieldObjects.find("cellDist");
|
||||
if (iter.found())
|
||||
{
|
||||
fieldObjects.erase(celDistIter);
|
||||
fieldObjects.erase(iter);
|
||||
}
|
||||
|
||||
// Get sorted set of names (different processors might read objects in
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd |
|
||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2016-2017 Wikki Ltd
|
||||
@ -273,23 +273,20 @@ Foam::faFieldReconstructor::reconstructFaAreaField
|
||||
|
||||
// Now construct and write the field
|
||||
// setting the internalField and patchFields
|
||||
return tmp<GeometricField<Type, faPatchField, areaMesh>>
|
||||
return tmp<GeometricField<Type, faPatchField, areaMesh>>::New
|
||||
(
|
||||
new GeometricField<Type, faPatchField, areaMesh>
|
||||
IOobject
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
fieldIoObject.name(),
|
||||
mesh_.time().timeName(),
|
||||
mesh_(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh_,
|
||||
procFields[0].dimensions(),
|
||||
internalField,
|
||||
patchFields
|
||||
)
|
||||
fieldIoObject.name(),
|
||||
mesh_.time().timeName(),
|
||||
mesh_(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh_,
|
||||
procFields[0].dimensions(),
|
||||
internalField,
|
||||
patchFields
|
||||
);
|
||||
}
|
||||
|
||||
@ -553,23 +550,20 @@ Foam::faFieldReconstructor::reconstructFaEdgeField
|
||||
|
||||
// Now construct and write the field
|
||||
// setting the internalField and patchFields
|
||||
return tmp<GeometricField<Type, faePatchField, edgeMesh>>
|
||||
return tmp<GeometricField<Type, faePatchField, edgeMesh>>::New
|
||||
(
|
||||
new GeometricField<Type, faePatchField, edgeMesh>
|
||||
IOobject
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
fieldIoObject.name(),
|
||||
mesh_.time().timeName(),
|
||||
mesh_(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh_,
|
||||
procFields[0].dimensions(),
|
||||
internalField,
|
||||
patchFields
|
||||
)
|
||||
fieldIoObject.name(),
|
||||
mesh_.time().timeName(),
|
||||
mesh_(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh_,
|
||||
procFields[0].dimensions(),
|
||||
internalField,
|
||||
patchFields
|
||||
);
|
||||
}
|
||||
|
||||
@ -581,31 +575,26 @@ void Foam::faFieldReconstructor::reconstructFaAreaFields
|
||||
const IOobjectList& objects
|
||||
)
|
||||
{
|
||||
const word& fieldClassName =
|
||||
const word& clsName =
|
||||
GeometricField<Type, faPatchField, areaMesh>::typeName;
|
||||
|
||||
IOobjectList fields = objects.lookupClass(fieldClassName);
|
||||
const wordList fieldNames = objects.sortedNames(clsName);
|
||||
|
||||
if (fields.size())
|
||||
if (fieldNames.size())
|
||||
{
|
||||
Info<< " Reconstructing " << fieldClassName << "s\n" << endl;
|
||||
|
||||
for
|
||||
(
|
||||
IOobjectList::const_iterator fieldIter = fields.begin();
|
||||
fieldIter != fields.end();
|
||||
++fieldIter
|
||||
)
|
||||
{
|
||||
Info << " " << fieldIter()->name() << endl;
|
||||
|
||||
reconstructFaAreaField<Type>(*fieldIter())().write();
|
||||
}
|
||||
|
||||
Info<< endl;
|
||||
Info<< " Reconstructing " << clsName << "s\n" << endl;
|
||||
}
|
||||
|
||||
for (const word& fieldName : fieldNames)
|
||||
{
|
||||
Info << " " << fieldName << endl;
|
||||
reconstructFaAreaField<Type>(*(objects[fieldName]))().write();
|
||||
}
|
||||
|
||||
if (fieldNames.size()) Info<< endl;
|
||||
}
|
||||
|
||||
|
||||
// Reconstruct and write all edge fields
|
||||
template<class Type>
|
||||
void Foam::faFieldReconstructor::reconstructFaEdgeFields
|
||||
@ -613,29 +602,24 @@ void Foam::faFieldReconstructor::reconstructFaEdgeFields
|
||||
const IOobjectList& objects
|
||||
)
|
||||
{
|
||||
const word& fieldClassName =
|
||||
const word& clsName =
|
||||
GeometricField<Type, faePatchField, edgeMesh>::typeName;
|
||||
|
||||
IOobjectList fields = objects.lookupClass(fieldClassName);
|
||||
const wordList fieldNames = objects.sortedNames(clsName);
|
||||
|
||||
if (fields.size())
|
||||
if (fieldNames.size())
|
||||
{
|
||||
Info<< " Reconstructing " << fieldClassName << "s\n" << endl;
|
||||
|
||||
for
|
||||
(
|
||||
IOobjectList::const_iterator fieldIter = fields.begin();
|
||||
fieldIter != fields.end();
|
||||
++fieldIter
|
||||
)
|
||||
{
|
||||
Info<< " " << fieldIter()->name() << endl;
|
||||
|
||||
reconstructFaEdgeField<Type>(*fieldIter())().write();
|
||||
}
|
||||
|
||||
Info<< endl;
|
||||
Info<< " Reconstructing " << clsName << "s\n" << endl;
|
||||
}
|
||||
|
||||
for (const word& fieldName : fieldNames)
|
||||
{
|
||||
Info << " " << fieldName << endl;
|
||||
|
||||
reconstructFaEdgeField<Type>(*(objects[fieldName]))().write();
|
||||
}
|
||||
|
||||
if (fieldNames.size()) Info<< endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -780,18 +780,18 @@ int main(int argc, char *argv[])
|
||||
);
|
||||
|
||||
IOobjectList cSets(objects.lookupClass(cellSet::typeName));
|
||||
forAllConstIter(IOobjectList, cSets, iter)
|
||||
forAllConstIters(cSets, iter)
|
||||
{
|
||||
cSetNames.insert(iter.key(), cSetNames.size());
|
||||
}
|
||||
|
||||
IOobjectList fSets(objects.lookupClass(faceSet::typeName));
|
||||
forAllConstIter(IOobjectList, fSets, iter)
|
||||
forAllConstIters(fSets, iter)
|
||||
{
|
||||
fSetNames.insert(iter.key(), fSetNames.size());
|
||||
}
|
||||
IOobjectList pSets(objects.lookupClass(pointSet::typeName));
|
||||
forAllConstIter(IOobjectList, pSets, iter)
|
||||
forAllConstIters(pSets, iter)
|
||||
{
|
||||
pSetNames.insert(iter.key(), pSetNames.size());
|
||||
}
|
||||
@ -842,7 +842,7 @@ int main(int argc, char *argv[])
|
||||
objects.lookupClass(cellSet::typeName)
|
||||
);
|
||||
|
||||
forAllConstIter(IOobjectList, cSets, iter)
|
||||
forAllConstIters(cSets, iter)
|
||||
{
|
||||
// Load cellSet
|
||||
const cellSet procSet(*iter());
|
||||
@ -878,7 +878,7 @@ int main(int argc, char *argv[])
|
||||
objects.lookupClass(faceSet::typeName)
|
||||
);
|
||||
|
||||
forAllConstIter(IOobjectList, fSets, iter)
|
||||
forAllConstIters(fSets, iter)
|
||||
{
|
||||
// Load faceSet
|
||||
const faceSet procSet(*iter());
|
||||
@ -912,7 +912,7 @@ int main(int argc, char *argv[])
|
||||
(
|
||||
objects.lookupClass(pointSet::typeName)
|
||||
);
|
||||
forAllConstIter(IOobjectList, pSets, iter)
|
||||
forAllConstIters(pSets, iter)
|
||||
{
|
||||
// Load pointSet
|
||||
const pointSet propSet(*iter());
|
||||
|
||||
@ -159,7 +159,7 @@ Foam::autoPtr<Foam::fvMesh> Foam::loadOrCreateMesh
|
||||
|
||||
if (!haveMesh)
|
||||
{
|
||||
bool oldParRun = Pstream::parRun();
|
||||
const bool oldParRun = Pstream::parRun();
|
||||
Pstream::parRun() = false;
|
||||
|
||||
|
||||
@ -383,17 +383,17 @@ Foam::autoPtr<Foam::fvMesh> Foam::loadOrCreateMesh
|
||||
|
||||
if (!haveMesh)
|
||||
{
|
||||
forAll(pointSetNames, i)
|
||||
for (const word& setName : pointSetNames)
|
||||
{
|
||||
pointSet(mesh, pointSetNames[i], 0).write();
|
||||
pointSet(mesh, setName, 0).write();
|
||||
}
|
||||
forAll(faceSetNames, i)
|
||||
for (const word& setName : faceSetNames)
|
||||
{
|
||||
faceSet(mesh, faceSetNames[i], 0).write();
|
||||
faceSet(mesh, setName, 0).write();
|
||||
}
|
||||
forAll(cellSetNames, i)
|
||||
for (const word& setName : cellSetNames)
|
||||
{
|
||||
cellSet(mesh, cellSetNames[i], 0).write();
|
||||
cellSet(mesh, setName, 0).write();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -66,15 +66,12 @@ Foam::parFvFieldReconstructor::reconstructFvVolumeInternalField
|
||||
IOobject::NO_WRITE
|
||||
);
|
||||
|
||||
tmp<DimensionedField<Type, volMesh>> tfield
|
||||
auto tfield = tmp<DimensionedField<Type, volMesh>>::New
|
||||
(
|
||||
new DimensionedField<Type, volMesh>
|
||||
(
|
||||
baseIO,
|
||||
baseMesh_,
|
||||
fld.dimensions(),
|
||||
internalField
|
||||
)
|
||||
baseIO,
|
||||
baseMesh_,
|
||||
fld.dimensions(),
|
||||
internalField
|
||||
);
|
||||
|
||||
tfield.ref().oriented() = fld.oriented();
|
||||
@ -213,16 +210,13 @@ Foam::parFvFieldReconstructor::reconstructFvVolumeField
|
||||
IOobject::NO_WRITE
|
||||
);
|
||||
|
||||
tmp<GeometricField<Type, fvPatchField, volMesh>> tfield
|
||||
auto tfield = tmp<GeometricField<Type, fvPatchField, volMesh>>::New
|
||||
(
|
||||
new GeometricField<Type, fvPatchField, volMesh>
|
||||
(
|
||||
baseIO,
|
||||
baseMesh_,
|
||||
fld.dimensions(),
|
||||
internalField,
|
||||
basePatchFields
|
||||
)
|
||||
baseIO,
|
||||
baseMesh_,
|
||||
fld.dimensions(),
|
||||
internalField,
|
||||
basePatchFields
|
||||
);
|
||||
|
||||
tfield.ref().oriented()= fld.oriented();
|
||||
@ -380,16 +374,13 @@ Foam::parFvFieldReconstructor::reconstructFvSurfaceField
|
||||
IOobject::NO_WRITE
|
||||
);
|
||||
|
||||
tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> tfield
|
||||
auto tfield = tmp<GeometricField<Type, fvsPatchField, surfaceMesh>>::New
|
||||
(
|
||||
new GeometricField<Type, fvsPatchField, surfaceMesh>
|
||||
(
|
||||
baseIO,
|
||||
baseMesh_,
|
||||
fld.dimensions(),
|
||||
internalField,
|
||||
basePatchFields
|
||||
)
|
||||
baseIO,
|
||||
baseMesh_,
|
||||
fld.dimensions(),
|
||||
internalField,
|
||||
basePatchFields
|
||||
);
|
||||
|
||||
tfield.ref().oriented() = fld.oriented();
|
||||
@ -423,37 +414,37 @@ void Foam::parFvFieldReconstructor::reconstructFvVolumeInternalFields
|
||||
const wordHashSet& selectedFields
|
||||
) const
|
||||
{
|
||||
const word& fieldClassName = DimensionedField<Type, volMesh>::typeName;
|
||||
typedef DimensionedField<Type, volMesh> FieldType;
|
||||
const word& clsName = FieldType::typeName;
|
||||
|
||||
IOobjectList fields = objects.lookupClass(fieldClassName);
|
||||
// Available fields, sorted order
|
||||
const wordList fieldNames =
|
||||
(
|
||||
selectedFields.empty()
|
||||
? objects.sortedNames(clsName)
|
||||
: objects.sortedNames(clsName, selectedFields)
|
||||
);
|
||||
|
||||
if (fields.size())
|
||||
if (fieldNames.size())
|
||||
{
|
||||
Info<< " Reconstructing " << fieldClassName << "s\n" << endl;
|
||||
|
||||
forAllConstIter(IOobjectList, fields, fieldIter)
|
||||
{
|
||||
if
|
||||
(
|
||||
selectedFields.empty()
|
||||
|| selectedFields.found(fieldIter()->name())
|
||||
)
|
||||
{
|
||||
Info<< " " << fieldIter()->name() << endl;
|
||||
|
||||
tmp<DimensionedField<Type, volMesh>> tfld
|
||||
(
|
||||
reconstructFvVolumeInternalField<Type>(*fieldIter())
|
||||
);
|
||||
|
||||
if (isWriteProc_)
|
||||
{
|
||||
tfld().write();
|
||||
}
|
||||
}
|
||||
}
|
||||
Info<< endl;
|
||||
Info<< " Reconstructing " << clsName << "s\n" << endl;
|
||||
}
|
||||
|
||||
for (const word& fieldName : fieldNames)
|
||||
{
|
||||
Info<< " " << fieldName << endl;
|
||||
|
||||
tmp<FieldType> tfld
|
||||
(
|
||||
reconstructFvVolumeInternalField<Type>(*(objects[fieldName]))
|
||||
);
|
||||
if (isWriteProc_)
|
||||
{
|
||||
tfld().write();
|
||||
}
|
||||
}
|
||||
|
||||
if (fieldNames.size()) Info<< endl;
|
||||
}
|
||||
|
||||
|
||||
@ -464,39 +455,41 @@ void Foam::parFvFieldReconstructor::reconstructFvVolumeFields
|
||||
const wordHashSet& selectedFields
|
||||
) const
|
||||
{
|
||||
const word& fieldClassName =
|
||||
GeometricField<Type, fvPatchField, volMesh>::typeName;
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> FieldType;
|
||||
const word& clsName = FieldType::typeName;
|
||||
|
||||
IOobjectList fields = objects.lookupClass(fieldClassName);
|
||||
// Available fields, sorted order
|
||||
const wordList fieldNames =
|
||||
(
|
||||
selectedFields.empty()
|
||||
? objects.sortedNames(clsName)
|
||||
: objects.sortedNames(clsName, selectedFields)
|
||||
);
|
||||
|
||||
if (fields.size())
|
||||
if (fieldNames.size())
|
||||
{
|
||||
Info<< " Reconstructing " << fieldClassName << "s\n" << endl;
|
||||
|
||||
forAllConstIter(IOobjectList, fields, fieldIter)
|
||||
{
|
||||
const word& name = fieldIter()->name();
|
||||
|
||||
if
|
||||
(
|
||||
(selectedFields.empty() || selectedFields.found(name))
|
||||
&& name != "cellDist"
|
||||
)
|
||||
{
|
||||
Info<< " " << name << endl;
|
||||
|
||||
tmp<GeometricField<Type, fvPatchField, volMesh>> tfld
|
||||
(
|
||||
reconstructFvVolumeField<Type>(*fieldIter())
|
||||
);
|
||||
if (isWriteProc_)
|
||||
{
|
||||
tfld().write();
|
||||
}
|
||||
}
|
||||
}
|
||||
Info<< endl;
|
||||
Info<< " Reconstructing " << clsName << "s\n" << endl;
|
||||
}
|
||||
|
||||
for (const word& fieldName : fieldNames)
|
||||
{
|
||||
if ("cellDist" == fieldName)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Info<< " " << fieldName << endl;
|
||||
|
||||
tmp<FieldType> tfld
|
||||
(
|
||||
reconstructFvVolumeField<Type>(*(objects[fieldName]))
|
||||
);
|
||||
if (isWriteProc_)
|
||||
{
|
||||
tfld().write();
|
||||
}
|
||||
}
|
||||
|
||||
if (fieldNames.size()) Info<< endl;
|
||||
}
|
||||
|
||||
|
||||
@ -507,37 +500,37 @@ void Foam::parFvFieldReconstructor::reconstructFvSurfaceFields
|
||||
const wordHashSet& selectedFields
|
||||
) const
|
||||
{
|
||||
const word& fieldClassName =
|
||||
GeometricField<Type, fvsPatchField, surfaceMesh>::typeName;
|
||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> FieldType;
|
||||
const word& clsName = FieldType::typeName;
|
||||
|
||||
IOobjectList fields = objects.lookupClass(fieldClassName);
|
||||
// Available fields, sorted order
|
||||
const wordList fieldNames =
|
||||
(
|
||||
selectedFields.empty()
|
||||
? objects.sortedNames(clsName)
|
||||
: objects.sortedNames(clsName, selectedFields)
|
||||
);
|
||||
|
||||
if (fields.size())
|
||||
if (fieldNames.size())
|
||||
{
|
||||
Info<< " Reconstructing " << fieldClassName << "s\n" << endl;
|
||||
|
||||
forAllConstIter(IOobjectList, fields, fieldIter)
|
||||
{
|
||||
if
|
||||
(
|
||||
selectedFields.empty()
|
||||
|| selectedFields.found(fieldIter()->name())
|
||||
)
|
||||
{
|
||||
Info<< " " << fieldIter()->name() << endl;
|
||||
|
||||
tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> tfld
|
||||
(
|
||||
reconstructFvSurfaceField<Type>(*fieldIter())
|
||||
);
|
||||
if (isWriteProc_)
|
||||
{
|
||||
tfld().write();
|
||||
}
|
||||
}
|
||||
}
|
||||
Info<< endl;
|
||||
Info<< " Reconstructing " << clsName << "s\n" << endl;
|
||||
}
|
||||
|
||||
for (const word& fieldName : fieldNames)
|
||||
{
|
||||
Info<< " " << fieldName << endl;
|
||||
|
||||
tmp<FieldType> tfld
|
||||
(
|
||||
reconstructFvSurfaceField<Type>(*(objects[fieldName]))
|
||||
);
|
||||
if (isWriteProc_)
|
||||
{
|
||||
tfld().write();
|
||||
}
|
||||
}
|
||||
|
||||
if (fieldNames.size()) Info<< endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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.
|
||||
@ -40,25 +40,20 @@ Foam::wordList Foam::parLagrangianRedistributor::filterObjects
|
||||
const wordHashSet& selectedFields
|
||||
)
|
||||
{
|
||||
const word fieldClassName(Container::typeName);
|
||||
|
||||
// Parallel synchronise
|
||||
wordList fieldNames(objects.names(fieldClassName));
|
||||
wordList fieldNames =
|
||||
(
|
||||
selectedFields.empty()
|
||||
? objects.names(Container::typeName)
|
||||
: objects.names(Container::typeName, selectedFields)
|
||||
);
|
||||
|
||||
Pstream::combineGather(fieldNames, ListOps::uniqueEqOp<word>());
|
||||
Pstream::combineScatter(fieldNames);
|
||||
|
||||
if (!selectedFields.empty())
|
||||
{
|
||||
DynamicList<word> selectedNames(fieldNames.size());
|
||||
forAll(fieldNames, i)
|
||||
{
|
||||
if (selectedFields.found(fieldNames[i]))
|
||||
{
|
||||
selectedNames.append(fieldNames[i]);
|
||||
}
|
||||
}
|
||||
fieldNames.transfer(selectedNames);
|
||||
}
|
||||
// Ensure order is consistent
|
||||
Foam::sort(fieldNames);
|
||||
|
||||
return fieldNames;
|
||||
}
|
||||
|
||||
@ -72,6 +67,8 @@ void Foam::parLagrangianRedistributor::redistributeLagrangianFields
|
||||
const wordHashSet& selectedFields
|
||||
) const
|
||||
{
|
||||
const word fieldClassName(IOField<Type>::typeName);
|
||||
|
||||
const wordList objectNames
|
||||
(
|
||||
filterObjects<IOField<Type>>
|
||||
@ -83,55 +80,53 @@ void Foam::parLagrangianRedistributor::redistributeLagrangianFields
|
||||
|
||||
if (objectNames.size())
|
||||
{
|
||||
const word fieldClassName(IOField<Type>::typeName);
|
||||
|
||||
Info<< " Redistributing lagrangian "
|
||||
<< fieldClassName << "s\n" << endl;
|
||||
}
|
||||
|
||||
forAll(objectNames, i)
|
||||
for (const word& objectName : objectNames)
|
||||
{
|
||||
Info<< " " << objectName << endl;
|
||||
|
||||
// Read if present
|
||||
IOField<Type> field
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
objectName,
|
||||
srcMesh_.time().timeName(),
|
||||
cloud::prefix/cloudName,
|
||||
srcMesh_,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
label(0)
|
||||
);
|
||||
|
||||
map.distribute(field);
|
||||
|
||||
|
||||
if (field.size())
|
||||
{
|
||||
Info<< " " << objectNames[i] << endl;
|
||||
|
||||
// Read if present
|
||||
IOField<Type> field
|
||||
IOField<Type>
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
objectNames[i],
|
||||
srcMesh_.time().timeName(),
|
||||
objectName,
|
||||
tgtMesh_.time().timeName(),
|
||||
cloud::prefix/cloudName,
|
||||
srcMesh_,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
tgtMesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
label(0)
|
||||
);
|
||||
|
||||
map.distribute(field);
|
||||
|
||||
|
||||
if (field.size())
|
||||
{
|
||||
IOField<Type>
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
objectNames[i],
|
||||
tgtMesh_.time().timeName(),
|
||||
cloud::prefix/cloudName,
|
||||
tgtMesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
std::move(field)
|
||||
).write();
|
||||
}
|
||||
std::move(field)
|
||||
).write();
|
||||
}
|
||||
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
if (objectNames.size()) Info<< endl;
|
||||
}
|
||||
|
||||
|
||||
@ -144,6 +139,8 @@ void Foam::parLagrangianRedistributor::redistributeLagrangianFieldFields
|
||||
const wordHashSet& selectedFields
|
||||
) const
|
||||
{
|
||||
const word fieldClassName(CompactIOField<Field<Type>, Type>::typeName);
|
||||
|
||||
wordList objectNames
|
||||
(
|
||||
filterObjects<CompactIOField<Field<Type>, Type>>
|
||||
@ -153,9 +150,9 @@ void Foam::parLagrangianRedistributor::redistributeLagrangianFieldFields
|
||||
)
|
||||
);
|
||||
|
||||
// Append IOField names
|
||||
// Append IOField Field names
|
||||
{
|
||||
const wordList ioFieldNames
|
||||
wordList ioFieldNames
|
||||
(
|
||||
filterObjects<IOField<Field<Type>>>
|
||||
(
|
||||
@ -169,52 +166,50 @@ void Foam::parLagrangianRedistributor::redistributeLagrangianFieldFields
|
||||
|
||||
if (objectNames.size())
|
||||
{
|
||||
const word fieldClassName(CompactIOField<Field<Type>, Type>::typeName);
|
||||
|
||||
Info<< " Redistributing lagrangian "
|
||||
<< fieldClassName << "s\n" << endl;
|
||||
}
|
||||
|
||||
forAll(objectNames, i)
|
||||
for (const word& objectName : objectNames)
|
||||
{
|
||||
Info<< " " << objectName << endl;
|
||||
|
||||
// Read if present
|
||||
CompactIOField<Field<Type>, Type> field
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
objectName,
|
||||
srcMesh_.time().timeName(),
|
||||
cloud::prefix/cloudName,
|
||||
srcMesh_,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
label(0)
|
||||
);
|
||||
|
||||
// Distribute
|
||||
map.distribute(field);
|
||||
|
||||
// Write
|
||||
if (field.size())
|
||||
{
|
||||
Info<< " " << objectNames[i] << endl;
|
||||
|
||||
// Read if present
|
||||
CompactIOField<Field<Type>, Type> field
|
||||
CompactIOField<Field<Type>, Type>
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
objectNames[i],
|
||||
srcMesh_.time().timeName(),
|
||||
objectName,
|
||||
tgtMesh_.time().timeName(),
|
||||
cloud::prefix/cloudName,
|
||||
srcMesh_,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
tgtMesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
label(0)
|
||||
);
|
||||
|
||||
// Distribute
|
||||
map.distribute(field);
|
||||
|
||||
// Write
|
||||
if (field.size())
|
||||
{
|
||||
CompactIOField<Field<Type>, Type>
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
objectNames[i],
|
||||
tgtMesh_.time().timeName(),
|
||||
cloud::prefix/cloudName,
|
||||
tgtMesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
std::move(field)
|
||||
).write();
|
||||
}
|
||||
std::move(field)
|
||||
).write();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -228,6 +223,8 @@ void Foam::parLagrangianRedistributor::readLagrangianFields
|
||||
const wordHashSet& selectedFields
|
||||
)
|
||||
{
|
||||
const word fieldClassName(Container::typeName);
|
||||
|
||||
const wordList objectNames
|
||||
(
|
||||
filterObjects<Container>
|
||||
@ -239,31 +236,29 @@ void Foam::parLagrangianRedistributor::readLagrangianFields
|
||||
|
||||
if (objectNames.size())
|
||||
{
|
||||
const word fieldClassName(Container::typeName);
|
||||
|
||||
Info<< " Reading lagrangian "
|
||||
<< fieldClassName << "s\n" << endl;
|
||||
}
|
||||
|
||||
forAll(objectNames, i)
|
||||
{
|
||||
Info<< " " << objectNames[i] << endl;
|
||||
for (const word& objectName : objectNames)
|
||||
{
|
||||
Info<< " " << objectName << endl;
|
||||
|
||||
// Read if present
|
||||
Container* fieldPtr = new Container
|
||||
// Read if present
|
||||
Container* fieldPtr = new Container
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
objectNames[i],
|
||||
cloud.time().timeName(),
|
||||
cloud,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
label(0)
|
||||
);
|
||||
objectName,
|
||||
cloud.time().timeName(),
|
||||
cloud,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
label(0)
|
||||
);
|
||||
|
||||
fieldPtr->store();
|
||||
}
|
||||
fieldPtr->store();
|
||||
}
|
||||
}
|
||||
|
||||
@ -275,6 +270,8 @@ void Foam::parLagrangianRedistributor::redistributeStoredLagrangianFields
|
||||
passivePositionParticleCloud& cloud
|
||||
) const
|
||||
{
|
||||
const word fieldClassName(Container::typeName);
|
||||
|
||||
HashTable<Container*> fields
|
||||
(
|
||||
cloud.lookupClass<Container>()
|
||||
@ -282,36 +279,34 @@ void Foam::parLagrangianRedistributor::redistributeStoredLagrangianFields
|
||||
|
||||
if (fields.size())
|
||||
{
|
||||
const word fieldClassName(Container::typeName);
|
||||
|
||||
Info<< " Redistributing lagrangian "
|
||||
<< fieldClassName << "s\n" << endl;
|
||||
}
|
||||
|
||||
forAllIter(typename HashTable<Container*>, fields, iter)
|
||||
forAllIters(fields, iter)
|
||||
{
|
||||
Container& field = *(*iter);
|
||||
|
||||
Info<< " " << field.name() << endl;
|
||||
|
||||
map.distribute(field);
|
||||
|
||||
if (field.size())
|
||||
{
|
||||
Container& field = *iter();
|
||||
|
||||
Info<< " " << field.name() << endl;
|
||||
|
||||
map.distribute(field);
|
||||
|
||||
if (field.size())
|
||||
{
|
||||
Container
|
||||
Container
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
field.name(),
|
||||
tgtMesh_.time().timeName(),
|
||||
cloud::prefix/cloud.name(),
|
||||
tgtMesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
std::move(field)
|
||||
).write();
|
||||
}
|
||||
field.name(),
|
||||
tgtMesh_.time().timeName(),
|
||||
cloud::prefix/cloud.name(),
|
||||
tgtMesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
std::move(field)
|
||||
).write();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -636,11 +636,11 @@ void readFields
|
||||
if (haveMesh[Pstream::myProcNo()] && objectNames != masterNames)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "differing fields of type " << GeoField::typeName
|
||||
<< " on processors." << nl
|
||||
<< "Master has:" << masterNames << endl
|
||||
<< Pstream::myProcNo() << " has:" << objectNames
|
||||
<< abort(FatalError);
|
||||
<< "Objects not synchronised across processors." << nl
|
||||
<< "Master has " << flatOutput(masterNames) << nl
|
||||
<< "Processor " << Pstream::myProcNo()
|
||||
<< " has " << flatOutput(objectNames)
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
fields.setSize(masterNames.size());
|
||||
|
||||
@ -109,51 +109,49 @@ int main(int argc, char *argv[])
|
||||
IOobjectList objects(mesh, runTime.timeName());
|
||||
|
||||
|
||||
// Converting volScalarField
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
// Search list of objects for volScalarFields
|
||||
IOobjectList scalarFields(objects.lookupClass("volScalarField"));
|
||||
|
||||
forAllIter(IOobjectList, scalarFields, iter)
|
||||
// volScalarField
|
||||
for
|
||||
(
|
||||
const word& fieldName
|
||||
: objects.sortedNames(volScalarField::typeName)
|
||||
)
|
||||
{
|
||||
// Read field
|
||||
volScalarField field(*iter(), mesh);
|
||||
|
||||
// lookup field from dictionary and convert field
|
||||
// Lookup field from dictionary and convert field
|
||||
label unitNumber;
|
||||
if
|
||||
(
|
||||
foamDataToFluentDict.readIfPresent(field.name(), unitNumber)
|
||||
foamDataToFluentDict.readIfPresent(fieldName, unitNumber)
|
||||
&& unitNumber > 0
|
||||
)
|
||||
{
|
||||
Info<< " Converting field " << field.name() << endl;
|
||||
// Read field
|
||||
volScalarField field(*(objects[fieldName]), mesh);
|
||||
|
||||
Info<< " Converting field " << fieldName << nl;
|
||||
writeFluentField(field, unitNumber, fluentDataFile);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Converting volVectorField
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
// Search list of objects for volVectorFields
|
||||
IOobjectList vectorFields(objects.lookupClass("volVectorField"));
|
||||
|
||||
forAllIter(IOobjectList, vectorFields, iter)
|
||||
// volVectorField
|
||||
for
|
||||
(
|
||||
const word& fieldName
|
||||
: objects.sortedNames(volVectorField::typeName)
|
||||
)
|
||||
{
|
||||
// Read field
|
||||
volVectorField field(*iter(), mesh);
|
||||
|
||||
// lookup field from dictionary and convert field
|
||||
// Lookup field from dictionary and convert field
|
||||
label unitNumber;
|
||||
if
|
||||
(
|
||||
foamDataToFluentDict.readIfPresent(field.name(), unitNumber)
|
||||
foamDataToFluentDict.readIfPresent(fieldName, unitNumber)
|
||||
&& unitNumber > 0
|
||||
)
|
||||
{
|
||||
Info<< " Converting field " << field.name() << endl;
|
||||
// Read field
|
||||
volVectorField field(*(objects[fieldName]), mesh);
|
||||
|
||||
Info<< " Converting field " << fieldName << nl;
|
||||
writeFluentField(field, unitNumber, fluentDataFile);
|
||||
}
|
||||
}
|
||||
|
||||
@ -316,7 +316,7 @@ int main(int argc, char *argv[])
|
||||
// and doesn't cost much) and simultaneously remove all
|
||||
// "*_0" restart fields
|
||||
|
||||
for (auto fieldType : volFieldTypes)
|
||||
for (const word& fieldType : volFieldTypes)
|
||||
{
|
||||
usableObjects
|
||||
(
|
||||
@ -360,7 +360,7 @@ int main(int argc, char *argv[])
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~
|
||||
Info<< "Write volume field (";
|
||||
|
||||
for (auto fieldType : volFieldTypes)
|
||||
for (const word& fieldType : volFieldTypes)
|
||||
{
|
||||
// For convenience, just force each field-type into existence.
|
||||
// This simplifies code logic and doesn't cost much at all.
|
||||
|
||||
@ -13,7 +13,7 @@ if (timeDirs.size())
|
||||
|
||||
IOobjectList objs(mesh, lastTimeName);
|
||||
|
||||
forAllConstIter(IOobjectList, objs, fieldIter)
|
||||
forAllConstIters(objs, fieldIter)
|
||||
{
|
||||
const IOobject& obj = *fieldIter();
|
||||
const word& fieldName = obj.name();
|
||||
|
||||
@ -49,13 +49,13 @@ Description
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
const label nTypes = 4;
|
||||
const word fieldTypes[] =
|
||||
{
|
||||
const wordList fieldTypes
|
||||
({
|
||||
"volScalarField",
|
||||
"volVectorField",
|
||||
"surfaceScalarField",
|
||||
cloud::prefix
|
||||
};
|
||||
});
|
||||
|
||||
#include "setRootCase.H"
|
||||
|
||||
|
||||
@ -1,16 +1,14 @@
|
||||
for (label i=0; i < nTypes; i++)
|
||||
for (const word& fieldType : fieldTypes)
|
||||
{
|
||||
wordList fieldNames = objects.names(fieldTypes[i]);
|
||||
const wordList fieldNames = objects.sortedNames(fieldType);
|
||||
|
||||
if (fieldTypes[i] == "volScalarField")
|
||||
if (fieldType == "volScalarField")
|
||||
{
|
||||
gmvFile << "variable" << nl;
|
||||
}
|
||||
|
||||
forAll(fieldNames, j)
|
||||
for (const word& fieldName : fieldNames)
|
||||
{
|
||||
const word& fieldName = fieldNames[j];
|
||||
|
||||
IOobject fieldObject
|
||||
(
|
||||
fieldName,
|
||||
@ -20,18 +18,18 @@ for (label i=0; i < nTypes; i++)
|
||||
IOobject::NO_WRITE
|
||||
);
|
||||
|
||||
if (fieldTypes[i] == "volScalarField")
|
||||
if (fieldType == "volScalarField")
|
||||
{
|
||||
volScalarField fld(fieldObject, mesh);
|
||||
gmvFile << fieldName << " 0" << nl;
|
||||
for (label indx=0;indx<mesh.nCells();indx++)
|
||||
for (label indx=0; indx<mesh.nCells(); ++indx)
|
||||
{
|
||||
gmvFile << fld[indx] << " ";
|
||||
}
|
||||
gmvFile << nl;
|
||||
}
|
||||
|
||||
if (fieldTypes[i] == "volVectorField")
|
||||
if (fieldType == "volVectorField")
|
||||
{
|
||||
if (fieldName == vComp)
|
||||
{
|
||||
@ -53,14 +51,14 @@ for (label i=0; i < nTypes; i++)
|
||||
}
|
||||
}
|
||||
|
||||
if (fieldTypes[i] == "surfaceScalarField")
|
||||
if (fieldType == "surfaceScalarField")
|
||||
{
|
||||
// ...
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (fieldTypes[i] == cloud::prefix)
|
||||
if (fieldType == cloud::prefix)
|
||||
{
|
||||
IOobject positionsHeader
|
||||
(
|
||||
@ -96,8 +94,8 @@ for (label i=0; i < nTypes; i++)
|
||||
|
||||
IOobjectList objects(mesh, runTime.timeName(), cloud::prefix);
|
||||
|
||||
wordList lagrangianScalarNames = objects.names("scalarField");
|
||||
wordList lagrangianVectorNames = objects.names("vectorField");
|
||||
wordList lagrangianScalarNames(objects.sortedNames("scalarField"));
|
||||
wordList lagrangianVectorNames(objects.sortedNames("vectorField"));
|
||||
|
||||
if (particles.size())
|
||||
{
|
||||
@ -106,7 +104,7 @@ for (label i=0; i < nTypes; i++)
|
||||
}
|
||||
}
|
||||
|
||||
if (fieldTypes[i] == "volScalarField")
|
||||
if (fieldType == "volScalarField")
|
||||
{
|
||||
gmvFile << "endvars" << nl;
|
||||
}
|
||||
|
||||
@ -17,10 +17,8 @@ forAllConstIter(Cloud<passiveParticle>, particles, iter)
|
||||
}
|
||||
gmvFile << nl;
|
||||
|
||||
forAll(lagrangianScalarNames, i)
|
||||
for (const word& name : lagrangianScalarNames)
|
||||
{
|
||||
const word& name = lagrangianScalarNames[i];
|
||||
|
||||
IOField<scalar> fld
|
||||
(
|
||||
IOobject
|
||||
@ -48,10 +46,8 @@ forAll(lagrangianScalarNames, i)
|
||||
|
||||
}
|
||||
|
||||
forAll(lagrangianVectorNames, i)
|
||||
for (const word& name : lagrangianVectorNames)
|
||||
{
|
||||
const word& name = lagrangianVectorNames[i];
|
||||
|
||||
IOField<vector> fld
|
||||
(
|
||||
IOobject
|
||||
|
||||
@ -62,7 +62,7 @@ void ReadAndMapFields
|
||||
tetFields.setSize(fieldObjects.size());
|
||||
|
||||
label i = 0;
|
||||
forAllConstIter(IOobjectList, fieldObjects, iter)
|
||||
forAllConstIters(fieldObjects, iter)
|
||||
{
|
||||
Info<< "Converting " << ReadGeoField::typeName << ' ' << iter.key()
|
||||
<< endl;
|
||||
@ -138,8 +138,6 @@ void ReadAndMapFields
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#include "addOverwriteOption.H"
|
||||
@ -152,7 +150,6 @@ int main(int argc, char *argv[])
|
||||
#include "checkTimeOptions.H"
|
||||
runTime.setTime(Times[startTime], startTime);
|
||||
|
||||
|
||||
// Read the mesh
|
||||
#include "createNamedMesh.H"
|
||||
|
||||
|
||||
@ -24,7 +24,6 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "readFields.H"
|
||||
#include "IOobjectList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -43,37 +42,37 @@ label readFields
|
||||
PtrList<const GeoField>& fields
|
||||
)
|
||||
{
|
||||
label nFields = 0;
|
||||
|
||||
// Available fields of type GeomField
|
||||
const wordList fieldNames = objects.sortedNames(GeoField::typeName);
|
||||
|
||||
fields.setSize(fieldNames.size());
|
||||
// Available fields of type GeoField, sorted order
|
||||
const wordList fieldNames =
|
||||
(
|
||||
selectedFields.empty()
|
||||
? objects.sortedNames(GeoField::typeName)
|
||||
: objects.sortedNames(GeoField::typeName, selectedFields)
|
||||
);
|
||||
|
||||
// Construct the fields
|
||||
fields.resize(fieldNames.size());
|
||||
|
||||
label nFields = 0;
|
||||
|
||||
for (const word& fieldName : fieldNames)
|
||||
{
|
||||
if (selectedFields.empty() || selectedFields.found(fieldName))
|
||||
{
|
||||
fields.set
|
||||
fields.set
|
||||
(
|
||||
nFields++,
|
||||
proxy.interpolate
|
||||
(
|
||||
nFields++,
|
||||
proxy.interpolate
|
||||
(
|
||||
GeoField(*(objects[fieldName]), mesh)
|
||||
).ptr()
|
||||
);
|
||||
}
|
||||
GeoField(*(objects[fieldName]), mesh)
|
||||
).ptr()
|
||||
);
|
||||
}
|
||||
|
||||
fields.setSize(nFields);
|
||||
|
||||
return nFields;
|
||||
}
|
||||
|
||||
|
||||
template<class GeoField>
|
||||
void readFields
|
||||
label readFields
|
||||
(
|
||||
const typename GeoField::Mesh& mesh,
|
||||
const IOobjectList& objects,
|
||||
@ -81,26 +80,29 @@ void readFields
|
||||
PtrList<const GeoField>& fields
|
||||
)
|
||||
{
|
||||
// Search list of objects for fields of type GeomField
|
||||
IOobjectList fieldObjects(objects.lookupClass(GeoField::typeName));
|
||||
// Available fields of type GeoField, sorted order
|
||||
const wordList fieldNames =
|
||||
(
|
||||
selectedFields.empty()
|
||||
? objects.sortedNames(GeoField::typeName)
|
||||
: objects.sortedNames(GeoField::typeName, selectedFields)
|
||||
);
|
||||
|
||||
// Construct the fields
|
||||
fields.setSize(fieldObjects.size());
|
||||
fields.resize(fieldNames.size());
|
||||
|
||||
label nFields = 0;
|
||||
|
||||
forAllIters(fieldObjects, iter)
|
||||
for (const word& fieldName : fieldNames)
|
||||
{
|
||||
if (selectedFields.empty() || selectedFields.found(iter()->name()))
|
||||
{
|
||||
fields.set
|
||||
(
|
||||
nFields++,
|
||||
new GeoField(*iter(), mesh)
|
||||
);
|
||||
}
|
||||
fields.set
|
||||
(
|
||||
nFields++,
|
||||
new GeoField(*(objects[fieldName]), mesh)
|
||||
);
|
||||
}
|
||||
|
||||
fields.setSize(nFields);
|
||||
return nFields;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -35,16 +35,16 @@ SourceFiles
|
||||
#define readFields_H
|
||||
|
||||
#include "fvMeshSubsetProxy.H"
|
||||
#include "HashSet.H"
|
||||
#include "PtrList.H"
|
||||
#include "IOobjectList.H"
|
||||
#include "HashSet.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Read the fields, optionally subset, and place on the pointer list
|
||||
//- Read the fields, optionally subset, and place on the pointer list
|
||||
template<class GeoField>
|
||||
label readFields
|
||||
(
|
||||
@ -55,6 +55,18 @@ label readFields
|
||||
PtrList<const GeoField>& fields
|
||||
);
|
||||
|
||||
|
||||
//- Read the fields, and place on the pointer list
|
||||
template<class GeoField>
|
||||
label readFields
|
||||
(
|
||||
const typename GeoField::Mesh& mesh,
|
||||
const IOobjectList& objects,
|
||||
const wordHashSet& selectedFields,
|
||||
PtrList<const GeoField>& fields
|
||||
);
|
||||
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -194,7 +194,6 @@ void Foam::vtkPVFoam::convertAreaFields()
|
||||
// Get objects (fields) for this time - only keep selected fields
|
||||
// the region name is already in the mesh db
|
||||
IOobjectList objects(mesh.mesh(), dbPtr_().timeName());
|
||||
|
||||
objects.filterKeys(selectedFields);
|
||||
|
||||
if (objects.empty())
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -53,7 +53,7 @@ class fieldInterpolator
|
||||
Time& runTime_;
|
||||
const fvMesh& mesh_;
|
||||
const IOobjectList& objects_;
|
||||
const wordHashSet& selectedFields_;
|
||||
const wordRes& selectedFields_;
|
||||
instant ti_;
|
||||
instant ti1_;
|
||||
const interpolationWeights& interpolator_;
|
||||
@ -67,7 +67,7 @@ public:
|
||||
Time& runTime,
|
||||
const fvMesh& mesh,
|
||||
const IOobjectList& objects,
|
||||
const wordHashSet& selectedFields,
|
||||
const wordRes& selectedFields,
|
||||
const instant& ti,
|
||||
const instant& ti1,
|
||||
const interpolationWeights& interpolator,
|
||||
@ -94,95 +94,93 @@ public:
|
||||
template<class GeoFieldType>
|
||||
void fieldInterpolator::interpolate()
|
||||
{
|
||||
const word& fieldClassName = GeoFieldType::typeName;
|
||||
const word& clsName = GeoFieldType::typeName;
|
||||
|
||||
IOobjectList fields = objects_.lookupClass(fieldClassName);
|
||||
const wordList fieldNames =
|
||||
(
|
||||
selectedFields_.empty()
|
||||
? objects_.sortedNames(clsName)
|
||||
: objects_.sortedNames(clsName, selectedFields_)
|
||||
);
|
||||
|
||||
if (fields.size())
|
||||
if (fieldNames.size())
|
||||
{
|
||||
Info<< " " << fieldClassName << "s:";
|
||||
Info<< " " << clsName << 's';
|
||||
}
|
||||
|
||||
forAllConstIter(IOobjectList, fields, fieldIter)
|
||||
for (const word& fieldName : fieldNames)
|
||||
{
|
||||
Info<< ' ' << fieldName << '(';
|
||||
|
||||
const scalar deltaT = (ti1_.value() - ti_.value())/(divisions_ + 1);
|
||||
|
||||
for (int j=0; j<divisions_; j++)
|
||||
{
|
||||
if
|
||||
(
|
||||
selectedFields_.empty()
|
||||
|| selectedFields_.found(fieldIter()->name())
|
||||
)
|
||||
instant timej = instant(ti_.value() + (j + 1)*deltaT);
|
||||
|
||||
runTime_.setTime(instant(timej.name()), 0);
|
||||
|
||||
Info<< timej.name();
|
||||
|
||||
if (j < divisions_-1)
|
||||
{
|
||||
Info<< " " << fieldIter()->name() << '(';
|
||||
|
||||
scalar deltaT = (ti1_.value() - ti_.value())/(divisions_ + 1);
|
||||
|
||||
for (int j=0; j<divisions_; j++)
|
||||
{
|
||||
instant timej = instant(ti_.value() + (j + 1)*deltaT);
|
||||
|
||||
runTime_.setTime(instant(timej.name()), 0);
|
||||
|
||||
Info<< timej.name();
|
||||
|
||||
if (j < divisions_-1)
|
||||
{
|
||||
Info<< " ";
|
||||
}
|
||||
|
||||
// Calculate times to read and weights
|
||||
labelList indices;
|
||||
scalarField weights;
|
||||
interpolator_.valueWeights
|
||||
(
|
||||
runTime_.value(),
|
||||
indices,
|
||||
weights
|
||||
);
|
||||
|
||||
const wordList selectedTimeNames
|
||||
(
|
||||
UIndirectList<word>(timeNames_, indices)()
|
||||
);
|
||||
|
||||
//Info<< "For time " << runTime_.value()
|
||||
// << " need times " << selectedTimeNames
|
||||
// << " need weights " << weights << endl;
|
||||
|
||||
|
||||
// Read on the objectRegistry all the required fields
|
||||
ReadFields<GeoFieldType>
|
||||
(
|
||||
fieldIter()->name(),
|
||||
mesh_,
|
||||
selectedTimeNames
|
||||
);
|
||||
|
||||
GeoFieldType fieldj
|
||||
(
|
||||
uniformInterpolate<GeoFieldType>
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
fieldIter()->name(),
|
||||
runTime_.timeName(),
|
||||
fieldIter()->db(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
fieldIter()->name(),
|
||||
selectedTimeNames,
|
||||
weights
|
||||
)
|
||||
);
|
||||
|
||||
fieldj.write();
|
||||
}
|
||||
|
||||
Info<< ')';
|
||||
Info<< " ";
|
||||
}
|
||||
|
||||
// Calculate times to read and weights
|
||||
labelList indices;
|
||||
scalarField weights;
|
||||
interpolator_.valueWeights
|
||||
(
|
||||
runTime_.value(),
|
||||
indices,
|
||||
weights
|
||||
);
|
||||
|
||||
const wordList selectedTimeNames
|
||||
(
|
||||
UIndirectList<word>(timeNames_, indices)()
|
||||
);
|
||||
|
||||
//Info<< "For time " << runTime_.value()
|
||||
// << " need times " << selectedTimeNames
|
||||
// << " need weights " << weights << endl;
|
||||
|
||||
|
||||
// Read on the objectRegistry all the required fields
|
||||
ReadFields<GeoFieldType>
|
||||
(
|
||||
fieldName,
|
||||
mesh_,
|
||||
selectedTimeNames
|
||||
);
|
||||
|
||||
GeoFieldType fieldj
|
||||
(
|
||||
uniformInterpolate<GeoFieldType>
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
fieldName,
|
||||
runTime_.timeName(),
|
||||
objects_[fieldName]->db(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
fieldName,
|
||||
selectedTimeNames,
|
||||
weights
|
||||
)
|
||||
);
|
||||
|
||||
fieldj.write();
|
||||
}
|
||||
|
||||
Info<< endl;
|
||||
Info<< ')';
|
||||
}
|
||||
|
||||
if (fieldNames.size()) Info<< endl;
|
||||
}
|
||||
|
||||
|
||||
@ -195,9 +193,9 @@ int main(int argc, char *argv[])
|
||||
argList::addOption
|
||||
(
|
||||
"fields",
|
||||
"list",
|
||||
"specify a list of fields to be interpolated. Eg, '(U T p)' - "
|
||||
"regular expressions not currently supported"
|
||||
"wordRes",
|
||||
"the fields (or field) to be interpolated."
|
||||
" Eg, '(U T p \"Y.*\")' or a single field 'U'"
|
||||
);
|
||||
argList::addOption
|
||||
(
|
||||
@ -216,24 +214,22 @@ int main(int argc, char *argv[])
|
||||
#include "createTime.H"
|
||||
runTime.functionObjects().off();
|
||||
|
||||
wordHashSet selectedFields;
|
||||
args.readIfPresent("fields", selectedFields);
|
||||
wordRes selectedFields;
|
||||
args.readListIfPresent<wordRe>("fields", selectedFields);
|
||||
|
||||
if (selectedFields.size())
|
||||
if (selectedFields.empty())
|
||||
{
|
||||
Info<< "Interpolating fields " << selectedFields << nl << endl;
|
||||
Info<< "Interpolating all fields" << nl << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "Interpolating all fields" << nl << endl;
|
||||
Info<< "Interpolating fields " << flatOutput(selectedFields)
|
||||
<< nl << endl;
|
||||
}
|
||||
|
||||
|
||||
int divisions = 1;
|
||||
if (args.found("divisions"))
|
||||
{
|
||||
args.lookup("divisions")() >> divisions;
|
||||
}
|
||||
args.readIfPresent("divisions", divisions);
|
||||
Info<< "Using " << divisions << " per time interval" << nl << endl;
|
||||
|
||||
|
||||
|
||||
@ -298,10 +298,10 @@ void rewriteField
|
||||
|
||||
label nChanged = 0;
|
||||
|
||||
forAllConstIter(HashTable<word>, thisNames, iter)
|
||||
forAllConstIters(thisNames, iter)
|
||||
{
|
||||
const word& patchName = iter.key();
|
||||
const word& newName = iter();
|
||||
const word& newName = iter.object();
|
||||
|
||||
Info<< "Looking for entry for patch " << patchName << endl;
|
||||
|
||||
@ -376,13 +376,13 @@ void rewriteFields
|
||||
const HashTable<word>& nbrNames
|
||||
)
|
||||
{
|
||||
forAll(fieldNames, i)
|
||||
for (const word& fieldName : fieldNames)
|
||||
{
|
||||
rewriteField
|
||||
(
|
||||
isTestRun,
|
||||
runTime,
|
||||
fieldNames[i],
|
||||
fieldName,
|
||||
thisNames,
|
||||
nbrNames
|
||||
);
|
||||
|
||||
@ -51,7 +51,7 @@ void MapConsistentVolFields
|
||||
|
||||
IOobjectList fields = objects.lookupClass(fieldType::typeName);
|
||||
|
||||
forAllIter(IOobjectList, fields, fieldIter)
|
||||
forAllConstIters(fields, fieldIter)
|
||||
{
|
||||
Info<< " interpolating " << fieldIter()->name()
|
||||
<< endl;
|
||||
|
||||
@ -60,7 +60,7 @@ void MapLagrangianFields
|
||||
{
|
||||
IOobjectList fields = objects.lookupClass(IOField<Type>::typeName);
|
||||
|
||||
forAllIter(IOobjectList, fields, fieldIter)
|
||||
forAllConstIters(fields, fieldIter)
|
||||
{
|
||||
Info<< " mapping lagrangian field "
|
||||
<< fieldIter()->name() << endl;
|
||||
@ -98,7 +98,7 @@ void MapLagrangianFields
|
||||
IOobjectList fieldFields =
|
||||
objects.lookupClass(IOField<Field<Type>>::typeName);
|
||||
|
||||
forAllIter(IOobjectList, fieldFields, fieldIter)
|
||||
forAllConstIters(fieldFields, fieldIter)
|
||||
{
|
||||
Info<< " mapping lagrangian fieldField "
|
||||
<< fieldIter()->name() << endl;
|
||||
@ -137,7 +137,7 @@ void MapLagrangianFields
|
||||
IOobjectList fieldFields =
|
||||
objects.lookupClass(CompactIOField<Field<Type>, Type>::typeName);
|
||||
|
||||
forAllIter(IOobjectList, fieldFields, fieldIter)
|
||||
forAllConstIters(fieldFields, fieldIter)
|
||||
{
|
||||
Info<< " mapping lagrangian fieldField "
|
||||
<< fieldIter()->name() << endl;
|
||||
|
||||
@ -51,7 +51,7 @@ void MapVolFields
|
||||
|
||||
IOobjectList fields = objects.lookupClass(fieldType::typeName);
|
||||
|
||||
forAllIter(IOobjectList, fields, fieldIter)
|
||||
forAllConstIters(fields, fieldIter)
|
||||
{
|
||||
IOobject fieldTargetIOobject
|
||||
(
|
||||
|
||||
@ -39,7 +39,7 @@ void UnMapped(const IOobjectList& objects)
|
||||
{
|
||||
IOobjectList fields = objects.lookupClass(Type::typeName);
|
||||
|
||||
forAllConstIter(IOobjectList, fields, fieldIter)
|
||||
forAllConstIters(fields, fieldIter)
|
||||
{
|
||||
mvBak(fieldIter()->objectPath(), "unmapped");
|
||||
}
|
||||
|
||||
@ -58,7 +58,7 @@ void MapLagrangianFields
|
||||
{
|
||||
IOobjectList fields = objects.lookupClass(IOField<Type>::typeName);
|
||||
|
||||
forAllIter(IOobjectList, fields, fieldIter)
|
||||
forAllConstIters(fields, fieldIter)
|
||||
{
|
||||
const word& fieldName = fieldIter()->name();
|
||||
|
||||
@ -97,7 +97,7 @@ void MapLagrangianFields
|
||||
IOobjectList fieldFields =
|
||||
objects.lookupClass(IOField<Field<Type>>::typeName);
|
||||
|
||||
forAllIter(IOobjectList, fieldFields, fieldIter)
|
||||
forAllConstIters(fieldFields, fieldIter)
|
||||
{
|
||||
const word& fieldName = fieldIter()->name();
|
||||
|
||||
@ -149,7 +149,7 @@ void MapLagrangianFields
|
||||
IOobjectList fieldFields =
|
||||
objects.lookupClass(CompactIOField<Field<Type>, Type>::typeName);
|
||||
|
||||
forAllIter(IOobjectList, fieldFields, fieldIter)
|
||||
forAllConstIters(fieldFields, fieldIter)
|
||||
{
|
||||
const word& fieldName = fieldIter()->name();
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -131,52 +131,56 @@ void MapVolFields
|
||||
const fvMesh& meshSource = static_cast<const fvMesh&>(interp.srcRegion());
|
||||
const fvMesh& meshTarget = static_cast<const fvMesh&>(interp.tgtRegion());
|
||||
|
||||
IOobjectList fields = objects.lookupClass(fieldType::typeName);
|
||||
// Available fields, sorted order
|
||||
const wordList fieldNames =
|
||||
(
|
||||
selectedFields.empty()
|
||||
? objects.sortedNames(fieldType::typeName)
|
||||
: objects.sortedNames(fieldType::typeName, selectedFields)
|
||||
);
|
||||
|
||||
forAllIter(IOobjectList, fields, fieldIter)
|
||||
for (const word& fieldName : fieldNames)
|
||||
{
|
||||
const word& fieldName = fieldIter()->name();
|
||||
const fieldType fieldSource(*(objects[fieldName]), meshSource);
|
||||
|
||||
if (selectedFields.empty() || selectedFields.found(fieldName))
|
||||
IOobject targetIO
|
||||
(
|
||||
fieldName,
|
||||
meshTarget.time().timeName(),
|
||||
meshTarget,
|
||||
IOobject::MUST_READ
|
||||
);
|
||||
|
||||
if (targetIO.typeHeaderOk<fieldType>(true))
|
||||
{
|
||||
const fieldType fieldSource(*fieldIter(), meshSource);
|
||||
Info<< " interpolating onto existing field "
|
||||
<< fieldName << endl;
|
||||
|
||||
IOobject targetIO
|
||||
fieldType fieldTarget(targetIO, meshTarget);
|
||||
|
||||
interp.mapSrcToTgt(fieldSource, cop, fieldTarget);
|
||||
|
||||
evaluateConstraintTypes(fieldTarget);
|
||||
|
||||
fieldTarget.write();
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< " creating new field "
|
||||
<< fieldName << endl;
|
||||
|
||||
targetIO.readOpt() = IOobject::NO_READ;
|
||||
|
||||
tmp<fieldType> tfieldTarget
|
||||
(
|
||||
fieldName,
|
||||
meshTarget.time().timeName(),
|
||||
meshTarget,
|
||||
IOobject::MUST_READ
|
||||
interp.mapSrcToTgt(fieldSource, cop)
|
||||
);
|
||||
|
||||
if (targetIO.typeHeaderOk<fieldType>(true))
|
||||
{
|
||||
Info<< " interpolating onto existing field "
|
||||
<< fieldName << endl;
|
||||
fieldType fieldTarget(targetIO, meshTarget);
|
||||
fieldType fieldTarget(targetIO, tfieldTarget);
|
||||
|
||||
interp.mapSrcToTgt(fieldSource, cop, fieldTarget);
|
||||
evaluateConstraintTypes(fieldTarget);
|
||||
|
||||
evaluateConstraintTypes(fieldTarget);
|
||||
|
||||
fieldTarget.write();
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< " creating new field "
|
||||
<< fieldName << endl;
|
||||
|
||||
targetIO.readOpt() = IOobject::NO_READ;
|
||||
|
||||
tmp<fieldType>
|
||||
tfieldTarget(interp.mapSrcToTgt(fieldSource, cop));
|
||||
|
||||
fieldType fieldTarget(targetIO, tfieldTarget);
|
||||
|
||||
evaluateConstraintTypes(fieldTarget);
|
||||
|
||||
fieldTarget.write();
|
||||
}
|
||||
fieldTarget.write();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ void UnMapped(const IOobjectList& objects)
|
||||
{
|
||||
IOobjectList fields = objects.lookupClass(Type::typeName);
|
||||
|
||||
forAllConstIter(IOobjectList, fields, fieldIter)
|
||||
forAllConstIters(fields, fieldIter)
|
||||
{
|
||||
mvBak(fieldIter()->objectPath(), "unmapped");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user