mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'update-selection-ordering' into 'develop'
Updates to function objects handling of patches / selection names for parallel consistent order See merge request Development/openfoam!617
This commit is contained in:
@ -86,6 +86,7 @@ VoFPatchTransfer::VoFPatchTransfer
|
|||||||
wordRes patchNames;
|
wordRes patchNames;
|
||||||
if (coeffDict_.readIfPresent("patches", patchNames))
|
if (coeffDict_.readIfPresent("patches", patchNames))
|
||||||
{
|
{
|
||||||
|
// Can also use pbm.indices(), but no warnings...
|
||||||
patchIDs_ = pbm.patchSet(patchNames).sortedToc();
|
patchIDs_ = pbm.patchSet(patchNames).sortedToc();
|
||||||
|
|
||||||
Info<< " applying to " << patchIDs_.size() << " patches:" << nl;
|
Info<< " applying to " << patchIDs_.size() << " patches:" << nl;
|
||||||
|
|||||||
@ -52,7 +52,9 @@ namespace Foam
|
|||||||
const Foam::volScalarField&
|
const Foam::volScalarField&
|
||||||
Foam::radiation::localDensityAbsorptionEmission::alpha(word alphaName) const
|
Foam::radiation::localDensityAbsorptionEmission::alpha(word alphaName) const
|
||||||
{
|
{
|
||||||
if (!mesh_.foundObject<volScalarField>(alphaName))
|
const volScalarField* ptr = mesh_.cfindObject<volScalarField>(alphaName);
|
||||||
|
|
||||||
|
if (!ptr)
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Unable to retrieve density field " << alphaName << " from "
|
<< "Unable to retrieve density field " << alphaName << " from "
|
||||||
@ -60,7 +62,7 @@ Foam::radiation::localDensityAbsorptionEmission::alpha(word alphaName) const
|
|||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
return mesh_.lookupObject<volScalarField>(alphaName);
|
return *ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -85,7 +85,7 @@ Description
|
|||||||
|
|
||||||
fileNameList procDirs
|
fileNameList procDirs
|
||||||
(
|
(
|
||||||
DirLister::dirs(".").sorted<fileName>(matchProcs)
|
DirLister::dirs(".").csorted<fileName>(matchProcs)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
\endcode
|
\endcode
|
||||||
@ -206,11 +206,11 @@ public:
|
|||||||
|
|
||||||
//- Return a complete list of names, sorted in natural order
|
//- Return a complete list of names, sorted in natural order
|
||||||
template<class StringType=Foam::word>
|
template<class StringType=Foam::word>
|
||||||
List<StringType> sorted() const;
|
List<StringType> csorted() const;
|
||||||
|
|
||||||
//- Return complete list of names, sorted in natural order
|
//- Return complete list of names, sorted in natural order
|
||||||
template<class StringType=Foam::word, class UnaryPredicate>
|
template<class StringType=Foam::word, class UnaryPredicate>
|
||||||
List<StringType> sorted
|
List<StringType> csorted
|
||||||
(
|
(
|
||||||
const UnaryPredicate& pred,
|
const UnaryPredicate& pred,
|
||||||
const bool prune = false
|
const bool prune = false
|
||||||
|
|||||||
@ -70,23 +70,23 @@ Foam::List<StringType> Foam::DirLister::list() const
|
|||||||
|
|
||||||
|
|
||||||
template<class StringType, class UnaryPredicate>
|
template<class StringType, class UnaryPredicate>
|
||||||
Foam::List<StringType> Foam::DirLister::sorted
|
Foam::List<StringType> Foam::DirLister::csorted
|
||||||
(
|
(
|
||||||
const UnaryPredicate& pred,
|
const UnaryPredicate& pred,
|
||||||
const bool prune
|
const bool prune
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
List<StringType> lst(list<StringType>(pred, prune));
|
List<StringType> list(list<StringType>(pred, prune));
|
||||||
sort(lst, stringOps::natural_sort());
|
Foam::sort(list, stringOps::natural_sort());
|
||||||
|
|
||||||
return lst;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class StringType>
|
template<class StringType>
|
||||||
Foam::List<StringType> Foam::DirLister::sorted() const
|
Foam::List<StringType> Foam::DirLister::csorted() const
|
||||||
{
|
{
|
||||||
return sorted<StringType>(predicates::always());
|
return csorted<StringType>(predicates::always());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -162,7 +162,7 @@ int main(int argc, char *argv[])
|
|||||||
Info<< "dirList: "
|
Info<< "dirList: "
|
||||||
<< flatOutput
|
<< flatOutput
|
||||||
(
|
(
|
||||||
DirLister::dirs(".").sorted<fileName>(relist)
|
DirLister::dirs(".").csorted<fileName>(relist)
|
||||||
) << nl;
|
) << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -75,8 +75,8 @@ int main()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Info<< "\ntable1 sorted() :" << endl;
|
Info<< "\ntable1 csorted() :" << endl;
|
||||||
for (const auto& iter : table1.sorted())
|
for (const auto& iter : table1.csorted())
|
||||||
{
|
{
|
||||||
Info<< " " << iter.key() << " => " << iter.val() << nl;
|
Info<< " " << iter.key() << " => " << iter.val() << nl;
|
||||||
}
|
}
|
||||||
@ -100,7 +100,7 @@ int main()
|
|||||||
}
|
}
|
||||||
|
|
||||||
Info<< "\nInplace modified - via sorted() access :" << endl;
|
Info<< "\nInplace modified - via sorted() access :" << endl;
|
||||||
for (const auto& iter : table1.sorted())
|
for (const auto& iter : table1.csorted())
|
||||||
{
|
{
|
||||||
Info<< " " << iter.key() << " => " << iter.val() << nl;
|
Info<< " " << iter.key() << " => " << iter.val() << nl;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -290,14 +290,14 @@ int main(int argc, char *argv[])
|
|||||||
Info<< "Time: " << runTime.timeName() << nl;
|
Info<< "Time: " << runTime.timeName() << nl;
|
||||||
|
|
||||||
report(objects);
|
report(objects);
|
||||||
report(objects.sorted());
|
report(objects.csorted());
|
||||||
|
|
||||||
report(objects.sorted<volScalarField>());
|
report(objects.csorted<volScalarField>());
|
||||||
report(objects.sorted<volVectorField>());
|
report(objects.csorted<volVectorField>());
|
||||||
|
|
||||||
// Extra checks
|
// Extra checks
|
||||||
report<volScalarField>(objects.sorted<volScalarField>());
|
report<volScalarField>(objects.csorted<volScalarField>());
|
||||||
report<volScalarField>(objects.sorted<volVectorField>());
|
report<volScalarField>(objects.csorted<volVectorField>());
|
||||||
|
|
||||||
|
|
||||||
findObjectTest(objects);
|
findObjectTest(objects);
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2022 OpenCFD Ltd.
|
Copyright (C) 2022-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -139,7 +139,7 @@ void printInfo(const ensightMesh& mesh, int verbose = 0)
|
|||||||
FixedList<label, 3> cellStats(Zero);
|
FixedList<label, 3> cellStats(Zero);
|
||||||
FixedList<label, 3> faceStats(Zero);
|
FixedList<label, 3> faceStats(Zero);
|
||||||
|
|
||||||
for (const auto& iter : mesh.cellZoneParts().sorted())
|
for (const auto& iter : mesh.cellZoneParts().csorted())
|
||||||
{
|
{
|
||||||
FixedList<label, 3> stats = printPartInfo(iter.val(), verbose);
|
FixedList<label, 3> stats = printPartInfo(iter.val(), verbose);
|
||||||
|
|
||||||
@ -149,7 +149,7 @@ void printInfo(const ensightMesh& mesh, int verbose = 0)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& iter : mesh.faceZoneParts().sorted())
|
for (const auto& iter : mesh.faceZoneParts().csorted())
|
||||||
{
|
{
|
||||||
FixedList<label, 3> stats = printPartInfo(iter.val(), verbose);
|
FixedList<label, 3> stats = printPartInfo(iter.val(), verbose);
|
||||||
|
|
||||||
@ -159,7 +159,7 @@ void printInfo(const ensightMesh& mesh, int verbose = 0)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& iter : mesh.boundaryParts().sorted())
|
for (const auto& iter : mesh.boundaryParts().csorted())
|
||||||
{
|
{
|
||||||
FixedList<label, 3> stats = printPartInfo(iter.val(), verbose);
|
FixedList<label, 3> stats = printPartInfo(iter.val(), verbose);
|
||||||
|
|
||||||
|
|||||||
@ -57,7 +57,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
Info<< "Found: " << objects << nl << endl;
|
Info<< "Found: " << objects << nl << endl;
|
||||||
|
|
||||||
for (const IOobject& io : objects.sorted<uniformDimensionedVectorField>())
|
for (const IOobject& io : objects.csorted<uniformDimensionedVectorField>())
|
||||||
{
|
{
|
||||||
if (io.name() == meshObjects::gravity::typeName)
|
if (io.name() == meshObjects::gravity::typeName)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
Copyright (C) 2016-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -78,8 +78,8 @@ void printRegistry
|
|||||||
Foam::label indent
|
Foam::label indent
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UPtrList<const regIOobject> objects(obr.sorted());
|
const UPtrList<const regIOobject> objects(obr.csorted());
|
||||||
wordList regNames(obr.sortedNames<objectRegistry>());
|
const wordList regNames(obr.sortedNames<objectRegistry>());
|
||||||
|
|
||||||
std::string prefix;
|
std::string prefix;
|
||||||
for (label i=indent; i; --i)
|
for (label i=indent; i; --i)
|
||||||
|
|||||||
@ -145,8 +145,8 @@ void printRegistry
|
|||||||
Foam::label indent
|
Foam::label indent
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UPtrList<const regIOobject> objects(obr.sorted());
|
const UPtrList<const regIOobject> objects(obr.csorted());
|
||||||
wordList regNames(obr.sortedNames<objectRegistry>());
|
const wordList regNames(obr.sortedNames<objectRegistry>());
|
||||||
|
|
||||||
std::string prefix;
|
std::string prefix;
|
||||||
for (label i=indent; i; --i)
|
for (label i=indent; i; --i)
|
||||||
@ -315,7 +315,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
registryTests(mesh);
|
registryTests(mesh);
|
||||||
|
|
||||||
report(mesh.sorted<const volScalarField>());
|
report(mesh.csorted<volScalarField>());
|
||||||
report(mesh.csorted<volVectorField>());
|
report(mesh.csorted<volVectorField>());
|
||||||
|
|
||||||
Info<< nl;
|
Info<< nl;
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
Copyright (C) 2016-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -131,40 +131,56 @@ void modifyOrAddFace
|
|||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void subsetVolFields
|
PtrList<GeometricField<Type, fvPatchField, volMesh>> subsetVolFields
|
||||||
(
|
(
|
||||||
const fvMeshSubset& subsetter,
|
const fvMeshSubset& subsetter,
|
||||||
const IOobjectList& objects,
|
const IOobjectList& objects,
|
||||||
const label patchi,
|
const label patchi,
|
||||||
const Type& exposedValue,
|
const Type& exposedValue
|
||||||
PtrList<GeometricField<Type, fvPatchField, volMesh>>& subFields
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
typedef GeometricField<Type, fvPatchField, volMesh> GeoField;
|
typedef GeometricField<Type, fvPatchField, volMesh> GeoField;
|
||||||
|
|
||||||
const fvMesh& baseMesh = subsetter.baseMesh();
|
const fvMesh& baseMesh = subsetter.baseMesh();
|
||||||
|
|
||||||
|
const UPtrList<const IOobject> fieldObjects
|
||||||
|
(
|
||||||
|
objects.csorted<GeoField>()
|
||||||
|
);
|
||||||
|
|
||||||
|
PtrList<GeoField> subFields(fieldObjects.size());
|
||||||
|
|
||||||
label nFields = 0;
|
label nFields = 0;
|
||||||
|
for (const IOobject& io : fieldObjects)
|
||||||
for (const word& fieldName : objects.sortedNames<GeoField>())
|
|
||||||
{
|
{
|
||||||
const IOobject* ioptr = objects.findObject(fieldName);
|
|
||||||
|
|
||||||
if (!nFields)
|
if (!nFields)
|
||||||
{
|
{
|
||||||
Info<< "Subsetting " << GeoField::typeName << nl;
|
Info<< "Subsetting " << GeoField::typeName << " (";
|
||||||
}
|
}
|
||||||
Info<< " " << fieldName << endl;
|
else
|
||||||
|
{
|
||||||
|
Info<< ' ';
|
||||||
|
}
|
||||||
|
Info<< " " << io.name() << endl;
|
||||||
|
|
||||||
GeoField origField(*ioptr, baseMesh);
|
// Read unregistered
|
||||||
|
IOobject rio(io, IOobjectOption::NO_REGISTER);
|
||||||
|
GeoField origField(rio, baseMesh);
|
||||||
|
|
||||||
subFields.set(nFields, subsetter.interpolate(origField));
|
subFields.set(nFields, subsetter.interpolate(origField));
|
||||||
|
auto& subField = subFields[nFields];
|
||||||
|
++nFields;
|
||||||
|
|
||||||
|
|
||||||
|
// Subsetting adds 'subset' prefix. Rename field to be like original.
|
||||||
|
subField.rename(io.name());
|
||||||
|
subField.writeOpt(IOobjectOption::AUTO_WRITE);
|
||||||
|
|
||||||
|
|
||||||
// Explicitly set exposed faces (in patchi) to exposedValue.
|
// Explicitly set exposed faces (in patchi) to exposedValue.
|
||||||
if (patchi >= 0)
|
if (patchi >= 0)
|
||||||
{
|
{
|
||||||
fvPatchField<Type>& fld =
|
fvPatchField<Type>& fld = subField.boundaryFieldRef()[patchi];
|
||||||
subFields[nFields].boundaryFieldRef()[patchi];
|
|
||||||
|
|
||||||
const label newStart = fld.patch().patch().start();
|
const label newStart = fld.patch().patch().start();
|
||||||
const label oldPatchi = subsetter.patchMap()[patchi];
|
const label oldPatchi = subsetter.patchMap()[patchi];
|
||||||
@ -195,48 +211,68 @@ void subsetVolFields
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
++nFields;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (nFields)
|
||||||
|
{
|
||||||
|
Info<< ')' << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return subFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void subsetSurfaceFields
|
PtrList<GeometricField<Type, fvsPatchField, surfaceMesh>> subsetSurfaceFields
|
||||||
(
|
(
|
||||||
const fvMeshSubset& subsetter,
|
const fvMeshSubset& subsetter,
|
||||||
const IOobjectList& objects,
|
const IOobjectList& objects,
|
||||||
const label patchi,
|
const label patchi,
|
||||||
const Type& exposedValue,
|
const Type& exposedValue
|
||||||
PtrList<GeometricField<Type, fvsPatchField, surfaceMesh>>& subFields
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> GeoField;
|
typedef GeometricField<Type, fvsPatchField, surfaceMesh> GeoField;
|
||||||
|
|
||||||
const fvMesh& baseMesh = subsetter.baseMesh();
|
const fvMesh& baseMesh = subsetter.baseMesh();
|
||||||
|
|
||||||
|
const UPtrList<const IOobject> fieldObjects
|
||||||
|
(
|
||||||
|
objects.csorted<GeoField>()
|
||||||
|
);
|
||||||
|
|
||||||
|
PtrList<GeoField> subFields(fieldObjects.size());
|
||||||
|
|
||||||
label nFields = 0;
|
label nFields = 0;
|
||||||
|
for (const IOobject& io : fieldObjects)
|
||||||
for (const word& fieldName : objects.sortedNames<GeoField>())
|
|
||||||
{
|
{
|
||||||
const IOobject* ioptr = objects.findObject(fieldName);
|
|
||||||
|
|
||||||
if (!nFields)
|
if (!nFields)
|
||||||
{
|
{
|
||||||
Info<< "Subsetting " << GeoField::typeName << nl;
|
Info<< "Subsetting " << GeoField::typeName << " (";
|
||||||
}
|
}
|
||||||
Info<< " " << fieldName << endl;
|
else
|
||||||
|
{
|
||||||
|
Info<< ' ';
|
||||||
|
}
|
||||||
|
Info<< io.name();
|
||||||
|
|
||||||
GeoField origField(*ioptr, baseMesh);
|
// Read unregistered
|
||||||
|
IOobject rio(io, IOobjectOption::NO_REGISTER);
|
||||||
|
GeoField origField(rio, baseMesh);
|
||||||
|
|
||||||
subFields.set(nFields, subsetter.interpolate(origField));
|
subFields.set(nFields, subsetter.interpolate(origField));
|
||||||
|
auto& subField = subFields[nFields];
|
||||||
|
++nFields;
|
||||||
|
|
||||||
|
// Subsetting adds 'subset' prefix. Rename field to be like original.
|
||||||
|
subField.rename(io.name());
|
||||||
|
subField.writeOpt(IOobjectOption::AUTO_WRITE);
|
||||||
|
|
||||||
|
|
||||||
// Explicitly set exposed faces (in patchi) to exposedValue.
|
// Explicitly set exposed faces (in patchi) to exposedValue.
|
||||||
if (patchi >= 0)
|
if (patchi >= 0)
|
||||||
{
|
{
|
||||||
fvsPatchField<Type>& fld =
|
fvsPatchField<Type>& fld = subField.boundaryFieldRef()[patchi];
|
||||||
subFields[nFields].boundaryFieldRef()[patchi];
|
|
||||||
|
|
||||||
const label newStart = fld.patch().patch().start();
|
const label newStart = fld.patch().patch().start();
|
||||||
const label oldPatchi = subsetter.patchMap()[patchi];
|
const label oldPatchi = subsetter.patchMap()[patchi];
|
||||||
@ -268,9 +304,14 @@ void subsetSurfaceFields
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
++nFields;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (nFields)
|
||||||
|
{
|
||||||
|
Info<< ')' << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return subFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -284,16 +325,9 @@ void initCreatedPatches
|
|||||||
const typename GeoField::value_type initValue
|
const typename GeoField::value_type initValue
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
HashTable<const GeoField*> fields
|
for (const GeoField& field : mesh.objectRegistry::csorted<GeoField>())
|
||||||
(
|
|
||||||
mesh.objectRegistry::lookupClass<GeoField>()
|
|
||||||
);
|
|
||||||
|
|
||||||
forAllIters(fields, fieldIter)
|
|
||||||
{
|
{
|
||||||
GeoField& field = const_cast<GeoField&>(*fieldIter());
|
auto& fieldBf = const_cast<GeoField&>(field).boundaryFieldRef();
|
||||||
|
|
||||||
auto& fieldBf = field.boundaryFieldRef();
|
|
||||||
|
|
||||||
forAll(fieldBf, patchi)
|
forAll(fieldBf, patchi)
|
||||||
{
|
{
|
||||||
@ -326,43 +360,36 @@ void subsetTopoSets
|
|||||||
PtrList<TopoSet> sets;
|
PtrList<TopoSet> sets;
|
||||||
ReadFields<TopoSet>(objects, sets);
|
ReadFields<TopoSet>(objects, sets);
|
||||||
|
|
||||||
subSets.resize(sets.size());
|
subSets.resize_null(sets.size());
|
||||||
|
|
||||||
forAll(sets, seti)
|
forAll(sets, seti)
|
||||||
{
|
{
|
||||||
TopoSet& set = sets[seti];
|
const TopoSet& set = sets[seti];
|
||||||
|
|
||||||
Info<< "Subsetting " << set.type() << " " << set.name() << endl;
|
Info<< "Subsetting " << set.type() << ' ' << set.name() << endl;
|
||||||
|
|
||||||
|
labelHashSet subset(2*min(set.size(), map.size()));
|
||||||
|
|
||||||
// Map the data
|
// Map the data
|
||||||
bitSet isSet(set.maxSize(mesh));
|
forAll(map, i)
|
||||||
for (const label id : set)
|
|
||||||
{
|
{
|
||||||
isSet.set(id);
|
if (set.contains(map[i]))
|
||||||
}
|
|
||||||
|
|
||||||
label nSet = 0;
|
|
||||||
for (const label id : map)
|
|
||||||
{
|
|
||||||
if (isSet.test(id))
|
|
||||||
{
|
{
|
||||||
++nSet;
|
subset.insert(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
subSets.set
|
subSets.set
|
||||||
(
|
(
|
||||||
seti,
|
seti,
|
||||||
new TopoSet(subMesh, set.name(), nSet, IOobject::AUTO_WRITE)
|
new TopoSet
|
||||||
|
(
|
||||||
|
subMesh,
|
||||||
|
set.name(),
|
||||||
|
std::move(subset),
|
||||||
|
IOobjectOption::AUTO_WRITE
|
||||||
|
)
|
||||||
);
|
);
|
||||||
TopoSet& subSet = subSets[seti];
|
|
||||||
|
|
||||||
forAll(map, i)
|
|
||||||
{
|
|
||||||
if (isSet.test(map[i]))
|
|
||||||
{
|
|
||||||
subSet.insert(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -613,6 +640,7 @@ label findPatch(const polyBoundaryMesh& patches, const word& patchName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@ -844,138 +872,117 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read vol fields and subset.
|
// Read vol fields and subset.
|
||||||
|
PtrList<volScalarField> scalarFlds
|
||||||
wordList scalarNames(objects.sortedNames<volScalarField>());
|
|
||||||
PtrList<volScalarField> scalarFlds(scalarNames.size());
|
|
||||||
subsetVolFields
|
|
||||||
(
|
(
|
||||||
subsetter,
|
subsetVolFields<scalar>
|
||||||
objects,
|
(
|
||||||
defaultPatchi,
|
subsetter,
|
||||||
scalar(Zero),
|
objects,
|
||||||
scalarFlds
|
defaultPatchi,
|
||||||
|
scalar(Zero)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
wordList vectorNames(objects.sortedNames<volVectorField>());
|
PtrList<volVectorField> vectorFlds
|
||||||
PtrList<volVectorField> vectorFlds(vectorNames.size());
|
|
||||||
subsetVolFields
|
|
||||||
(
|
(
|
||||||
subsetter,
|
subsetVolFields<vector>
|
||||||
objects,
|
(
|
||||||
defaultPatchi,
|
subsetter,
|
||||||
vector(Zero),
|
objects,
|
||||||
vectorFlds
|
defaultPatchi,
|
||||||
|
vector(Zero)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
wordList sphTensorNames
|
|
||||||
(
|
|
||||||
objects.sortedNames<volSphericalTensorField>()
|
|
||||||
);
|
|
||||||
PtrList<volSphericalTensorField> sphTensorFlds
|
PtrList<volSphericalTensorField> sphTensorFlds
|
||||||
(
|
(
|
||||||
sphTensorNames.size()
|
subsetVolFields<sphericalTensor>
|
||||||
);
|
(
|
||||||
subsetVolFields
|
subsetter,
|
||||||
(
|
objects,
|
||||||
subsetter,
|
defaultPatchi,
|
||||||
objects,
|
sphericalTensor(Zero)
|
||||||
defaultPatchi,
|
)
|
||||||
sphericalTensor(Zero),
|
|
||||||
sphTensorFlds
|
|
||||||
);
|
);
|
||||||
|
|
||||||
wordList symmTensorNames(objects.sortedNames<volSymmTensorField>());
|
PtrList<volSymmTensorField> symmTensorFlds
|
||||||
PtrList<volSymmTensorField> symmTensorFlds(symmTensorNames.size());
|
|
||||||
subsetVolFields
|
|
||||||
(
|
(
|
||||||
subsetter,
|
subsetVolFields<symmTensor>
|
||||||
objects,
|
(
|
||||||
defaultPatchi,
|
subsetter,
|
||||||
symmTensor(Zero),
|
objects,
|
||||||
symmTensorFlds
|
defaultPatchi,
|
||||||
|
symmTensor(Zero)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
wordList tensorNames(objects.sortedNames<volTensorField>());
|
PtrList<volTensorField> tensorFlds
|
||||||
PtrList<volTensorField> tensorFlds(tensorNames.size());
|
|
||||||
subsetVolFields
|
|
||||||
(
|
(
|
||||||
subsetter,
|
subsetVolFields<tensor>
|
||||||
objects,
|
(
|
||||||
defaultPatchi,
|
subsetter,
|
||||||
tensor(Zero),
|
objects,
|
||||||
tensorFlds
|
defaultPatchi,
|
||||||
|
tensor(Zero)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Read surface fields and subset.
|
// Read surface fields and subset.
|
||||||
|
PtrList<surfaceScalarField> surfScalarFlds
|
||||||
wordList surfScalarNames(objects.sortedNames<surfaceScalarField>());
|
|
||||||
PtrList<surfaceScalarField> surfScalarFlds(surfScalarNames.size());
|
|
||||||
subsetSurfaceFields
|
|
||||||
(
|
(
|
||||||
subsetter,
|
subsetSurfaceFields<scalar>
|
||||||
objects,
|
(
|
||||||
defaultPatchi,
|
subsetter,
|
||||||
scalar(Zero),
|
objects,
|
||||||
surfScalarFlds
|
defaultPatchi,
|
||||||
|
scalar(Zero)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
wordList surfVectorNames(objects.sortedNames<surfaceVectorField>());
|
PtrList<surfaceVectorField> surfVectorFlds
|
||||||
PtrList<surfaceVectorField> surfVectorFlds(surfVectorNames.size());
|
|
||||||
subsetSurfaceFields
|
|
||||||
(
|
(
|
||||||
subsetter,
|
subsetSurfaceFields<vector>
|
||||||
objects,
|
(
|
||||||
defaultPatchi,
|
subsetter,
|
||||||
vector(Zero),
|
objects,
|
||||||
surfVectorFlds
|
defaultPatchi,
|
||||||
|
vector(Zero)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
wordList surfSphTensorNames
|
|
||||||
(
|
|
||||||
objects.sortedNames<surfaceSphericalTensorField>()
|
|
||||||
);
|
|
||||||
PtrList<surfaceSphericalTensorField> surfSphericalTensorFlds
|
PtrList<surfaceSphericalTensorField> surfSphericalTensorFlds
|
||||||
(
|
(
|
||||||
surfSphTensorNames.size()
|
subsetSurfaceFields<sphericalTensor>
|
||||||
);
|
(
|
||||||
subsetSurfaceFields
|
subsetter,
|
||||||
(
|
objects,
|
||||||
subsetter,
|
defaultPatchi,
|
||||||
objects,
|
sphericalTensor(Zero)
|
||||||
defaultPatchi,
|
)
|
||||||
sphericalTensor(Zero),
|
|
||||||
surfSphericalTensorFlds
|
|
||||||
);
|
|
||||||
|
|
||||||
wordList surfSymmTensorNames
|
|
||||||
(
|
|
||||||
objects.sortedNames<surfaceSymmTensorField>()
|
|
||||||
);
|
);
|
||||||
|
|
||||||
PtrList<surfaceSymmTensorField> surfSymmTensorFlds
|
PtrList<surfaceSymmTensorField> surfSymmTensorFlds
|
||||||
(
|
(
|
||||||
surfSymmTensorNames.size()
|
subsetSurfaceFields<symmTensor>
|
||||||
|
(
|
||||||
|
subsetter,
|
||||||
|
objects,
|
||||||
|
defaultPatchi,
|
||||||
|
symmTensor(Zero)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
subsetSurfaceFields
|
PtrList<surfaceTensorField> surfTensorFlds
|
||||||
(
|
(
|
||||||
subsetter,
|
subsetSurfaceFields<tensor>
|
||||||
objects,
|
(
|
||||||
defaultPatchi,
|
subsetter,
|
||||||
symmTensor(Zero),
|
objects,
|
||||||
surfSymmTensorFlds
|
defaultPatchi,
|
||||||
);
|
tensor(Zero)
|
||||||
|
)
|
||||||
wordList surfTensorNames(objects.sortedNames<surfaceTensorField>());
|
|
||||||
PtrList<surfaceTensorField> surfTensorFlds(surfTensorNames.size());
|
|
||||||
subsetSurfaceFields
|
|
||||||
(
|
|
||||||
subsetter,
|
|
||||||
objects,
|
|
||||||
defaultPatchi,
|
|
||||||
tensor(Zero),
|
|
||||||
surfTensorFlds
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@ -1017,62 +1024,8 @@ int main(int argc, char *argv[])
|
|||||||
++runTime;
|
++runTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< "Writing mesh without blockedCells to time " << runTime.value()
|
Info<< "Writing mesh without blockedCells to time "
|
||||||
<< endl;
|
<< runTime.value() << endl;
|
||||||
|
|
||||||
// Subsetting adds 'subset' prefix. Rename field to be like original.
|
|
||||||
forAll(scalarFlds, i)
|
|
||||||
{
|
|
||||||
scalarFlds[i].rename(scalarNames[i]);
|
|
||||||
scalarFlds[i].writeOpt(IOobject::AUTO_WRITE);
|
|
||||||
}
|
|
||||||
forAll(vectorFlds, i)
|
|
||||||
{
|
|
||||||
vectorFlds[i].rename(vectorNames[i]);
|
|
||||||
vectorFlds[i].writeOpt(IOobject::AUTO_WRITE);
|
|
||||||
}
|
|
||||||
forAll(sphTensorFlds, i)
|
|
||||||
{
|
|
||||||
sphTensorFlds[i].rename(sphTensorNames[i]);
|
|
||||||
sphTensorFlds[i].writeOpt(IOobject::AUTO_WRITE);
|
|
||||||
}
|
|
||||||
forAll(symmTensorFlds, i)
|
|
||||||
{
|
|
||||||
symmTensorFlds[i].rename(symmTensorNames[i]);
|
|
||||||
symmTensorFlds[i].writeOpt(IOobject::AUTO_WRITE);
|
|
||||||
}
|
|
||||||
forAll(tensorFlds, i)
|
|
||||||
{
|
|
||||||
tensorFlds[i].rename(tensorNames[i]);
|
|
||||||
tensorFlds[i].writeOpt(IOobject::AUTO_WRITE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Surface ones.
|
|
||||||
forAll(surfScalarFlds, i)
|
|
||||||
{
|
|
||||||
surfScalarFlds[i].rename(surfScalarNames[i]);
|
|
||||||
surfScalarFlds[i].writeOpt(IOobject::AUTO_WRITE);
|
|
||||||
}
|
|
||||||
forAll(surfVectorFlds, i)
|
|
||||||
{
|
|
||||||
surfVectorFlds[i].rename(surfVectorNames[i]);
|
|
||||||
surfVectorFlds[i].writeOpt(IOobject::AUTO_WRITE);
|
|
||||||
}
|
|
||||||
forAll(surfSphericalTensorFlds, i)
|
|
||||||
{
|
|
||||||
surfSphericalTensorFlds[i].rename(surfSphTensorNames[i]);
|
|
||||||
surfSphericalTensorFlds[i].writeOpt(IOobject::AUTO_WRITE);
|
|
||||||
}
|
|
||||||
forAll(surfSymmTensorFlds, i)
|
|
||||||
{
|
|
||||||
surfSymmTensorFlds[i].rename(surfSymmTensorNames[i]);
|
|
||||||
surfSymmTensorFlds[i].writeOpt(IOobject::AUTO_WRITE);
|
|
||||||
}
|
|
||||||
forAll(surfTensorNames, i)
|
|
||||||
{
|
|
||||||
surfTensorFlds[i].rename(surfTensorNames[i]);
|
|
||||||
surfTensorFlds[i].writeOpt(IOobject::AUTO_WRITE);
|
|
||||||
}
|
|
||||||
|
|
||||||
subsetter.subMesh().write();
|
subsetter.subMesh().write();
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -55,12 +55,9 @@ void ReadAndRotateFields
|
|||||||
const dimensionedTensor& rotT
|
const dimensionedTensor& rotT
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Objects of field type
|
for (const IOobject& io : objects.csorted<GeoField>())
|
||||||
IOobjectList fields(objects.lookupClass<GeoField>());
|
|
||||||
|
|
||||||
forAllConstIters(fields, fieldIter)
|
|
||||||
{
|
{
|
||||||
GeoField fld(*fieldIter(), mesh);
|
GeoField fld(io, mesh);
|
||||||
Info<< " Rotating " << fld.name() << endl;
|
Info<< " Rotating " << fld.name() << endl;
|
||||||
transform(fld, rotT, fld);
|
transform(fld, rotT, fld);
|
||||||
fld.write();
|
fld.write();
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2018 OpenFOAM Foundation
|
Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -158,7 +158,7 @@ void printSets(Ostream& os, const IOobjectList& objects)
|
|||||||
{
|
{
|
||||||
label n = 0;
|
label n = 0;
|
||||||
|
|
||||||
for (const IOobject& io : objects.sorted<SetType>())
|
for (const IOobject& io : objects.csorted<SetType>())
|
||||||
{
|
{
|
||||||
SetType set(io);
|
SetType set(io);
|
||||||
if (!n++) os << SetType::typeName << "s:" << nl;
|
if (!n++) os << SetType::typeName << "s:" << nl;
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
Copyright (C) 2021-2022 OpenCFD Ltd.
|
Copyright (C) 2021-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -105,7 +105,7 @@ int main(int argc, char *argv[])
|
|||||||
<< endl;
|
<< endl;
|
||||||
|
|
||||||
|
|
||||||
for (const IOobject& io : objects.sorted<pointSet>())
|
for (const IOobject& io : objects.csorted<pointSet>())
|
||||||
{
|
{
|
||||||
// Not in memory. Load it.
|
// Not in memory. Load it.
|
||||||
pointSet set(io);
|
pointSet set(io);
|
||||||
@ -137,7 +137,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
wordHashSet slaveCellSets;
|
wordHashSet slaveCellSets;
|
||||||
|
|
||||||
for (const IOobject& io : objects.sorted<faceSet>())
|
for (const IOobject& io : objects.csorted<faceSet>())
|
||||||
{
|
{
|
||||||
// Not in memory. Load it.
|
// Not in memory. Load it.
|
||||||
faceSet set(io);
|
faceSet set(io);
|
||||||
@ -259,7 +259,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (const IOobject& io : objects.sorted<cellSet>())
|
for (const IOobject& io : objects.csorted<cellSet>())
|
||||||
{
|
{
|
||||||
if (!slaveCellSets.found(io.name()))
|
if (!slaveCellSets.found(io.name()))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
Copyright (C) 2015-2022 OpenCFD Ltd.
|
Copyright (C) 2015-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -164,14 +164,8 @@ void subsetVolFields
|
|||||||
{
|
{
|
||||||
const labelList patchMap(identity(mesh.boundaryMesh().size()));
|
const labelList patchMap(identity(mesh.boundaryMesh().size()));
|
||||||
|
|
||||||
HashTable<const GeoField*> fields
|
for (const GeoField& fld : mesh.objectRegistry::csorted<GeoField>())
|
||||||
(
|
|
||||||
mesh.objectRegistry::lookupClass<GeoField>()
|
|
||||||
);
|
|
||||||
forAllConstIters(fields, iter)
|
|
||||||
{
|
{
|
||||||
const GeoField& fld = *iter.val();
|
|
||||||
|
|
||||||
Info<< "Mapping field " << fld.name() << endl;
|
Info<< "Mapping field " << fld.name() << endl;
|
||||||
|
|
||||||
tmp<GeoField> tSubFld
|
tmp<GeoField> tSubFld
|
||||||
@ -192,8 +186,7 @@ void subsetVolFields
|
|||||||
{
|
{
|
||||||
if (addedPatches.found(patchi))
|
if (addedPatches.found(patchi))
|
||||||
{
|
{
|
||||||
tSubFld.ref().boundaryFieldRef()[patchi] ==
|
tSubFld.ref().boundaryFieldRef()[patchi] == Zero;
|
||||||
typename GeoField::value_type(Zero);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,14 +211,8 @@ void subsetSurfaceFields
|
|||||||
{
|
{
|
||||||
const labelList patchMap(identity(mesh.boundaryMesh().size()));
|
const labelList patchMap(identity(mesh.boundaryMesh().size()));
|
||||||
|
|
||||||
HashTable<const GeoField*> fields
|
for (const GeoField& fld : mesh.objectRegistry::csorted<GeoField>())
|
||||||
(
|
|
||||||
mesh.objectRegistry::lookupClass<GeoField>()
|
|
||||||
);
|
|
||||||
forAllConstIters(fields, iter)
|
|
||||||
{
|
{
|
||||||
const GeoField& fld = *iter.val();
|
|
||||||
|
|
||||||
Info<< "Mapping field " << fld.name() << endl;
|
Info<< "Mapping field " << fld.name() << endl;
|
||||||
|
|
||||||
tmp<GeoField> tSubFld
|
tmp<GeoField> tSubFld
|
||||||
@ -246,8 +233,7 @@ void subsetSurfaceFields
|
|||||||
{
|
{
|
||||||
if (addedPatches.found(patchi))
|
if (addedPatches.found(patchi))
|
||||||
{
|
{
|
||||||
tSubFld.ref().boundaryFieldRef()[patchi] ==
|
tSubFld.ref().boundaryFieldRef()[patchi] == Zero;
|
||||||
typename GeoField::value_type(Zero);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -149,178 +149,127 @@ labelList nearestPatch(const polyMesh& mesh, const labelList& patchIDs)
|
|||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Subset field-type, availability information cached
|
// Subset DimensionedField/GeometricField
|
||||||
// in the availableFields hashtable.
|
|
||||||
//
|
//
|
||||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
template<class FieldType>
|
||||||
void subsetFields
|
PtrList<FieldType> subsetFields
|
||||||
(
|
(
|
||||||
const fvMeshSubset& subsetter,
|
const fvMeshSubset& subsetter,
|
||||||
HashTable<wordHashSet>& availableFields,
|
const IOobjectList& objects
|
||||||
PtrList<GeometricField<Type, PatchField, GeoMesh>>& subFields
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
typedef GeometricField<Type, PatchField, GeoMesh> FieldType;
|
|
||||||
const word fieldType = FieldType::typeName;
|
|
||||||
|
|
||||||
const wordList fieldNames = availableFields(fieldType).sortedToc();
|
|
||||||
subFields.setSize(fieldNames.size());
|
|
||||||
|
|
||||||
const fvMesh& baseMesh = subsetter.baseMesh();
|
const fvMesh& baseMesh = subsetter.baseMesh();
|
||||||
|
|
||||||
|
const UPtrList<const IOobject> fieldObjects
|
||||||
|
(
|
||||||
|
objects.csorted<FieldType>()
|
||||||
|
);
|
||||||
|
|
||||||
|
PtrList<FieldType> subFields(fieldObjects.size());
|
||||||
|
|
||||||
label nFields = 0;
|
label nFields = 0;
|
||||||
for (const word& fieldName : fieldNames)
|
for (const IOobject& io : fieldObjects)
|
||||||
{
|
{
|
||||||
if (!nFields)
|
if (!nFields)
|
||||||
{
|
{
|
||||||
Info<< "Subsetting " << fieldType << " (";
|
Info<< "Subsetting " << FieldType::typeName << " (";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Info<< ' ';
|
Info<< ' ';
|
||||||
}
|
}
|
||||||
Info<< fieldName;
|
Info<< io.name();
|
||||||
|
|
||||||
FieldType fld
|
FieldType fld
|
||||||
(
|
(
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
fieldName,
|
io.name(),
|
||||||
baseMesh.time().timeName(),
|
baseMesh.time().timeName(),
|
||||||
baseMesh,
|
baseMesh,
|
||||||
IOobject::MUST_READ,
|
IOobjectOption::MUST_READ,
|
||||||
IOobject::NO_WRITE
|
IOobjectOption::NO_WRITE,
|
||||||
|
IOobjectOption::NO_REGISTER
|
||||||
),
|
),
|
||||||
baseMesh
|
baseMesh
|
||||||
);
|
);
|
||||||
|
|
||||||
subFields.set(nFields, subsetter.interpolate(fld));
|
subFields.set(nFields, subsetter.interpolate(fld));
|
||||||
|
auto& subField = subFields[nFields];
|
||||||
|
++nFields;
|
||||||
|
|
||||||
// Subsetting adds 'subset' prefix - rename to match original.
|
// Subsetting adds 'subset' prefix - rename to match original.
|
||||||
subFields[nFields].rename(fieldName);
|
subField.rename(io.name());
|
||||||
|
|
||||||
++nFields;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nFields)
|
if (nFields)
|
||||||
{
|
{
|
||||||
Info<< ')' << nl;
|
Info<< ')' << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return subFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
// Subset point fields
|
||||||
void subsetPointFields
|
template<class FieldType>
|
||||||
|
PtrList<FieldType> subsetFields
|
||||||
(
|
(
|
||||||
const fvMeshSubset& subsetter,
|
const fvMeshSubset& subsetter,
|
||||||
const pointMesh& pMesh,
|
const IOobjectList& objects,
|
||||||
HashTable<wordHashSet>& availableFields,
|
const pointMesh& pMesh
|
||||||
PtrList<GeometricField<Type, pointPatchField, pointMesh>>& subFields
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
typedef GeometricField<Type, pointPatchField, pointMesh> FieldType;
|
|
||||||
const word fieldType = FieldType::typeName;
|
|
||||||
|
|
||||||
const wordList fieldNames = availableFields(fieldType).sortedToc();
|
|
||||||
subFields.setSize(fieldNames.size());
|
|
||||||
|
|
||||||
const fvMesh& baseMesh = subsetter.baseMesh();
|
const fvMesh& baseMesh = subsetter.baseMesh();
|
||||||
|
|
||||||
|
const UPtrList<const IOobject> fieldObjects
|
||||||
|
(
|
||||||
|
objects.csorted<FieldType>()
|
||||||
|
);
|
||||||
|
|
||||||
|
PtrList<FieldType> subFields(fieldObjects.size());
|
||||||
|
|
||||||
label nFields = 0;
|
label nFields = 0;
|
||||||
for (const word& fieldName : fieldNames)
|
for (const IOobject& io : fieldObjects)
|
||||||
{
|
{
|
||||||
if (!nFields)
|
if (!nFields)
|
||||||
{
|
{
|
||||||
Info<< "Subsetting " << fieldType << " (";
|
Info<< "Subsetting " << FieldType::typeName << " (";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Info<< ' ';
|
Info<< ' ';
|
||||||
}
|
}
|
||||||
Info<< fieldName;
|
Info<< io.name();
|
||||||
|
|
||||||
FieldType fld
|
FieldType fld
|
||||||
(
|
(
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
fieldName,
|
io.name(),
|
||||||
baseMesh.time().timeName(),
|
baseMesh.time().timeName(),
|
||||||
baseMesh,
|
baseMesh,
|
||||||
IOobject::MUST_READ,
|
IOobjectOption::MUST_READ,
|
||||||
IOobject::NO_WRITE
|
IOobjectOption::NO_WRITE,
|
||||||
|
IOobjectOption::NO_REGISTER
|
||||||
),
|
),
|
||||||
pMesh
|
pMesh
|
||||||
);
|
);
|
||||||
|
|
||||||
subFields.set(nFields, subsetter.interpolate(fld));
|
subFields.set(nFields, subsetter.interpolate(fld));
|
||||||
|
auto& subField = subFields[nFields];
|
||||||
|
++nFields;
|
||||||
|
|
||||||
// Subsetting adds 'subset' prefix - rename to match original.
|
// Subsetting adds 'subset' prefix - rename to match original.
|
||||||
subFields[nFields].rename(fieldName);
|
subField.rename(io.name());
|
||||||
|
|
||||||
++nFields;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nFields)
|
if (nFields)
|
||||||
{
|
{
|
||||||
Info<< ')' << nl;
|
Info<< ')' << nl;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
return subFields;
|
||||||
template<class Type>
|
|
||||||
void subsetDimensionedFields
|
|
||||||
(
|
|
||||||
const fvMeshSubset& subsetter,
|
|
||||||
HashTable<wordHashSet>& availableFields,
|
|
||||||
PtrList<DimensionedField<Type, volMesh>>& subFields
|
|
||||||
)
|
|
||||||
{
|
|
||||||
typedef DimensionedField<Type, volMesh> FieldType;
|
|
||||||
const word fieldType = FieldType::typeName;
|
|
||||||
|
|
||||||
const wordList fieldNames = availableFields(fieldType).sortedToc();
|
|
||||||
subFields.setSize(fieldNames.size());
|
|
||||||
|
|
||||||
const fvMesh& baseMesh = subsetter.baseMesh();
|
|
||||||
|
|
||||||
label nFields = 0;
|
|
||||||
for (const word& fieldName : fieldNames)
|
|
||||||
{
|
|
||||||
if (!nFields)
|
|
||||||
{
|
|
||||||
Info<< "Subsetting " << fieldType << " (";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Info<< ' ';
|
|
||||||
}
|
|
||||||
Info<< fieldName;
|
|
||||||
|
|
||||||
FieldType fld
|
|
||||||
(
|
|
||||||
IOobject
|
|
||||||
(
|
|
||||||
fieldName,
|
|
||||||
baseMesh.time().timeName(),
|
|
||||||
baseMesh,
|
|
||||||
IOobject::MUST_READ,
|
|
||||||
IOobject::NO_WRITE
|
|
||||||
),
|
|
||||||
baseMesh
|
|
||||||
);
|
|
||||||
|
|
||||||
subFields.set(nFields, subsetter.interpolate(fld));
|
|
||||||
|
|
||||||
// Subsetting adds 'subset' prefix - rename to match original.
|
|
||||||
subFields[nFields].rename(fieldName);
|
|
||||||
|
|
||||||
++nFields;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nFields)
|
|
||||||
{
|
|
||||||
Info<< ')' << nl;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -338,7 +287,8 @@ void subsetTopoSets
|
|||||||
PtrList<TopoSet> sets;
|
PtrList<TopoSet> sets;
|
||||||
ReadFields<TopoSet>(objects, sets);
|
ReadFields<TopoSet>(objects, sets);
|
||||||
|
|
||||||
subSets.setSize(sets.size());
|
subSets.resize_null(sets.size());
|
||||||
|
|
||||||
forAll(sets, seti)
|
forAll(sets, seti)
|
||||||
{
|
{
|
||||||
const TopoSet& set = sets[seti];
|
const TopoSet& set = sets[seti];
|
||||||
@ -347,6 +297,7 @@ void subsetTopoSets
|
|||||||
|
|
||||||
labelHashSet subset(2*min(set.size(), map.size()));
|
labelHashSet subset(2*min(set.size(), map.size()));
|
||||||
|
|
||||||
|
// Map the data
|
||||||
forAll(map, i)
|
forAll(map, i)
|
||||||
{
|
{
|
||||||
if (set.found(map[i]))
|
if (set.found(map[i]))
|
||||||
@ -363,13 +314,14 @@ void subsetTopoSets
|
|||||||
subMesh,
|
subMesh,
|
||||||
set.name(),
|
set.name(),
|
||||||
std::move(subset),
|
std::move(subset),
|
||||||
IOobject::AUTO_WRITE
|
IOobjectOption::AUTO_WRITE
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@ -568,54 +520,51 @@ int main(int argc, char *argv[])
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< "Subset "
|
FixedList<label, 2> cellCount;
|
||||||
<< returnReduce(subsetter.subMesh().nCells(), sumOp<label>())
|
cellCount[0] = subsetter.subMesh().nCells();
|
||||||
<< " of "
|
cellCount[1] = mesh.nCells();
|
||||||
<< returnReduce(mesh.nCells(), sumOp<label>())
|
reduce(cellCount, sumOp<label>());
|
||||||
|
|
||||||
|
Info<< "Subset " << cellCount[0] << " of " << cellCount[1]
|
||||||
<< " cells" << nl << nl;
|
<< " cells" << nl << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
IOobjectList objects(mesh, runTime.timeName());
|
IOobjectList objects(mesh, runTime.timeName());
|
||||||
HashTable<wordHashSet> availableFields = objects.classes();
|
|
||||||
|
|
||||||
|
// Read fields and subset
|
||||||
|
#undef createSubsetFields
|
||||||
|
#define createSubsetFields(FieldType, Variable) \
|
||||||
|
PtrList<FieldType> Variable \
|
||||||
|
( \
|
||||||
|
subsetFields<FieldType>(subsetter, objects) \
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
// Read vol fields and subset
|
// Read vol fields and subset
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
createSubsetFields(volScalarField, vScalarFlds);
|
||||||
PtrList<volScalarField> vScalarFlds;
|
createSubsetFields(volVectorField, vVectorFlds);
|
||||||
subsetFields(subsetter, availableFields, vScalarFlds);
|
createSubsetFields(volSphericalTensorField, vSphTensorFlds);
|
||||||
|
createSubsetFields(volSymmTensorField, vSymmTensorFlds);
|
||||||
PtrList<volVectorField> vVectorFlds;
|
createSubsetFields(volTensorField, vTensorFlds);
|
||||||
subsetFields(subsetter, availableFields, vVectorFlds);
|
|
||||||
|
|
||||||
PtrList<volSphericalTensorField> vSphTensorFlds;
|
|
||||||
subsetFields(subsetter, availableFields, vSphTensorFlds);
|
|
||||||
|
|
||||||
PtrList<volSymmTensorField> vSymmTensorFlds;
|
|
||||||
subsetFields(subsetter, availableFields, vSymmTensorFlds);
|
|
||||||
|
|
||||||
PtrList<volTensorField> vTensorFlds;
|
|
||||||
subsetFields(subsetter, availableFields, vTensorFlds);
|
|
||||||
|
|
||||||
|
|
||||||
// Read surface fields and subset
|
// Read surface fields and subset
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
createSubsetFields(surfaceScalarField, sScalarFlds);
|
||||||
|
createSubsetFields(surfaceVectorField, sVectorFlds);
|
||||||
|
createSubsetFields(surfaceSphericalTensorField, sSphTensorFlds);
|
||||||
|
createSubsetFields(surfaceSymmTensorField, sSymmTensorFlds);
|
||||||
|
createSubsetFields(surfaceTensorField, sTensorFlds);
|
||||||
|
|
||||||
PtrList<surfaceScalarField> sScalarFlds;
|
// Read dimensioned fields and subset
|
||||||
subsetFields(subsetter, availableFields, sScalarFlds);
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
createSubsetFields(volScalarField::Internal, dScalarFlds);
|
||||||
PtrList<surfaceVectorField> sVectorFlds;
|
createSubsetFields(volVectorField::Internal, dVectorFlds);
|
||||||
subsetFields(subsetter, availableFields, sVectorFlds);
|
createSubsetFields(volSphericalTensorField::Internal, dSphTensorFlds);
|
||||||
|
createSubsetFields(volSymmTensorField::Internal, dSymmTensorFlds);
|
||||||
PtrList<surfaceSphericalTensorField> sSphTensorFlds;
|
createSubsetFields(volTensorField::Internal, dTensorFlds);
|
||||||
subsetFields(subsetter, availableFields, sSphTensorFlds);
|
|
||||||
|
|
||||||
PtrList<surfaceSymmTensorField> sSymmTensorFlds;
|
|
||||||
subsetFields(subsetter, availableFields, sSymmTensorFlds);
|
|
||||||
|
|
||||||
PtrList<surfaceTensorField> sTensorFlds;
|
|
||||||
subsetFields(subsetter, availableFields, sTensorFlds);
|
|
||||||
|
|
||||||
|
|
||||||
// Read point fields and subset
|
// Read point fields and subset
|
||||||
@ -623,39 +572,20 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
const pointMesh& pMesh = pointMesh::New(mesh);
|
const pointMesh& pMesh = pointMesh::New(mesh);
|
||||||
|
|
||||||
PtrList<pointScalarField> pScalarFlds;
|
#undef createSubsetFields
|
||||||
subsetPointFields(subsetter, pMesh, availableFields, pScalarFlds);
|
#define createSubsetFields(FieldType, Variable) \
|
||||||
|
PtrList<FieldType> Variable \
|
||||||
|
( \
|
||||||
|
subsetFields<FieldType>(subsetter, objects, pMesh) \
|
||||||
|
);
|
||||||
|
|
||||||
PtrList<pointVectorField> pVectorFlds;
|
createSubsetFields(pointScalarField, pScalarFlds);
|
||||||
subsetPointFields(subsetter, pMesh, availableFields, pVectorFlds);
|
createSubsetFields(pointVectorField, pVectorFlds);
|
||||||
|
createSubsetFields(pointSphericalTensorField, pSphTensorFlds);
|
||||||
|
createSubsetFields(pointSymmTensorField, pSymmTensorFlds);
|
||||||
|
createSubsetFields(pointTensorField, pTensorFlds);
|
||||||
|
|
||||||
PtrList<pointSphericalTensorField> pSphTensorFlds;
|
#undef createSubsetFields
|
||||||
subsetPointFields(subsetter, pMesh, availableFields, pSphTensorFlds);
|
|
||||||
|
|
||||||
PtrList<pointSymmTensorField> pSymmTensorFlds;
|
|
||||||
subsetPointFields(subsetter, pMesh, availableFields, pSymmTensorFlds);
|
|
||||||
|
|
||||||
PtrList<pointTensorField> pTensorFlds;
|
|
||||||
subsetPointFields(subsetter, pMesh, availableFields, pTensorFlds);
|
|
||||||
|
|
||||||
|
|
||||||
// Read dimensioned fields and subset
|
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
PtrList<volScalarField::Internal> dScalarFlds;
|
|
||||||
subsetDimensionedFields(subsetter, availableFields, dScalarFlds);
|
|
||||||
|
|
||||||
PtrList<volVectorField::Internal> dVectorFlds;
|
|
||||||
subsetDimensionedFields(subsetter, availableFields, dVectorFlds);
|
|
||||||
|
|
||||||
PtrList<volSphericalTensorField::Internal> dSphTensorFlds;
|
|
||||||
subsetDimensionedFields(subsetter, availableFields, dSphTensorFlds);
|
|
||||||
|
|
||||||
PtrList<volSymmTensorField::Internal> dSymmTensorFlds;
|
|
||||||
subsetDimensionedFields(subsetter, availableFields, dSymmTensorFlds);
|
|
||||||
|
|
||||||
PtrList<volTensorField::Internal> dTensorFlds;
|
|
||||||
subsetDimensionedFields(subsetter, availableFields, dTensorFlds);
|
|
||||||
|
|
||||||
|
|
||||||
// Read topoSets and subset
|
// Read topoSets and subset
|
||||||
@ -735,13 +665,6 @@ int main(int argc, char *argv[])
|
|||||||
for (const auto& fld : sSymmTensorFlds) { fld.write(); }
|
for (const auto& fld : sSymmTensorFlds) { fld.write(); }
|
||||||
for (const auto& fld : sTensorFlds) { fld.write(); }
|
for (const auto& fld : sTensorFlds) { fld.write(); }
|
||||||
|
|
||||||
// Point fields
|
|
||||||
for (const auto& fld : pScalarFlds) { fld.write(); }
|
|
||||||
for (const auto& fld : pVectorFlds) { fld.write(); }
|
|
||||||
for (const auto& fld : pSphTensorFlds) { fld.write(); }
|
|
||||||
for (const auto& fld : pSymmTensorFlds) { fld.write(); }
|
|
||||||
for (const auto& fld : pTensorFlds) { fld.write(); }
|
|
||||||
|
|
||||||
// Dimensioned fields
|
// Dimensioned fields
|
||||||
for (const auto& fld : dScalarFlds) { fld.write(); }
|
for (const auto& fld : dScalarFlds) { fld.write(); }
|
||||||
for (const auto& fld : dVectorFlds) { fld.write(); }
|
for (const auto& fld : dVectorFlds) { fld.write(); }
|
||||||
@ -749,6 +672,13 @@ int main(int argc, char *argv[])
|
|||||||
for (const auto& fld : dSymmTensorFlds) { fld.write(); }
|
for (const auto& fld : dSymmTensorFlds) { fld.write(); }
|
||||||
for (const auto& fld : dTensorFlds) { fld.write(); }
|
for (const auto& fld : dTensorFlds) { fld.write(); }
|
||||||
|
|
||||||
|
// Point fields
|
||||||
|
for (const auto& fld : pScalarFlds) { fld.write(); }
|
||||||
|
for (const auto& fld : pVectorFlds) { fld.write(); }
|
||||||
|
for (const auto& fld : pSphTensorFlds) { fld.write(); }
|
||||||
|
for (const auto& fld : pSymmTensorFlds) { fld.write(); }
|
||||||
|
for (const auto& fld : pTensorFlds) { fld.write(); }
|
||||||
|
|
||||||
Info<< "\nEnd\n" << endl;
|
Info<< "\nEnd\n" << endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
Copyright (C) 2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -89,50 +90,41 @@ int main(int argc, char *argv[])
|
|||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
const wordList objNames
|
const IOobjectList objects(mesh, runTime.timeName());
|
||||||
(
|
|
||||||
IOobjectList(mesh, runTime.timeName()).sortedNames()
|
Info<< "Reading fields:" << endl;
|
||||||
|
|
||||||
|
// Read fields
|
||||||
|
#undef createFields
|
||||||
|
#define createFields(FieldType, Variable) \
|
||||||
|
PtrList<FieldType> Variable \
|
||||||
|
( \
|
||||||
|
readFields<FieldType>(objects, mesh) \
|
||||||
);
|
);
|
||||||
|
|
||||||
PtrList<volScalarField> vsf(objNames.size());
|
createFields(volScalarField, vsf);
|
||||||
PtrList<volVectorField> vvf(objNames.size());
|
createFields(volVectorField, vvf);
|
||||||
PtrList<volSphericalTensorField> vsptf(objNames.size());
|
createFields(volSphericalTensorField, vsptf);
|
||||||
PtrList<volSymmTensorField> vsytf(objNames.size());
|
createFields(volSymmTensorField, vsytf);
|
||||||
PtrList<volTensorField> vtf(objNames.size());
|
createFields(volTensorField, vtf);
|
||||||
|
|
||||||
PtrList<pointScalarField> psf(objNames.size());
|
// Point fields
|
||||||
PtrList<pointVectorField> pvf(objNames.size());
|
const pointMesh& pMesh = pointMesh::New(mesh);
|
||||||
PtrList<pointSphericalTensorField> psptf(objNames.size());
|
|
||||||
PtrList<pointSymmTensorField> psytf(objNames.size());
|
|
||||||
PtrList<pointTensorField> ptf(objNames.size());
|
|
||||||
|
|
||||||
Info<< "Valid fields:" << endl;
|
#undef createFields
|
||||||
|
#define createFields(FieldType, Variable) \
|
||||||
|
PtrList<FieldType> Variable \
|
||||||
|
( \
|
||||||
|
readFields<FieldType>(objects, pMesh) \
|
||||||
|
);
|
||||||
|
|
||||||
forAll(objNames, objI)
|
createFields(pointScalarField, psf);
|
||||||
{
|
createFields(pointVectorField, pvf);
|
||||||
IOobject obj
|
createFields(pointSphericalTensorField, psptf);
|
||||||
(
|
createFields(pointSymmTensorField, psytf);
|
||||||
objNames[objI],
|
createFields(pointTensorField, ptf);
|
||||||
runTime.timeName(),
|
|
||||||
mesh,
|
|
||||||
IOobject::MUST_READ
|
|
||||||
);
|
|
||||||
|
|
||||||
if (obj.typeHeaderOk<volScalarField>(false))
|
#undef createFields
|
||||||
{
|
|
||||||
addToFieldList(vsf, obj, objI, mesh);
|
|
||||||
addToFieldList(vvf, obj, objI, mesh);
|
|
||||||
addToFieldList(vsptf, obj, objI, mesh);
|
|
||||||
addToFieldList(vsytf, obj, objI, mesh);
|
|
||||||
addToFieldList(vtf, obj, objI, mesh);
|
|
||||||
|
|
||||||
addToFieldList(psf, obj, objI, pointMesh::New(mesh));
|
|
||||||
addToFieldList(pvf, obj, objI, pointMesh::New(mesh));
|
|
||||||
addToFieldList(psptf, obj, objI, pointMesh::New(mesh));
|
|
||||||
addToFieldList(psytf, obj, objI, pointMesh::New(mesh));
|
|
||||||
addToFieldList(ptf, obj, objI, pointMesh::New(mesh));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Info<< endl;
|
Info<< endl;
|
||||||
|
|
||||||
@ -144,6 +136,7 @@ int main(int argc, char *argv[])
|
|||||||
forAll(bm, patchi)
|
forAll(bm, patchi)
|
||||||
{
|
{
|
||||||
Info<< bm[patchi].type() << "\t: " << bm[patchi].name() << nl;
|
Info<< bm[patchi].type() << "\t: " << bm[patchi].name() << nl;
|
||||||
|
|
||||||
outputFieldList(vsf, patchi);
|
outputFieldList(vsf, patchi);
|
||||||
outputFieldList(vvf, patchi);
|
outputFieldList(vvf, patchi);
|
||||||
outputFieldList(vsptf, patchi);
|
outputFieldList(vsptf, patchi);
|
||||||
@ -167,6 +160,7 @@ int main(int argc, char *argv[])
|
|||||||
DynamicList<HashTable<word>> fieldToTypes(bm.size());
|
DynamicList<HashTable<word>> fieldToTypes(bm.size());
|
||||||
// Per 'group' the patches
|
// Per 'group' the patches
|
||||||
DynamicList<DynamicList<label>> groupToPatches(bm.size());
|
DynamicList<DynamicList<label>> groupToPatches(bm.size());
|
||||||
|
|
||||||
forAll(bm, patchi)
|
forAll(bm, patchi)
|
||||||
{
|
{
|
||||||
HashTable<word> fieldToType;
|
HashTable<word> fieldToType;
|
||||||
@ -208,40 +202,39 @@ int main(int argc, char *argv[])
|
|||||||
labelHashSet nonGroupPatches;
|
labelHashSet nonGroupPatches;
|
||||||
bm.matchGroups(patchIDs, groups, nonGroupPatches);
|
bm.matchGroups(patchIDs, groups, nonGroupPatches);
|
||||||
|
|
||||||
const labelList sortedPatches(nonGroupPatches.sortedToc());
|
for (const label patchi : nonGroupPatches.sortedToc())
|
||||||
forAll(sortedPatches, i)
|
|
||||||
{
|
{
|
||||||
Info<< bm[sortedPatches[i]].type()
|
Info<< bm[patchi].type()
|
||||||
<< "\t: " << bm[sortedPatches[i]].name() << nl;
|
<< "\t: " << bm[patchi].name() << nl;
|
||||||
}
|
}
|
||||||
if (groups.size())
|
for (const word& groupName : groups)
|
||||||
{
|
{
|
||||||
forAll(groups, i)
|
Info<< "group\t: " << groupName << nl;
|
||||||
{
|
|
||||||
Info<< "group\t: " << groups[i] << nl;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
outputFieldList(vsf, patchIDs[0]);
|
|
||||||
outputFieldList(vvf, patchIDs[0]);
|
|
||||||
outputFieldList(vsptf, patchIDs[0]);
|
|
||||||
outputFieldList(vsytf, patchIDs[0]);
|
|
||||||
outputFieldList(vtf, patchIDs[0]);
|
|
||||||
|
|
||||||
outputFieldList(psf, patchIDs[0]);
|
const label patchi = patchIDs[0];
|
||||||
outputFieldList(pvf, patchIDs[0]);
|
|
||||||
outputFieldList(psptf, patchIDs[0]);
|
outputFieldList(vsf, patchi);
|
||||||
outputFieldList(psytf, patchIDs[0]);
|
outputFieldList(vvf, patchi);
|
||||||
outputFieldList(ptf, patchIDs[0]);
|
outputFieldList(vsptf, patchi);
|
||||||
|
outputFieldList(vsytf, patchi);
|
||||||
|
outputFieldList(vtf, patchi);
|
||||||
|
|
||||||
|
outputFieldList(psf, patchi);
|
||||||
|
outputFieldList(pvf, patchi);
|
||||||
|
outputFieldList(psptf, patchi);
|
||||||
|
outputFieldList(psytf, patchi);
|
||||||
|
outputFieldList(ptf, patchi);
|
||||||
Info<< endl;
|
Info<< endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// No group.
|
// No group.
|
||||||
forAll(patchIDs, i)
|
for (const label patchi : patchIDs)
|
||||||
{
|
{
|
||||||
label patchi = patchIDs[i];
|
|
||||||
Info<< bm[patchi].type()
|
Info<< bm[patchi].type()
|
||||||
<< "\t: " << bm[patchi].name() << nl;
|
<< "\t: " << bm[patchi].name() << nl;
|
||||||
|
|
||||||
outputFieldList(vsf, patchi);
|
outputFieldList(vsf, patchi);
|
||||||
outputFieldList(vvf, patchi);
|
outputFieldList(vvf, patchi);
|
||||||
outputFieldList(vsptf, patchi);
|
outputFieldList(vsptf, patchi);
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
Copyright (C) 2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -31,30 +32,49 @@ License
|
|||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class GeoField>
|
template<class GeoField>
|
||||||
void Foam::addToFieldList
|
Foam::PtrList<GeoField> Foam::readFields
|
||||||
(
|
(
|
||||||
PtrList<GeoField>& fieldList,
|
const IOobjectList& objects,
|
||||||
const IOobject& obj,
|
|
||||||
const label fieldi,
|
|
||||||
const typename GeoField::Mesh& mesh
|
const typename GeoField::Mesh& mesh
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (obj.isHeaderClass<GeoField>())
|
const UPtrList<const IOobject> fieldObjects
|
||||||
|
(
|
||||||
|
objects.csorted<GeoField>()
|
||||||
|
);
|
||||||
|
|
||||||
|
PtrList<GeoField> fields(fieldObjects.size());
|
||||||
|
|
||||||
|
label nFields = 0;
|
||||||
|
for (const IOobject& io : fieldObjects)
|
||||||
{
|
{
|
||||||
fieldList.set
|
if (!nFields)
|
||||||
(
|
{
|
||||||
fieldi,
|
Info<< " " << GeoField::typeName << " (";
|
||||||
new GeoField(obj, mesh)
|
}
|
||||||
);
|
else
|
||||||
Info<< " " << GeoField::typeName << tab << obj.name() << endl;
|
{
|
||||||
|
Info<< ' ';
|
||||||
|
}
|
||||||
|
Info<< io.name();
|
||||||
|
|
||||||
|
fields.emplace_set(nFields, io, mesh);
|
||||||
|
++nFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (nFields)
|
||||||
|
{
|
||||||
|
Info<< ')' << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class GeoField>
|
template<class GeoField>
|
||||||
void Foam::outputFieldList
|
void Foam::outputFieldList
|
||||||
(
|
(
|
||||||
const PtrList<GeoField>& fieldList,
|
const UPtrList<GeoField>& fieldList,
|
||||||
const label patchi
|
const label patchi
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -74,7 +94,7 @@ void Foam::outputFieldList
|
|||||||
template<class GeoField>
|
template<class GeoField>
|
||||||
void Foam::collectFieldList
|
void Foam::collectFieldList
|
||||||
(
|
(
|
||||||
const PtrList<GeoField>& fieldList,
|
const UPtrList<GeoField>& fieldList,
|
||||||
const label patchi,
|
const label patchi,
|
||||||
HashTable<word>& fieldToType
|
HashTable<word>& fieldToType
|
||||||
)
|
)
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
Copyright (C) 2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -25,39 +26,39 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef patchSummaryTemplates_H
|
#ifndef Foam_patchSummaryTemplates_H
|
||||||
#define patchSummaryTemplates_H
|
#define Foam_patchSummaryTemplates_H
|
||||||
|
|
||||||
#include "fvCFD.H"
|
|
||||||
#include "volFields.H"
|
#include "volFields.H"
|
||||||
|
#include "IOobjectList.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
template<class GeoField>
|
|
||||||
void addToFieldList
|
|
||||||
(
|
|
||||||
PtrList<GeoField>& fieldList,
|
|
||||||
const IOobject& obj,
|
|
||||||
const label fieldi,
|
|
||||||
const typename GeoField::Mesh& mesh
|
|
||||||
);
|
|
||||||
|
|
||||||
template<class GeoField>
|
template<class GeoField>
|
||||||
void outputFieldList
|
PtrList<GeoField> readFields
|
||||||
(
|
(
|
||||||
const PtrList<GeoField>& fieldList,
|
const IOobjectList& objects,
|
||||||
const label patchi
|
const typename GeoField::Mesh& mesh
|
||||||
);
|
);
|
||||||
|
|
||||||
|
template<class GeoField>
|
||||||
|
void outputFieldList
|
||||||
|
(
|
||||||
|
const UPtrList<GeoField>& fieldList,
|
||||||
|
const label patchi
|
||||||
|
);
|
||||||
|
|
||||||
|
template<class GeoField>
|
||||||
|
void collectFieldList
|
||||||
|
(
|
||||||
|
const UPtrList<GeoField>& fieldList,
|
||||||
|
const label patchi,
|
||||||
|
HashTable<word>& fieldToType
|
||||||
|
);
|
||||||
|
|
||||||
template<class GeoField>
|
|
||||||
void collectFieldList
|
|
||||||
(
|
|
||||||
const PtrList<GeoField>& fieldList,
|
|
||||||
const label patchi,
|
|
||||||
HashTable<word>& fieldToType
|
|
||||||
);
|
|
||||||
} // End namespace Foam
|
} // End namespace Foam
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -186,26 +186,17 @@ bool Foam::domainDecomposition::writeDecomposition(const bool decomposeSets)
|
|||||||
{
|
{
|
||||||
// Read sets
|
// Read sets
|
||||||
IOobjectList objects(*this, facesInstance(), "polyMesh/sets");
|
IOobjectList objects(*this, facesInstance(), "polyMesh/sets");
|
||||||
|
for (const IOobject& io : objects.csorted<cellSet>())
|
||||||
{
|
{
|
||||||
IOobjectList sets(objects.lookupClass<cellSet>());
|
cellSets.emplace_back(io);
|
||||||
forAllConstIters(sets, iter)
|
|
||||||
{
|
|
||||||
cellSets.append(new cellSet(*(iter.val())));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
for (const IOobject& io : objects.csorted<faceSet>())
|
||||||
{
|
{
|
||||||
IOobjectList sets(objects.lookupClass<faceSet>());
|
faceSets.emplace_back(io);
|
||||||
forAllConstIters(sets, iter)
|
|
||||||
{
|
|
||||||
faceSets.append(new faceSet(*(iter.val())));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
for (const IOobject& io : objects.csorted<pointSet>())
|
||||||
{
|
{
|
||||||
IOobjectList sets(objects.lookupClass<pointSet>());
|
pointSets.emplace_back(io);
|
||||||
forAllConstIters(sets, iter)
|
|
||||||
{
|
|
||||||
pointSets.append(new pointSet(*(iter.val())));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,9 +210,9 @@ bool Foam::domainDecomposition::writeDecomposition(const bool decomposeSets)
|
|||||||
facesInstance(),
|
facesInstance(),
|
||||||
polyMesh::meshSubDir,
|
polyMesh::meshSubDir,
|
||||||
*this,
|
*this,
|
||||||
IOobject::READ_IF_PRESENT,
|
IOobjectOption::READ_IF_PRESENT,
|
||||||
IOobject::NO_WRITE,
|
IOobjectOption::NO_WRITE,
|
||||||
IOobject::NO_REGISTER
|
IOobjectOption::NO_REGISTER
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
Copyright (C) 2015-2022 OpenCFD Ltd.
|
Copyright (C) 2015-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -597,19 +597,19 @@ int main(int argc, char *argv[])
|
|||||||
polyMesh::meshSubDir/"sets"
|
polyMesh::meshSubDir/"sets"
|
||||||
);
|
);
|
||||||
|
|
||||||
for (const word& setName : objects.sortedNames<cellSet>())
|
for (const IOobject& io : objects.csorted<cellSet>())
|
||||||
{
|
{
|
||||||
cSetNames.insert(setName, cSetNames.size());
|
cSetNames.insert(io.name(), cSetNames.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const word& setName : objects.sortedNames<faceSet>())
|
for (const IOobject& io : objects.csorted<faceSet>())
|
||||||
{
|
{
|
||||||
fSetNames.insert(setName, fSetNames.size());
|
fSetNames.insert(io.name(), fSetNames.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const word& setName : objects.sortedNames<pointSet>())
|
for (const IOobject& io : objects.csorted<pointSet>())
|
||||||
{
|
{
|
||||||
pSetNames.insert(setName, pSetNames.size());
|
pSetNames.insert(io.name(), pSetNames.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -653,7 +653,7 @@ int main(int argc, char *argv[])
|
|||||||
const labelList& cellMap =
|
const labelList& cellMap =
|
||||||
procMeshes.cellProcAddressing()[proci];
|
procMeshes.cellProcAddressing()[proci];
|
||||||
|
|
||||||
for (const IOobject& io : objects.sorted<cellSet>())
|
for (const IOobject& io : objects.csorted<cellSet>())
|
||||||
{
|
{
|
||||||
// Load cellSet
|
// Load cellSet
|
||||||
const cellSet procSet(io);
|
const cellSet procSet(io);
|
||||||
@ -684,7 +684,7 @@ int main(int argc, char *argv[])
|
|||||||
const labelList& faceMap =
|
const labelList& faceMap =
|
||||||
procMeshes.faceProcAddressing()[proci];
|
procMeshes.faceProcAddressing()[proci];
|
||||||
|
|
||||||
for (const IOobject& io : objects.sorted<faceSet>())
|
for (const IOobject& io : objects.csorted<faceSet>())
|
||||||
{
|
{
|
||||||
// Load faceSet
|
// Load faceSet
|
||||||
const faceSet procSet(io);
|
const faceSet procSet(io);
|
||||||
@ -714,7 +714,7 @@ int main(int argc, char *argv[])
|
|||||||
const labelList& pointMap =
|
const labelList& pointMap =
|
||||||
procMeshes.pointProcAddressing()[proci];
|
procMeshes.pointProcAddressing()[proci];
|
||||||
|
|
||||||
for (const IOobject& io : objects.sorted<pointSet>())
|
for (const IOobject& io : objects.csorted<pointSet>())
|
||||||
{
|
{
|
||||||
// Load pointSet
|
// Load pointSet
|
||||||
const pointSet procSet(io);
|
const pointSet procSet(io);
|
||||||
|
|||||||
@ -405,20 +405,20 @@ Foam::label Foam::parFvFieldDistributor::distributeInternalFields
|
|||||||
{
|
{
|
||||||
typedef DimensionedField<Type, volMesh> fieldType;
|
typedef DimensionedField<Type, volMesh> fieldType;
|
||||||
|
|
||||||
// Available fields, sorted order
|
|
||||||
const wordList fieldNames =
|
|
||||||
(
|
|
||||||
selectedFields.empty()
|
|
||||||
? objects.sortedNames<fieldType>()
|
|
||||||
: objects.sortedNames<fieldType>(selectedFields)
|
|
||||||
);
|
|
||||||
|
|
||||||
label nFields = 0;
|
label nFields = 0;
|
||||||
for (const word& fieldName : fieldNames)
|
for
|
||||||
|
(
|
||||||
|
const IOobject& io :
|
||||||
|
(
|
||||||
|
selectedFields.empty()
|
||||||
|
? objects.csorted<fieldType>()
|
||||||
|
: objects.csorted<fieldType>(selectedFields)
|
||||||
|
)
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if ("cellDist" == fieldName)
|
if ("cellDist" == io.name())
|
||||||
{
|
{
|
||||||
// There is an odd chance this is an internal field
|
// Ignore cellDist (internal or volume) field
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (verbose_)
|
if (verbose_)
|
||||||
@ -428,13 +428,13 @@ Foam::label Foam::parFvFieldDistributor::distributeInternalFields
|
|||||||
Info<< " Reconstructing "
|
Info<< " Reconstructing "
|
||||||
<< fieldType::typeName << "s\n" << nl;
|
<< fieldType::typeName << "s\n" << nl;
|
||||||
}
|
}
|
||||||
Info<< " " << fieldName << nl;
|
Info<< " " << io.name() << nl;
|
||||||
}
|
}
|
||||||
++nFields;
|
++nFields;
|
||||||
|
|
||||||
tmp<fieldType> tfld
|
tmp<fieldType> tfld
|
||||||
(
|
(
|
||||||
distributeInternalField<Type>(*(objects[fieldName]))
|
distributeInternalField<Type>(io)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (isWriteProc_.good())
|
if (isWriteProc_.good())
|
||||||
@ -470,19 +470,20 @@ Foam::label Foam::parFvFieldDistributor::distributeVolumeFields
|
|||||||
{
|
{
|
||||||
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
|
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
|
||||||
|
|
||||||
// Available fields, sorted order
|
|
||||||
const wordList fieldNames =
|
|
||||||
(
|
|
||||||
selectedFields.empty()
|
|
||||||
? objects.sortedNames<fieldType>()
|
|
||||||
: objects.sortedNames<fieldType>(selectedFields)
|
|
||||||
);
|
|
||||||
|
|
||||||
label nFields = 0;
|
label nFields = 0;
|
||||||
for (const word& fieldName : fieldNames)
|
for
|
||||||
|
(
|
||||||
|
const IOobject& io :
|
||||||
|
(
|
||||||
|
selectedFields.empty()
|
||||||
|
? objects.csorted<fieldType>()
|
||||||
|
: objects.csorted<fieldType>(selectedFields)
|
||||||
|
)
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if ("cellDist" == fieldName)
|
if ("cellDist" == io.name())
|
||||||
{
|
{
|
||||||
|
// Ignore cellDist (internal or volume) field
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (verbose_)
|
if (verbose_)
|
||||||
@ -492,13 +493,13 @@ Foam::label Foam::parFvFieldDistributor::distributeVolumeFields
|
|||||||
Info<< " Reconstructing "
|
Info<< " Reconstructing "
|
||||||
<< fieldType::typeName << "s\n" << nl;
|
<< fieldType::typeName << "s\n" << nl;
|
||||||
}
|
}
|
||||||
Info<< " " << fieldName << nl;
|
Info<< " " << io.name() << nl;
|
||||||
}
|
}
|
||||||
++nFields;
|
++nFields;
|
||||||
|
|
||||||
tmp<fieldType> tfld
|
tmp<fieldType> tfld
|
||||||
(
|
(
|
||||||
distributeVolumeField<Type>(*(objects[fieldName]))
|
distributeVolumeField<Type>(io)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (isWriteProc_.good())
|
if (isWriteProc_.good())
|
||||||
@ -534,16 +535,16 @@ Foam::label Foam::parFvFieldDistributor::distributeSurfaceFields
|
|||||||
{
|
{
|
||||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> fieldType;
|
typedef GeometricField<Type, fvsPatchField, surfaceMesh> fieldType;
|
||||||
|
|
||||||
// Available fields, sorted order
|
|
||||||
const wordList fieldNames =
|
|
||||||
(
|
|
||||||
selectedFields.empty()
|
|
||||||
? objects.sortedNames<fieldType>()
|
|
||||||
: objects.sortedNames<fieldType>(selectedFields)
|
|
||||||
);
|
|
||||||
|
|
||||||
label nFields = 0;
|
label nFields = 0;
|
||||||
for (const word& fieldName : fieldNames)
|
for
|
||||||
|
(
|
||||||
|
const IOobject& io :
|
||||||
|
(
|
||||||
|
selectedFields.empty()
|
||||||
|
? objects.csorted<fieldType>()
|
||||||
|
: objects.csorted<fieldType>(selectedFields)
|
||||||
|
)
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (verbose_)
|
if (verbose_)
|
||||||
{
|
{
|
||||||
@ -552,13 +553,13 @@ Foam::label Foam::parFvFieldDistributor::distributeSurfaceFields
|
|||||||
Info<< " Reconstructing "
|
Info<< " Reconstructing "
|
||||||
<< fieldType::typeName << "s\n" << nl;
|
<< fieldType::typeName << "s\n" << nl;
|
||||||
}
|
}
|
||||||
Info<< " " << fieldName << nl;
|
Info<< " " << io.name() << nl;
|
||||||
}
|
}
|
||||||
++nFields;
|
++nFields;
|
||||||
|
|
||||||
tmp<fieldType> tfld
|
tmp<fieldType> tfld
|
||||||
(
|
(
|
||||||
distributeSurfaceField<Type>(*(objects[fieldName]))
|
distributeSurfaceField<Type>(io)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (isWriteProc_.good())
|
if (isWriteProc_.good())
|
||||||
|
|||||||
@ -82,7 +82,7 @@ void Foam::parLagrangianDistributor::findClouds
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
cloudNames.setSize(localCloudDirs.size());
|
cloudNames.resize_nocopy(localCloudDirs.size());
|
||||||
forAll(localCloudDirs, i)
|
forAll(localCloudDirs, i)
|
||||||
{
|
{
|
||||||
cloudNames[i] = localCloudDirs[i];
|
cloudNames[i] = localCloudDirs[i];
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2015 OpenFOAM Foundation
|
Copyright (C) 2015 OpenFOAM Foundation
|
||||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
Copyright (C) 2018-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -324,18 +324,11 @@ Foam::label Foam::parLagrangianDistributor::distributeStoredFields
|
|||||||
passivePositionParticleCloud& cloud
|
passivePositionParticleCloud& cloud
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
HashTable<Container*> fields
|
|
||||||
(
|
|
||||||
cloud.lookupClass<Container>()
|
|
||||||
);
|
|
||||||
|
|
||||||
bool reconstruct = false;
|
bool reconstruct = false;
|
||||||
|
|
||||||
label nFields = 0;
|
label nFields = 0;
|
||||||
forAllIters(fields, iter)
|
|
||||||
{
|
|
||||||
Container& field = *(iter.val());
|
|
||||||
|
|
||||||
|
for (Container& field : cloud.sorted<Container>())
|
||||||
|
{
|
||||||
if (!nFields)
|
if (!nFields)
|
||||||
{
|
{
|
||||||
// Performing an all-to-one (reconstruct)?
|
// Performing an all-to-one (reconstruct)?
|
||||||
|
|||||||
@ -185,11 +185,11 @@ Foam::label Foam::parPointFieldDistributor::distributePointFields
|
|||||||
{
|
{
|
||||||
typedef GeometricField<Type, pointPatchField, pointMesh> fieldType;
|
typedef GeometricField<Type, pointPatchField, pointMesh> fieldType;
|
||||||
|
|
||||||
UPtrList<const IOobject> fieldObjects
|
const UPtrList<const IOobject> fieldObjects
|
||||||
(
|
(
|
||||||
selectedFields.empty()
|
selectedFields.empty()
|
||||||
? objects.sorted<fieldType>()
|
? objects.csorted<fieldType>()
|
||||||
: objects.sorted<fieldType>(selectedFields)
|
: objects.csorted<fieldType>(selectedFields)
|
||||||
);
|
);
|
||||||
|
|
||||||
label nFields = 0;
|
label nFields = 0;
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
Copyright (C) 2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -105,8 +106,9 @@ int main(int argc, char *argv[])
|
|||||||
"foamDataToFluentDict",
|
"foamDataToFluentDict",
|
||||||
runTime.system(),
|
runTime.system(),
|
||||||
mesh,
|
mesh,
|
||||||
IOobject::MUST_READ_IF_MODIFIED,
|
IOobjectOption::MUST_READ,
|
||||||
IOobject::NO_WRITE
|
IOobjectOption::NO_WRITE,
|
||||||
|
IOobjectOption::NO_REGISTER
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -115,44 +117,21 @@ int main(int argc, char *argv[])
|
|||||||
IOobjectList objects(mesh, runTime.timeName());
|
IOobjectList objects(mesh, runTime.timeName());
|
||||||
|
|
||||||
|
|
||||||
// volScalarField
|
readFieldsAndWriteFluent<volScalarField>
|
||||||
for (const word& fieldName : objects.sortedNames<volScalarField>())
|
(
|
||||||
{
|
foamDataToFluentDict,
|
||||||
// Lookup field from dictionary and convert field
|
objects,
|
||||||
label unitNumber;
|
mesh,
|
||||||
if
|
fluentDataFile
|
||||||
(
|
);
|
||||||
foamDataToFluentDict.readIfPresent(fieldName, unitNumber)
|
|
||||||
&& unitNumber > 0
|
|
||||||
)
|
|
||||||
{
|
|
||||||
// Read field
|
|
||||||
volScalarField field(*(objects[fieldName]), mesh);
|
|
||||||
|
|
||||||
Info<< " Converting field " << fieldName << nl;
|
readFieldsAndWriteFluent<volVectorField>
|
||||||
writeFluentField(field, unitNumber, fluentDataFile);
|
(
|
||||||
}
|
foamDataToFluentDict,
|
||||||
}
|
objects,
|
||||||
|
mesh,
|
||||||
|
fluentDataFile
|
||||||
// volVectorField
|
);
|
||||||
for (const word& fieldName : objects.sortedNames<volVectorField>())
|
|
||||||
{
|
|
||||||
// Lookup field from dictionary and convert field
|
|
||||||
label unitNumber;
|
|
||||||
if
|
|
||||||
(
|
|
||||||
foamDataToFluentDict.readIfPresent(fieldName, unitNumber)
|
|
||||||
&& unitNumber > 0
|
|
||||||
)
|
|
||||||
{
|
|
||||||
// Read field
|
|
||||||
volVectorField field(*(objects[fieldName]), mesh);
|
|
||||||
|
|
||||||
Info<< " Converting field " << fieldName << nl;
|
|
||||||
writeFluentField(field, unitNumber, fluentDataFile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Info<< endl;
|
Info<< endl;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,10 +28,12 @@ InClass
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef writeFluentFields_H
|
#ifndef Foam_writeFluentFields_H
|
||||||
#define writeFluentFields_H
|
#define Foam_writeFluentFields_H
|
||||||
|
|
||||||
#include "volFields.H"
|
#include "volFields.H"
|
||||||
|
#include "dictionary.H"
|
||||||
|
#include "IOobjectList.H"
|
||||||
#include "Ostream.H"
|
#include "Ostream.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -43,16 +45,48 @@ void writeFluentField
|
|||||||
(
|
(
|
||||||
const volScalarField& phi,
|
const volScalarField& phi,
|
||||||
const label fluentFieldIdentifier,
|
const label fluentFieldIdentifier,
|
||||||
Ostream& stream
|
Ostream& os
|
||||||
);
|
);
|
||||||
|
|
||||||
void writeFluentField
|
void writeFluentField
|
||||||
(
|
(
|
||||||
const volVectorField& phi,
|
const volVectorField& phi,
|
||||||
const label fluentFieldIdentifier,
|
const label fluentFieldIdentifier,
|
||||||
Ostream& stream
|
Ostream& os
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
template<class GeoField>
|
||||||
|
void readFieldsAndWriteFluent
|
||||||
|
(
|
||||||
|
const dictionary& dict,
|
||||||
|
const IOobjectList& objects,
|
||||||
|
const fvMesh& mesh,
|
||||||
|
Ostream& os
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (const IOobject& io : objects.csorted<GeoField>())
|
||||||
|
{
|
||||||
|
// Lookup field from dictionary and convert field
|
||||||
|
const word& fieldName = io.name();
|
||||||
|
label unitNumber;
|
||||||
|
if
|
||||||
|
(
|
||||||
|
dict.readIfPresent(fieldName, unitNumber)
|
||||||
|
&& unitNumber > 0
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// Read field
|
||||||
|
GeoField field(io, mesh);
|
||||||
|
|
||||||
|
Info<< " Converting field " << fieldName << nl;
|
||||||
|
writeFluentField(field, unitNumber, os);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
} // End namespace Foam
|
} // End namespace Foam
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
Copyright (C) 2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -35,12 +36,7 @@ Description
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
void Foam::writeFluentField
|
||||||
{
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
void writeFluentField
|
|
||||||
(
|
(
|
||||||
const volScalarField& phi,
|
const volScalarField& phi,
|
||||||
const label fluentFieldIdentifier,
|
const label fluentFieldIdentifier,
|
||||||
@ -58,15 +54,15 @@ void writeFluentField
|
|||||||
<< "1 " // Number of components (scalar=1, vector=3)
|
<< "1 " // Number of components (scalar=1, vector=3)
|
||||||
<< "0 0 " // Unused
|
<< "0 0 " // Unused
|
||||||
<< "1 " << phiInternal.size() // Start and end of list
|
<< "1 " << phiInternal.size() // Start and end of list
|
||||||
<< ")(" << endl;
|
<< ")(" << nl;
|
||||||
|
|
||||||
forAll(phiInternal, celli)
|
for (const scalar val : phiInternal)
|
||||||
{
|
{
|
||||||
stream << phiInternal[celli] << endl;
|
stream << val << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
stream
|
stream
|
||||||
<< "))" << endl;
|
<< "))" << nl;
|
||||||
|
|
||||||
label nWrittenFaces = phiInternal.size();
|
label nWrittenFaces = phiInternal.size();
|
||||||
|
|
||||||
@ -92,13 +88,13 @@ void writeFluentField
|
|||||||
<< "0 0 " // Unused
|
<< "0 0 " // Unused
|
||||||
<< nWrittenFaces + 1 << " "
|
<< nWrittenFaces + 1 << " "
|
||||||
<< nWrittenFaces + emptyFaceCells.size()// Start and end of list
|
<< nWrittenFaces + emptyFaceCells.size()// Start and end of list
|
||||||
<< ")(" << endl;
|
<< ")(" << nl;
|
||||||
|
|
||||||
nWrittenFaces += emptyFaceCells.size();
|
nWrittenFaces += emptyFaceCells.size();
|
||||||
|
|
||||||
forAll(emptyFaceCells, facei)
|
forAll(emptyFaceCells, facei)
|
||||||
{
|
{
|
||||||
stream << phiInternal[emptyFaceCells[facei]] << endl;
|
stream << phiInternal[emptyFaceCells[facei]] << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
stream
|
stream
|
||||||
@ -120,13 +116,13 @@ void writeFluentField
|
|||||||
<< "0 0 " // Unused
|
<< "0 0 " // Unused
|
||||||
<< nWrittenFaces + 1 << " " << nWrittenFaces + patchPhi.size()
|
<< nWrittenFaces + 1 << " " << nWrittenFaces + patchPhi.size()
|
||||||
// Start and end of list
|
// Start and end of list
|
||||||
<< ")(" << endl;
|
<< ")(" << nl;
|
||||||
|
|
||||||
nWrittenFaces += patchPhi.size();
|
nWrittenFaces += patchPhi.size();
|
||||||
|
|
||||||
forAll(patchPhi, facei)
|
for (const scalar val : patchPhi)
|
||||||
{
|
{
|
||||||
stream << patchPhi[facei] << endl;
|
stream << val << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
stream
|
stream
|
||||||
@ -136,8 +132,4 @@ void writeFluentField
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
Copyright (C) 2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -34,12 +35,7 @@ Description
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
void Foam::writeFluentField
|
||||||
{
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
void writeFluentField
|
|
||||||
(
|
(
|
||||||
const volVectorField& phi,
|
const volVectorField& phi,
|
||||||
const label fluentFieldIdentifier,
|
const label fluentFieldIdentifier,
|
||||||
@ -57,19 +53,16 @@ void writeFluentField
|
|||||||
<< "3 " // Number of components (scalar=1, vector=3)
|
<< "3 " // Number of components (scalar=1, vector=3)
|
||||||
<< "0 0 " // Unused
|
<< "0 0 " // Unused
|
||||||
<< "1 " << phiInternal.size() // Start and end of list
|
<< "1 " << phiInternal.size() // Start and end of list
|
||||||
<< ")(" << endl;
|
<< ")(" << nl;
|
||||||
|
|
||||||
forAll(phiInternal, celli)
|
for (const vector& val : phiInternal)
|
||||||
{
|
{
|
||||||
stream
|
stream
|
||||||
<< phiInternal[celli].x() << " "
|
<< val.x() << ' ' << val.y() << ' ' << val.z() << nl;
|
||||||
<< phiInternal[celli].y() << " "
|
|
||||||
<< phiInternal[celli].z() << " "
|
|
||||||
<< endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stream
|
stream
|
||||||
<< "))" << endl;
|
<< "))" << nl;
|
||||||
|
|
||||||
label nWrittenFaces = phiInternal.size();
|
label nWrittenFaces = phiInternal.size();
|
||||||
|
|
||||||
@ -87,17 +80,14 @@ void writeFluentField
|
|||||||
<< "0 0 " // Unused
|
<< "0 0 " // Unused
|
||||||
<< nWrittenFaces + 1 << " " << nWrittenFaces + patchPhi.size()
|
<< nWrittenFaces + 1 << " " << nWrittenFaces + patchPhi.size()
|
||||||
// Start and end of list
|
// Start and end of list
|
||||||
<< ")(" << endl;
|
<< ")(" << nl;
|
||||||
|
|
||||||
nWrittenFaces += patchPhi.size();
|
nWrittenFaces += patchPhi.size();
|
||||||
|
|
||||||
forAll(patchPhi, facei)
|
for (const vector& val : patchPhi)
|
||||||
{
|
{
|
||||||
stream
|
stream
|
||||||
<< patchPhi[facei].x() << " "
|
<< val.x() << ' ' << val.y() << ' ' << val.z() << nl;
|
||||||
<< patchPhi[facei].y() << " "
|
|
||||||
<< patchPhi[facei].z() << " "
|
|
||||||
<< endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stream
|
stream
|
||||||
@ -106,6 +96,4 @@ void writeFluentField
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2021-2022 OpenCFD Ltd.
|
Copyright (C) 2021-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||||
@ -28,9 +28,9 @@ forAll(meshes, regioni)
|
|||||||
|
|
||||||
IOobjectList objects(0);
|
IOobjectList objects(0);
|
||||||
|
|
||||||
if (doConvertFields)
|
if (doConvertFields && !timeDirs.empty())
|
||||||
{
|
{
|
||||||
objects = IOobjectList(mesh, timeDirs.last().name());
|
objects = IOobjectList(mesh, timeDirs.back().name());
|
||||||
|
|
||||||
if (fieldSelector && !fieldSelector().empty())
|
if (fieldSelector && !fieldSelector().empty())
|
||||||
{
|
{
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
Copyright (C) 2018-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -35,18 +35,30 @@ SourceFiles
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef readFields_H
|
#ifndef ensight_readFields_H
|
||||||
#define readFields_H
|
#define ensight_readFields_H
|
||||||
|
|
||||||
#include "instantList.H"
|
#include "instantList.H"
|
||||||
#include "IOobjectList.H"
|
#include "IOobjectList.H"
|
||||||
#include "zeroGradientFvPatchFields.H"
|
#include "fvPatchField.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
|
//- Get the field or FatalError
|
||||||
|
template<class GeoField>
|
||||||
|
tmp<GeoField> getField
|
||||||
|
(
|
||||||
|
const IOobject& io,
|
||||||
|
const typename GeoField::Mesh& mesh
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return tmp<GeoField>::New(io, mesh);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//- Get the field or return nullptr
|
//- Get the field or return nullptr
|
||||||
template<class GeoField>
|
template<class GeoField>
|
||||||
tmp<GeoField> getField
|
tmp<GeoField> getField
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2021-2022 OpenCFD Ltd.
|
Copyright (C) 2021-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||||
@ -72,7 +72,7 @@ label writeAreaFields
|
|||||||
|
|
||||||
label count = 0;
|
label count = 0;
|
||||||
|
|
||||||
for (const word& fieldName : objects.sortedNames<FieldType>())
|
for (const IOobject& io : objects.csorted<FieldType>())
|
||||||
{
|
{
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
@ -80,11 +80,11 @@ label writeAreaFields
|
|||||||
(
|
(
|
||||||
ensCase,
|
ensCase,
|
||||||
ensMesh,
|
ensMesh,
|
||||||
getField<FieldType>(objects.findObject(fieldName), mesh)
|
getField<FieldType>(io, mesh)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
Info<< ' ' << fieldName;
|
Info<< ' ' << io.name();
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
Copyright (C) 2018-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||||
@ -69,7 +69,7 @@ label writeDimFields
|
|||||||
|
|
||||||
label count = 0;
|
label count = 0;
|
||||||
|
|
||||||
for (const word& fieldName : objects.sortedNames<FieldType>())
|
for (const IOobject& io : objects.csorted<FieldType>())
|
||||||
{
|
{
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
@ -77,11 +77,11 @@ label writeDimFields
|
|||||||
(
|
(
|
||||||
ensCase,
|
ensCase,
|
||||||
ensMesh,
|
ensMesh,
|
||||||
getField<FieldType>(objects.findObject(fieldName), mesh)
|
getField<FieldType>(io, mesh)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
Info<< ' ' << fieldName;
|
Info<< ' ' << io.name();
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2020-2022 OpenCFD Ltd.
|
Copyright (C) 2020-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||||
@ -70,11 +70,11 @@ label writePointFields
|
|||||||
{
|
{
|
||||||
typedef PointField<Type> FieldType;
|
typedef PointField<Type> FieldType;
|
||||||
|
|
||||||
const pointMesh& ptMesh = pointMesh::New(ensMesh.mesh());
|
const pointMesh& pMesh = pointMesh::New(ensMesh.mesh());
|
||||||
|
|
||||||
label count = 0;
|
label count = 0;
|
||||||
|
|
||||||
for (const word& fieldName : objects.sortedNames<FieldType>())
|
for (const IOobject& io : objects.csorted<FieldType>())
|
||||||
{
|
{
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
@ -82,11 +82,11 @@ label writePointFields
|
|||||||
(
|
(
|
||||||
ensCase,
|
ensCase,
|
||||||
ensMesh,
|
ensMesh,
|
||||||
getField<FieldType>(ptMesh, objects, fieldName)
|
getField<FieldType>(io, pMesh)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
Info<< ' ' << fieldName;
|
Info<< ' ' << io.name();
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
Copyright (C) 2018-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||||
@ -92,7 +92,7 @@ label writeVolFields
|
|||||||
|
|
||||||
label count = 0;
|
label count = 0;
|
||||||
|
|
||||||
for (const word& fieldName : objects.sortedNames<FieldType>())
|
for (const IOobject& io : objects.csorted<FieldType>())
|
||||||
{
|
{
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
@ -100,12 +100,12 @@ label writeVolFields
|
|||||||
(
|
(
|
||||||
ensCase,
|
ensCase,
|
||||||
ensMesh,
|
ensMesh,
|
||||||
getField<FieldType>(objects.findObject(fieldName), mesh),
|
getField<FieldType>(io, mesh),
|
||||||
nearCellValue
|
nearCellValue
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
Info<< ' ' << fieldName;
|
Info<< ' ' << io.name();
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
Copyright (C) 2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -58,18 +59,21 @@ void ReadAndMapFields
|
|||||||
{
|
{
|
||||||
typedef typename MappedGeoField::value_type Type;
|
typedef typename MappedGeoField::value_type Type;
|
||||||
|
|
||||||
// Search list of objects for wanted type
|
// Objects of wanted type
|
||||||
IOobjectList fieldObjects(objects.lookupClass(ReadGeoField::typeName));
|
const UPtrList<const IOobject> fieldObjects
|
||||||
|
(
|
||||||
|
objects.csorted<ReadGeoField>()
|
||||||
|
);
|
||||||
|
|
||||||
tetFields.setSize(fieldObjects.size());
|
tetFields.resize(fieldObjects.size());
|
||||||
|
|
||||||
label i = 0;
|
label i = 0;
|
||||||
forAllConstIters(fieldObjects, iter)
|
for (const IOobject& io : fieldObjects)
|
||||||
{
|
{
|
||||||
Info<< "Converting " << ReadGeoField::typeName << ' ' << iter.key()
|
Info<< "Converting "
|
||||||
<< endl;
|
<< ReadGeoField::typeName << ' ' << io.name() << endl;
|
||||||
|
|
||||||
ReadGeoField readField(*iter(), mesh);
|
ReadGeoField readField(io, mesh);
|
||||||
|
|
||||||
tetFields.set
|
tetFields.set
|
||||||
(
|
(
|
||||||
@ -82,8 +86,8 @@ void ReadAndMapFields
|
|||||||
readField.instance(),
|
readField.instance(),
|
||||||
readField.local(),
|
readField.local(),
|
||||||
tetDualMesh,
|
tetDualMesh,
|
||||||
IOobject::NO_READ,
|
IOobjectOption::NO_READ,
|
||||||
IOobject::AUTO_WRITE,
|
IOobjectOption::AUTO_WRITE,
|
||||||
readField.registerObject()
|
readField.registerObject()
|
||||||
),
|
),
|
||||||
pointMesh::New(tetDualMesh),
|
pointMesh::New(tetDualMesh),
|
||||||
|
|||||||
@ -79,8 +79,8 @@ Foam::tmp<GeoField> Foam::getField
|
|||||||
{
|
{
|
||||||
// Move field to the cache
|
// Move field to the cache
|
||||||
IOobject newIO(tfield(), *cache);
|
IOobject newIO(tfield(), *cache);
|
||||||
newIO.readOpt(IOobject::NO_READ);
|
newIO.readOpt(IOobjectOption::NO_READ);
|
||||||
newIO.writeOpt(IOobject::NO_WRITE);
|
newIO.writeOpt(IOobjectOption::NO_WRITE);
|
||||||
|
|
||||||
tfield.ref().checkOut(); // Paranoid
|
tfield.ref().checkOut(); // Paranoid
|
||||||
cache->store(new GeoField(newIO, tfield));
|
cache->store(new GeoField(newIO, tfield));
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
Copyright (C) 2016-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -108,24 +108,12 @@ void Foam::processFields
|
|||||||
const IOobjectList& cloudObjects
|
const IOobjectList& cloudObjects
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
for (const word& fldName : cloudObjects.sortedNames<IOField<Type>>())
|
for (const IOobject& io : cloudObjects.csorted<IOField<Type>>())
|
||||||
{
|
{
|
||||||
const IOobject* io = cloudObjects.cfindObject<IOField<Type>>(fldName);
|
Info<< " reading field " << io.name() << endl;
|
||||||
|
IOField<Type> field(io);
|
||||||
|
|
||||||
if (!io)
|
writeVTKField<Type>(os, field, addr);
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Could not read field:" << fldName
|
|
||||||
<< " type:" << IOField<Type>::typeName
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Info<< " reading field " << fldName << endl;
|
|
||||||
IOField<Type> field(*io);
|
|
||||||
|
|
||||||
writeVTKField<Type>(os, field, addr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2015 OpenFOAM Foundation
|
Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
Copyright (C) 2018-2020 OpenCFD Ltd.
|
Copyright (C) 2018-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -97,22 +97,24 @@ public:
|
|||||||
template<class GeoFieldType>
|
template<class GeoFieldType>
|
||||||
void fieldInterpolator::interpolate()
|
void fieldInterpolator::interpolate()
|
||||||
{
|
{
|
||||||
const word& clsName = GeoFieldType::typeName;
|
label nFields = 0;
|
||||||
|
for
|
||||||
const wordList fieldNames =
|
|
||||||
(
|
(
|
||||||
selectedFields_.empty()
|
const IOobject& io :
|
||||||
? objects_.sortedNames(clsName)
|
(
|
||||||
: objects_.sortedNames(clsName, selectedFields_)
|
selectedFields_.empty()
|
||||||
);
|
? objects_.csorted<GeoFieldType>()
|
||||||
|
: objects_.csorted<GeoFieldType>(selectedFields_)
|
||||||
if (fieldNames.size())
|
)
|
||||||
|
)
|
||||||
{
|
{
|
||||||
Info<< " " << clsName << 's';
|
const word& fieldName = io.name();
|
||||||
}
|
|
||||||
|
if (!nFields)
|
||||||
|
{
|
||||||
|
Info<< " " << GeoFieldType::typeName << 's';
|
||||||
|
}
|
||||||
|
|
||||||
for (const word& fieldName : fieldNames)
|
|
||||||
{
|
|
||||||
Info<< ' ' << fieldName << '(';
|
Info<< ' ' << fieldName << '(';
|
||||||
|
|
||||||
const scalar deltaT = (ti1_.value() - ti_.value())/(divisions_ + 1);
|
const scalar deltaT = (ti1_.value() - ti_.value())/(divisions_ + 1);
|
||||||
@ -166,7 +168,7 @@ void fieldInterpolator::interpolate()
|
|||||||
(
|
(
|
||||||
fieldName,
|
fieldName,
|
||||||
runTime_.timeName(),
|
runTime_.timeName(),
|
||||||
objects_[fieldName]->db(),
|
io.db(),
|
||||||
IOobject::NO_READ,
|
IOobject::NO_READ,
|
||||||
IOobject::NO_WRITE,
|
IOobject::NO_WRITE,
|
||||||
IOobject::NO_REGISTER
|
IOobject::NO_REGISTER
|
||||||
@ -181,9 +183,10 @@ void fieldInterpolator::interpolate()
|
|||||||
}
|
}
|
||||||
|
|
||||||
Info<< ')';
|
Info<< ')';
|
||||||
|
++nFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fieldNames.size()) Info<< endl;
|
if (nFields) Info<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2016 OpenFOAM Foundation
|
Copyright (C) 2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
Copyright (C) 2018-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -49,35 +49,41 @@ using namespace Foam;
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#define ReadFields(GeoFieldType) \
|
|
||||||
readFields<GeoFieldType>(mesh, objects, selectedFields, storedObjects);
|
|
||||||
|
|
||||||
#define ReadPointFields(GeoFieldType) \
|
|
||||||
readFields<GeoFieldType>(pMesh, objects, selectedFields, storedObjects);
|
|
||||||
|
|
||||||
#define ReadUniformFields(FieldType) \
|
|
||||||
readUniformFields<FieldType> \
|
|
||||||
(constantObjects, selectedFields, storedObjects);
|
|
||||||
|
|
||||||
void executeFunctionObjects
|
void executeFunctionObjects
|
||||||
(
|
(
|
||||||
const argList& args,
|
const argList& args,
|
||||||
const Time& runTime,
|
const Time& runTime,
|
||||||
fvMesh& mesh,
|
fvMesh& mesh,
|
||||||
const wordHashSet& selectedFields,
|
const wordList& selectedFields,
|
||||||
functionObjectList& functions,
|
functionObjectList& functions,
|
||||||
bool lastTime
|
bool lastTime
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
Info<< nl << "Reading fields:" << endl;
|
Info<< nl << "Reading fields:" << endl;
|
||||||
|
|
||||||
// Maintain a stack of the stored objects to clear after executing
|
// Read objects in constant directory
|
||||||
// the functionObjects
|
IOobjectList constObjects(mesh, runTime.constant());
|
||||||
LIFOStack<regIOobject*> storedObjects;
|
|
||||||
|
|
||||||
// Read objects in time directory
|
// Read objects in time directory
|
||||||
IOobjectList objects(mesh, runTime.timeName());
|
IOobjectList objects(mesh, runTime.timeName());
|
||||||
|
|
||||||
|
// List of stored objects to clear after executing functionObjects
|
||||||
|
DynamicList<regIOobject*> storedObjects
|
||||||
|
(
|
||||||
|
objects.size() + constObjects.size()
|
||||||
|
);
|
||||||
|
|
||||||
|
const auto nameMatcher = [&](const word& name) -> bool
|
||||||
|
{
|
||||||
|
return selectedFields.contains(name);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Read GeometricFields
|
||||||
|
|
||||||
|
#undef ReadFields
|
||||||
|
#define ReadFields(FieldType) \
|
||||||
|
readFields<FieldType>(mesh, objects, nameMatcher, storedObjects);
|
||||||
|
|
||||||
// Read volFields
|
// Read volFields
|
||||||
ReadFields(volScalarField);
|
ReadFields(volScalarField);
|
||||||
ReadFields(volVectorField);
|
ReadFields(volVectorField);
|
||||||
@ -99,8 +105,12 @@ void executeFunctionObjects
|
|||||||
ReadFields(surfaceSymmTensorField);
|
ReadFields(surfaceSymmTensorField);
|
||||||
ReadFields(surfaceTensorField);
|
ReadFields(surfaceTensorField);
|
||||||
|
|
||||||
|
|
||||||
// Read point fields.
|
// Read point fields.
|
||||||
const pointMesh& pMesh = pointMesh::New(mesh);
|
const pointMesh& pMesh = pointMesh::New(mesh);
|
||||||
|
#undef ReadPointFields
|
||||||
|
#define ReadPointFields(FieldType) \
|
||||||
|
readFields<FieldType>(pMesh, objects, nameMatcher, storedObjects);
|
||||||
|
|
||||||
ReadPointFields(pointScalarField)
|
ReadPointFields(pointScalarField)
|
||||||
ReadPointFields(pointVectorField);
|
ReadPointFields(pointVectorField);
|
||||||
@ -108,8 +118,12 @@ void executeFunctionObjects
|
|||||||
ReadPointFields(pointSymmTensorField);
|
ReadPointFields(pointSymmTensorField);
|
||||||
ReadPointFields(pointTensorField);
|
ReadPointFields(pointTensorField);
|
||||||
|
|
||||||
|
|
||||||
// Read uniform dimensioned fields
|
// Read uniform dimensioned fields
|
||||||
IOobjectList constantObjects(mesh, runTime.constant());
|
|
||||||
|
#undef ReadUniformFields
|
||||||
|
#define ReadUniformFields(FieldType) \
|
||||||
|
readUniformFields<FieldType>(constObjects, nameMatcher, storedObjects);
|
||||||
|
|
||||||
ReadUniformFields(uniformDimensionedScalarField);
|
ReadUniformFields(uniformDimensionedScalarField);
|
||||||
ReadUniformFields(uniformDimensionedVectorField);
|
ReadUniformFields(uniformDimensionedVectorField);
|
||||||
@ -130,7 +144,8 @@ void executeFunctionObjects
|
|||||||
|
|
||||||
while (!storedObjects.empty())
|
while (!storedObjects.empty())
|
||||||
{
|
{
|
||||||
storedObjects.pop()->checkOut();
|
storedObjects.back()->checkOut();
|
||||||
|
storedObjects.pop_back();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -285,7 +285,7 @@ void rewriteField
|
|||||||
fieldName,
|
fieldName,
|
||||||
runTime.timeName(),
|
runTime.timeName(),
|
||||||
runTime,
|
runTime,
|
||||||
IOobject::MUST_READ_IF_MODIFIED,
|
IOobject::MUST_READ,
|
||||||
IOobject::NO_WRITE,
|
IOobject::NO_WRITE,
|
||||||
IOobject::NO_REGISTER
|
IOobject::NO_REGISTER
|
||||||
)
|
)
|
||||||
@ -369,29 +369,7 @@ void rewriteField
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void rewriteFields
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
(
|
|
||||||
const bool dryrun,
|
|
||||||
const Time& runTime,
|
|
||||||
const wordList& fieldNames,
|
|
||||||
const HashTable<word>& thisNames,
|
|
||||||
const HashTable<word>& nbrNames
|
|
||||||
)
|
|
||||||
{
|
|
||||||
for (const word& fieldName : fieldNames)
|
|
||||||
{
|
|
||||||
rewriteField
|
|
||||||
(
|
|
||||||
dryrun,
|
|
||||||
runTime,
|
|
||||||
fieldName,
|
|
||||||
thisNames,
|
|
||||||
nbrNames
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@ -473,9 +451,9 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
// Convert any fields
|
// Convert any fields
|
||||||
|
|
||||||
forAll(timeDirs, timeI)
|
forAll(timeDirs, timei)
|
||||||
{
|
{
|
||||||
runTime.setTime(timeDirs[timeI], timeI);
|
runTime.setTime(timeDirs[timei], timei);
|
||||||
|
|
||||||
Info<< "Time: " << runTime.timeName() << endl;
|
Info<< "Time: " << runTime.timeName() << endl;
|
||||||
|
|
||||||
@ -514,139 +492,44 @@ int main(int argc, char *argv[])
|
|||||||
entry::disableFunctionEntries = 1;
|
entry::disableFunctionEntries = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Rewriting of fields:
|
||||||
|
|
||||||
|
#undef rewriteFields
|
||||||
|
#define rewriteFields(FieldType) \
|
||||||
|
for (const word& fieldName : objects.sortedNames<FieldType>()) \
|
||||||
|
{ \
|
||||||
|
rewriteField(dryrun, runTime, fieldName, thisNames, nbrNames); \
|
||||||
|
}
|
||||||
|
|
||||||
// volFields
|
// volFields
|
||||||
// ~~~~~~~~~
|
// ~~~~~~~~~
|
||||||
|
|
||||||
rewriteFields
|
rewriteFields(volScalarField);
|
||||||
(
|
rewriteFields(volVectorField);
|
||||||
dryrun,
|
rewriteFields(volSphericalTensorField);
|
||||||
runTime,
|
rewriteFields(volSymmTensorField);
|
||||||
objects.names(volScalarField::typeName),
|
rewriteFields(volTensorField);
|
||||||
thisNames,
|
|
||||||
nbrNames
|
|
||||||
);
|
|
||||||
rewriteFields
|
|
||||||
(
|
|
||||||
dryrun,
|
|
||||||
runTime,
|
|
||||||
objects.names(volVectorField::typeName),
|
|
||||||
thisNames,
|
|
||||||
nbrNames
|
|
||||||
);
|
|
||||||
rewriteFields
|
|
||||||
(
|
|
||||||
dryrun,
|
|
||||||
runTime,
|
|
||||||
objects.names(volSphericalTensorField::typeName),
|
|
||||||
thisNames,
|
|
||||||
nbrNames
|
|
||||||
);
|
|
||||||
rewriteFields
|
|
||||||
(
|
|
||||||
dryrun,
|
|
||||||
runTime,
|
|
||||||
objects.names(volSymmTensorField::typeName),
|
|
||||||
thisNames,
|
|
||||||
nbrNames
|
|
||||||
);
|
|
||||||
rewriteFields
|
|
||||||
(
|
|
||||||
dryrun,
|
|
||||||
runTime,
|
|
||||||
objects.names(volTensorField::typeName),
|
|
||||||
thisNames,
|
|
||||||
nbrNames
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
// pointFields
|
// pointFields
|
||||||
// ~~~~~~~~~~~
|
// ~~~~~~~~~~~
|
||||||
|
|
||||||
rewriteFields
|
rewriteFields(pointScalarField);
|
||||||
(
|
rewriteFields(pointVectorField);
|
||||||
dryrun,
|
rewriteFields(pointSphericalTensorField);
|
||||||
runTime,
|
rewriteFields(pointSymmTensorField);
|
||||||
objects.names(pointScalarField::typeName),
|
rewriteFields(pointTensorField);
|
||||||
thisNames,
|
|
||||||
nbrNames
|
|
||||||
);
|
|
||||||
rewriteFields
|
|
||||||
(
|
|
||||||
dryrun,
|
|
||||||
runTime,
|
|
||||||
objects.names(pointVectorField::typeName),
|
|
||||||
thisNames,
|
|
||||||
nbrNames
|
|
||||||
);
|
|
||||||
rewriteFields
|
|
||||||
(
|
|
||||||
dryrun,
|
|
||||||
runTime,
|
|
||||||
objects.names(pointSphericalTensorField::typeName),
|
|
||||||
thisNames,
|
|
||||||
nbrNames
|
|
||||||
);
|
|
||||||
rewriteFields
|
|
||||||
(
|
|
||||||
dryrun,
|
|
||||||
runTime,
|
|
||||||
objects.names(pointSymmTensorField::typeName),
|
|
||||||
thisNames,
|
|
||||||
nbrNames
|
|
||||||
);
|
|
||||||
rewriteFields
|
|
||||||
(
|
|
||||||
dryrun,
|
|
||||||
runTime,
|
|
||||||
objects.names(pointTensorField::typeName),
|
|
||||||
thisNames,
|
|
||||||
nbrNames
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
// surfaceFields
|
// surfaceFields
|
||||||
// ~~~~~~~~~~~
|
// ~~~~~~~~~~~~~
|
||||||
|
|
||||||
rewriteFields
|
rewriteFields(surfaceScalarField);
|
||||||
(
|
rewriteFields(surfaceVectorField);
|
||||||
dryrun,
|
rewriteFields(surfaceSphericalTensorField);
|
||||||
runTime,
|
rewriteFields(surfaceSymmTensorField);
|
||||||
objects.names(surfaceScalarField::typeName),
|
rewriteFields(surfaceTensorField);
|
||||||
thisNames,
|
|
||||||
nbrNames
|
#undef rewriteFields
|
||||||
);
|
|
||||||
rewriteFields
|
|
||||||
(
|
|
||||||
dryrun,
|
|
||||||
runTime,
|
|
||||||
objects.names(surfaceVectorField::typeName),
|
|
||||||
thisNames,
|
|
||||||
nbrNames
|
|
||||||
);
|
|
||||||
rewriteFields
|
|
||||||
(
|
|
||||||
dryrun,
|
|
||||||
runTime,
|
|
||||||
objects.names(surfaceSphericalTensorField::typeName),
|
|
||||||
thisNames,
|
|
||||||
nbrNames
|
|
||||||
);
|
|
||||||
rewriteFields
|
|
||||||
(
|
|
||||||
dryrun,
|
|
||||||
runTime,
|
|
||||||
objects.names(surfaceSymmTensorField::typeName),
|
|
||||||
thisNames,
|
|
||||||
nbrNames
|
|
||||||
);
|
|
||||||
rewriteFields
|
|
||||||
(
|
|
||||||
dryrun,
|
|
||||||
runTime,
|
|
||||||
objects.names(surfaceTensorField::typeName),
|
|
||||||
thisNames,
|
|
||||||
nbrNames
|
|
||||||
);
|
|
||||||
|
|
||||||
entry::disableFunctionEntries = oldFlag;
|
entry::disableFunctionEntries = oldFlag;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -52,23 +52,20 @@ void MapConsistentVolFields
|
|||||||
const fvMesh& meshSource = meshToMesh0Interp.fromMesh();
|
const fvMesh& meshSource = meshToMesh0Interp.fromMesh();
|
||||||
const fvMesh& meshTarget = meshToMesh0Interp.toMesh();
|
const fvMesh& meshTarget = meshToMesh0Interp.toMesh();
|
||||||
|
|
||||||
IOobjectList fields = objects.lookupClass(fieldType::typeName);
|
for (const IOobject& io : objects.csorted<fieldType>())
|
||||||
|
|
||||||
forAllConstIters(fields, fieldIter)
|
|
||||||
{
|
{
|
||||||
Info<< " interpolating " << (*fieldIter)->name()
|
Info<< " interpolating " << io.name() << endl;
|
||||||
<< endl;
|
|
||||||
|
|
||||||
// Read field. Do not auto-load old-time field
|
// Read field. Do not auto-load old-time field
|
||||||
fieldType fieldSource(*fieldIter(), meshSource, false);
|
fieldType fieldSource(io, meshSource, false);
|
||||||
|
|
||||||
IOobject fieldTargetIOobject
|
IOobject fieldTargetIOobject
|
||||||
(
|
(
|
||||||
(*fieldIter)->name(),
|
io.name(),
|
||||||
meshTarget.time().timeName(),
|
meshTarget.time().timeName(),
|
||||||
meshTarget,
|
meshTarget,
|
||||||
IOobject::MUST_READ,
|
IOobjectOption::MUST_READ,
|
||||||
IOobject::AUTO_WRITE
|
IOobjectOption::AUTO_WRITE
|
||||||
);
|
);
|
||||||
|
|
||||||
if (fieldTargetIOobject.typeHeaderOk<fieldType>(true))
|
if (fieldTargetIOobject.typeHeaderOk<fieldType>(true))
|
||||||
@ -90,7 +87,7 @@ void MapConsistentVolFields
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fieldTargetIOobject.readOpt(IOobject::NO_READ);
|
fieldTargetIOobject.readOpt(IOobjectOption::NO_READ);
|
||||||
|
|
||||||
// Interpolate field
|
// Interpolate field
|
||||||
fieldType fieldTarget
|
fieldType fieldTarget
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2019 OpenCFD Ltd.
|
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -33,8 +33,8 @@ Description
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef MapLagrangianFields_H
|
#ifndef Foam_MapLagrangianFields_H
|
||||||
#define MapLagrangianFields_H
|
#define Foam_MapLagrangianFields_H
|
||||||
|
|
||||||
#include "cloud.H"
|
#include "cloud.H"
|
||||||
#include "GeometricField.H"
|
#include "GeometricField.H"
|
||||||
@ -47,6 +47,59 @@ Description
|
|||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
|
//- Gets the indices of (source)particles that have been appended to the
|
||||||
|
// target cloud and maps the lagrangian fields accordingly.
|
||||||
|
template<class SourceIOFieldType, class TargetIOFieldType>
|
||||||
|
void MapLagrangianFields
|
||||||
|
(
|
||||||
|
const string& cloudName,
|
||||||
|
const IOobjectList& objects,
|
||||||
|
const meshToMesh0& meshToMesh0Interp,
|
||||||
|
const labelList& addParticles,
|
||||||
|
const char* msg
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const fvMesh& meshTarget = meshToMesh0Interp.toMesh();
|
||||||
|
|
||||||
|
for (const IOobject& io : objects.csorted<SourceIOFieldType>())
|
||||||
|
{
|
||||||
|
Info<< " mapping lagrangian " << msg << ' ' << io.name() << endl;
|
||||||
|
|
||||||
|
// Read field (does not need mesh)
|
||||||
|
// Note: some fieldFields are 0 size (e.g. collision records)
|
||||||
|
// if not used, so catch any of those for Field as well
|
||||||
|
|
||||||
|
SourceIOFieldType fieldSource(io);
|
||||||
|
|
||||||
|
// Map
|
||||||
|
TargetIOFieldType fieldTarget
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
io.name(),
|
||||||
|
meshTarget.time().timeName(),
|
||||||
|
cloud::prefix/cloudName,
|
||||||
|
meshTarget,
|
||||||
|
IOobjectOption::NO_READ,
|
||||||
|
IOobjectOption::NO_WRITE,
|
||||||
|
IOobjectOption::NO_REGISTER
|
||||||
|
),
|
||||||
|
min(fieldSource.size(), addParticles.size()) // handle 0 size
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!fieldSource.empty())
|
||||||
|
{
|
||||||
|
forAll(addParticles, i)
|
||||||
|
{
|
||||||
|
fieldTarget[i] = fieldSource[addParticles[i]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fieldTarget.write();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//- Gets the indices of (source)particles that have been appended to the
|
//- Gets the indices of (source)particles that have been appended to the
|
||||||
// target cloud and maps the lagrangian fields accordingly.
|
// target cloud and maps the lagrangian fields accordingly.
|
||||||
template<class Type>
|
template<class Type>
|
||||||
@ -60,119 +113,46 @@ void MapLagrangianFields
|
|||||||
{
|
{
|
||||||
const fvMesh& meshTarget = meshToMesh0Interp.toMesh();
|
const fvMesh& meshTarget = meshToMesh0Interp.toMesh();
|
||||||
|
|
||||||
{
|
MapLagrangianFields
|
||||||
IOobjectList fields = objects.lookupClass(IOField<Type>::typeName);
|
<
|
||||||
|
IOField<Type>,
|
||||||
|
IOField<Type>
|
||||||
|
>
|
||||||
|
(
|
||||||
|
cloudName,
|
||||||
|
objects,
|
||||||
|
meshToMesh0Interp,
|
||||||
|
addParticles,
|
||||||
|
"Field"
|
||||||
|
);
|
||||||
|
|
||||||
forAllConstIters(fields, fieldIter)
|
// Target is CompactIOField to automatically write in
|
||||||
{
|
// compact form for binary format.
|
||||||
Info<< " mapping lagrangian field "
|
MapLagrangianFields
|
||||||
<< (*fieldIter)->name() << endl;
|
<
|
||||||
|
IOField<Field<Type>>,
|
||||||
|
CompactIOField<Field<Type>, Type>
|
||||||
|
>
|
||||||
|
(
|
||||||
|
cloudName,
|
||||||
|
objects,
|
||||||
|
meshToMesh0Interp,
|
||||||
|
addParticles,
|
||||||
|
"FieldField"
|
||||||
|
);
|
||||||
|
|
||||||
// Read field (does not need mesh)
|
MapLagrangianFields
|
||||||
IOField<Type> fieldSource(*fieldIter());
|
<
|
||||||
|
CompactIOField<Field<Type>, Type>,
|
||||||
// Map
|
CompactIOField<Field<Type>, Type>
|
||||||
IOField<Type> fieldTarget
|
>
|
||||||
(
|
(
|
||||||
IOobject
|
cloudName,
|
||||||
(
|
objects,
|
||||||
(*fieldIter)->name(),
|
meshToMesh0Interp,
|
||||||
meshTarget.time().timeName(),
|
addParticles,
|
||||||
cloud::prefix/cloudName,
|
"FieldField"
|
||||||
meshTarget,
|
);
|
||||||
IOobject::NO_READ,
|
|
||||||
IOobject::NO_WRITE,
|
|
||||||
IOobject::NO_REGISTER
|
|
||||||
),
|
|
||||||
addParticles.size()
|
|
||||||
);
|
|
||||||
|
|
||||||
forAll(addParticles, i)
|
|
||||||
{
|
|
||||||
fieldTarget[i] = fieldSource[addParticles[i]];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write field
|
|
||||||
fieldTarget.write();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
IOobjectList fieldFields =
|
|
||||||
objects.lookupClass(IOField<Field<Type>>::typeName);
|
|
||||||
|
|
||||||
forAllConstIters(fieldFields, fieldIter)
|
|
||||||
{
|
|
||||||
Info<< " mapping lagrangian fieldField "
|
|
||||||
<< (*fieldIter)->name() << endl;
|
|
||||||
|
|
||||||
// Read field (does not need mesh)
|
|
||||||
IOField<Field<Type>> fieldSource(*fieldIter());
|
|
||||||
|
|
||||||
// Map - use CompactIOField to automatically write in
|
|
||||||
// compact form for binary format.
|
|
||||||
CompactIOField<Field<Type>, Type> fieldTarget
|
|
||||||
(
|
|
||||||
IOobject
|
|
||||||
(
|
|
||||||
(*fieldIter)->name(),
|
|
||||||
meshTarget.time().timeName(),
|
|
||||||
cloud::prefix/cloudName,
|
|
||||||
meshTarget,
|
|
||||||
IOobject::NO_READ,
|
|
||||||
IOobject::NO_WRITE,
|
|
||||||
IOobject::NO_REGISTER
|
|
||||||
),
|
|
||||||
addParticles.size()
|
|
||||||
);
|
|
||||||
|
|
||||||
forAll(addParticles, i)
|
|
||||||
{
|
|
||||||
fieldTarget[i] = fieldSource[addParticles[i]];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write field
|
|
||||||
fieldTarget.write();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
IOobjectList fieldFields =
|
|
||||||
objects.lookupClass(CompactIOField<Field<Type>, Type>::typeName);
|
|
||||||
|
|
||||||
forAllConstIters(fieldFields, fieldIter)
|
|
||||||
{
|
|
||||||
Info<< " mapping lagrangian fieldField "
|
|
||||||
<< (*fieldIter)->name() << endl;
|
|
||||||
|
|
||||||
// Read field (does not need mesh)
|
|
||||||
CompactIOField<Field<Type>, Type> fieldSource(*fieldIter());
|
|
||||||
|
|
||||||
// Map
|
|
||||||
CompactIOField<Field<Type>, Type> fieldTarget
|
|
||||||
(
|
|
||||||
IOobject
|
|
||||||
(
|
|
||||||
(*fieldIter)->name(),
|
|
||||||
meshTarget.time().timeName(),
|
|
||||||
cloud::prefix/cloudName,
|
|
||||||
meshTarget,
|
|
||||||
IOobject::NO_READ,
|
|
||||||
IOobject::NO_WRITE,
|
|
||||||
IOobject::NO_REGISTER
|
|
||||||
),
|
|
||||||
addParticles.size()
|
|
||||||
);
|
|
||||||
|
|
||||||
forAll(addParticles, i)
|
|
||||||
{
|
|
||||||
fieldTarget[i] = fieldSource[addParticles[i]];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write field
|
|
||||||
fieldTarget.write();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
|
Copyright (C) 2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -51,25 +52,23 @@ void MapVolFields
|
|||||||
const fvMesh& meshSource = meshToMesh0Interp.fromMesh();
|
const fvMesh& meshSource = meshToMesh0Interp.fromMesh();
|
||||||
const fvMesh& meshTarget = meshToMesh0Interp.toMesh();
|
const fvMesh& meshTarget = meshToMesh0Interp.toMesh();
|
||||||
|
|
||||||
IOobjectList fields = objects.lookupClass(fieldType::typeName);
|
for (const IOobject& io : objects.csorted<fieldType>())
|
||||||
|
|
||||||
forAllConstIters(fields, fieldIter)
|
|
||||||
{
|
{
|
||||||
IOobject fieldTargetIOobject
|
IOobject fieldTargetIOobject
|
||||||
(
|
(
|
||||||
(*fieldIter)->name(),
|
io.name(),
|
||||||
meshTarget.time().timeName(),
|
meshTarget.time().timeName(),
|
||||||
meshTarget,
|
meshTarget,
|
||||||
IOobject::MUST_READ,
|
IOobjectOption::MUST_READ,
|
||||||
IOobject::AUTO_WRITE
|
IOobjectOption::AUTO_WRITE
|
||||||
);
|
);
|
||||||
|
|
||||||
if (fieldTargetIOobject.typeHeaderOk<fieldType>(true))
|
if (fieldTargetIOobject.typeHeaderOk<fieldType>(true))
|
||||||
{
|
{
|
||||||
Info<< " interpolating " << (*fieldIter)->name() << endl;
|
Info<< " interpolating " << io.name() << endl;
|
||||||
|
|
||||||
// Read field fieldSource. Do not auto-load old-time fields
|
// Read field fieldSource. Do not auto-load old-time fields
|
||||||
fieldType fieldSource(*fieldIter(), meshSource, false);
|
fieldType fieldSource(io, meshSource, false);
|
||||||
|
|
||||||
// Read fieldTarget. Do not auto-load old-time fields
|
// Read fieldTarget. Do not auto-load old-time fields
|
||||||
fieldType fieldTarget
|
fieldType fieldTarget
|
||||||
|
|||||||
@ -40,11 +40,9 @@ namespace Foam
|
|||||||
template<class Type>
|
template<class Type>
|
||||||
void UnMapped(const IOobjectList& objects)
|
void UnMapped(const IOobjectList& objects)
|
||||||
{
|
{
|
||||||
IOobjectList fields = objects.lookupClass(Type::typeName);
|
for (const IOobject& io : objects.csorted<Type>())
|
||||||
|
|
||||||
forAllConstIters(fields, fieldIter)
|
|
||||||
{
|
{
|
||||||
mvBak((*fieldIter)->objectPath(), "unmapped");
|
mvBak(io.objectPath(), "unmapped");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2019 OpenCFD Ltd.
|
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -33,8 +33,8 @@ Description
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef MapLagrangianFields_H
|
#ifndef Foam_MapLagrangianFields_H
|
||||||
#define MapLagrangianFields_H
|
#define Foam_MapLagrangianFields_H
|
||||||
|
|
||||||
#include "cloud.H"
|
#include "cloud.H"
|
||||||
#include "GeometricField.H"
|
#include "GeometricField.H"
|
||||||
@ -47,6 +47,63 @@ Description
|
|||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
|
//- Gets the indices of (source)particles that have been appended to the
|
||||||
|
// target cloud and maps the lagrangian fields accordingly.
|
||||||
|
template<class SourceIOFieldType, class TargetIOFieldType>
|
||||||
|
void MapLagrangianFields
|
||||||
|
(
|
||||||
|
const string& cloudName,
|
||||||
|
const IOobjectList& objects,
|
||||||
|
const polyMesh& meshTarget,
|
||||||
|
const labelList& addParticles,
|
||||||
|
const char* msg
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (const IOobject& io : objects.csorted<SourceIOFieldType>())
|
||||||
|
{
|
||||||
|
Info<< " mapping lagrangian " << msg << ' ' << io.name() << endl;
|
||||||
|
|
||||||
|
// Read field (does not need mesh)
|
||||||
|
// Note: some fieldFields are 0 size (e.g. collision records)
|
||||||
|
// if not used, so catch any of those for Field as well
|
||||||
|
|
||||||
|
SourceIOFieldType fieldSource(io);
|
||||||
|
|
||||||
|
// Map
|
||||||
|
TargetIOFieldType fieldTarget
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
io.name(),
|
||||||
|
meshTarget.time().timeName(),
|
||||||
|
cloud::prefix/cloudName,
|
||||||
|
meshTarget,
|
||||||
|
IOobjectOption::NO_READ,
|
||||||
|
IOobjectOption::NO_WRITE,
|
||||||
|
IOobjectOption::NO_REGISTER
|
||||||
|
),
|
||||||
|
min(fieldSource.size(), addParticles.size()) // handle 0 size
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!fieldSource.empty())
|
||||||
|
{
|
||||||
|
forAll(addParticles, i)
|
||||||
|
{
|
||||||
|
fieldTarget[i] = fieldSource[addParticles[i]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (cloud::debug && !addParticles.empty())
|
||||||
|
{
|
||||||
|
Pout<< "Not mapping " << io.name()
|
||||||
|
<< " since source size = 0 and cloud size = "
|
||||||
|
<< addParticles.size() << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
fieldTarget.write();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//- Gets the indices of (source)particles that have been appended to the
|
//- Gets the indices of (source)particles that have been appended to the
|
||||||
// target cloud and maps the lagrangian fields accordingly.
|
// target cloud and maps the lagrangian fields accordingly.
|
||||||
template<class Type>
|
template<class Type>
|
||||||
@ -58,144 +115,46 @@ void MapLagrangianFields
|
|||||||
const labelList& addParticles
|
const labelList& addParticles
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
{
|
MapLagrangianFields
|
||||||
IOobjectList fields = objects.lookupClass(IOField<Type>::typeName);
|
<
|
||||||
|
IOField<Type>,
|
||||||
|
IOField<Type>
|
||||||
|
>
|
||||||
|
(
|
||||||
|
cloudName,
|
||||||
|
objects,
|
||||||
|
meshTarget,
|
||||||
|
addParticles,
|
||||||
|
"Field"
|
||||||
|
);
|
||||||
|
|
||||||
forAllConstIters(fields, fieldIter)
|
// Target is CompactIOField to automatically write in
|
||||||
{
|
// compact form for binary format.
|
||||||
const word& fieldName = (*fieldIter)->name();
|
MapLagrangianFields
|
||||||
|
<
|
||||||
|
IOField<Field<Type>>,
|
||||||
|
CompactIOField<Field<Type>, Type>
|
||||||
|
>
|
||||||
|
(
|
||||||
|
cloudName,
|
||||||
|
objects,
|
||||||
|
meshTarget,
|
||||||
|
addParticles,
|
||||||
|
"FieldField"
|
||||||
|
);
|
||||||
|
|
||||||
Info<< " mapping lagrangian field " << fieldName << endl;
|
MapLagrangianFields
|
||||||
|
<
|
||||||
// Read field (does not need mesh)
|
CompactIOField<Field<Type>, Type>,
|
||||||
IOField<Type> fieldSource(*fieldIter());
|
CompactIOField<Field<Type>, Type>
|
||||||
|
>
|
||||||
// Map
|
(
|
||||||
IOField<Type> fieldTarget
|
cloudName,
|
||||||
(
|
objects,
|
||||||
IOobject
|
meshTarget,
|
||||||
(
|
addParticles,
|
||||||
fieldName,
|
"FieldField"
|
||||||
meshTarget.time().timeName(),
|
);
|
||||||
cloud::prefix/cloudName,
|
|
||||||
meshTarget,
|
|
||||||
IOobject::NO_READ,
|
|
||||||
IOobject::NO_WRITE,
|
|
||||||
IOobject::NO_REGISTER
|
|
||||||
),
|
|
||||||
addParticles.size()
|
|
||||||
);
|
|
||||||
|
|
||||||
forAll(addParticles, i)
|
|
||||||
{
|
|
||||||
fieldTarget[i] = fieldSource[addParticles[i]];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write field
|
|
||||||
fieldTarget.write();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
IOobjectList fieldFields =
|
|
||||||
objects.lookupClass(IOField<Field<Type>>::typeName);
|
|
||||||
|
|
||||||
forAllConstIters(fieldFields, fieldIter)
|
|
||||||
{
|
|
||||||
const word& fieldName = (*fieldIter)->name();
|
|
||||||
|
|
||||||
Info<< " mapping lagrangian fieldField " << fieldName << endl;
|
|
||||||
|
|
||||||
// Read field (does not need mesh)
|
|
||||||
// Note: some fieldFields are 0 size (e.g. collision records) if
|
|
||||||
// not used
|
|
||||||
IOField<Field<Type>> fieldSource(*fieldIter());
|
|
||||||
|
|
||||||
// Map - use CompactIOField to automatically write in
|
|
||||||
// compact form for binary format.
|
|
||||||
CompactIOField<Field<Type>, Type> fieldTarget
|
|
||||||
(
|
|
||||||
IOobject
|
|
||||||
(
|
|
||||||
fieldName,
|
|
||||||
meshTarget.time().timeName(),
|
|
||||||
cloud::prefix/cloudName,
|
|
||||||
meshTarget,
|
|
||||||
IOobject::NO_READ,
|
|
||||||
IOobject::NO_WRITE,
|
|
||||||
IOobject::NO_REGISTER
|
|
||||||
),
|
|
||||||
min(fieldSource.size(), addParticles.size()) // handle 0 size
|
|
||||||
);
|
|
||||||
|
|
||||||
if (fieldSource.size())
|
|
||||||
{
|
|
||||||
forAll(addParticles, i)
|
|
||||||
{
|
|
||||||
fieldTarget[i] = fieldSource[addParticles[i]];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (cloud::debug)
|
|
||||||
{
|
|
||||||
Pout<< "Not mapping " << fieldName << " since source size "
|
|
||||||
<< fieldSource.size() << " different to"
|
|
||||||
<< " cloud size " << addParticles.size()
|
|
||||||
<< endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write field
|
|
||||||
fieldTarget.write();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
IOobjectList fieldFields =
|
|
||||||
objects.lookupClass(CompactIOField<Field<Type>, Type>::typeName);
|
|
||||||
|
|
||||||
forAllConstIters(fieldFields, fieldIter)
|
|
||||||
{
|
|
||||||
const word& fieldName = (*fieldIter)->name();
|
|
||||||
|
|
||||||
Info<< " mapping lagrangian fieldField " << fieldName << endl;
|
|
||||||
|
|
||||||
// Read field (does not need mesh)
|
|
||||||
CompactIOField<Field<Type>, Type> fieldSource(*fieldIter());
|
|
||||||
|
|
||||||
// Map
|
|
||||||
CompactIOField<Field<Type>, Type> fieldTarget
|
|
||||||
(
|
|
||||||
IOobject
|
|
||||||
(
|
|
||||||
fieldName,
|
|
||||||
meshTarget.time().timeName(),
|
|
||||||
cloud::prefix/cloudName,
|
|
||||||
meshTarget,
|
|
||||||
IOobject::NO_READ,
|
|
||||||
IOobject::NO_WRITE,
|
|
||||||
IOobject::NO_REGISTER
|
|
||||||
),
|
|
||||||
min(fieldSource.size(), addParticles.size()) // handle 0 size
|
|
||||||
);
|
|
||||||
|
|
||||||
if (fieldSource.size())
|
|
||||||
{
|
|
||||||
forAll(addParticles, i)
|
|
||||||
{
|
|
||||||
fieldTarget[i] = fieldSource[addParticles[i]];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (cloud::debug)
|
|
||||||
{
|
|
||||||
Pout<< "Not mapping " << fieldName << " since source size "
|
|
||||||
<< fieldSource.size() << " different to"
|
|
||||||
<< " cloud size " << addParticles.size()
|
|
||||||
<< endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write field
|
|
||||||
fieldTarget.write();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
Copyright (C) 2018-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -132,20 +132,21 @@ void MapVolFields
|
|||||||
const fvMesh& meshTarget = static_cast<const fvMesh&>(interp.tgtRegion());
|
const fvMesh& meshTarget = static_cast<const fvMesh&>(interp.tgtRegion());
|
||||||
|
|
||||||
// Available fields, sorted order
|
// Available fields, sorted order
|
||||||
const wordList fieldNames =
|
for
|
||||||
(
|
(
|
||||||
selectedFields.empty()
|
const IOobject& io :
|
||||||
? objects.sortedNames<fieldType>()
|
(
|
||||||
: objects.sortedNames<fieldType>(selectedFields)
|
selectedFields.empty()
|
||||||
);
|
? objects.csorted<fieldType>()
|
||||||
|
: objects.csorted<fieldType>(selectedFields)
|
||||||
for (const word& fieldName : fieldNames)
|
)
|
||||||
|
)
|
||||||
{
|
{
|
||||||
const fieldType fieldSource(*(objects[fieldName]), meshSource, false);
|
const fieldType fieldSource(io, meshSource, false);
|
||||||
|
|
||||||
IOobject targetIO
|
IOobject targetIO
|
||||||
(
|
(
|
||||||
fieldName,
|
io.name(),
|
||||||
meshTarget.time().timeName(),
|
meshTarget.time().timeName(),
|
||||||
meshTarget,
|
meshTarget,
|
||||||
IOobject::MUST_READ
|
IOobject::MUST_READ
|
||||||
@ -154,7 +155,7 @@ void MapVolFields
|
|||||||
if (targetIO.typeHeaderOk<fieldType>(true))
|
if (targetIO.typeHeaderOk<fieldType>(true))
|
||||||
{
|
{
|
||||||
Info<< " interpolating onto existing field "
|
Info<< " interpolating onto existing field "
|
||||||
<< fieldName << endl;
|
<< targetIO.name() << endl;
|
||||||
|
|
||||||
fieldType fieldTarget(targetIO, meshTarget, false);
|
fieldType fieldTarget(targetIO, meshTarget, false);
|
||||||
|
|
||||||
@ -167,7 +168,7 @@ void MapVolFields
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
Info<< " creating new field "
|
Info<< " creating new field "
|
||||||
<< fieldName << endl;
|
<< targetIO.name() << endl;
|
||||||
|
|
||||||
targetIO.readOpt(IOobject::NO_READ);
|
targetIO.readOpt(IOobject::NO_READ);
|
||||||
|
|
||||||
|
|||||||
@ -40,11 +40,9 @@ namespace Foam
|
|||||||
template<class Type>
|
template<class Type>
|
||||||
void UnMapped(const IOobjectList& objects)
|
void UnMapped(const IOobjectList& objects)
|
||||||
{
|
{
|
||||||
IOobjectList fields = objects.lookupClass(Type::typeName);
|
for (const IOobject& io : objects.csorted<Type>())
|
||||||
|
|
||||||
forAllConstIters(fields, fieldIter)
|
|
||||||
{
|
{
|
||||||
mvBak((*fieldIter)->objectPath(), "unmapped");
|
mvBak(io.objectPath(), "unmapped");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -192,14 +192,6 @@ Foam::HashTable<T, Key, Hash>::csorted() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, class Key, class Hash>
|
|
||||||
Foam::UPtrList<const typename Foam::HashTable<T, Key, Hash>::node_type>
|
|
||||||
Foam::HashTable<T, Key, Hash>::sorted() const
|
|
||||||
{
|
|
||||||
return csorted();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class T, class Key, class Hash>
|
template<class T, class Key, class Hash>
|
||||||
Foam::UPtrList<typename Foam::HashTable<T, Key, Hash>::node_type>
|
Foam::UPtrList<typename Foam::HashTable<T, Key, Hash>::node_type>
|
||||||
Foam::HashTable<T, Key, Hash>::sorted()
|
Foam::HashTable<T, Key, Hash>::sorted()
|
||||||
|
|||||||
@ -34,7 +34,7 @@ Description
|
|||||||
depends on the method used to generate the hash key index, the
|
depends on the method used to generate the hash key index, the
|
||||||
table capacity, insertion order etc. When the key order is
|
table capacity, insertion order etc. When the key order is
|
||||||
important, use the sortedToc() method to obtain a list of sorted
|
important, use the sortedToc() method to obtain a list of sorted
|
||||||
keys and use that for further access, or the sorted() method
|
keys and use that for further access, or the csorted()/sorted() methods
|
||||||
to obtain a UPtrList of entries to traverse in sorted order.
|
to obtain a UPtrList of entries to traverse in sorted order.
|
||||||
|
|
||||||
Internally the table uses closed addressing into a flat storage space
|
Internally the table uses closed addressing into a flat storage space
|
||||||
@ -351,11 +351,6 @@ public:
|
|||||||
// The lifetime of the returned content cannot exceed the parent!
|
// The lifetime of the returned content cannot exceed the parent!
|
||||||
UPtrList<const node_type> csorted() const;
|
UPtrList<const node_type> csorted() const;
|
||||||
|
|
||||||
//- Const access to the hash-table contents in sorted order
|
|
||||||
//- (sorted by keys).
|
|
||||||
// The lifetime of the returned content cannot exceed the parent!
|
|
||||||
UPtrList<const node_type> sorted() const;
|
|
||||||
|
|
||||||
//- Non-const access to the hash-table contents in sorted order
|
//- Non-const access to the hash-table contents in sorted order
|
||||||
//- (sorted by keys).
|
//- (sorted by keys).
|
||||||
// The lifetime of the returned content cannot exceed the parent!
|
// The lifetime of the returned content cannot exceed the parent!
|
||||||
@ -1006,6 +1001,11 @@ public:
|
|||||||
|
|
||||||
//- Same as contains()
|
//- Same as contains()
|
||||||
bool found(const Key& key) const { return this->contains(key); }
|
bool found(const Key& key) const { return this->contains(key); }
|
||||||
|
|
||||||
|
//- Deprecated(2023-07) use csorted() method
|
||||||
|
// \deprecated(2023-07) - use csorted() method
|
||||||
|
FOAM_DEPRECATED_FOR(2023-07, "csorted() method")
|
||||||
|
UPtrList<const node_type> sorted() const { return this->csorted(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -220,22 +220,6 @@ Foam::label Foam::IOobjectList::count(const char* clsName) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
Foam::UPtrList<const Foam::IOobject>
|
|
||||||
Foam::IOobjectList::sorted() const
|
|
||||||
{
|
|
||||||
return sorted<void>();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::UPtrList<const Foam::IOobject>
|
|
||||||
Foam::IOobjectList::sorted(const bool syncPar) const
|
|
||||||
{
|
|
||||||
return sorted<void>(syncPar);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::wordList Foam::IOobjectList::names() const
|
Foam::wordList Foam::IOobjectList::names() const
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
Copyright (C) 2016-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -129,12 +129,13 @@ class IOobjectList
|
|||||||
const bool doSort
|
const bool doSort
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Templated implementation for sorted()
|
//- Templated implementation for csorted()/sorted()
|
||||||
template<class Type, class MatchPredicate>
|
template<class Type, class MatchPredicate>
|
||||||
static UPtrList<const IOobject> objectsTypeImpl
|
static UPtrList<const IOobject> objectsTypeImpl
|
||||||
(
|
(
|
||||||
const IOobjectList& list,
|
const IOobjectList& list,
|
||||||
const MatchPredicate& matchName
|
const MatchPredicate& matchName,
|
||||||
|
const bool doSort
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Templated implementation for lookup()
|
//- Templated implementation for lookup()
|
||||||
@ -421,26 +422,37 @@ public:
|
|||||||
HashTable<wordHashSet> classes(const MatchPredicate& matchName) const;
|
HashTable<wordHashSet> classes(const MatchPredicate& matchName) const;
|
||||||
|
|
||||||
|
|
||||||
// Sorted access
|
// List-wise access (unsorted)
|
||||||
|
|
||||||
//- The sorted list of IOobjects
|
//- The unsorted list of IOobjects with
|
||||||
// The lifetime of the returned content cannot exceed the parent!
|
//- headerClassName == Type::typeName
|
||||||
UPtrList<const IOobject> sorted() const;
|
|
||||||
|
|
||||||
//- The sorted list of IOobjects with optional check for
|
|
||||||
//- parallel consistency.
|
|
||||||
// FatalError if syncPar = true and names are not consistent on all
|
|
||||||
// processors.
|
|
||||||
// The lifetime of the returned content cannot exceed the parent!
|
|
||||||
UPtrList<const IOobject> sorted(const bool syncPar) const;
|
|
||||||
|
|
||||||
//- The sorted list of IOobjects with headerClassName == Type::typeName
|
|
||||||
//
|
//
|
||||||
// \note If \a Type is \c void, no headerClassName check is used
|
// \note If \a Type is \c void, no headerClassName check is used
|
||||||
// (always true).
|
// (always true).
|
||||||
// The lifetime of the returned content cannot exceed the parent!
|
// The lifetime of the returned content cannot exceed the parent!
|
||||||
template<class Type>
|
template<class Type>
|
||||||
UPtrList<const IOobject> sorted() const;
|
UPtrList<const IOobject> cobjects() const;
|
||||||
|
|
||||||
|
//- The unsorted list of IOobjects with
|
||||||
|
//- headerClassName == Type::typeName
|
||||||
|
//- that also have a matching object name.
|
||||||
|
// The lifetime of the returned content cannot exceed the parent!
|
||||||
|
template<class Type, class MatchPredicate>
|
||||||
|
UPtrList<const IOobject> cobjects
|
||||||
|
(
|
||||||
|
const MatchPredicate& matchName
|
||||||
|
) const;
|
||||||
|
|
||||||
|
// List-wise access (sorted)
|
||||||
|
|
||||||
|
//- The sorted list of IOobjects with
|
||||||
|
//- headerClassName == Type::typeName
|
||||||
|
//
|
||||||
|
// \note If \a Type is \c void, no headerClassName check is used
|
||||||
|
// (always true).
|
||||||
|
// The lifetime of the returned content cannot exceed the parent!
|
||||||
|
template<class Type>
|
||||||
|
UPtrList<const IOobject> csorted() const;
|
||||||
|
|
||||||
//- The sorted names of the IOobjects with optional check for
|
//- The sorted names of the IOobjects with optional check for
|
||||||
//- parallel consistency.
|
//- parallel consistency.
|
||||||
@ -448,13 +460,30 @@ public:
|
|||||||
// processors.
|
// processors.
|
||||||
// The lifetime of the returned content cannot exceed the parent!
|
// The lifetime of the returned content cannot exceed the parent!
|
||||||
template<class Type>
|
template<class Type>
|
||||||
UPtrList<const IOobject> sorted(const bool syncPar) const;
|
UPtrList<const IOobject> csorted(const bool syncPar) const;
|
||||||
|
|
||||||
|
//- The sorted list of IOobjects
|
||||||
|
// The lifetime of the returned content cannot exceed the parent!
|
||||||
|
UPtrList<const IOobject> csorted() const
|
||||||
|
{
|
||||||
|
return csorted<void>();
|
||||||
|
}
|
||||||
|
|
||||||
|
//- The sorted list of IOobjects with optional check for
|
||||||
|
//- parallel consistency.
|
||||||
|
// FatalError if syncPar = true and names are not consistent on all
|
||||||
|
// processors.
|
||||||
|
// The lifetime of the returned content cannot exceed the parent!
|
||||||
|
UPtrList<const IOobject> csorted(const bool syncPar) const
|
||||||
|
{
|
||||||
|
return csorted<void>(syncPar);
|
||||||
|
}
|
||||||
|
|
||||||
//- The sorted list of IOobjects with headerClassName == Type::typeName
|
//- The sorted list of IOobjects with headerClassName == Type::typeName
|
||||||
//- that also have a matching object name.
|
//- that also have a matching object name.
|
||||||
// The lifetime of the returned content cannot exceed the parent!
|
// The lifetime of the returned content cannot exceed the parent!
|
||||||
template<class Type, class MatchPredicate>
|
template<class Type, class MatchPredicate>
|
||||||
UPtrList<const IOobject> sorted(const MatchPredicate& matchName) const;
|
UPtrList<const IOobject> csorted(const MatchPredicate& matchName) const;
|
||||||
|
|
||||||
//- The sorted list of IOobjects with headerClassName == Type::typeName
|
//- The sorted list of IOobjects with headerClassName == Type::typeName
|
||||||
//- that also have a matching object name.
|
//- that also have a matching object name.
|
||||||
@ -462,7 +491,7 @@ public:
|
|||||||
// processors.
|
// processors.
|
||||||
// The lifetime of the returned content cannot exceed the parent!
|
// The lifetime of the returned content cannot exceed the parent!
|
||||||
template<class Type, class MatchPredicate>
|
template<class Type, class MatchPredicate>
|
||||||
UPtrList<const IOobject> sorted
|
UPtrList<const IOobject> csorted
|
||||||
(
|
(
|
||||||
const MatchPredicate& matchName,
|
const MatchPredicate& matchName,
|
||||||
const bool syncPar
|
const bool syncPar
|
||||||
@ -769,10 +798,67 @@ public:
|
|||||||
{
|
{
|
||||||
return getObject(objName);
|
return getObject(objName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//- Deprecated(2023-07) use csorted() method
|
||||||
|
// \deprecated(2023-07) - use csorted() method
|
||||||
|
template<class Type>
|
||||||
|
FOAM_DEPRECATED_FOR(2023-07, "csorted() method")
|
||||||
|
UPtrList<const IOobject> sorted() const
|
||||||
|
{
|
||||||
|
return csorted<Type>();
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Deprecated(2023-07) use csorted() method
|
||||||
|
// \deprecated(2023-07) - use csorted() method
|
||||||
|
template<class Type>
|
||||||
|
FOAM_DEPRECATED_FOR(2023-07, "csorted() method")
|
||||||
|
UPtrList<const IOobject> sorted(const bool syncPar) const
|
||||||
|
{
|
||||||
|
return csorted<Type>(syncPar);
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Deprecated(2023-07) use csorted() method
|
||||||
|
// \deprecated(2023-07) - use csorted() method
|
||||||
|
FOAM_DEPRECATED_FOR(2023-07, "csorted() method")
|
||||||
|
UPtrList<const IOobject> sorted() const
|
||||||
|
{
|
||||||
|
return csorted<void>();
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Deprecated(2023-07) use csorted() method
|
||||||
|
// \deprecated(2023-07) - use csorted() method
|
||||||
|
FOAM_DEPRECATED_FOR(2023-07, "csorted() method")
|
||||||
|
UPtrList<const IOobject> sorted(const bool syncPar) const
|
||||||
|
{
|
||||||
|
return csorted<void>(syncPar);
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Deprecated(2023-07) use csorted() method
|
||||||
|
// \deprecated(2023-07) - use csorted() method
|
||||||
|
template<class Type, class MatchPredicate>
|
||||||
|
FOAM_DEPRECATED_FOR(2023-07, "csorted() method")
|
||||||
|
UPtrList<const IOobject> sorted(const MatchPredicate& matchName) const
|
||||||
|
{
|
||||||
|
return csorted<Type>(matchName);
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Deprecated(2023-07) use csorted() method
|
||||||
|
// \deprecated(2023-07) - use csorted() method
|
||||||
|
template<class Type, class MatchPredicate>
|
||||||
|
FOAM_DEPRECATED_FOR(2023-07, "csorted() method")
|
||||||
|
UPtrList<const IOobject> sorted
|
||||||
|
(
|
||||||
|
const MatchPredicate& matchName,
|
||||||
|
const bool syncPar
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
return csorted<Type>(matchName, syncPar);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Ostream operator
|
// Ostream Operator
|
||||||
Ostream& operator<<(Ostream& os, const IOobjectList& list);
|
Ostream& operator<<(Ostream& os, const IOobjectList& list);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
Copyright (C) 2018-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -177,13 +177,14 @@ Foam::wordList Foam::IOobjectList::namesTypeImpl
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Templated implementation for sorted()
|
// Templated implementation for csorted(), csorted()
|
||||||
template<class Type, class MatchPredicate>
|
template<class Type, class MatchPredicate>
|
||||||
Foam::UPtrList<const Foam::IOobject>
|
Foam::UPtrList<const Foam::IOobject>
|
||||||
Foam::IOobjectList::objectsTypeImpl
|
Foam::IOobjectList::objectsTypeImpl
|
||||||
(
|
(
|
||||||
const IOobjectList& list,
|
const IOobjectList& list,
|
||||||
const MatchPredicate& matchName
|
const MatchPredicate& matchName,
|
||||||
|
const bool doSort
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UPtrList<const IOobject> result(list.size());
|
UPtrList<const IOobject> result(list.size());
|
||||||
@ -203,7 +204,10 @@ Foam::IOobjectList::objectsTypeImpl
|
|||||||
|
|
||||||
result.resize(count);
|
result.resize(count);
|
||||||
|
|
||||||
Foam::sort(result, nameOp<IOobject>()); // Sort by object name()
|
if (doSort)
|
||||||
|
{
|
||||||
|
Foam::sort(result, nameOp<IOobject>()); // Sort by object name()
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -472,19 +476,30 @@ Foam::label Foam::IOobjectList::count
|
|||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
Foam::UPtrList<const Foam::IOobject>
|
Foam::UPtrList<const Foam::IOobject>
|
||||||
Foam::IOobjectList::sorted() const
|
Foam::IOobjectList::cobjects() const
|
||||||
{
|
{
|
||||||
return objectsTypeImpl<Type>(*this, predicates::always());
|
// doSort = false
|
||||||
|
return objectsTypeImpl<Type>(*this, predicates::always(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
Foam::UPtrList<const Foam::IOobject>
|
Foam::UPtrList<const Foam::IOobject>
|
||||||
Foam::IOobjectList::sorted(const bool syncPar) const
|
Foam::IOobjectList::csorted() const
|
||||||
|
{
|
||||||
|
// doSort = true
|
||||||
|
return objectsTypeImpl<Type>(*this, predicates::always(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
Foam::UPtrList<const Foam::IOobject>
|
||||||
|
Foam::IOobjectList::csorted(const bool syncPar) const
|
||||||
{
|
{
|
||||||
UPtrList<const IOobject> list
|
UPtrList<const IOobject> list
|
||||||
(
|
(
|
||||||
objectsTypeImpl<Type>(*this, predicates::always())
|
// doSort = true
|
||||||
|
objectsTypeImpl<Type>(*this, predicates::always(), true)
|
||||||
);
|
);
|
||||||
|
|
||||||
checkObjectOrder(list, syncPar);
|
checkObjectOrder(list, syncPar);
|
||||||
@ -495,18 +510,31 @@ Foam::IOobjectList::sorted(const bool syncPar) const
|
|||||||
|
|
||||||
template<class Type, class MatchPredicate>
|
template<class Type, class MatchPredicate>
|
||||||
Foam::UPtrList<const Foam::IOobject>
|
Foam::UPtrList<const Foam::IOobject>
|
||||||
Foam::IOobjectList::sorted
|
Foam::IOobjectList::cobjects
|
||||||
(
|
(
|
||||||
const MatchPredicate& matchName
|
const MatchPredicate& matchName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
return objectsTypeImpl<Type>(*this, matchName);
|
// doSort = false
|
||||||
|
return objectsTypeImpl<Type>(*this, matchName, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type, class MatchPredicate>
|
template<class Type, class MatchPredicate>
|
||||||
Foam::UPtrList<const Foam::IOobject>
|
Foam::UPtrList<const Foam::IOobject>
|
||||||
Foam::IOobjectList::sorted
|
Foam::IOobjectList::csorted
|
||||||
|
(
|
||||||
|
const MatchPredicate& matchName
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
// doSort = true
|
||||||
|
return objectsTypeImpl<Type>(*this, matchName, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type, class MatchPredicate>
|
||||||
|
Foam::UPtrList<const Foam::IOobject>
|
||||||
|
Foam::IOobjectList::csorted
|
||||||
(
|
(
|
||||||
const MatchPredicate& matchName,
|
const MatchPredicate& matchName,
|
||||||
const bool syncPar
|
const bool syncPar
|
||||||
@ -514,7 +542,8 @@ Foam::IOobjectList::sorted
|
|||||||
{
|
{
|
||||||
UPtrList<const IOobject> list
|
UPtrList<const IOobject> list
|
||||||
(
|
(
|
||||||
objectsTypeImpl<Type>(*this, matchName)
|
// doSort = true
|
||||||
|
objectsTypeImpl<Type>(*this, matchName, true)
|
||||||
);
|
);
|
||||||
|
|
||||||
checkObjectOrder(list, syncPar);
|
checkObjectOrder(list, syncPar);
|
||||||
@ -531,6 +560,7 @@ Foam::wordList Foam::IOobjectList::names
|
|||||||
const MatchPredicate& matchClass
|
const MatchPredicate& matchClass
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
|
// doSort = false
|
||||||
return namesImpl(*this, matchClass, predicates::always(), false);
|
return namesImpl(*this, matchClass, predicates::always(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -553,6 +583,7 @@ Foam::wordList Foam::IOobjectList::names
|
|||||||
const MatchPredicate2& matchName
|
const MatchPredicate2& matchName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
|
// doSort = false
|
||||||
return namesImpl(*this, matchClass, matchName, false);
|
return namesImpl(*this, matchClass, matchName, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -572,6 +603,7 @@ Foam::wordList Foam::IOobjectList::names
|
|||||||
template<class Type>
|
template<class Type>
|
||||||
Foam::wordList Foam::IOobjectList::names() const
|
Foam::wordList Foam::IOobjectList::names() const
|
||||||
{
|
{
|
||||||
|
// doSort = false
|
||||||
return namesTypeImpl<Type>(*this, predicates::always(), false);
|
return namesTypeImpl<Type>(*this, predicates::always(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -589,6 +621,7 @@ Foam::wordList Foam::IOobjectList::names
|
|||||||
const MatchPredicate& matchName
|
const MatchPredicate& matchName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
|
// doSort = false
|
||||||
return namesTypeImpl<Type>(*this, matchName, false);
|
return namesTypeImpl<Type>(*this, matchName, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -158,27 +158,6 @@ Foam::label Foam::objectRegistry::count(const char* clsName) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::UPtrList<const Foam::regIOobject>
|
|
||||||
Foam::objectRegistry::csorted() const
|
|
||||||
{
|
|
||||||
return objectsTypeImpl<const regIOobject>(*this, predicates::always());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::UPtrList<const Foam::regIOobject>
|
|
||||||
Foam::objectRegistry::sorted() const
|
|
||||||
{
|
|
||||||
return objectsTypeImpl<const regIOobject>(*this, predicates::always());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::UPtrList<Foam::regIOobject>
|
|
||||||
Foam::objectRegistry::sorted()
|
|
||||||
{
|
|
||||||
return objectsTypeImpl<regIOobject>(*this, predicates::always());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::wordList Foam::objectRegistry::names() const
|
Foam::wordList Foam::objectRegistry::names() const
|
||||||
{
|
{
|
||||||
return HashTable<regIOobject*>::toc();
|
return HashTable<regIOobject*>::toc();
|
||||||
|
|||||||
@ -150,13 +150,24 @@ class objectRegistry
|
|||||||
const bool doSort
|
const bool doSort
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Templated implementation for sorted()
|
//- Templated implementation for csorted()/sorted()
|
||||||
// Called with 'Type' or 'const Type'
|
// Called with 'Type' or 'const Type'
|
||||||
template<class Type, class MatchPredicate>
|
template<class Type, class MatchPredicate>
|
||||||
static UPtrList<Type> objectsTypeImpl
|
static UPtrList<Type> objectsTypeImpl
|
||||||
(
|
(
|
||||||
|
const bool strict, // Check with isType<Type>
|
||||||
const objectRegistry& list,
|
const objectRegistry& list,
|
||||||
const MatchPredicate& matchName
|
const MatchPredicate& matchName,
|
||||||
|
const bool doSort // Sort the list by name
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Templated implementation for lookupClass()
|
||||||
|
// Called with 'Type' or 'const Type'
|
||||||
|
template<class Type>
|
||||||
|
static HashTable<Type*> lookupClassTypeImpl
|
||||||
|
(
|
||||||
|
const bool strict, // Check with isType<Type>
|
||||||
|
const objectRegistry& list
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@ -240,49 +251,69 @@ public:
|
|||||||
HashTable<wordHashSet> classes(const MatchPredicate& matchName) const;
|
HashTable<wordHashSet> classes(const MatchPredicate& matchName) const;
|
||||||
|
|
||||||
|
|
||||||
// Sorted access
|
// List-wise access (unsorted)
|
||||||
|
|
||||||
//- Return sorted list of objects
|
//- Return unsorted list of objects with a class satisfying
|
||||||
|
//- \c isA\<Type\> or \c isType\<Type\> (with Strict)
|
||||||
// The lifetime of the returned content cannot exceed the parent!
|
// The lifetime of the returned content cannot exceed the parent!
|
||||||
UPtrList<const regIOobject> csorted() const;
|
template<class Type, bool Strict=false>
|
||||||
|
UPtrList<const Type> cobjects() const;
|
||||||
|
|
||||||
//- Return sorted list of objects
|
//- Return unsorted list of objects with a class satisfying
|
||||||
|
//- \c isA\<Type\> or \c isType\<Type\> (with Strict)
|
||||||
// The lifetime of the returned content cannot exceed the parent!
|
// The lifetime of the returned content cannot exceed the parent!
|
||||||
UPtrList<const regIOobject> sorted() const;
|
template<class Type, bool Strict=false>
|
||||||
|
UPtrList<Type> objects();
|
||||||
|
|
||||||
//- Return sorted list of objects
|
//- Return unsorted list of objects with a class satisfying
|
||||||
|
//- \c isA\<Type\> that also have a matching object name.
|
||||||
// The lifetime of the returned content cannot exceed the parent!
|
// The lifetime of the returned content cannot exceed the parent!
|
||||||
UPtrList<regIOobject> sorted();
|
template<class Type, class MatchPredicate>
|
||||||
|
UPtrList<const Type> cobjects(const MatchPredicate& matchName) const;
|
||||||
//- Return sorted list of objects with a class satisfying \c isA\<Type\>
|
|
||||||
// The lifetime of the returned content cannot exceed the parent!
|
|
||||||
template<class Type>
|
|
||||||
UPtrList<const Type> csorted() const;
|
|
||||||
|
|
||||||
//- Return sorted list of objects with a class satisfying \c isA\<Type\>
|
|
||||||
// The lifetime of the returned content cannot exceed the parent!
|
|
||||||
template<class Type>
|
|
||||||
UPtrList<const Type> sorted() const;
|
|
||||||
|
|
||||||
//- Return sorted list of objects with a class satisfying \c isA\<Type\>
|
|
||||||
// The lifetime of the returned content cannot exceed the parent!
|
|
||||||
template<class Type>
|
|
||||||
UPtrList<Type> sorted();
|
|
||||||
|
|
||||||
//- Return sorted list of objects with a class satisfying \c isA\<Type\>
|
//- Return sorted list of objects with a class satisfying \c isA\<Type\>
|
||||||
//- that also have a matching object name.
|
//- that also have a matching object name.
|
||||||
// The lifetime of the returned content cannot exceed the parent!
|
// The lifetime of the returned content cannot exceed the parent!
|
||||||
template<class Type, class MatchPredicate>
|
template<class Type, class MatchPredicate>
|
||||||
|
UPtrList<Type> objects(const MatchPredicate& matchName);
|
||||||
|
|
||||||
|
|
||||||
|
// List-wise access (sorted)
|
||||||
|
|
||||||
|
//- Return sorted list of objects with a class satisfying
|
||||||
|
//- \c isA\<Type\> or \c isType\<Type\> (with Strict)
|
||||||
|
// The lifetime of the returned content cannot exceed the parent!
|
||||||
|
template<class Type, bool Strict=false>
|
||||||
|
UPtrList<const Type> csorted() const;
|
||||||
|
|
||||||
|
//- Return sorted list of objects with a class satisfying
|
||||||
|
//- \c isA\<Type\> or \c isType\<Type\> (with Strict)
|
||||||
|
// The lifetime of the returned content cannot exceed the parent!
|
||||||
|
template<class Type, bool Strict=false>
|
||||||
|
UPtrList<Type> sorted();
|
||||||
|
|
||||||
|
//- Return sorted list of objects
|
||||||
|
// The lifetime of the returned content cannot exceed the parent!
|
||||||
|
UPtrList<const regIOobject> csorted() const
|
||||||
|
{
|
||||||
|
return csorted<regIOobject>();
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Return sorted list of objects
|
||||||
|
// The lifetime of the returned content cannot exceed the parent!
|
||||||
|
UPtrList<regIOobject> sorted()
|
||||||
|
{
|
||||||
|
return sorted<regIOobject>();
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Return sorted list of objects with a class satisfying
|
||||||
|
//- \c isA\<Type\> that also have a matching object name.
|
||||||
|
// The lifetime of the returned content cannot exceed the parent!
|
||||||
|
template<class Type, class MatchPredicate>
|
||||||
UPtrList<const Type> csorted(const MatchPredicate& matchName) const;
|
UPtrList<const Type> csorted(const MatchPredicate& matchName) const;
|
||||||
|
|
||||||
//- Return sorted list of objects with a class satisfying \c isA\<Type\>
|
//- Return sorted list of objects with a class satisfying
|
||||||
//- that also have a matching object name.
|
//- \c isA\<Type\> that also have a matching object name.
|
||||||
// The lifetime of the returned content cannot exceed the parent!
|
|
||||||
template<class Type, class MatchPredicate>
|
|
||||||
UPtrList<const Type> sorted(const MatchPredicate& matchName) const;
|
|
||||||
|
|
||||||
//- Return sorted list of objects with a class satisfying \c isA\<Type\>
|
|
||||||
//- that also have a matching object name.
|
|
||||||
// The lifetime of the returned content cannot exceed the parent!
|
// The lifetime of the returned content cannot exceed the parent!
|
||||||
template<class Type, class MatchPredicate>
|
template<class Type, class MatchPredicate>
|
||||||
UPtrList<Type> sorted(const MatchPredicate& matchName);
|
UPtrList<Type> sorted(const MatchPredicate& matchName);
|
||||||
@ -351,7 +382,7 @@ public:
|
|||||||
const MatchPredicate2& matchName
|
const MatchPredicate2& matchName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- The unsorted names of objects with a class satisfying \c isA\<Type\>.
|
//- The unsorted names of objects with a class satisfying \c isA\<Type\>
|
||||||
//
|
//
|
||||||
// \note If \a Type is \c void, no isA check is used (always true).
|
// \note If \a Type is \c void, no isA check is used (always true).
|
||||||
template<class Type>
|
template<class Type>
|
||||||
@ -417,17 +448,27 @@ public:
|
|||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
//- Return all objects with a class satisfying \c isA\<Type\>
|
//- Return all objects with a class satisfying
|
||||||
//
|
//- \c isA\<Type\> or \c isType\<Type\> (with Strict)
|
||||||
// \param strict use \c isType\<Type\> instead of \c isA\<Type\>
|
template<class Type, bool Strict=false>
|
||||||
template<class Type>
|
HashTable<const Type*> lookupClass() const;
|
||||||
HashTable<const Type*> lookupClass(const bool strict = false) const;
|
|
||||||
|
//- Return all objects with a class satisfying
|
||||||
|
//- \c isA\<Type\> or \c isType\<Type\> (with Strict)
|
||||||
|
template<class Type, bool Strict=false>
|
||||||
|
HashTable<Type*> lookupClass();
|
||||||
|
|
||||||
//- Return all objects with a class satisfying \c isA\<Type\>
|
//- Return all objects with a class satisfying \c isA\<Type\>
|
||||||
//
|
//
|
||||||
// \param strict use \c isType\<Type\> instead of \c isA\<Type\>
|
// \param strict use \c isType\<Type\> instead of \c isA\<Type\>
|
||||||
template<class Type>
|
template<class Type>
|
||||||
HashTable<Type*> lookupClass(const bool strict = false);
|
HashTable<const Type*> lookupClass(const bool strict) const;
|
||||||
|
|
||||||
|
//- Return all objects with a class satisfying \c isA\<Type\>
|
||||||
|
//
|
||||||
|
// \param strict use \c isType\<Type\> instead of \c isA\<Type\>
|
||||||
|
template<class Type>
|
||||||
|
HashTable<Type*> lookupClass(const bool strict);
|
||||||
|
|
||||||
//- Return const pointer to the regIOobject.
|
//- Return const pointer to the regIOobject.
|
||||||
//
|
//
|
||||||
@ -673,6 +714,32 @@ public:
|
|||||||
{
|
{
|
||||||
return this->getObjectPtr<Type>(name, recursive);
|
return this->getObjectPtr<Type>(name, recursive);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//- Deprecated(2023-07) use csorted() method
|
||||||
|
// \deprecated(2023-07) - use csorted() method
|
||||||
|
template<class Type>
|
||||||
|
FOAM_DEPRECATED_FOR(2023-07, "csorted() method")
|
||||||
|
UPtrList<const Type> sorted() const
|
||||||
|
{
|
||||||
|
return csorted<Type>();
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Deprecated(2023-07) use csorted() method
|
||||||
|
// \deprecated(2023-07) - use csorted() method
|
||||||
|
FOAM_DEPRECATED_FOR(2023-07, "csorted() method")
|
||||||
|
UPtrList<const regIOobject> sorted() const
|
||||||
|
{
|
||||||
|
return csorted<regIOobject>();
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Deprecated(2023-07) use csorted() method
|
||||||
|
// \deprecated(2023-07) - use csorted() method
|
||||||
|
template<class Type, class MatchPredicate>
|
||||||
|
FOAM_DEPRECATED_FOR(2023-07, "csorted() method")
|
||||||
|
UPtrList<const Type> sorted(const MatchPredicate& matchName) const
|
||||||
|
{
|
||||||
|
return csorted<Type>(matchName);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -184,13 +184,15 @@ Foam::wordList Foam::objectRegistry::namesTypeImpl
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Templated implementation for sorted()
|
// Templated implementation for cobjects()/objects(), csorted()/sorted()
|
||||||
template<class Type, class MatchPredicate>
|
template<class Type, class MatchPredicate>
|
||||||
Foam::UPtrList<Type>
|
Foam::UPtrList<Type>
|
||||||
Foam::objectRegistry::objectsTypeImpl
|
Foam::objectRegistry::objectsTypeImpl
|
||||||
(
|
(
|
||||||
|
const bool strict,
|
||||||
const objectRegistry& list,
|
const objectRegistry& list,
|
||||||
const MatchPredicate& matchName
|
const MatchPredicate& matchName,
|
||||||
|
const bool doSort
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
typedef typename std::remove_cv<Type>::type BaseType;
|
typedef typename std::remove_cv<Type>::type BaseType;
|
||||||
@ -200,9 +202,15 @@ Foam::objectRegistry::objectsTypeImpl
|
|||||||
label count = 0;
|
label count = 0;
|
||||||
forAllConstIters(list, iter)
|
forAllConstIters(list, iter)
|
||||||
{
|
{
|
||||||
const BaseType* ptr = Foam::isA<BaseType>(*iter.val());
|
const regIOobject* obj = iter.val();
|
||||||
|
const BaseType* ptr = dynamic_cast<const BaseType*>(obj);
|
||||||
|
|
||||||
if (ptr && matchName(ptr->name()))
|
if
|
||||||
|
(
|
||||||
|
ptr
|
||||||
|
&& (!strict || Foam::isType<BaseType>(*obj))
|
||||||
|
&& matchName(ptr->name())
|
||||||
|
)
|
||||||
{
|
{
|
||||||
result.set(count, const_cast<BaseType*>(ptr));
|
result.set(count, const_cast<BaseType*>(ptr));
|
||||||
++count;
|
++count;
|
||||||
@ -211,7 +219,42 @@ Foam::objectRegistry::objectsTypeImpl
|
|||||||
|
|
||||||
result.resize(count);
|
result.resize(count);
|
||||||
|
|
||||||
Foam::sort(result, nameOp<Type>()); // Sort by object name()
|
if (doSort)
|
||||||
|
{
|
||||||
|
Foam::sort(result, nameOp<Type>()); // Sort by object name()
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Templated implementation for lookupClass()
|
||||||
|
template<class Type>
|
||||||
|
Foam::HashTable<Type*>
|
||||||
|
Foam::objectRegistry::lookupClassTypeImpl
|
||||||
|
(
|
||||||
|
const bool strict,
|
||||||
|
const objectRegistry& list
|
||||||
|
)
|
||||||
|
{
|
||||||
|
typedef typename std::remove_cv<Type>::type BaseType;
|
||||||
|
|
||||||
|
HashTable<Type*> result(list.capacity());
|
||||||
|
|
||||||
|
forAllConstIters(list, iter)
|
||||||
|
{
|
||||||
|
const regIOobject* obj = iter.val();
|
||||||
|
const BaseType* ptr = dynamic_cast<const BaseType*>(obj);
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
ptr
|
||||||
|
&& (!strict || Foam::isType<BaseType>(*obj))
|
||||||
|
)
|
||||||
|
{
|
||||||
|
result.insert(obj->name(), const_cast<BaseType*>(ptr));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -294,27 +337,71 @@ Foam::label Foam::objectRegistry::count
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
template<class Type, bool Strict>
|
||||||
|
Foam::UPtrList<const Type>
|
||||||
|
Foam::objectRegistry::cobjects() const
|
||||||
|
{
|
||||||
|
return objectsTypeImpl<const Type>
|
||||||
|
(
|
||||||
|
Strict, *this, predicates::always(), false // doSort = false
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type, bool Strict>
|
||||||
|
Foam::UPtrList<Type>
|
||||||
|
Foam::objectRegistry::objects()
|
||||||
|
{
|
||||||
|
return objectsTypeImpl<Type>
|
||||||
|
(
|
||||||
|
Strict, *this, predicates::always(), false // doSort = false
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type, bool Strict>
|
||||||
Foam::UPtrList<const Type>
|
Foam::UPtrList<const Type>
|
||||||
Foam::objectRegistry::csorted() const
|
Foam::objectRegistry::csorted() const
|
||||||
{
|
{
|
||||||
return objectsTypeImpl<const Type>(*this, predicates::always());
|
return objectsTypeImpl<const Type>
|
||||||
|
(
|
||||||
|
Strict, *this, predicates::always(), true // doSort = true
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type, bool Strict>
|
||||||
Foam::UPtrList<const Type>
|
|
||||||
Foam::objectRegistry::sorted() const
|
|
||||||
{
|
|
||||||
return objectsTypeImpl<const Type>(*this, predicates::always());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
Foam::UPtrList<Type>
|
Foam::UPtrList<Type>
|
||||||
Foam::objectRegistry::sorted()
|
Foam::objectRegistry::sorted()
|
||||||
{
|
{
|
||||||
return objectsTypeImpl<Type>(*this, predicates::always());
|
return objectsTypeImpl<Type>
|
||||||
|
(
|
||||||
|
Strict, *this, predicates::always(), true // doSort = false
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type, class MatchPredicate>
|
||||||
|
Foam::UPtrList<const Type>
|
||||||
|
Foam::objectRegistry::cobjects
|
||||||
|
(
|
||||||
|
const MatchPredicate& matchName
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
// doSort = false
|
||||||
|
return objectsTypeImpl<const Type>(false, *this, matchName, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type, class MatchPredicate>
|
||||||
|
Foam::UPtrList<Type>
|
||||||
|
Foam::objectRegistry::objects
|
||||||
|
(
|
||||||
|
const MatchPredicate& matchName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// doSort = false
|
||||||
|
return objectsTypeImpl<Type>(false, *this, matchName, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -325,20 +412,10 @@ Foam::objectRegistry::csorted
|
|||||||
const MatchPredicate& matchName
|
const MatchPredicate& matchName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
return objectsTypeImpl<const Type>(*this, matchName);
|
return objectsTypeImpl<const Type>(false, *this, matchName, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type, class MatchPredicate>
|
|
||||||
Foam::UPtrList<const Type>
|
|
||||||
Foam::objectRegistry::sorted
|
|
||||||
(
|
|
||||||
const MatchPredicate& matchName
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
return objectsTypeImpl<const Type>(*this, matchName);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class Type, class MatchPredicate>
|
template<class Type, class MatchPredicate>
|
||||||
Foam::UPtrList<Type>
|
Foam::UPtrList<Type>
|
||||||
Foam::objectRegistry::sorted
|
Foam::objectRegistry::sorted
|
||||||
@ -346,7 +423,7 @@ Foam::objectRegistry::sorted
|
|||||||
const MatchPredicate& matchName
|
const MatchPredicate& matchName
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return objectsTypeImpl<Type>(*this, matchName);
|
return objectsTypeImpl<Type>(false, *this, matchName, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -428,30 +505,27 @@ Foam::wordList Foam::objectRegistry::sortedNames
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type, bool Strict>
|
||||||
|
Foam::HashTable<const Type*> Foam::objectRegistry::lookupClass() const
|
||||||
|
{
|
||||||
|
return lookupClassTypeImpl<const Type>(Strict, *this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type, bool Strict>
|
||||||
|
Foam::HashTable<Type*> Foam::objectRegistry::lookupClass()
|
||||||
|
{
|
||||||
|
return lookupClassTypeImpl<Type>(Strict, *this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
Foam::HashTable<const Type*> Foam::objectRegistry::lookupClass
|
Foam::HashTable<const Type*> Foam::objectRegistry::lookupClass
|
||||||
(
|
(
|
||||||
const bool strict
|
const bool strict
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
HashTable<const Type*> objectsOfClass(size());
|
return lookupClassTypeImpl<const Type>(strict, *this);
|
||||||
|
|
||||||
forAllConstIters(*this, iter)
|
|
||||||
{
|
|
||||||
const regIOobject* obj = iter.val();
|
|
||||||
|
|
||||||
if
|
|
||||||
(
|
|
||||||
strict
|
|
||||||
? bool(Foam::isType<Type>(*obj))
|
|
||||||
: bool(Foam::isA<Type>(*obj))
|
|
||||||
)
|
|
||||||
{
|
|
||||||
objectsOfClass.insert(obj->name(), dynamic_cast<const Type*>(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return objectsOfClass;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -461,24 +535,7 @@ Foam::HashTable<Type*> Foam::objectRegistry::lookupClass
|
|||||||
const bool strict
|
const bool strict
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
HashTable<Type*> objectsOfClass(size());
|
return lookupClassTypeImpl<Type>(strict, *this);
|
||||||
|
|
||||||
forAllIters(*this, iter)
|
|
||||||
{
|
|
||||||
regIOobject* obj = iter.val();
|
|
||||||
|
|
||||||
if
|
|
||||||
(
|
|
||||||
strict
|
|
||||||
? bool(Foam::isType<Type>(*obj))
|
|
||||||
: bool(Foam::isA<Type>(*obj))
|
|
||||||
)
|
|
||||||
{
|
|
||||||
objectsOfClass.insert(obj->name(), dynamic_cast<Type*>(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return objectsOfClass;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2012 OpenFOAM Foundation
|
Copyright (C) 2012 OpenFOAM Foundation
|
||||||
Copyright (C) 2019 OpenCFD Ltd.
|
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -46,20 +46,23 @@ template<class Type, class MeshMapper, class GeoMesh>
|
|||||||
void MapDimensionedFields(const MeshMapper& mapper)
|
void MapDimensionedFields(const MeshMapper& mapper)
|
||||||
{
|
{
|
||||||
typedef DimensionedField<Type, GeoMesh> FieldType;
|
typedef DimensionedField<Type, GeoMesh> FieldType;
|
||||||
typedef HashTable<const FieldType*> TableType;
|
|
||||||
|
|
||||||
TableType fields(mapper.thisDb().template lookupClass<FieldType>(true));
|
// Note: use strict=true to avoid picking up volFields
|
||||||
|
const UPtrList<const FieldType> fields
|
||||||
|
(
|
||||||
|
mapper.thisDb().template csorted<FieldType, true>()
|
||||||
|
);
|
||||||
|
|
||||||
forAllConstIters(fields, fieldIter)
|
for (const auto& fld : fields)
|
||||||
{
|
{
|
||||||
FieldType& field = const_cast<FieldType&>(*fieldIter());
|
FieldType& field = const_cast<FieldType&>(fld);
|
||||||
|
|
||||||
if (&field.mesh() == &mapper.mesh())
|
if (&field.mesh() == &mapper.mesh())
|
||||||
{
|
{
|
||||||
if (polyMesh::debug)
|
if (polyMesh::debug)
|
||||||
{
|
{
|
||||||
Info<< "Mapping " << field.typeName << ' ' << field.name()
|
Info<< "Mapping "
|
||||||
<< endl;
|
<< FieldType::typeName << ' ' << field.name() << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
MapInternalField<Type, MeshMapper, GeoMesh>()(field, mapper);
|
MapInternalField<Type, MeshMapper, GeoMesh>()(field, mapper);
|
||||||
@ -68,7 +71,8 @@ void MapDimensionedFields(const MeshMapper& mapper)
|
|||||||
}
|
}
|
||||||
else if (polyMesh::debug)
|
else if (polyMesh::debug)
|
||||||
{
|
{
|
||||||
Info<< "Not mapping " << field.typeName << ' ' << field.name()
|
Info<< "Not mapping "
|
||||||
|
<< FieldType::typeName << ' ' << field.name()
|
||||||
<< " since originating mesh differs from that of mapper."
|
<< " since originating mesh differs from that of mapper."
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2017-2019 OpenCFD Ltd.
|
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -49,8 +49,7 @@ class MapInternalField
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
MapInternalField()
|
MapInternalField() = default;
|
||||||
{}
|
|
||||||
|
|
||||||
void operator()
|
void operator()
|
||||||
(
|
(
|
||||||
@ -77,10 +76,9 @@ void MapGeometricFields
|
|||||||
{
|
{
|
||||||
typedef GeometricField<Type, PatchField, GeoMesh> FieldType;
|
typedef GeometricField<Type, PatchField, GeoMesh> FieldType;
|
||||||
|
|
||||||
HashTable<const FieldType*> fields
|
const UPtrList<const FieldType> fields
|
||||||
(
|
(
|
||||||
mapper.thisDb().objectRegistry::template
|
mapper.thisDb().objectRegistry::template csorted<FieldType>()
|
||||||
lookupClass<FieldType>()
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// It is necessary to enforce that all old-time fields are stored
|
// It is necessary to enforce that all old-time fields are stored
|
||||||
@ -88,39 +86,37 @@ void MapGeometricFields
|
|||||||
// old-time-level field is mapped before the field itself, sizes
|
// old-time-level field is mapped before the field itself, sizes
|
||||||
// will not match.
|
// will not match.
|
||||||
|
|
||||||
forAllConstIters(fields, fieldIter)
|
for (const auto& field : fields)
|
||||||
{
|
{
|
||||||
FieldType& field = const_cast<FieldType&>(*fieldIter());
|
|
||||||
|
|
||||||
//Note: check can be removed once pointFields are actually stored on
|
//Note: check can be removed once pointFields are actually stored on
|
||||||
// the pointMesh instead of now on the polyMesh!
|
// the pointMesh instead of now on the polyMesh!
|
||||||
if (&field.mesh() == &mapper.mesh())
|
if (&field.mesh() == &mapper.mesh())
|
||||||
{
|
{
|
||||||
field.storeOldTimes();
|
const_cast<FieldType&>(field).storeOldTimes();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
forAllConstIters(fields, fieldIter)
|
for (const auto& field : fields)
|
||||||
{
|
{
|
||||||
FieldType& field = const_cast<FieldType&>(*fieldIter());
|
FieldType& fld = const_cast<FieldType&>(field);
|
||||||
|
|
||||||
if (&field.mesh() == &mapper.mesh())
|
if (&field.mesh() == &mapper.mesh())
|
||||||
{
|
{
|
||||||
if (polyMesh::debug)
|
if (polyMesh::debug)
|
||||||
{
|
{
|
||||||
Info<< "Mapping " << field.typeName << ' ' << field.name()
|
Info<< "Mapping "
|
||||||
<< endl;
|
<< FieldType::typeName << ' ' << field.name() << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Map the internal field
|
// Map the internal field
|
||||||
MapInternalField<Type, MeshMapper, GeoMesh>()
|
MapInternalField<Type, MeshMapper, GeoMesh>()
|
||||||
(
|
(
|
||||||
field.internalFieldRef(),
|
fld.internalFieldRef(),
|
||||||
mapper
|
mapper
|
||||||
);
|
);
|
||||||
|
|
||||||
// Map the patch fields
|
// Map the patch fields
|
||||||
auto& bfield = field.boundaryFieldRef();
|
auto& bfield = fld.boundaryFieldRef();
|
||||||
|
|
||||||
forAll(bfield, patchi)
|
forAll(bfield, patchi)
|
||||||
{
|
{
|
||||||
@ -132,11 +128,12 @@ void MapGeometricFields
|
|||||||
bfield[patchi].autoMap(mapper.boundaryMap()[patchi]);
|
bfield[patchi].autoMap(mapper.boundaryMap()[patchi]);
|
||||||
}
|
}
|
||||||
|
|
||||||
field.instance() = field.time().timeName();
|
fld.instance() = fld.time().timeName();
|
||||||
}
|
}
|
||||||
else if (polyMesh::debug)
|
else if (polyMesh::debug)
|
||||||
{
|
{
|
||||||
Info<< "Not mapping " << field.typeName << ' ' << field.name()
|
Info<< "Not mapping "
|
||||||
|
<< FieldType::typeName << ' ' << field.name()
|
||||||
<< " since originating mesh differs from that of mapper."
|
<< " since originating mesh differs from that of mapper."
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2016-2018 OpenCFD Ltd.
|
Copyright (C) 2016-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -36,11 +36,12 @@ SourceFiles
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef ReadFields_H
|
#ifndef Foam_ReadFields_H
|
||||||
#define ReadFields_H
|
#define Foam_ReadFields_H
|
||||||
|
|
||||||
#include "PtrList.H"
|
#include "PtrList.H"
|
||||||
#include "wordList.H"
|
#include "wordList.H"
|
||||||
|
#include "DynamicList.H"
|
||||||
#include "GeometricField.H"
|
#include "GeometricField.H"
|
||||||
#include "HashSet.H"
|
#include "HashSet.H"
|
||||||
#include "LIFOStack.H"
|
#include "LIFOStack.H"
|
||||||
@ -113,27 +114,63 @@ static void ReadFields
|
|||||||
const word& registryName = "fieldsCache"
|
const word& registryName = "fieldsCache"
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Read the selected GeometricFields of the templated type.
|
|
||||||
// The fields are transferred to the objectRegistry and a list of them is
|
//- Read the selected GeometricFields of the templated type
|
||||||
// returned as a stack for later cleanup
|
//- and store on the objectRegistry.
|
||||||
template<class GeoFieldType>
|
// Returns a list of field pointers for later cleanup
|
||||||
|
template<class GeoFieldType, class NameMatchPredicate>
|
||||||
void readFields
|
void readFields
|
||||||
(
|
(
|
||||||
const typename GeoFieldType::Mesh& mesh,
|
const typename GeoFieldType::Mesh& mesh,
|
||||||
const IOobjectList& objects,
|
const IOobjectList& objects,
|
||||||
const wordHashSet& selectedFields,
|
//! Restrict to fields with matching names
|
||||||
|
const NameMatchPredicate& selectedFields,
|
||||||
|
//! [out] List of field pointers for later cleanup
|
||||||
|
DynamicList<regIOobject*>& storedObjects
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Read the selected UniformDimensionedFields of the templated type
|
||||||
|
//- and store on the objectRegistry.
|
||||||
|
// Returns a list of field pointers for later cleanup
|
||||||
|
template<class UniformFieldType, class NameMatchPredicate>
|
||||||
|
void readUniformFields
|
||||||
|
(
|
||||||
|
const IOobjectList& objects,
|
||||||
|
//! Restrict to fields with matching names
|
||||||
|
const NameMatchPredicate& selectedFields,
|
||||||
|
//! [out] List of field pointers for later cleanup
|
||||||
|
DynamicList<regIOobject*>& storedObjects,
|
||||||
|
const bool syncPar = true
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// Housekeeping
|
||||||
|
|
||||||
|
//- Read the selected GeometricFields of the templated type
|
||||||
|
//- and store on the objectRegistry.
|
||||||
|
// \deprecated(2023-07) - prefer the DynamicList version
|
||||||
|
// Returns a stack of field pointers for later cleanup
|
||||||
|
template<class GeoFieldType, class NameMatchPredicate>
|
||||||
|
FOAM_DEPRECATED_FOR(2023-07, "DynamicList version")
|
||||||
|
void readFields
|
||||||
|
(
|
||||||
|
const typename GeoFieldType::Mesh& mesh,
|
||||||
|
const IOobjectList& objects,
|
||||||
|
const NameMatchPredicate& selectedFields,
|
||||||
LIFOStack<regIOobject*>& storedObjects
|
LIFOStack<regIOobject*>& storedObjects
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
//- Read the selected UniformDimensionedFields of the templated type.
|
//- Read the selected UniformDimensionedFields of the templated type
|
||||||
// The fields are transferred to the objectRegistry and a list of them is
|
//- and store on the objectRegistry.
|
||||||
// returned as a stack for later cleanup
|
// \deprecated(2023-07) - prefer the DynamicList version
|
||||||
template<class GeoFieldType>
|
// Returns a stack of field pointers for later cleanup
|
||||||
|
template<class UniformFieldType, class NameMatchPredicate>
|
||||||
|
FOAM_DEPRECATED_FOR(2023-07, "DynamicList version")
|
||||||
void readUniformFields
|
void readUniformFields
|
||||||
(
|
(
|
||||||
const IOobjectList& objects,
|
const IOobjectList& objects,
|
||||||
const wordHashSet& selectedFields,
|
const NameMatchPredicate& selectedFields,
|
||||||
LIFOStack<regIOobject*>& storedObjects,
|
LIFOStack<regIOobject*>& storedObjects,
|
||||||
const bool syncPar = true
|
const bool syncPar = true
|
||||||
);
|
);
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2014 OpenFOAM Foundation
|
Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||||
Copyright (C) 2018 OpenCFD Ltd.
|
Copyright (C) 2018-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -45,10 +45,10 @@ Foam::wordList Foam::ReadFields
|
|||||||
typedef GeometricField<Type, PatchField, GeoMesh> GeoField;
|
typedef GeometricField<Type, PatchField, GeoMesh> GeoField;
|
||||||
|
|
||||||
// Names of GeoField objects, sorted order.
|
// Names of GeoField objects, sorted order.
|
||||||
const wordList fieldNames(objects.names(GeoField::typeName, syncPar));
|
const wordList fieldNames(objects.sortedNames<GeoField>(syncPar));
|
||||||
|
|
||||||
// Construct the fields - reading in consistent (master) order.
|
// Construct the fields - reading in consistent (master) order.
|
||||||
fields.resize(fieldNames.size());
|
fields.resize_null(fieldNames.size());
|
||||||
|
|
||||||
label nFields = 0;
|
label nFields = 0;
|
||||||
|
|
||||||
@ -73,8 +73,8 @@ Foam::wordList Foam::ReadFields
|
|||||||
io.instance(),
|
io.instance(),
|
||||||
io.local(),
|
io.local(),
|
||||||
io.db(),
|
io.db(),
|
||||||
IOobject::MUST_READ,
|
IOobjectOption::MUST_READ,
|
||||||
IOobject::AUTO_WRITE,
|
IOobjectOption::AUTO_WRITE,
|
||||||
io.registerObject()
|
io.registerObject()
|
||||||
),
|
),
|
||||||
mesh,
|
mesh,
|
||||||
@ -99,10 +99,10 @@ Foam::wordList Foam::ReadFields
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Names of GeoField objects, sorted order.
|
// Names of GeoField objects, sorted order.
|
||||||
const wordList fieldNames(objects.names(GeoField::typeName, syncPar));
|
const wordList fieldNames(objects.sortedNames<GeoField>(syncPar));
|
||||||
|
|
||||||
// Construct the fields - reading in consistent (master) order.
|
// Construct the fields - reading in consistent (master) order.
|
||||||
fields.resize(fieldNames.size());
|
fields.resize_null(fieldNames.size());
|
||||||
|
|
||||||
label nFields = 0;
|
label nFields = 0;
|
||||||
|
|
||||||
@ -127,8 +127,8 @@ Foam::wordList Foam::ReadFields
|
|||||||
io.instance(),
|
io.instance(),
|
||||||
io.local(),
|
io.local(),
|
||||||
io.db(),
|
io.db(),
|
||||||
IOobject::MUST_READ,
|
IOobjectOption::MUST_READ,
|
||||||
IOobject::AUTO_WRITE,
|
IOobjectOption::AUTO_WRITE,
|
||||||
io.registerObject()
|
io.registerObject()
|
||||||
),
|
),
|
||||||
mesh
|
mesh
|
||||||
@ -151,10 +151,10 @@ Foam::wordList Foam::ReadFields
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Names of GeoField objects, sorted order.
|
// Names of GeoField objects, sorted order.
|
||||||
const wordList fieldNames(objects.names(GeoField::typeName, syncPar));
|
const wordList fieldNames(objects.sortedNames<GeoField>(syncPar));
|
||||||
|
|
||||||
// Construct the fields - reading in consistent (master) order.
|
// Construct the fields - reading in consistent (master) order.
|
||||||
fields.resize(fieldNames.size());
|
fields.resize_null(fieldNames.size());
|
||||||
|
|
||||||
label nFields = 0;
|
label nFields = 0;
|
||||||
|
|
||||||
@ -179,8 +179,8 @@ Foam::wordList Foam::ReadFields
|
|||||||
io.instance(),
|
io.instance(),
|
||||||
io.local(),
|
io.local(),
|
||||||
io.db(),
|
io.db(),
|
||||||
IOobject::MUST_READ,
|
IOobjectOption::MUST_READ,
|
||||||
IOobject::AUTO_WRITE,
|
IOobjectOption::AUTO_WRITE,
|
||||||
io.registerObject()
|
io.registerObject()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -235,9 +235,9 @@ void Foam::ReadFields
|
|||||||
timeName,
|
timeName,
|
||||||
timeName,
|
timeName,
|
||||||
fieldsCache,
|
fieldsCache,
|
||||||
IOobject::NO_READ,
|
IOobjectOption::NO_READ,
|
||||||
IOobject::NO_WRITE,
|
IOobjectOption::NO_WRITE,
|
||||||
IOobject::REGISTER
|
IOobjectOption::REGISTER
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
timeCachePtr->store();
|
timeCachePtr->store();
|
||||||
@ -260,9 +260,9 @@ void Foam::ReadFields
|
|||||||
fieldName,
|
fieldName,
|
||||||
timeName,
|
timeName,
|
||||||
mesh.thisDb(),
|
mesh.thisDb(),
|
||||||
IOobject::MUST_READ,
|
IOobjectOption::MUST_READ,
|
||||||
IOobject::NO_WRITE,
|
IOobjectOption::NO_WRITE,
|
||||||
IOobject::NO_REGISTER
|
IOobjectOption::NO_REGISTER
|
||||||
),
|
),
|
||||||
mesh
|
mesh
|
||||||
);
|
);
|
||||||
@ -275,9 +275,9 @@ void Foam::ReadFields
|
|||||||
fieldName,
|
fieldName,
|
||||||
timeName,
|
timeName,
|
||||||
timeCache,
|
timeCache,
|
||||||
IOobject::NO_READ,
|
IOobjectOption::NO_READ,
|
||||||
IOobject::NO_WRITE,
|
IOobjectOption::NO_WRITE,
|
||||||
IOobject::REGISTER
|
IOobjectOption::REGISTER
|
||||||
),
|
),
|
||||||
loadedFld
|
loadedFld
|
||||||
);
|
);
|
||||||
@ -309,53 +309,51 @@ void Foam::ReadFields
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class GeoFieldType>
|
template<class GeoFieldType, class NameMatchPredicate>
|
||||||
void Foam::readFields
|
void Foam::readFields
|
||||||
(
|
(
|
||||||
const typename GeoFieldType::Mesh& mesh,
|
const typename GeoFieldType::Mesh& mesh,
|
||||||
const IOobjectList& objects,
|
const IOobjectList& objects,
|
||||||
const wordHashSet& selectedFields,
|
const NameMatchPredicate& selectedFields,
|
||||||
LIFOStack<regIOobject*>& storedObjects
|
DynamicList<regIOobject*>& storedObjects
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Names of GeoField objects, sorted order. Not synchronised.
|
// GeoField objects, sorted order. Not synchronised.
|
||||||
const wordList fieldNames
|
const UPtrList<const IOobject> fieldObjects
|
||||||
(
|
(
|
||||||
objects.sortedNames
|
objects.csorted<GeoFieldType>(selectedFields)
|
||||||
(
|
|
||||||
GeoFieldType::typeName,
|
|
||||||
selectedFields // Only permit these
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// pre-extend reserve
|
||||||
|
storedObjects.reserve(storedObjects.size() + fieldObjects.size());
|
||||||
|
|
||||||
label nFields = 0;
|
label nFields = 0;
|
||||||
|
|
||||||
for (const word& fieldName : fieldNames)
|
for (const IOobject& io : fieldObjects)
|
||||||
{
|
{
|
||||||
const IOobject& io = *objects[fieldName];
|
|
||||||
|
|
||||||
if (!nFields)
|
if (!nFields)
|
||||||
{
|
{
|
||||||
Info<< " " << GeoFieldType::typeName << ':';
|
Info<< " " << GeoFieldType::typeName << ':';
|
||||||
}
|
}
|
||||||
Info<< ' ' << fieldName;
|
Info<< ' ' << io.name();
|
||||||
|
|
||||||
GeoFieldType* fieldPtr = new GeoFieldType
|
GeoFieldType* fieldPtr = new GeoFieldType
|
||||||
(
|
(
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
fieldName,
|
io.name(),
|
||||||
io.instance(),
|
io.instance(),
|
||||||
io.local(),
|
io.local(),
|
||||||
io.db(),
|
io.db(),
|
||||||
IOobject::MUST_READ,
|
IOobjectOption::MUST_READ,
|
||||||
IOobject::NO_WRITE,
|
IOobjectOption::NO_WRITE,
|
||||||
IOobject::REGISTER
|
IOobjectOption::REGISTER
|
||||||
),
|
),
|
||||||
mesh
|
mesh
|
||||||
);
|
);
|
||||||
fieldPtr->store();
|
fieldPtr->store();
|
||||||
storedObjects.push(fieldPtr);
|
storedObjects.push_back(fieldPtr);
|
||||||
|
|
||||||
++nFields;
|
++nFields;
|
||||||
}
|
}
|
||||||
@ -364,53 +362,49 @@ void Foam::readFields
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class UniformFieldType>
|
template<class UniformFieldType, class NameMatchPredicate>
|
||||||
void Foam::readUniformFields
|
void Foam::readUniformFields
|
||||||
(
|
(
|
||||||
const IOobjectList& objects,
|
const IOobjectList& objects,
|
||||||
const wordHashSet& selectedFields,
|
const NameMatchPredicate& selectedFields,
|
||||||
LIFOStack<regIOobject*>& storedObjects,
|
DynamicList<regIOobject*>& storedObjects,
|
||||||
const bool syncPar
|
const bool syncPar
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Names of UniformField objects, sorted order.
|
// UniformField objects, sorted order, synchronised.
|
||||||
const wordList fieldNames
|
const UPtrList<const IOobject> fieldObjects
|
||||||
(
|
(
|
||||||
objects.names
|
objects.csorted<UniformFieldType>(selectedFields, syncPar)
|
||||||
(
|
|
||||||
UniformFieldType::typeName,
|
|
||||||
selectedFields, // Only permit these
|
|
||||||
syncPar
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// pre-extend reserve
|
||||||
|
storedObjects.reserve(storedObjects.size() + fieldObjects.size());
|
||||||
|
|
||||||
label nFields = 0;
|
label nFields = 0;
|
||||||
|
|
||||||
for (const word& fieldName : fieldNames)
|
for (const IOobject& io : fieldObjects)
|
||||||
{
|
{
|
||||||
const IOobject& io = *objects[fieldName];
|
|
||||||
|
|
||||||
if (!nFields)
|
if (!nFields)
|
||||||
{
|
{
|
||||||
Info<< " " << UniformFieldType::typeName << ':';
|
Info<< " " << UniformFieldType::typeName << ':';
|
||||||
}
|
}
|
||||||
Info<< ' ' << fieldName;
|
Info<< ' ' << io.name();
|
||||||
|
|
||||||
UniformFieldType* fieldPtr = new UniformFieldType
|
UniformFieldType* fieldPtr = new UniformFieldType
|
||||||
(
|
(
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
fieldName,
|
io.name(),
|
||||||
io.instance(),
|
io.instance(),
|
||||||
io.local(),
|
io.local(),
|
||||||
io.db(),
|
io.db(),
|
||||||
IOobject::MUST_READ,
|
IOobjectOption::MUST_READ,
|
||||||
IOobject::NO_WRITE,
|
IOobjectOption::NO_WRITE,
|
||||||
IOobject::REGISTER
|
IOobjectOption::REGISTER
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
fieldPtr->store();
|
fieldPtr->store();
|
||||||
storedObjects.push(fieldPtr);
|
storedObjects.push_back(fieldPtr);
|
||||||
|
|
||||||
++nFields;
|
++nFields;
|
||||||
}
|
}
|
||||||
@ -419,4 +413,58 @@ void Foam::readUniformFields
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class GeoFieldType, class NameMatchPredicate>
|
||||||
|
void Foam::readFields
|
||||||
|
(
|
||||||
|
const typename GeoFieldType::Mesh& mesh,
|
||||||
|
const IOobjectList& objects,
|
||||||
|
const NameMatchPredicate& selectedFields,
|
||||||
|
LIFOStack<regIOobject*>& storedObjects
|
||||||
|
)
|
||||||
|
{
|
||||||
|
DynamicList<regIOobject*> newObjects;
|
||||||
|
|
||||||
|
readFields<GeoFieldType, NameMatchPredicate>
|
||||||
|
(
|
||||||
|
mesh,
|
||||||
|
objects,
|
||||||
|
selectedFields,
|
||||||
|
newObjects
|
||||||
|
);
|
||||||
|
|
||||||
|
// Transcribe from list to stack
|
||||||
|
for (regIOobject* fieldPtr : newObjects)
|
||||||
|
{
|
||||||
|
storedObjects.push(fieldPtr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class UniformFieldType, class NameMatchPredicate>
|
||||||
|
void Foam::readUniformFields
|
||||||
|
(
|
||||||
|
const IOobjectList& objects,
|
||||||
|
const NameMatchPredicate& selectedFields,
|
||||||
|
LIFOStack<regIOobject*>& storedObjects,
|
||||||
|
const bool syncPar
|
||||||
|
)
|
||||||
|
{
|
||||||
|
DynamicList<regIOobject*> newObjects;
|
||||||
|
|
||||||
|
readUniformFields<UniformFieldType, NameMatchPredicate>
|
||||||
|
(
|
||||||
|
objects,
|
||||||
|
selectedFields,
|
||||||
|
newObjects,
|
||||||
|
syncPar
|
||||||
|
);
|
||||||
|
|
||||||
|
// Transcribe from list to stack
|
||||||
|
for (regIOobject* fieldPtr : newObjects)
|
||||||
|
{
|
||||||
|
storedObjects.push(fieldPtr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -34,8 +34,8 @@ Description
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef mapClouds_H
|
#ifndef Foam_mapClouds_H
|
||||||
#define mapClouds_H
|
#define Foam_mapClouds_H
|
||||||
|
|
||||||
#include "cloud.H"
|
#include "cloud.H"
|
||||||
#include "objectRegistry.H"
|
#include "objectRegistry.H"
|
||||||
@ -50,18 +50,14 @@ namespace Foam
|
|||||||
// fields depending on mesh type.
|
// fields depending on mesh type.
|
||||||
inline void mapClouds(const objectRegistry& db, const mapPolyMesh& mapper)
|
inline void mapClouds(const objectRegistry& db, const mapPolyMesh& mapper)
|
||||||
{
|
{
|
||||||
HashTable<const cloud*> clouds(db.lookupClass<cloud>());
|
for (const cloud& c : db.csorted<cloud>())
|
||||||
|
|
||||||
forAllIters(clouds, iter)
|
|
||||||
{
|
{
|
||||||
cloud& c = const_cast<cloud&>(*iter());
|
|
||||||
|
|
||||||
if (polyMesh::debug)
|
if (polyMesh::debug)
|
||||||
{
|
{
|
||||||
Info<< "Mapping cloud " << c.name() << endl;
|
Info<< "Mapping cloud " << c.name() << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
c.autoMap(mapper);
|
const_cast<cloud&>(c).autoMap(mapper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -161,14 +161,10 @@ Foam::label Foam::coupleGroupIdentifier::findOtherPatchID
|
|||||||
|
|
||||||
|
|
||||||
// Loop over all regions to find other patch in coupleGroup
|
// Loop over all regions to find other patch in coupleGroup
|
||||||
HashTable<const polyMesh*> meshSet = runTime.lookupClass<polyMesh>();
|
|
||||||
|
|
||||||
label otherPatchID = -1;
|
label otherPatchID = -1;
|
||||||
|
|
||||||
forAllConstIters(meshSet, iter)
|
for (const polyMesh& mesh : runTime.cobjects<polyMesh>())
|
||||||
{
|
{
|
||||||
const polyMesh& mesh = *iter();
|
|
||||||
|
|
||||||
const label patchID = findOtherPatchID(mesh, thisPatch);
|
const label patchID = findOtherPatchID(mesh, thisPatch);
|
||||||
|
|
||||||
if (patchID != -1)
|
if (patchID != -1)
|
||||||
@ -178,15 +174,15 @@ Foam::label Foam::coupleGroupIdentifier::findOtherPatchID
|
|||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Couple patchGroup " << name()
|
<< "Couple patchGroup " << name()
|
||||||
<< " should be present on only two patches"
|
<< " should be present on only two patches"
|
||||||
<< " in any of the meshes in " << meshSet.sortedToc()
|
<< " in any of the meshes in "
|
||||||
<< endl
|
<< runTime.sortedNames<polyMesh>() << nl
|
||||||
<< " It seems to be present on patch "
|
<< " It seems to be present on patch "
|
||||||
<< thisPatch.name()
|
<< thisPatch.name()
|
||||||
<< " in region " << thisMesh.name()
|
<< " in region " << thisMesh.name()
|
||||||
<< ", on patch " << otherPatchID
|
<< ", on patch " << otherPatchID
|
||||||
<< " in region " << otherRegion
|
<< " in region " << otherRegion
|
||||||
<< " and on patch " << patchID
|
<< " and on patch " << patchID
|
||||||
<< " in region " << mesh.name()
|
<< " in region " << mesh.name() << endl
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
otherPatchID = patchID;
|
otherPatchID = patchID;
|
||||||
@ -198,7 +194,8 @@ Foam::label Foam::coupleGroupIdentifier::findOtherPatchID
|
|||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Couple patchGroup " << name()
|
<< "Couple patchGroup " << name()
|
||||||
<< " not found in any of the other meshes " << meshSet.sortedToc()
|
<< " not found in any of the other meshes "
|
||||||
|
<< flatOutput(runTime.sortedNames<polyMesh>())
|
||||||
<< " on patch " << thisPatch.name()
|
<< " on patch " << thisPatch.name()
|
||||||
<< " region " << thisMesh.name()
|
<< " region " << thisMesh.name()
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
|
|||||||
@ -206,7 +206,7 @@ void Foam::meshObject::updateMesh(objectRegistry& obr, const mapPolyMesh& mpm)
|
|||||||
|
|
||||||
forAllIters(meshObjects, iter)
|
forAllIters(meshObjects, iter)
|
||||||
{
|
{
|
||||||
// isA<MoveableMeshObject<Mesh>>
|
// isA<UpdateableMeshObject<Mesh>>
|
||||||
auto* objectPtr = dynamic_cast<UpdateableMeshObject<Mesh>*>(*iter);
|
auto* objectPtr = dynamic_cast<UpdateableMeshObject<Mesh>*>(*iter);
|
||||||
|
|
||||||
if (objectPtr)
|
if (objectPtr)
|
||||||
@ -277,7 +277,7 @@ void Foam::meshObject::clearUpto(objectRegistry& obr)
|
|||||||
|
|
||||||
forAllIters(meshObjects, iter)
|
forAllIters(meshObjects, iter)
|
||||||
{
|
{
|
||||||
// isA<ToType<Mesh>
|
// isA<ToType<Mesh>>
|
||||||
auto* objectPtr = dynamic_cast<ToType<Mesh>*>(*iter);
|
auto* objectPtr = dynamic_cast<ToType<Mesh>*>(*iter);
|
||||||
|
|
||||||
if (!objectPtr)
|
if (!objectPtr)
|
||||||
|
|||||||
@ -65,10 +65,10 @@ void Foam::fieldsDistributor::readFields
|
|||||||
typedef GeometricField<Type, PatchField, GeoMesh> GeoField;
|
typedef GeometricField<Type, PatchField, GeoMesh> GeoField;
|
||||||
|
|
||||||
// GeoField fields - sorted for consistent order on all processors
|
// GeoField fields - sorted for consistent order on all processors
|
||||||
UPtrList<const IOobject> fieldObjects(objects.sorted<GeoField>());
|
const UPtrList<const IOobject> fieldObjects(objects.csorted<GeoField>());
|
||||||
|
|
||||||
// Construct the fields
|
// Construct the fields
|
||||||
fields.resize(fieldObjects.size());
|
fields.resize_null(fieldObjects.size());
|
||||||
|
|
||||||
forAll(fieldObjects, i)
|
forAll(fieldObjects, i)
|
||||||
{
|
{
|
||||||
@ -86,10 +86,10 @@ void Foam::fieldsDistributor::readFields
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
// GeoField fields - sorted for consistent order on all processors
|
// GeoField fields - sorted for consistent order on all processors
|
||||||
UPtrList<const IOobject> fieldObjects(objects.sorted<GeoField>());
|
const UPtrList<const IOobject> fieldObjects(objects.csorted<GeoField>());
|
||||||
|
|
||||||
// Construct the fields
|
// Construct the fields
|
||||||
fields.resize(fieldObjects.size());
|
fields.resize_null(fieldObjects.size());
|
||||||
|
|
||||||
forAll(fieldObjects, i)
|
forAll(fieldObjects, i)
|
||||||
{
|
{
|
||||||
@ -167,18 +167,16 @@ void Foam::fieldsDistributor::readFieldsImpl
|
|||||||
if (deregister)
|
if (deregister)
|
||||||
{
|
{
|
||||||
// Extra safety - remove all such types
|
// Extra safety - remove all such types
|
||||||
HashTable<const GeoField*> other
|
const UPtrList<const GeoField> other
|
||||||
(
|
(
|
||||||
mesh.thisDb().objectRegistry::template lookupClass<GeoField>()
|
mesh.thisDb().objectRegistry::template cobjects<GeoField>()
|
||||||
);
|
);
|
||||||
|
|
||||||
forAllConstIters(other, iter)
|
for (const GeoField& field : other)
|
||||||
{
|
{
|
||||||
GeoField& fld = const_cast<GeoField&>(*iter.val());
|
if (!field.ownedByRegistry())
|
||||||
|
|
||||||
if (!fld.ownedByRegistry())
|
|
||||||
{
|
{
|
||||||
fld.checkOut();
|
const_cast<GeoField&>(field).checkOut();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
Copyright (C) 2018-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -295,9 +295,9 @@ void Foam::dynamicRefineFvMesh::mapFields(const mapPolyMesh& mpm)
|
|||||||
Pout<< "Found " << masterFaces.count() << " split faces " << endl;
|
Pout<< "Found " << masterFaces.count() << " split faces " << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
HashTable<surfaceScalarField*> fluxes
|
UPtrList<surfaceScalarField> fluxes
|
||||||
(
|
(
|
||||||
lookupClass<surfaceScalarField>()
|
this->objectRegistry::sorted<surfaceScalarField>()
|
||||||
);
|
);
|
||||||
|
|
||||||
// Remove surfaceInterpolation to allow re-calculation on demand
|
// Remove surfaceInterpolation to allow re-calculation on demand
|
||||||
@ -305,44 +305,39 @@ void Foam::dynamicRefineFvMesh::mapFields(const mapPolyMesh& mpm)
|
|||||||
// might need the old interpolation fields (weights, etc).
|
// might need the old interpolation fields (weights, etc).
|
||||||
surfaceInterpolation::clearOut();
|
surfaceInterpolation::clearOut();
|
||||||
|
|
||||||
forAllIters(fluxes, iter)
|
for (surfaceScalarField& phi : fluxes)
|
||||||
{
|
{
|
||||||
if (!correctFluxes_.found(iter.key()))
|
const word& UName = correctFluxes_.lookup(phi.name(), word::null);
|
||||||
|
|
||||||
|
if (UName.empty())
|
||||||
{
|
{
|
||||||
WarningInFunction
|
WarningInFunction
|
||||||
<< "Cannot find surfaceScalarField " << iter.key()
|
<< "Cannot find surfaceScalarField " << phi.name()
|
||||||
<< " in user-provided flux mapping table "
|
<< " in user-provided flux mapping table "
|
||||||
<< correctFluxes_ << endl
|
<< correctFluxes_ << endl
|
||||||
<< " The flux mapping table is used to recreate the"
|
<< " The flux mapping table is used to recreate the"
|
||||||
<< " flux on newly created faces." << endl
|
<< " flux on newly created faces." << endl
|
||||||
<< " Either add the entry if it is a flux or use ("
|
<< " Either add the entry if it is a flux or use ("
|
||||||
<< iter.key() << " none) to suppress this warning."
|
<< phi.name() << " none) to suppress this warning."
|
||||||
<< endl;
|
<< endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const word& UName = correctFluxes_[iter.key()];
|
|
||||||
|
|
||||||
if (UName == "none")
|
if (UName == "none")
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
surfaceScalarField& phi = *iter();
|
|
||||||
|
|
||||||
if (UName == "NaN")
|
if (UName == "NaN")
|
||||||
{
|
{
|
||||||
Pout<< "Setting surfaceScalarField " << iter.key()
|
Pout<< "Setting surfaceScalarField " << phi.name()
|
||||||
<< " to NaN" << endl;
|
<< " to NaN" << endl;
|
||||||
|
|
||||||
sigFpe::fillNan(phi.primitiveFieldRef());
|
sigFpe::fillNan(phi.primitiveFieldRef());
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Pout<< "Mapping flux " << iter.key()
|
Pout<< "Mapping flux " << phi.name()
|
||||||
<< " using interpolated flux " << UName
|
<< " using interpolated flux " << UName
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
@ -374,7 +369,7 @@ void Foam::dynamicRefineFvMesh::mapFields(const mapPolyMesh& mpm)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Recalculate new boundary faces.
|
// Recalculate new boundary faces.
|
||||||
surfaceScalarField::Boundary& phiBf = phi.boundaryFieldRef();
|
auto& phiBf = phi.boundaryFieldRef();
|
||||||
|
|
||||||
forAll(phiBf, patchi)
|
forAll(phiBf, patchi)
|
||||||
{
|
{
|
||||||
@ -617,42 +612,39 @@ Foam::dynamicRefineFvMesh::unrefine
|
|||||||
const labelList& reversePointMap = map().reversePointMap();
|
const labelList& reversePointMap = map().reversePointMap();
|
||||||
const labelList& reverseFaceMap = map().reverseFaceMap();
|
const labelList& reverseFaceMap = map().reverseFaceMap();
|
||||||
|
|
||||||
HashTable<surfaceScalarField*> fluxes
|
UPtrList<surfaceScalarField> fluxes
|
||||||
(
|
(
|
||||||
lookupClass<surfaceScalarField>()
|
this->objectRegistry::sorted<surfaceScalarField>()
|
||||||
);
|
);
|
||||||
forAllIters(fluxes, iter)
|
|
||||||
|
for (surfaceScalarField& phi : fluxes)
|
||||||
{
|
{
|
||||||
if (!correctFluxes_.found(iter.key()))
|
const word& UName = correctFluxes_.lookup(phi.name(), word::null);
|
||||||
|
|
||||||
|
if (UName.empty())
|
||||||
{
|
{
|
||||||
WarningInFunction
|
WarningInFunction
|
||||||
<< "Cannot find surfaceScalarField " << iter.key()
|
<< "Cannot find surfaceScalarField " << phi.name()
|
||||||
<< " in user-provided flux mapping table "
|
<< " in user-provided flux mapping table "
|
||||||
<< correctFluxes_ << endl
|
<< correctFluxes_ << endl
|
||||||
<< " The flux mapping table is used to recreate the"
|
<< " The flux mapping table is used to recreate the"
|
||||||
<< " flux on newly created faces." << endl
|
<< " flux on newly created faces." << endl
|
||||||
<< " Either add the entry if it is a flux or use ("
|
<< " Either add the entry if it is a flux or use ("
|
||||||
<< iter.key() << " none) to suppress this warning."
|
<< phi.name() << " none) to suppress this warning."
|
||||||
<< endl;
|
<< endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const word& UName = correctFluxes_[iter.key()];
|
|
||||||
|
|
||||||
if (UName == "none")
|
if (UName == "none")
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
DebugInfo
|
DebugInfo
|
||||||
<< "Mapping flux " << iter.key()
|
<< "Mapping flux " << phi.name()
|
||||||
<< " using interpolated flux " << UName
|
<< " using interpolated flux " << UName
|
||||||
<< endl;
|
<< endl;
|
||||||
|
|
||||||
|
auto& phiBf = phi.boundaryFieldRef();
|
||||||
surfaceScalarField& phi = *iter();
|
|
||||||
surfaceScalarField::Boundary& phiBf =
|
|
||||||
phi.boundaryFieldRef();
|
|
||||||
|
|
||||||
const surfaceScalarField phiU
|
const surfaceScalarField phiU
|
||||||
(
|
(
|
||||||
|
|||||||
@ -105,24 +105,20 @@ void Foam::dynamicRefineFvMesh::mapNewInternalFaces
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
typedef GeometricField<T, fvsPatchField, surfaceMesh> GeoField;
|
typedef GeometricField<T, fvsPatchField, surfaceMesh> GeoField;
|
||||||
HashTable<GeoField*> sFlds(this->objectRegistry::lookupClass<GeoField>());
|
|
||||||
|
|
||||||
forAllIters(sFlds, iter)
|
for (GeoField& sFld : this->objectRegistry::sorted<GeoField>())
|
||||||
{
|
{
|
||||||
//if (mapSurfaceFields_.found(iter.key()))
|
//if (mapSurfaceFields_.found(sFld.name()))
|
||||||
{
|
{
|
||||||
DebugInfo
|
DebugInfo
|
||||||
<< "dynamicRefineFvMesh::mapNewInternalFaces():"
|
<< "dynamicRefineFvMesh::mapNewInternalFaces():"
|
||||||
<< " Mapping new internal faces by interpolation on "
|
<< " Mapping new internal faces by interpolation on "
|
||||||
<< iter.key()<< endl;
|
<< sFld.name()<< endl;
|
||||||
|
|
||||||
GeoField& sFld = *iter();
|
|
||||||
|
|
||||||
if (sFld.is_oriented())
|
if (sFld.is_oriented())
|
||||||
{
|
{
|
||||||
WarningInFunction << "Ignoring mapping oriented field "
|
WarningInFunction << "Ignoring mapping oriented field "
|
||||||
<< sFld.name() << " since of type " << sFld.type()
|
<< sFld.name() << " since of type " << sFld.type() << endl;
|
||||||
<< endl;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -141,36 +137,34 @@ void Foam::dynamicRefineFvMesh::mapNewInternalFaces
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
typedef GeometricField<T, fvsPatchField, surfaceMesh> GeoField;
|
typedef GeometricField<T, fvsPatchField, surfaceMesh> GeoField;
|
||||||
HashTable<GeoField*> sFlds(this->objectRegistry::lookupClass<GeoField>());
|
|
||||||
|
|
||||||
forAllIters(sFlds, iter)
|
typedef GeometricField
|
||||||
|
<
|
||||||
|
typename outerProduct<vector, T>::type,
|
||||||
|
fvsPatchField,
|
||||||
|
surfaceMesh
|
||||||
|
> NormalGeoField;
|
||||||
|
|
||||||
|
|
||||||
|
for (GeoField& sFld : this->objectRegistry::sorted<GeoField>())
|
||||||
{
|
{
|
||||||
//if (mapSurfaceFields_.found(iter.key()))
|
//if (mapSurfaceFields_.found(sFld.name()))
|
||||||
{
|
{
|
||||||
DebugInfo
|
DebugInfo
|
||||||
<< "dynamicRefineFvMesh::mapNewInternalFaces():"
|
<< "dynamicRefineFvMesh::mapNewInternalFaces():"
|
||||||
<< " Mapping new internal faces by interpolation on "
|
<< " Mapping new internal faces by interpolation on "
|
||||||
<< iter.key() << endl;
|
<< sFld.name() << endl;
|
||||||
|
|
||||||
GeoField& sFld = *iter();
|
|
||||||
|
|
||||||
if (sFld.is_oriented())
|
if (sFld.is_oriented())
|
||||||
{
|
{
|
||||||
DebugInfo
|
DebugInfo
|
||||||
<< "dynamicRefineFvMesh::mapNewInternalFaces(): "
|
<< "dynamicRefineFvMesh::mapNewInternalFaces(): "
|
||||||
<< "Converting oriented field " << iter.key()
|
<< "Converting oriented field " << sFld.name()
|
||||||
<< " to intensive field and mapping" << endl;
|
<< " to intensive field and mapping" << endl;
|
||||||
|
|
||||||
// Assume any oriented field is face area weighted (i.e. a flux)
|
// Assume any oriented field is face area weighted (i.e. a flux)
|
||||||
// Convert to intensive (& oriented) before mapping. Untested.
|
// Convert to intensive (& oriented) before mapping. Untested.
|
||||||
|
|
||||||
typedef GeometricField
|
|
||||||
<
|
|
||||||
typename outerProduct<vector, T>::type,
|
|
||||||
fvsPatchField,
|
|
||||||
surfaceMesh
|
|
||||||
> NormalGeoField;
|
|
||||||
|
|
||||||
// Convert to intensive and non oriented
|
// Convert to intensive and non oriented
|
||||||
NormalGeoField fFld(sFld*Sf/Foam::sqr(magSf));
|
NormalGeoField fFld(sFld*Sf/Foam::sqr(magSf));
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2015-2021 OpenCFD Ltd.
|
Copyright (C) 2015-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -272,14 +272,9 @@ void Foam::fvMeshAdder::MapVolFields
|
|||||||
{
|
{
|
||||||
typedef GeometricField<Type, fvPatchField, volMesh> fldType;
|
typedef GeometricField<Type, fvPatchField, volMesh> fldType;
|
||||||
|
|
||||||
HashTable<const fldType*> fields
|
const UPtrList<const fldType> fields
|
||||||
(
|
(
|
||||||
mesh.objectRegistry::lookupClass<fldType>()
|
mesh.objectRegistry::csorted<fldType>()
|
||||||
);
|
|
||||||
|
|
||||||
HashTable<const fldType*> fieldsToAdd
|
|
||||||
(
|
|
||||||
meshToAdd.objectRegistry::lookupClass<fldType>()
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// It is necessary to enforce that all old-time fields are stored
|
// It is necessary to enforce that all old-time fields are stored
|
||||||
@ -287,36 +282,35 @@ void Foam::fvMeshAdder::MapVolFields
|
|||||||
// old-time-level field is mapped before the field itself, sizes
|
// old-time-level field is mapped before the field itself, sizes
|
||||||
// will not match.
|
// will not match.
|
||||||
|
|
||||||
forAllIters(fields, fieldIter)
|
for (const auto& field : fields)
|
||||||
{
|
{
|
||||||
fldType& fld = const_cast<fldType&>(*fieldIter());
|
|
||||||
|
|
||||||
DebugPout
|
DebugPout
|
||||||
<< "MapVolFields : Storing old time for " << fld.name() << endl;
|
<< "MapVolFields : Storing old time for "
|
||||||
|
<< field.name() << endl;
|
||||||
|
|
||||||
fld.storeOldTimes();
|
const_cast<fldType&>(field).storeOldTimes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
forAllIters(fields, fieldIter)
|
for (const auto& field : fields)
|
||||||
{
|
{
|
||||||
fldType& fld = const_cast<fldType&>(*fieldIter());
|
fldType& fld = const_cast<fldType&>(field);
|
||||||
|
|
||||||
if (fieldsToAdd.found(fld.name()))
|
const auto* toAdd =
|
||||||
|
meshToAdd.objectRegistry::cfindObject<fldType>(field.name());
|
||||||
|
|
||||||
|
if (toAdd)
|
||||||
{
|
{
|
||||||
const fldType& fldToAdd = *fieldsToAdd[fld.name()];
|
|
||||||
|
|
||||||
DebugPout
|
DebugPout
|
||||||
<< "MapVolFields : mapping " << fld.name()
|
<< "MapVolFields : mapping " << field.name() << endl;
|
||||||
<< " and " << fldToAdd.name() << endl;
|
|
||||||
|
|
||||||
MapVolField<Type>(meshMap, fld, fldToAdd, fullyMapped);
|
MapVolField<Type>(meshMap, fld, *toAdd, fullyMapped);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WarningInFunction
|
WarningInFunction
|
||||||
<< "Not mapping field " << fld.name()
|
<< "Not mapping field " << field.name()
|
||||||
<< " since not present on mesh to add" << endl;
|
<< " - not present on mesh to add" << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -582,14 +576,9 @@ void Foam::fvMeshAdder::MapSurfaceFields
|
|||||||
{
|
{
|
||||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> fldType;
|
typedef GeometricField<Type, fvsPatchField, surfaceMesh> fldType;
|
||||||
|
|
||||||
HashTable<const fldType*> fields
|
const UPtrList<const fldType> fields
|
||||||
(
|
(
|
||||||
mesh.objectRegistry::lookupClass<fldType>()
|
mesh.objectRegistry::csorted<fldType>()
|
||||||
);
|
|
||||||
|
|
||||||
HashTable<const fldType*> fieldsToAdd
|
|
||||||
(
|
|
||||||
meshToAdd.objectRegistry::lookupClass<fldType>()
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// It is necessary to enforce that all old-time fields are stored
|
// It is necessary to enforce that all old-time fields are stored
|
||||||
@ -597,36 +586,34 @@ void Foam::fvMeshAdder::MapSurfaceFields
|
|||||||
// old-time-level field is mapped before the field itself, sizes
|
// old-time-level field is mapped before the field itself, sizes
|
||||||
// will not match.
|
// will not match.
|
||||||
|
|
||||||
forAllIters(fields, fieldIter)
|
for (const auto& field : fields)
|
||||||
{
|
{
|
||||||
fldType& fld = const_cast<fldType&>(*fieldIter());
|
|
||||||
|
|
||||||
DebugPout
|
DebugPout
|
||||||
<< "MapSurfaceFields : Storing old time for " << fld.name() << endl;
|
<< "MapSurfaceFields : Storing old time for "
|
||||||
|
<< field.name() << endl;
|
||||||
|
|
||||||
fld.storeOldTimes();
|
const_cast<fldType&>(field).storeOldTimes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const auto& field : fields)
|
||||||
forAllIters(fields, fieldIter)
|
|
||||||
{
|
{
|
||||||
fldType& fld = const_cast<fldType&>(*fieldIter());
|
fldType& fld = const_cast<fldType&>(field);
|
||||||
|
|
||||||
if (fieldsToAdd.found(fld.name()))
|
const auto* toAdd =
|
||||||
|
meshToAdd.objectRegistry::cfindObject<fldType>(field.name());
|
||||||
|
|
||||||
|
if (toAdd)
|
||||||
{
|
{
|
||||||
const fldType& fldToAdd = *fieldsToAdd[fld.name()];
|
|
||||||
|
|
||||||
DebugPout
|
DebugPout
|
||||||
<< "MapSurfaceFields : mapping " << fld.name()
|
<< "MapSurfaceFields : mapping " << field.name() << endl;
|
||||||
<< " and " << fldToAdd.name() << endl;
|
|
||||||
|
|
||||||
MapSurfaceField<Type>(meshMap, fld, fldToAdd, fullyMapped);
|
MapSurfaceField<Type>(meshMap, fld, *toAdd, fullyMapped);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WarningInFunction
|
WarningInFunction
|
||||||
<< "Not mapping field " << fld.name()
|
<< "Not mapping field " << field.name()
|
||||||
<< " since not present on mesh to add" << endl;
|
<< " - not present on mesh to add" << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -663,37 +650,32 @@ void Foam::fvMeshAdder::MapDimFields
|
|||||||
{
|
{
|
||||||
typedef DimensionedField<Type, volMesh> fldType;
|
typedef DimensionedField<Type, volMesh> fldType;
|
||||||
|
|
||||||
// Note: use strict flag on lookupClass to avoid picking up
|
// NB: strict=true to avoid picking up volFields
|
||||||
// volFields
|
const UPtrList<const fldType> fields
|
||||||
HashTable<const fldType*> fields
|
|
||||||
(
|
(
|
||||||
mesh.objectRegistry::lookupClass<fldType>(true)
|
mesh.objectRegistry::csorted<fldType, true>()
|
||||||
);
|
);
|
||||||
|
|
||||||
HashTable<const fldType*> fieldsToAdd
|
for (const auto& field : fields)
|
||||||
(
|
|
||||||
meshToAdd.objectRegistry::lookupClass<fldType>(true)
|
|
||||||
);
|
|
||||||
|
|
||||||
forAllIters(fields, fieldIter)
|
|
||||||
{
|
{
|
||||||
fldType& fld = const_cast<fldType&>(*fieldIter());
|
fldType& fld = const_cast<fldType&>(field);
|
||||||
|
|
||||||
if (fieldsToAdd.found(fld.name()))
|
const auto* toAdd =
|
||||||
|
meshToAdd.objectRegistry::cfindObject<fldType>(field.name());
|
||||||
|
|
||||||
|
// Apply strict check (to avoid picking volFields)
|
||||||
|
if (toAdd && Foam::isType<fldType>(*toAdd))
|
||||||
{
|
{
|
||||||
const fldType& fldToAdd = *fieldsToAdd[fld.name()];
|
|
||||||
|
|
||||||
DebugPout
|
DebugPout
|
||||||
<< "MapDimFields : mapping " << fld.name()
|
<< "MapDimFields : mapping " << field.name() << endl;
|
||||||
<< " and " << fldToAdd.name() << endl;
|
|
||||||
|
|
||||||
MapDimField<Type>(meshMap, fld, fldToAdd);
|
MapDimField<Type>(meshMap, fld, *toAdd);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WarningInFunction
|
WarningInFunction
|
||||||
<< "Not mapping field " << fld.name()
|
<< "Not mapping field " << field.name()
|
||||||
<< " since not present on mesh to add" << endl;
|
<< " - not present on mesh to add" << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1115,9 +1097,9 @@ void Foam::fvMeshAdder::MapVolFields
|
|||||||
}
|
}
|
||||||
const auto& mesh0 = meshes[0];
|
const auto& mesh0 = meshes[0];
|
||||||
|
|
||||||
HashTable<const fldType*> fields
|
const UPtrList<const fldType> fields
|
||||||
(
|
(
|
||||||
mesh0.objectRegistry::lookupClass<fldType>()
|
mesh0.objectRegistry::csorted<fldType>()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@ -1126,19 +1108,19 @@ void Foam::fvMeshAdder::MapVolFields
|
|||||||
// old-time-level field is mapped before the field itself, sizes
|
// old-time-level field is mapped before the field itself, sizes
|
||||||
// will not match.
|
// will not match.
|
||||||
|
|
||||||
for (const auto& fld : fields)
|
for (const auto& field : fields)
|
||||||
{
|
{
|
||||||
DebugPout
|
DebugPout
|
||||||
<< "MapVolFields : Storing old time for " << fld->name()
|
<< "MapVolFields : Storing old time for "
|
||||||
<< endl;
|
<< field.name() << endl;
|
||||||
|
|
||||||
const_cast<fldType&>(*fld).storeOldTimes();
|
const_cast<fldType&>(field).storeOldTimes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (const auto& fld : fields)
|
for (const auto& field : fields)
|
||||||
{
|
{
|
||||||
const word& name0 = fld->name();
|
const word& name0 = field.name();
|
||||||
|
|
||||||
DebugPout
|
DebugPout
|
||||||
<< "MapVolFields : mapping " << name0 << endl;
|
<< "MapVolFields : mapping " << name0 << endl;
|
||||||
@ -1177,7 +1159,6 @@ void Foam::fvMeshAdder::MapDimFields
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
typedef DimensionedField<Type, volMesh> fldType;
|
typedef DimensionedField<Type, volMesh> fldType;
|
||||||
typedef GeometricField<Type, fvPatchField, volMesh> excludeType;
|
|
||||||
|
|
||||||
if (!meshes.test(0))
|
if (!meshes.test(0))
|
||||||
{
|
{
|
||||||
@ -1188,39 +1169,31 @@ void Foam::fvMeshAdder::MapDimFields
|
|||||||
}
|
}
|
||||||
const auto& mesh0 = meshes[0];
|
const auto& mesh0 = meshes[0];
|
||||||
|
|
||||||
HashTable<const fldType*> fields
|
// NB: strict=true to avoid picking up volFields
|
||||||
|
const UPtrList<const fldType> fields
|
||||||
(
|
(
|
||||||
mesh0.objectRegistry::lookupClass<fldType>()
|
mesh0.objectRegistry::csorted<fldType, true>()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
for (const auto& field : fields)
|
||||||
for (const auto& fld : fields)
|
|
||||||
{
|
{
|
||||||
if (!isA<excludeType>(*fld))
|
const word& name0 = field.name();
|
||||||
|
|
||||||
|
DebugPout
|
||||||
|
<< "MapDimFields : mapping " << name0 << endl;
|
||||||
|
|
||||||
|
UPtrList<fldType> meshToField(meshes.size());
|
||||||
|
forAll(meshes, meshi)
|
||||||
{
|
{
|
||||||
const word& name0 = fld->name();
|
if (meshes.set(meshi))
|
||||||
|
|
||||||
DebugPout
|
|
||||||
<< "MapDimFields : mapping " << name0 << endl;
|
|
||||||
|
|
||||||
UPtrList<fldType> meshToField(meshes.size());
|
|
||||||
forAll(meshes, meshi)
|
|
||||||
{
|
{
|
||||||
if (meshes.set(meshi))
|
auto& meshFld = meshes[meshi].
|
||||||
{
|
objectRegistry::lookupObjectRef<fldType>(name0);
|
||||||
auto& meshFld = meshes[meshi].
|
meshToField.set(meshi, &meshFld);
|
||||||
objectRegistry::lookupObjectRef<fldType>(name0);
|
|
||||||
meshToField.set(meshi, &meshFld);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MapDimField(meshToField, cellProcAddressing, fullyMapped);
|
MapDimField(meshToField, cellProcAddressing, fullyMapped);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DebugPout
|
|
||||||
<< "MapDimFields : ignoring " << fld->name() << endl;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1250,9 +1223,9 @@ void Foam::fvMeshAdder::MapSurfaceFields
|
|||||||
}
|
}
|
||||||
const auto& mesh0 = meshes[0];
|
const auto& mesh0 = meshes[0];
|
||||||
|
|
||||||
HashTable<const fldType*> fields
|
const UPtrList<const fldType> fields
|
||||||
(
|
(
|
||||||
mesh0.objectRegistry::lookupClass<fldType>()
|
mesh0.objectRegistry::csorted<fldType>()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@ -1261,22 +1234,22 @@ void Foam::fvMeshAdder::MapSurfaceFields
|
|||||||
// old-time-level field is mapped before the field itself, sizes
|
// old-time-level field is mapped before the field itself, sizes
|
||||||
// will not match.
|
// will not match.
|
||||||
|
|
||||||
for (const auto& fld : fields)
|
for (const auto& field : fields)
|
||||||
{
|
{
|
||||||
DebugPout
|
DebugPout
|
||||||
<< "MapSurfaceFields : Storing old time for " << fld->name()
|
<< "MapSurfaceFields : Storing old time for "
|
||||||
<< endl;
|
<< field.name() << endl;
|
||||||
|
|
||||||
const_cast<fldType&>(*fld).storeOldTimes();
|
const_cast<fldType&>(field).storeOldTimes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (const auto& fld : fields)
|
for (const auto& field : fields)
|
||||||
{
|
{
|
||||||
const word& name0 = fld->name();
|
const word& name0 = field.name();
|
||||||
|
|
||||||
DebugPout
|
DebugPout
|
||||||
<< "MapSurfaceFields : Mapping " << fld->name() << endl;
|
<< "MapSurfaceFields : Mapping " << field.name() << endl;
|
||||||
|
|
||||||
UPtrList<fldType> meshToField(meshes.size());
|
UPtrList<fldType> meshToField(meshes.size());
|
||||||
forAll(meshes, meshi)
|
forAll(meshes, meshi)
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2015-2022 OpenCFD Ltd.
|
Copyright (C) 2015-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -87,18 +87,12 @@ void Foam::fvMeshDistribute::printIntFieldInfo(const fvMesh& mesh)
|
|||||||
volMesh
|
volMesh
|
||||||
> excludeType;
|
> excludeType;
|
||||||
|
|
||||||
const HashTable<const GeoField*> flds
|
for (const GeoField& field : mesh.objectRegistry::csorted<GeoField>())
|
||||||
(
|
|
||||||
mesh.objectRegistry::lookupClass<GeoField>()
|
|
||||||
);
|
|
||||||
|
|
||||||
forAllConstIters(flds, iter)
|
|
||||||
{
|
{
|
||||||
const GeoField& fld = *iter();
|
if (!isA<excludeType>(field))
|
||||||
if (!isA<excludeType>(fld))
|
|
||||||
{
|
{
|
||||||
Pout<< "Field:" << iter.key() << " internalsize:" << fld.size()
|
Pout<< "Field:" << field.name() << " size:" << field.size()
|
||||||
//<< " value:" << fld
|
//<< " value:" << field
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -108,20 +102,13 @@ void Foam::fvMeshDistribute::printIntFieldInfo(const fvMesh& mesh)
|
|||||||
template<class GeoField>
|
template<class GeoField>
|
||||||
void Foam::fvMeshDistribute::printFieldInfo(const fvMesh& mesh)
|
void Foam::fvMeshDistribute::printFieldInfo(const fvMesh& mesh)
|
||||||
{
|
{
|
||||||
const HashTable<const GeoField*> flds
|
for (const GeoField& field : mesh.objectRegistry::csorted<GeoField>())
|
||||||
(
|
|
||||||
mesh.objectRegistry::lookupClass<GeoField>()
|
|
||||||
);
|
|
||||||
|
|
||||||
forAllConstIters(flds, iter)
|
|
||||||
{
|
{
|
||||||
const GeoField& fld = *iter();
|
Pout<< "Field:" << field.name() << " size:" << field.size()
|
||||||
|
//<< " value:" << field
|
||||||
Pout<< "Field:" << iter.key() << " internalsize:" << fld.size()
|
|
||||||
//<< " value:" << fld
|
|
||||||
<< endl;
|
<< endl;
|
||||||
|
|
||||||
for (const auto& patchFld : fld.boundaryField())
|
for (const auto& patchFld : field.boundaryField())
|
||||||
{
|
{
|
||||||
Pout<< " " << patchFld.patch().index()
|
Pout<< " " << patchFld.patch().index()
|
||||||
<< ' ' << patchFld.patch().name()
|
<< ' ' << patchFld.patch().name()
|
||||||
@ -143,21 +130,19 @@ void Foam::fvMeshDistribute::saveBoundaryFields
|
|||||||
|
|
||||||
typedef GeometricField<T, fvsPatchField, Mesh> fldType;
|
typedef GeometricField<T, fvsPatchField, Mesh> fldType;
|
||||||
|
|
||||||
HashTable<const fldType*> flds
|
const UPtrList<const fldType> flds
|
||||||
(
|
(
|
||||||
mesh_.objectRegistry::lookupClass<const fldType>()
|
mesh_.objectRegistry::csorted<fldType>()
|
||||||
);
|
);
|
||||||
|
|
||||||
bflds.resize(flds.size());
|
bflds.resize_null(flds.size());
|
||||||
|
|
||||||
label i = 0;
|
label fieldi = 0;
|
||||||
forAllConstIters(flds, iter)
|
for (const fldType& fld : flds)
|
||||||
{
|
{
|
||||||
const fldType& fld = *iter();
|
bflds.set(fieldi, fld.boundaryField().clone());
|
||||||
|
|
||||||
bflds.set(i, fld.boundaryField().clone());
|
++fieldi;
|
||||||
|
|
||||||
++i;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,9 +161,9 @@ void Foam::fvMeshDistribute::mapBoundaryFields
|
|||||||
|
|
||||||
typedef GeometricField<T, fvsPatchField, Mesh> fldType;
|
typedef GeometricField<T, fvsPatchField, Mesh> fldType;
|
||||||
|
|
||||||
HashTable<fldType*> flds
|
UPtrList<fldType> flds
|
||||||
(
|
(
|
||||||
mesh_.objectRegistry::lookupClass<fldType>()
|
mesh_.objectRegistry::sorted<fldType>()
|
||||||
);
|
);
|
||||||
|
|
||||||
if (flds.size() != oldBflds.size())
|
if (flds.size() != oldBflds.size())
|
||||||
@ -187,14 +172,10 @@ void Foam::fvMeshDistribute::mapBoundaryFields
|
|||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
label fieldi = 0;
|
forAll(flds, fieldi)
|
||||||
|
|
||||||
forAllIters(flds, iter)
|
|
||||||
{
|
{
|
||||||
fldType& fld = *iter();
|
auto& bfld = flds[fieldi].boundaryFieldRef();
|
||||||
auto& bfld = fld.boundaryFieldRef();
|
const auto& oldBfld = oldBflds[fieldi];
|
||||||
|
|
||||||
const FieldField<fvsPatchField, T>& oldBfld = oldBflds[fieldi++];
|
|
||||||
|
|
||||||
// Pull from old boundary field into bfld.
|
// Pull from old boundary field into bfld.
|
||||||
|
|
||||||
@ -231,22 +212,16 @@ void Foam::fvMeshDistribute::saveInternalFields
|
|||||||
{
|
{
|
||||||
typedef GeometricField<T, fvsPatchField, surfaceMesh> fldType;
|
typedef GeometricField<T, fvsPatchField, surfaceMesh> fldType;
|
||||||
|
|
||||||
HashTable<const fldType*> flds
|
const UPtrList<const fldType> fields
|
||||||
(
|
(
|
||||||
mesh_.objectRegistry::lookupClass<const fldType>()
|
mesh_.objectRegistry::csorted<fldType>()
|
||||||
);
|
);
|
||||||
|
|
||||||
iflds.resize(flds.size());
|
iflds.resize_null(fields.size());
|
||||||
|
|
||||||
label i = 0;
|
forAll(fields, fieldi)
|
||||||
|
|
||||||
forAllConstIters(flds, iter)
|
|
||||||
{
|
{
|
||||||
const fldType& fld = *iter();
|
iflds.set(fieldi, fields[fieldi].primitiveField().clone());
|
||||||
|
|
||||||
iflds.set(i, fld.primitiveField().clone());
|
|
||||||
|
|
||||||
++i;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,9 +239,9 @@ void Foam::fvMeshDistribute::mapExposedFaces
|
|||||||
|
|
||||||
typedef GeometricField<T, fvsPatchField, surfaceMesh> fldType;
|
typedef GeometricField<T, fvsPatchField, surfaceMesh> fldType;
|
||||||
|
|
||||||
HashTable<fldType*> flds
|
UPtrList<fldType> flds
|
||||||
(
|
(
|
||||||
mesh_.objectRegistry::lookupClass<fldType>()
|
mesh_.objectRegistry::sorted<fldType>()
|
||||||
);
|
);
|
||||||
|
|
||||||
if (flds.size() != oldFlds.size())
|
if (flds.size() != oldFlds.size())
|
||||||
@ -277,16 +252,15 @@ void Foam::fvMeshDistribute::mapExposedFaces
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
label fieldI = 0;
|
forAll(flds, fieldi)
|
||||||
|
|
||||||
forAllIters(flds, iter)
|
|
||||||
{
|
{
|
||||||
fldType& fld = *iter();
|
auto& fld = flds[fieldi];
|
||||||
|
const auto& oldInternal = oldFlds[fieldi];
|
||||||
|
|
||||||
const bool oriented = fld.is_oriented();
|
const bool oriented = fld.is_oriented();
|
||||||
|
|
||||||
typename fldType::Boundary& bfld = fld.boundaryFieldRef();
|
auto& bfld = fld.boundaryFieldRef();
|
||||||
|
|
||||||
const Field<T>& oldInternal = oldFlds[fieldI++];
|
|
||||||
|
|
||||||
// Pull from old internal field into bfld.
|
// Pull from old internal field into bfld.
|
||||||
|
|
||||||
@ -322,16 +296,10 @@ void Foam::fvMeshDistribute::initPatchFields
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Init patch fields of certain type
|
// Init patch fields of certain type
|
||||||
|
// - field order is irrelevant
|
||||||
|
|
||||||
HashTable<GeoField*> flds
|
for (GeoField& fld : mesh_.objectRegistry::objects<GeoField>())
|
||||||
(
|
|
||||||
mesh_.objectRegistry::lookupClass<GeoField>()
|
|
||||||
);
|
|
||||||
|
|
||||||
forAllIters(flds, iter)
|
|
||||||
{
|
{
|
||||||
GeoField& fld = *iter();
|
|
||||||
|
|
||||||
auto& bfld = fld.boundaryFieldRef();
|
auto& bfld = fld.boundaryFieldRef();
|
||||||
|
|
||||||
forAll(bfld, patchi)
|
forAll(bfld, patchi)
|
||||||
@ -350,14 +318,8 @@ void Foam::fvMeshDistribute::initPatchFields
|
|||||||
//{
|
//{
|
||||||
// // CorrectBoundaryConditions patch fields of certain type
|
// // CorrectBoundaryConditions patch fields of certain type
|
||||||
//
|
//
|
||||||
// HashTable<GeoField*> flds
|
// for (GeoField& fld : mesh_.objectRegistry::sorted<GeoField>())
|
||||||
// (
|
|
||||||
// mesh_.objectRegistry::lookupClass<GeoField>()
|
|
||||||
// );
|
|
||||||
//
|
|
||||||
// forAllIters(flds, iter)
|
|
||||||
// {
|
// {
|
||||||
// GeoField& fld = *iter();
|
|
||||||
// fld.correctBoundaryConditions();
|
// fld.correctBoundaryConditions();
|
||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
@ -377,19 +339,23 @@ void Foam::fvMeshDistribute::getFieldNames
|
|||||||
|
|
||||||
if (!excludeType.empty())
|
if (!excludeType.empty())
|
||||||
{
|
{
|
||||||
const wordList& excludeList = allFieldNames(excludeType);
|
const wordList& excludeList =
|
||||||
|
allFieldNames.lookup(excludeType, wordList::null());
|
||||||
|
|
||||||
DynamicList<word> newList(list.size());
|
if (!excludeList.empty())
|
||||||
for(const auto& name : list)
|
|
||||||
{
|
{
|
||||||
if (!excludeList.found(name))
|
DynamicList<word> newList(list.size());
|
||||||
|
for (const auto& name : list)
|
||||||
{
|
{
|
||||||
newList.append(name);
|
if (!excludeList.contains(name))
|
||||||
|
{
|
||||||
|
newList.push_back(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (newList.size() < list.size())
|
||||||
|
{
|
||||||
|
list = std::move(newList);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (newList.size() < list.size())
|
|
||||||
{
|
|
||||||
list = std::move(newList);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -92,10 +92,11 @@ class polyMeshFilter
|
|||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
template<class T>
|
//- Update all sets of the given type
|
||||||
|
template<class SetType>
|
||||||
static void updateSets(const mapPolyMesh& map);
|
static void updateSets(const mapPolyMesh& map);
|
||||||
|
|
||||||
template<class T>
|
template<class SetType>
|
||||||
static void copySets(const polyMesh& oldMesh, const polyMesh& newMesh);
|
static void copySets(const polyMesh& oldMesh, const polyMesh& newMesh);
|
||||||
|
|
||||||
label filterFacesLoop(const label nOriginalBadFaces);
|
label filterFacesLoop(const label nOriginalBadFaces);
|
||||||
|
|||||||
@ -36,16 +36,26 @@ License
|
|||||||
template<class SetType>
|
template<class SetType>
|
||||||
void Foam::polyMeshFilter::updateSets(const mapPolyMesh& map)
|
void Foam::polyMeshFilter::updateSets(const mapPolyMesh& map)
|
||||||
{
|
{
|
||||||
HashTable<const SetType*> sets =
|
//
|
||||||
map.mesh().objectRegistry::lookupClass<const SetType>();
|
// Update all sets in memory
|
||||||
|
//
|
||||||
|
|
||||||
forAllIters(sets, iter)
|
const HashTable<const SetType*> sets
|
||||||
|
(
|
||||||
|
map.mesh().objectRegistry::lookupClass<const SetType>()
|
||||||
|
);
|
||||||
|
|
||||||
|
for (const auto& iter : sets.csorted())
|
||||||
{
|
{
|
||||||
SetType& set = const_cast<SetType&>(*iter());
|
SetType& set = const_cast<SetType&>(*iter.val());
|
||||||
set.updateMesh(map);
|
set.updateMesh(map);
|
||||||
set.sync(map.mesh());
|
set.sync(map.mesh());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Update all sets on disk
|
||||||
|
//
|
||||||
|
|
||||||
IOobjectList objs
|
IOobjectList objs
|
||||||
(
|
(
|
||||||
map.mesh().time(),
|
map.mesh().time(),
|
||||||
@ -53,14 +63,12 @@ void Foam::polyMeshFilter::updateSets(const mapPolyMesh& map)
|
|||||||
"polyMesh/sets"
|
"polyMesh/sets"
|
||||||
);
|
);
|
||||||
|
|
||||||
IOobjectList fileSets(objs.lookupClass<SetType>());
|
for (const IOobject& io : objs.csorted<SetType>())
|
||||||
|
|
||||||
forAllConstIters(fileSets, iter)
|
|
||||||
{
|
{
|
||||||
if (!sets.found(iter.key()))
|
if (!sets.contains(io.name()))
|
||||||
{
|
{
|
||||||
// Not in memory. Load it.
|
// Not in memory. Load it.
|
||||||
SetType set(*iter());
|
SetType set(io);
|
||||||
set.updateMesh(map);
|
set.updateMesh(map);
|
||||||
|
|
||||||
set.write();
|
set.write();
|
||||||
@ -76,13 +84,8 @@ void Foam::polyMeshFilter::copySets
|
|||||||
const polyMesh& newMesh
|
const polyMesh& newMesh
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
HashTable<const SetType*> sets =
|
for (const SetType& set : oldMesh.objectRegistry::csorted<SetType>())
|
||||||
oldMesh.objectRegistry::lookupClass<const SetType>();
|
|
||||||
|
|
||||||
forAllConstIters(sets, iter)
|
|
||||||
{
|
{
|
||||||
const SetType& set = *iter();
|
|
||||||
|
|
||||||
auto* setPtr =
|
auto* setPtr =
|
||||||
newMesh.objectRegistry::getObjectPtr<SetType>(set.name());
|
newMesh.objectRegistry::getObjectPtr<SetType>(set.name());
|
||||||
|
|
||||||
|
|||||||
@ -57,9 +57,9 @@ class setUpdater
|
|||||||
{
|
{
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
//- Updates all sets
|
//- Update all sets of the given type
|
||||||
template<class Type>
|
template<class SetType>
|
||||||
void updateSets(const mapPolyMesh& morphMap) const;
|
static void updateSets(const mapPolyMesh& map);
|
||||||
|
|
||||||
//- No copy construct
|
//- No copy construct
|
||||||
setUpdater(const setUpdater&) = delete;
|
setUpdater(const setUpdater&) = delete;
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011 OpenFOAM Foundation
|
Copyright (C) 2011 OpenFOAM Foundation
|
||||||
Copyright (C) 2019 OpenCFD Ltd.
|
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -32,27 +32,29 @@ License
|
|||||||
#include "mapPolyMesh.H"
|
#include "mapPolyMesh.H"
|
||||||
#include "IOobjectList.H"
|
#include "IOobjectList.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
template<class SetType>
|
||||||
void Foam::setUpdater::updateSets(const mapPolyMesh& morphMap) const
|
void Foam::setUpdater::updateSets(const mapPolyMesh& map)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Update all sets in memory.
|
// Update all sets in memory
|
||||||
//
|
//
|
||||||
|
|
||||||
HashTable<const Type*> memSets =
|
const HashTable<const SetType*> sets
|
||||||
morphMap.mesh().objectRegistry::lookupClass<Type>();
|
(
|
||||||
|
map.mesh().objectRegistry::lookupClass<const SetType>()
|
||||||
|
);
|
||||||
|
|
||||||
forAllIters(memSets, iter)
|
for (const auto& iter : sets.csorted())
|
||||||
{
|
{
|
||||||
Type& set = const_cast<Type&>(*iter());
|
SetType& set = const_cast<SetType&>(*iter.val());
|
||||||
|
|
||||||
DebugPout
|
DebugPout
|
||||||
<< "Set:" << set.name() << " size:" << set.size()
|
<< "Set:" << set.name() << " size:" << set.size()
|
||||||
<< " updated in memory" << endl;
|
<< " updated in memory" << endl;
|
||||||
|
|
||||||
set.updateMesh(morphMap);
|
set.updateMesh(map);
|
||||||
|
|
||||||
// Write or not? Debatable.
|
// Write or not? Debatable.
|
||||||
set.write();
|
set.write();
|
||||||
@ -66,35 +68,30 @@ void Foam::setUpdater::updateSets(const mapPolyMesh& morphMap) const
|
|||||||
// Get last valid mesh (discard points-only change)
|
// Get last valid mesh (discard points-only change)
|
||||||
IOobjectList objs
|
IOobjectList objs
|
||||||
(
|
(
|
||||||
morphMap.mesh().time(),
|
map.mesh().time(),
|
||||||
morphMap.mesh().facesInstance(),
|
map.mesh().facesInstance(),
|
||||||
"polyMesh/sets"
|
"polyMesh/sets"
|
||||||
);
|
);
|
||||||
|
|
||||||
IOobjectList fileSets(objs.lookupClass<Type>());
|
for (const IOobject& io : objs.csorted<SetType>())
|
||||||
|
|
||||||
forAllConstIters(fileSets, iter)
|
|
||||||
{
|
{
|
||||||
if (!memSets.found(iter.key()))
|
if (!sets.contains(io.name()))
|
||||||
{
|
{
|
||||||
// Not in memory. Load it.
|
// Not in memory. Load it.
|
||||||
Type set(*iter());
|
SetType set(io);
|
||||||
|
|
||||||
if (debug)
|
DebugPout
|
||||||
{
|
<< "Set:" << set.name() << " size:" << set.size()
|
||||||
Pout<< "Set:" << set.name() << " size:" << set.size()
|
<< " updated on disk" << endl;
|
||||||
<< " updated on disk" << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
set.updateMesh(morphMap);
|
|
||||||
|
|
||||||
|
set.updateMesh(map);
|
||||||
set.write();
|
set.write();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DebugPout
|
DebugPout
|
||||||
<< "Set:" << iter.key() << " already updated from memory"
|
<< "Set:" << io.name()
|
||||||
<< endl;
|
<< " already updated from memory" << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2012 OpenFOAM Foundation
|
Copyright (C) 2012 OpenFOAM Foundation
|
||||||
Copyright (C) 2021 OpenCFD Ltd.
|
Copyright (C) 2021-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -33,20 +33,18 @@ License
|
|||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::vtkUnstructuredReader::printFieldStats(const objectRegistry& obj)
|
void Foam::vtkUnstructuredReader::printFieldStats(const objectRegistry& obj)
|
||||||
{
|
{
|
||||||
const wordList fieldNames(obj.sortedNames<Type>());
|
const UPtrList<const Type> fields(obj.csorted<Type>());
|
||||||
|
|
||||||
if (fieldNames.size())
|
if (!fields.empty())
|
||||||
{
|
{
|
||||||
Info<< "Read " << fieldNames.size() << ' ' << Type::typeName
|
Info<< "Read " << fields.size() << ' ' << Type::typeName
|
||||||
<< " fields:" << nl
|
<< " fields:" << nl
|
||||||
<< "Size\tName" << nl
|
<< "Size\tName" << nl
|
||||||
<< "----\t----" << nl;
|
<< "----\t----" << nl;
|
||||||
|
|
||||||
for (const word& fieldName : fieldNames)
|
for (const Type& field : fields)
|
||||||
{
|
{
|
||||||
Info<< obj.lookupObject<Type>(fieldName).size()
|
Info<< field.size() << '\t' << field.name() << nl;
|
||||||
<< '\t' << fieldName
|
|
||||||
<< nl;
|
|
||||||
}
|
}
|
||||||
Info<< endl;
|
Info<< endl;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -310,8 +310,8 @@ Foam::label Foam::faMeshDistributor::distributeAreaFields
|
|||||||
const IOobject& io :
|
const IOobject& io :
|
||||||
(
|
(
|
||||||
selectedFields.empty()
|
selectedFields.empty()
|
||||||
? objects.sorted<fieldType>()
|
? objects.csorted<fieldType>()
|
||||||
: objects.sorted<fieldType>(selectedFields)
|
: objects.csorted<fieldType>(selectedFields)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -368,8 +368,8 @@ Foam::label Foam::faMeshDistributor::distributeEdgeFields
|
|||||||
const IOobject& io :
|
const IOobject& io :
|
||||||
(
|
(
|
||||||
selectedFields.empty()
|
selectedFields.empty()
|
||||||
? objects.sorted<fieldType>()
|
? objects.csorted<fieldType>()
|
||||||
: objects.sorted<fieldType>(selectedFields)
|
: objects.csorted<fieldType>(selectedFields)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -101,14 +101,16 @@ bool Foam::loopControl::checkConverged() const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
HashTable<const fvMesh*> meshes = time_.lookupClass<const fvMesh>();
|
|
||||||
|
|
||||||
bool achieved = true;
|
bool achieved = true;
|
||||||
bool checked = false; // safety that some checks were indeed performed
|
bool checked = false; // safety that some checks were indeed performed
|
||||||
|
|
||||||
forAllConstIters(meshes, meshIter)
|
const objectRegistry& obr = time_;
|
||||||
|
|
||||||
|
forAllConstIters(obr, iter)
|
||||||
{
|
{
|
||||||
const fvMesh& regionMesh = *(meshIter.val());
|
const fvMesh* meshPtr = dynamic_cast<const fvMesh*>(iter.val());
|
||||||
|
if (!meshPtr) continue;
|
||||||
|
const fvMesh& regionMesh = *meshPtr;
|
||||||
|
|
||||||
const dictionary& solverDict = regionMesh.solverPerformanceDict();
|
const dictionary& solverDict = regionMesh.solverPerformanceDict();
|
||||||
for (const entry& dataDictEntry : solverDict)
|
for (const entry& dataDictEntry : solverDict)
|
||||||
|
|||||||
@ -37,12 +37,8 @@ void Foam::solutionControl::storePrevIter() const
|
|||||||
{
|
{
|
||||||
typedef GeometricField<Type, fvPatchField, volMesh> GeoField;
|
typedef GeometricField<Type, fvPatchField, volMesh> GeoField;
|
||||||
|
|
||||||
HashTable<GeoField*> flds(mesh_.objectRegistry::lookupClass<GeoField>());
|
for (GeoField& fld : mesh_.objectRegistry::sorted<GeoField>())
|
||||||
|
|
||||||
forAllIters(flds, iter)
|
|
||||||
{
|
{
|
||||||
GeoField& fld = *iter();
|
|
||||||
|
|
||||||
const word& fldName = fld.name();
|
const word& fldName = fld.name();
|
||||||
|
|
||||||
if (!fldName.contains("PrevIter") && mesh_.relaxField(fldName))
|
if (!fldName.contains("PrevIter") && mesh_.relaxField(fldName))
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -32,8 +32,8 @@ Description
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef functionObjects_fieldInfo_H
|
#ifndef Foam_functionObjects_fieldInfo_H
|
||||||
#define functionObjects_fieldInfo_H
|
#define Foam_functionObjects_fieldInfo_H
|
||||||
|
|
||||||
#include "label.H"
|
#include "label.H"
|
||||||
#include "wordRes.H"
|
#include "wordRes.H"
|
||||||
@ -57,7 +57,7 @@ Ostream& operator<<(Ostream&, const fieldInfo&);
|
|||||||
|
|
||||||
class fieldInfo
|
class fieldInfo
|
||||||
{
|
{
|
||||||
// Pivate Data
|
// Private Data
|
||||||
|
|
||||||
//- Pattern for the field name(s)
|
//- Pattern for the field name(s)
|
||||||
wordRe name_;
|
wordRe name_;
|
||||||
@ -65,8 +65,8 @@ class fieldInfo
|
|||||||
//- Field component
|
//- Field component
|
||||||
label component_;
|
label component_;
|
||||||
|
|
||||||
//- Found
|
//- Found the field
|
||||||
mutable Switch found_;
|
mutable bool found_;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -81,9 +81,8 @@ public:
|
|||||||
found_(false)
|
found_(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
//- Construct from components
|
//- Construct from components
|
||||||
fieldInfo(const wordRe& name, const label component = -1)
|
explicit fieldInfo(const wordRe& name, const label component = -1)
|
||||||
:
|
:
|
||||||
name_(name),
|
name_(name),
|
||||||
component_(component),
|
component_(component),
|
||||||
@ -91,7 +90,7 @@ public:
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
//- Construct from stream
|
//- Construct from stream
|
||||||
fieldInfo(Istream& is)
|
explicit fieldInfo(Istream& is)
|
||||||
:
|
:
|
||||||
name_(is),
|
name_(is),
|
||||||
component_(readLabel(is)),
|
component_(readLabel(is)),
|
||||||
@ -105,27 +104,27 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
const wordRe& name() const
|
//- Return the selector pattern for the field name(s)
|
||||||
{
|
const wordRe& name() const noexcept { return name_; }
|
||||||
return name_;
|
|
||||||
}
|
|
||||||
|
|
||||||
label component() const
|
//- Return the component
|
||||||
{
|
label component() const noexcept { return component_; }
|
||||||
return component_;
|
|
||||||
}
|
//- Return the found state
|
||||||
|
bool found() const noexcept { return found_; }
|
||||||
|
|
||||||
|
//- Set the found state to be 'on'
|
||||||
|
void found(bool on) const noexcept { found_ = on; }
|
||||||
|
|
||||||
Switch& found() const
|
|
||||||
{
|
|
||||||
return found_;
|
|
||||||
}
|
|
||||||
|
|
||||||
friend bool operator==(const fieldInfo& a, const fieldInfo& b)
|
friend bool operator==(const fieldInfo& a, const fieldInfo& b)
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
a.name_ == b.name_
|
(
|
||||||
&& a.component_ == b.component_
|
a.found() == b.found()
|
||||||
&& a.found_ == b.found_;
|
&& a.component() == b.component()
|
||||||
|
&& a.name() == b.name()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
friend bool operator!=(const fieldInfo& a, const fieldInfo& b)
|
friend bool operator!=(const fieldInfo& a, const fieldInfo& b)
|
||||||
@ -143,7 +142,9 @@ public:
|
|||||||
}
|
}
|
||||||
friend Ostream& operator<<(Ostream& os, const fieldInfo& fi)
|
friend Ostream& operator<<(Ostream& os, const fieldInfo& fi)
|
||||||
{
|
{
|
||||||
os << fi.name_ << ' ' << fi.component_ << ' ' << fi.found_;
|
os << fi.name_ << ' '
|
||||||
|
<< fi.component_ << ' '
|
||||||
|
<< Switch::name(fi.found_);
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -37,27 +37,28 @@ Foam::functionObjects::fieldSelection::fieldSelection
|
|||||||
const bool includeComponents
|
const bool includeComponents
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
List<fieldInfo>(),
|
|
||||||
obr_(obr),
|
obr_(obr),
|
||||||
includeComponents_(includeComponents),
|
includeComponents_(includeComponents)
|
||||||
selection_()
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::functionObjects::fieldSelection::resetFieldFilters
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Container>
|
||||||
|
bool Foam::functionObjects::fieldSelection::resetFieldFiltersImpl
|
||||||
(
|
(
|
||||||
const HashSet<wordRe>& names
|
const Container& names
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
static word cmptStr(".component(");
|
static std::string cmptStr(".component(");
|
||||||
static string::size_type len(cmptStr.size());
|
static std::string::size_type len(cmptStr.size());
|
||||||
|
|
||||||
DynamicList<fieldInfo> nameAndComponent(names.size());
|
DynamicList<fieldInfo> nameAndComponent(names.size());
|
||||||
|
|
||||||
for (const wordRe& name : names)
|
for (const wordRe& name : names)
|
||||||
{
|
{
|
||||||
string::size_type n = name.find(cmptStr);
|
const auto n = name.find(cmptStr);
|
||||||
if (n != string::npos)
|
if (n != std::string::npos)
|
||||||
{
|
{
|
||||||
// Field should be written <field>.component(i)
|
// Field should be written <field>.component(i)
|
||||||
|
|
||||||
@ -76,12 +77,12 @@ bool Foam::functionObjects::fieldSelection::resetFieldFilters
|
|||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
word baseName = name.substr(0, n);
|
const word baseName(name.substr(0, n));
|
||||||
|
|
||||||
// Extract the component - number between ()'s
|
// Extract the component - number between ()'s
|
||||||
string::size_type closei = name.find(')', n);
|
const auto closei = name.find(')', n);
|
||||||
|
|
||||||
if (closei == string::npos)
|
if (closei == std::string::npos)
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Invalid field component specification for "
|
<< "Invalid field component specification for "
|
||||||
@ -90,18 +91,18 @@ bool Foam::functionObjects::fieldSelection::resetFieldFilters
|
|||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
string::size_type cmptWidth = closei - n - len;
|
const auto cmptWidth = (closei - n - len);
|
||||||
|
|
||||||
label component
|
label component
|
||||||
(
|
(
|
||||||
readLabel(IStringStream(name.substr(n+len, cmptWidth))())
|
readLabel(name.substr(n+len, cmptWidth))
|
||||||
);
|
);
|
||||||
|
|
||||||
nameAndComponent.append(fieldInfo(wordRe(baseName), component));
|
nameAndComponent.emplace_back(wordRe(baseName), component);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nameAndComponent.append(fieldInfo(name));
|
nameAndComponent.emplace_back(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,12 +112,23 @@ bool Foam::functionObjects::fieldSelection::resetFieldFilters
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::functionObjects::fieldSelection::resetFieldFilters
|
||||||
|
(
|
||||||
|
const HashSet<wordRe>& names
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return resetFieldFiltersImpl(names);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::functionObjects::fieldSelection::resetFieldFilters
|
bool Foam::functionObjects::fieldSelection::resetFieldFilters
|
||||||
(
|
(
|
||||||
const wordRe& name
|
const wordRe& name
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return resetFieldFilters(HashSet<wordRe>({name}));
|
List<wordRe> names(1, name);
|
||||||
|
|
||||||
|
return resetFieldFiltersImpl(names);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -124,7 +136,8 @@ bool Foam::functionObjects::fieldSelection::resetFieldFilters
|
|||||||
|
|
||||||
bool Foam::functionObjects::fieldSelection::read(const dictionary& dict)
|
bool Foam::functionObjects::fieldSelection::read(const dictionary& dict)
|
||||||
{
|
{
|
||||||
HashSet<wordRe> fields(dict.lookup("fields"));
|
HashSet<wordRe> fields(0);
|
||||||
|
dict.readEntry("fields", fields);
|
||||||
|
|
||||||
return resetFieldFilters(fields);
|
return resetFieldFilters(fields);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,8 +39,8 @@ SourceFiles
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef functionObjects_fieldSelection_H
|
#ifndef Foam_functionObjects_fieldSelection_H
|
||||||
#define functionObjects_fieldSelection_H
|
#define Foam_functionObjects_fieldSelection_H
|
||||||
|
|
||||||
#include "fieldInfo.H"
|
#include "fieldInfo.H"
|
||||||
#include "DynamicList.H"
|
#include "DynamicList.H"
|
||||||
@ -51,6 +51,7 @@ SourceFiles
|
|||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
class dictionary;
|
class dictionary;
|
||||||
class objectRegistry;
|
class objectRegistry;
|
||||||
|
|
||||||
@ -65,17 +66,19 @@ class fieldSelection
|
|||||||
:
|
:
|
||||||
public List<fieldInfo>
|
public List<fieldInfo>
|
||||||
{
|
{
|
||||||
private:
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Reset the field filters to the given field names
|
||||||
|
template<class Container>
|
||||||
|
bool resetFieldFiltersImpl(const Container& names);
|
||||||
|
|
||||||
//- No copy construct
|
//- No copy construct
|
||||||
fieldSelection(const fieldSelection&) = delete;
|
fieldSelection(const fieldSelection&) = delete;
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// Protected member data
|
// Protected Member Data
|
||||||
|
|
||||||
//- Reference to the database
|
//- Reference to the database
|
||||||
const objectRegistry& obr_;
|
const objectRegistry& obr_;
|
||||||
@ -97,7 +100,7 @@ protected:
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
//- Construct from object registry
|
//- Construct from object registry
|
||||||
fieldSelection
|
explicit fieldSelection
|
||||||
(
|
(
|
||||||
const objectRegistry& obr,
|
const objectRegistry& obr,
|
||||||
const bool includeComponents = false
|
const bool includeComponents = false
|
||||||
@ -110,13 +113,17 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- Return the cuurent filters
|
//- The current field selection
|
||||||
|
const List<fieldInfo>& selection() const noexcept
|
||||||
|
{
|
||||||
|
return selection_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Return the current filters
|
||||||
inline HashSet<wordRe> filters() const;
|
inline HashSet<wordRe> filters() const;
|
||||||
|
|
||||||
inline const List<fieldInfo>& selection() const;
|
//- Return the current field selection, in sorted order
|
||||||
|
inline wordList selectionNames() const;
|
||||||
//- Return the current field selection
|
|
||||||
inline wordHashSet selectionNames() const;
|
|
||||||
|
|
||||||
//- Reset the field filters to the given field names
|
//- Reset the field filters to the given field names
|
||||||
virtual bool resetFieldFilters(const HashSet<wordRe>& names);
|
virtual bool resetFieldFilters(const HashSet<wordRe>& names);
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -25,36 +25,34 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
inline Foam::HashSet<Foam::wordRe>
|
inline Foam::HashSet<Foam::wordRe>
|
||||||
Foam::functionObjects::fieldSelection::filters() const
|
Foam::functionObjects::fieldSelection::filters() const
|
||||||
{
|
{
|
||||||
HashSet<wordRe> f;
|
HashSet<wordRe> values(2*this->size());
|
||||||
for (const fieldInfo& fi : *this)
|
for (const fieldInfo& fi : *this)
|
||||||
{
|
{
|
||||||
f.insert(fi.name());
|
values.insert(fi.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
return f;
|
return values;
|
||||||
}
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
|
|
||||||
|
|
||||||
inline const Foam::List<Foam::functionObjects::fieldInfo>&
|
|
||||||
Foam::functionObjects::fieldSelection::selection() const
|
|
||||||
{
|
|
||||||
return selection_;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Foam::wordHashSet
|
inline Foam::wordList
|
||||||
Foam::functionObjects::fieldSelection::selectionNames() const
|
Foam::functionObjects::fieldSelection::selectionNames() const
|
||||||
{
|
{
|
||||||
wordHashSet names;
|
DynamicList<word> values(selection_.size());
|
||||||
|
|
||||||
for (const fieldInfo& fi : selection_)
|
for (const fieldInfo& fi : selection_)
|
||||||
{
|
{
|
||||||
names.insert(fi.name());
|
values.push_uniq(fi.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wordList names(std::move(values));
|
||||||
|
Foam::sort(names); // Globally consistent order
|
||||||
|
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2017-2019 OpenCFD Ltd.
|
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -37,15 +37,14 @@ void Foam::functionObjects::fieldSelection::addRegistered
|
|||||||
{
|
{
|
||||||
for (const fieldInfo& fi : *this)
|
for (const fieldInfo& fi : *this)
|
||||||
{
|
{
|
||||||
wordList names(obr_.names<Type>(fi.name()));
|
const wordList names(obr_.sortedNames<Type>(fi.name()));
|
||||||
if (names.size())
|
if (!names.empty())
|
||||||
{
|
{
|
||||||
for (const word& name : names)
|
fi.found(true);
|
||||||
{
|
}
|
||||||
set.append(fieldInfo(wordRe(name), fi.component()));
|
for (const word& name : names)
|
||||||
}
|
{
|
||||||
|
set.emplace_back(wordRe(name), fi.component());
|
||||||
fi.found() = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -51,14 +51,13 @@ void Foam::functionObjects::fileFieldSelection::addFromFile
|
|||||||
{
|
{
|
||||||
const wordList names(objects.sortedNames<Type>(fi.name()));
|
const wordList names(objects.sortedNames<Type>(fi.name()));
|
||||||
|
|
||||||
if (names.size())
|
if (!names.empty())
|
||||||
{
|
{
|
||||||
for (const word& name : names)
|
fi.found(true);
|
||||||
{
|
}
|
||||||
set.append(fieldInfo(wordRe(name)));
|
for (const word& name : names)
|
||||||
}
|
{
|
||||||
|
set.emplace_back(wordRe(name));
|
||||||
fi.found() = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,8 +34,8 @@ SourceFiles
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef functionObjects_fileFieldSelection_H
|
#ifndef Foam_functionObjects_fileFieldSelection_H
|
||||||
#define functionObjects_fileFieldSelection_H
|
#define Foam_functionObjects_fileFieldSelection_H
|
||||||
|
|
||||||
#include "fieldSelection.H"
|
#include "fieldSelection.H"
|
||||||
|
|
||||||
@ -91,12 +91,12 @@ class fileFieldSelection
|
|||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
//- No copy construct
|
|
||||||
fileFieldSelection(const fileFieldSelection&) = delete;
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
//- No copy construct
|
||||||
|
fileFieldSelection(const fileFieldSelection&) = delete;
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from object registry
|
//- Construct from object registry
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2017 OpenCFD Ltd.
|
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -69,11 +69,8 @@ bool Foam::functionObjects::solverFieldSelection::updateSelection()
|
|||||||
{
|
{
|
||||||
if (fi.name().match(solvedField))
|
if (fi.name().match(solvedField))
|
||||||
{
|
{
|
||||||
newSelection.append
|
fi.found(true);
|
||||||
(
|
newSelection.emplace_back(wordRe(solvedField), fi.component());
|
||||||
fieldInfo(wordRe(solvedField), fi.component())
|
|
||||||
);
|
|
||||||
fi.found() = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2017-2019 OpenCFD Ltd.
|
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -34,8 +34,8 @@ SourceFiles
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef functionObjects_solverFieldSelection_H
|
#ifndef Foam_functionObjects_solverFieldSelection_H
|
||||||
#define functionObjects_solverFieldSelection_H
|
#define Foam_functionObjects_solverFieldSelection_H
|
||||||
|
|
||||||
#include "fieldSelection.H"
|
#include "fieldSelection.H"
|
||||||
|
|
||||||
@ -54,18 +54,14 @@ class solverFieldSelection
|
|||||||
:
|
:
|
||||||
public fieldSelection
|
public fieldSelection
|
||||||
{
|
{
|
||||||
private:
|
|
||||||
|
|
||||||
// Private Member Functions
|
|
||||||
|
|
||||||
//- No copy construct
|
|
||||||
solverFieldSelection(const solverFieldSelection&) = delete;
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
//- No copy construct
|
||||||
|
solverFieldSelection(const solverFieldSelection&) = delete;
|
||||||
|
|
||||||
|
|
||||||
//- Construct from object registry
|
//- Construct from object registry
|
||||||
solverFieldSelection
|
explicit solverFieldSelection
|
||||||
(
|
(
|
||||||
const objectRegistry& obr,
|
const objectRegistry& obr,
|
||||||
const bool includeComponents = false
|
const bool includeComponents = false
|
||||||
|
|||||||
@ -34,8 +34,8 @@ SourceFiles
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef functionObjects_volFieldSelection_H
|
#ifndef Foam_functionObjects_volFieldSelection_H
|
||||||
#define functionObjects_volFieldSelection_H
|
#define Foam_functionObjects_volFieldSelection_H
|
||||||
|
|
||||||
#include "fieldSelection.H"
|
#include "fieldSelection.H"
|
||||||
|
|
||||||
@ -54,14 +54,6 @@ class volFieldSelection
|
|||||||
:
|
:
|
||||||
public fieldSelection
|
public fieldSelection
|
||||||
{
|
{
|
||||||
private:
|
|
||||||
|
|
||||||
// Private Member Functions
|
|
||||||
|
|
||||||
//- No copy construct
|
|
||||||
volFieldSelection(const volFieldSelection&) = delete;
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// Protected Member Functions
|
// Protected Member Functions
|
||||||
@ -73,8 +65,12 @@ protected:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
//- No copy construct
|
||||||
|
volFieldSelection(const volFieldSelection&) = delete;
|
||||||
|
|
||||||
|
|
||||||
//- Construct from object registry
|
//- Construct from object registry
|
||||||
volFieldSelection
|
explicit volFieldSelection
|
||||||
(
|
(
|
||||||
const objectRegistry& obr,
|
const objectRegistry& obr,
|
||||||
const bool includeComponents = false
|
const bool includeComponents = false
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2012-2016 OpenFOAM Foundation
|
Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -41,14 +41,8 @@ void Foam::fvMeshTools::addPatchFields
|
|||||||
const typename GeoField::value_type& defaultPatchValue
|
const typename GeoField::value_type& defaultPatchValue
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
HashTable<GeoField*> flds
|
for (GeoField& fld : mesh.objectRegistry::sorted<GeoField>())
|
||||||
(
|
|
||||||
mesh.objectRegistry::lookupClass<GeoField>()
|
|
||||||
);
|
|
||||||
|
|
||||||
forAllIters(flds, iter)
|
|
||||||
{
|
{
|
||||||
GeoField& fld = *iter.val();
|
|
||||||
auto& bfld = fld.boundaryFieldRef();
|
auto& bfld = fld.boundaryFieldRef();
|
||||||
|
|
||||||
const label newPatchi = bfld.size();
|
const label newPatchi = bfld.size();
|
||||||
@ -95,14 +89,8 @@ void Foam::fvMeshTools::setPatchFields
|
|||||||
const dictionary& patchFieldDict
|
const dictionary& patchFieldDict
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
HashTable<GeoField*> flds
|
for (GeoField& fld : mesh.objectRegistry::sorted<GeoField>())
|
||||||
(
|
|
||||||
mesh.objectRegistry::lookupClass<GeoField>()
|
|
||||||
);
|
|
||||||
|
|
||||||
forAllIters(flds, iter)
|
|
||||||
{
|
{
|
||||||
GeoField& fld = *iter.val();
|
|
||||||
auto& bfld = fld.boundaryFieldRef();
|
auto& bfld = fld.boundaryFieldRef();
|
||||||
|
|
||||||
const dictionary* dict = patchFieldDict.findDict(fld.name());
|
const dictionary* dict = patchFieldDict.findDict(fld.name());
|
||||||
@ -132,14 +120,8 @@ void Foam::fvMeshTools::setPatchFields
|
|||||||
const typename GeoField::value_type& value
|
const typename GeoField::value_type& value
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
HashTable<GeoField*> flds
|
for (GeoField& fld : mesh.objectRegistry::sorted<GeoField>())
|
||||||
(
|
|
||||||
mesh.objectRegistry::lookupClass<GeoField>()
|
|
||||||
);
|
|
||||||
|
|
||||||
forAllIters(flds, iter)
|
|
||||||
{
|
{
|
||||||
GeoField& fld = *iter.val();
|
|
||||||
auto& bfld = fld.boundaryFieldRef();
|
auto& bfld = fld.boundaryFieldRef();
|
||||||
|
|
||||||
bfld[patchi] == value;
|
bfld[patchi] == value;
|
||||||
@ -151,15 +133,11 @@ void Foam::fvMeshTools::setPatchFields
|
|||||||
template<class GeoField>
|
template<class GeoField>
|
||||||
void Foam::fvMeshTools::trimPatchFields(fvMesh& mesh, const label nPatches)
|
void Foam::fvMeshTools::trimPatchFields(fvMesh& mesh, const label nPatches)
|
||||||
{
|
{
|
||||||
HashTable<GeoField*> flds
|
for (GeoField& fld : mesh.objectRegistry::sorted<GeoField>())
|
||||||
(
|
|
||||||
mesh.objectRegistry::lookupClass<GeoField>()
|
|
||||||
);
|
|
||||||
|
|
||||||
forAllIters(flds, iter)
|
|
||||||
{
|
{
|
||||||
GeoField& fld = *iter.val();
|
auto& bfld = fld.boundaryFieldRef();
|
||||||
fld.boundaryFieldRef().resize(nPatches);
|
|
||||||
|
bfld.resize(nPatches);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,14 +150,8 @@ void Foam::fvMeshTools::reorderPatchFields
|
|||||||
const labelList& oldToNew
|
const labelList& oldToNew
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
HashTable<GeoField*> flds
|
for (GeoField& fld : mesh.objectRegistry::sorted<GeoField>())
|
||||||
(
|
|
||||||
mesh.objectRegistry::lookupClass<GeoField>()
|
|
||||||
);
|
|
||||||
|
|
||||||
forAllIters(flds, iter)
|
|
||||||
{
|
{
|
||||||
GeoField& fld = *iter.val();
|
|
||||||
auto& bfld = fld.boundaryFieldRef();
|
auto& bfld = fld.boundaryFieldRef();
|
||||||
|
|
||||||
bfld.reorder(oldToNew);
|
bfld.reorder(oldToNew);
|
||||||
|
|||||||
@ -63,7 +63,6 @@ Foam::functionObjects::Curle::Curle
|
|||||||
fvMeshFunctionObject(name, runTime, dict),
|
fvMeshFunctionObject(name, runTime, dict),
|
||||||
writeFile(mesh_, name),
|
writeFile(mesh_, name),
|
||||||
pName_("p"),
|
pName_("p"),
|
||||||
patchSet_(),
|
|
||||||
observerPositions_(),
|
observerPositions_(),
|
||||||
c0_(0),
|
c0_(0),
|
||||||
rawFilePtrs_(),
|
rawFilePtrs_(),
|
||||||
@ -78,6 +77,8 @@ Foam::functionObjects::Curle::Curle
|
|||||||
|
|
||||||
bool Foam::functionObjects::Curle::read(const dictionary& dict)
|
bool Foam::functionObjects::Curle::read(const dictionary& dict)
|
||||||
{
|
{
|
||||||
|
const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
|
||||||
|
|
||||||
if (!(fvMeshFunctionObject::read(dict) && writeFile::read(dict)))
|
if (!(fvMeshFunctionObject::read(dict) && writeFile::read(dict)))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@ -85,14 +86,12 @@ bool Foam::functionObjects::Curle::read(const dictionary& dict)
|
|||||||
|
|
||||||
dict.readIfPresent("p", pName_);
|
dict.readIfPresent("p", pName_);
|
||||||
|
|
||||||
patchSet_ = mesh_.boundaryMesh().patchSet(dict.get<wordRes>("patches"));
|
patchIDs_ = pbm.patchSet(dict.get<wordRes>("patches")).sortedToc();
|
||||||
|
|
||||||
if (patchSet_.empty())
|
if (patchIDs_.empty())
|
||||||
{
|
{
|
||||||
WarningInFunction
|
WarningInFunction
|
||||||
<< "No patches defined"
|
<< "No patches defined" << endl;
|
||||||
<< endl;
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,8 +116,7 @@ bool Foam::functionObjects::Curle::read(const dictionary& dict)
|
|||||||
if (observerPositions_.empty())
|
if (observerPositions_.empty())
|
||||||
{
|
{
|
||||||
WarningInFunction
|
WarningInFunction
|
||||||
<< "No observer positions defined"
|
<< "No observer positions defined" << endl;
|
||||||
<< endl;
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -205,7 +203,7 @@ bool Foam::functionObjects::Curle::execute()
|
|||||||
|
|
||||||
scalarField pDash(observerPositions_.size(), 0);
|
scalarField pDash(observerPositions_.size(), 0);
|
||||||
|
|
||||||
for (auto patchi : patchSet_)
|
for (const label patchi : patchIDs_)
|
||||||
{
|
{
|
||||||
const scalarField& pp = pBf[patchi];
|
const scalarField& pp = pBf[patchi];
|
||||||
const scalarField& dpdtp = dpdtBf[patchi];
|
const scalarField& dpdtp = dpdtBf[patchi];
|
||||||
@ -228,7 +226,7 @@ bool Foam::functionObjects::Curle::execute()
|
|||||||
|
|
||||||
if (surfaceWriterPtr_)
|
if (surfaceWriterPtr_)
|
||||||
{
|
{
|
||||||
if (Pstream::master())
|
if (UPstream::master())
|
||||||
{
|
{
|
||||||
// Time-aware, with time spliced into the output path
|
// Time-aware, with time spliced into the output path
|
||||||
surfaceWriterPtr_->beginTime(time_);
|
surfaceWriterPtr_->beginTime(time_);
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -124,8 +124,8 @@ SourceFiles
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef functionObjects_Curle_H
|
#ifndef Foam_functionObjects_Curle_H
|
||||||
#define functionObjects_Curle_H
|
#define Foam_functionObjects_Curle_H
|
||||||
|
|
||||||
#include "fvMeshFunctionObject.H"
|
#include "fvMeshFunctionObject.H"
|
||||||
#include "writeFile.H"
|
#include "writeFile.H"
|
||||||
@ -163,8 +163,8 @@ class Curle
|
|||||||
//- Name of pressure field; default = p
|
//- Name of pressure field; default = p
|
||||||
word pName_;
|
word pName_;
|
||||||
|
|
||||||
//- Patches to integrate forces over
|
//- List of patches to process
|
||||||
labelHashSet patchSet_;
|
labelList patchIDs_;
|
||||||
|
|
||||||
//- Observer positions
|
//- Observer positions
|
||||||
List<point> observerPositions_;
|
List<point> observerPositions_;
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2021-2022 OpenCFD Ltd.
|
Copyright (C) 2021-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -122,12 +122,8 @@ Foam::binModel::binModel
|
|||||||
mesh_(mesh),
|
mesh_(mesh),
|
||||||
decomposePatchValues_(false),
|
decomposePatchValues_(false),
|
||||||
cumulative_(false),
|
cumulative_(false),
|
||||||
coordSysPtr_(),
|
coordSysPtr_(nullptr),
|
||||||
nBin_(1),
|
nBin_(1)
|
||||||
patchSet_(),
|
|
||||||
fieldNames_(),
|
|
||||||
cellZoneIDs_(),
|
|
||||||
filePtrs_()
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -135,19 +131,23 @@ Foam::binModel::binModel
|
|||||||
|
|
||||||
bool Foam::binModel::read(const dictionary& dict)
|
bool Foam::binModel::read(const dictionary& dict)
|
||||||
{
|
{
|
||||||
|
const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
|
||||||
|
|
||||||
if (!functionObjects::writeFile::read(dict))
|
if (!functionObjects::writeFile::read(dict))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
patchSet_ = mesh_.boundaryMesh().patchSet(dict.get<wordRes>("patches"));
|
// Can also use pbm.indices(), but no warnings...
|
||||||
|
patchIDs_ = pbm.patchSet(dict.get<wordRes>("patches")).sortedToc();
|
||||||
fieldNames_ = dict.get<wordHashSet>("fields").sortedToc();
|
fieldNames_ = dict.get<wordHashSet>("fields").sortedToc();
|
||||||
|
|
||||||
if (dict.found("cellZones"))
|
wordRes zoneNames;
|
||||||
|
if (dict.readIfPresent("cellZones", zoneNames))
|
||||||
{
|
{
|
||||||
DynamicList<label> zoneIDs;
|
DynamicList<label> zoneIDs;
|
||||||
DynamicList<wordRe> czUnmatched;
|
DynamicList<wordRe> czUnmatched;
|
||||||
for (const auto& cz : dict.get<wordRes>("cellZones"))
|
for (const auto& cz : zoneNames)
|
||||||
{
|
{
|
||||||
const labelList czi(mesh_.cellZones().indices(cz));
|
const labelList czi(mesh_.cellZones().indices(cz));
|
||||||
|
|
||||||
@ -174,7 +174,7 @@ bool Foam::binModel::read(const dictionary& dict)
|
|||||||
|
|
||||||
decomposePatchValues_ = dict.getOrDefault("decomposePatchValues", false);
|
decomposePatchValues_ = dict.getOrDefault("decomposePatchValues", false);
|
||||||
|
|
||||||
filePtrs_.setSize(fieldNames_.size());
|
filePtrs_.resize(fieldNames_.size());
|
||||||
forAll(filePtrs_, i)
|
forAll(filePtrs_, i)
|
||||||
{
|
{
|
||||||
filePtrs_.set(i, newFileAtStartTime(fieldNames_[i] + "Bin"));
|
filePtrs_.set(i, newFileAtStartTime(fieldNames_[i] + "Bin"));
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2021-2022 OpenCFD Ltd.
|
Copyright (C) 2021-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -84,7 +84,7 @@ protected:
|
|||||||
label nBin_;
|
label nBin_;
|
||||||
|
|
||||||
//- Indices of operand patches
|
//- Indices of operand patches
|
||||||
labelHashSet patchSet_;
|
labelList patchIDs_;
|
||||||
|
|
||||||
//- Names of operand fields
|
//- Names of operand fields
|
||||||
wordList fieldNames_;
|
wordList fieldNames_;
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2021-2022 OpenCFD Ltd.
|
Copyright (C) 2021-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -46,46 +46,69 @@ void Foam::binModels::singleDirectionUniformBin::initialise()
|
|||||||
{
|
{
|
||||||
const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
|
const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
|
||||||
|
|
||||||
// Determine extents of patches in a given direction
|
|
||||||
scalar geomMin = GREAT;
|
|
||||||
scalar geomMax = -GREAT;
|
|
||||||
for (const label patchi : patchSet_)
|
|
||||||
{
|
|
||||||
const polyPatch& pp = pbm[patchi];
|
|
||||||
const scalarField d(pp.faceCentres() & binDir_);
|
|
||||||
geomMin = min(min(d), geomMin);
|
|
||||||
geomMax = max(max(d), geomMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const label zonei : cellZoneIDs_)
|
|
||||||
{
|
|
||||||
const cellZone& cZone = mesh_.cellZones()[zonei];
|
|
||||||
const vectorField cz(mesh_.C(), cZone);
|
|
||||||
const scalarField d(cz & binDir_);
|
|
||||||
|
|
||||||
geomMin = min(min(d), geomMin);
|
|
||||||
geomMax = max(max(d), geomMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
reduce(geomMin, minOp<scalar>());
|
|
||||||
reduce(geomMax, maxOp<scalar>());
|
|
||||||
|
|
||||||
// Slightly boost max so that region of interest is fully within bounds
|
|
||||||
geomMax = 1.0001*(geomMax - geomMin) + geomMin;
|
|
||||||
|
|
||||||
// Use geometry limits if not specified by the user
|
// Use geometry limits if not specified by the user
|
||||||
if (binMin_ == GREAT) binMin_ = geomMin;
|
const bool useGeomLimits
|
||||||
if (binMax_ == GREAT) binMax_ = geomMax;
|
(
|
||||||
|
binLimits_.min() == GREAT
|
||||||
|
|| binLimits_.max() == GREAT
|
||||||
|
);
|
||||||
|
|
||||||
binDx_ = (binMax_ - binMin_)/scalar(nBin_);
|
if (useGeomLimits)
|
||||||
|
{
|
||||||
|
// Determine extents of patches/cells in a given direction
|
||||||
|
scalarMinMax geomLimits;
|
||||||
|
|
||||||
if (binDx_ <= 0)
|
for (const label patchi : patchIDs_)
|
||||||
|
{
|
||||||
|
for (const vector& p : pbm[patchi].faceCentres())
|
||||||
|
{
|
||||||
|
geomLimits.add(p & binDir_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const label zonei : cellZoneIDs_)
|
||||||
|
{
|
||||||
|
for (const label celli : mesh_.cellZones()[zonei])
|
||||||
|
{
|
||||||
|
geomLimits.add(mesh_.C()[celli] & binDir_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Globally consistent
|
||||||
|
reduce(geomLimits, minMaxOp<scalar>());
|
||||||
|
|
||||||
|
if (!geomLimits.good())
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "No patches/cellZones provided"
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Slightly boost max so that region of interest is fully within bounds
|
||||||
|
// TBD: also adjust min?
|
||||||
|
const scalar adjust(1e-4*geomLimits.span());
|
||||||
|
geomLimits.max() += adjust;
|
||||||
|
|
||||||
|
// Use geometry limits if not specified by the user
|
||||||
|
if (binLimits_.min() == GREAT)
|
||||||
|
{
|
||||||
|
binLimits_.min() = geomLimits.min();
|
||||||
|
}
|
||||||
|
if (binLimits_.max() == GREAT)
|
||||||
|
{
|
||||||
|
binLimits_.max() = geomLimits.max();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
binWidth_ = binLimits_.span()/scalar(nBin_);
|
||||||
|
|
||||||
|
if (binWidth_ <= 0)
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Max bound must be greater than min bound" << nl
|
<< "Max bound must be greater than min bound" << nl
|
||||||
<< " d = " << binDx_ << nl
|
<< " d = " << binWidth_ << nl
|
||||||
<< " min = " << binMin_ << nl
|
<< " min = " << binLimits_.min() << nl
|
||||||
<< " max = " << binMax_ << nl
|
<< " max = " << binLimits_.max() << nl
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -101,9 +124,8 @@ Foam::binModels::singleDirectionUniformBin::singleDirectionUniformBin
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
binModel(dict, mesh, outputPrefix),
|
binModel(dict, mesh, outputPrefix),
|
||||||
binDx_(0),
|
binWidth_(0),
|
||||||
binMin_(GREAT),
|
binLimits_(GREAT),
|
||||||
binMax_(GREAT),
|
|
||||||
binDir_(Zero)
|
binDir_(Zero)
|
||||||
{
|
{
|
||||||
read(dict);
|
read(dict);
|
||||||
@ -125,30 +147,30 @@ bool Foam::binModels::singleDirectionUniformBin::read(const dictionary& dict)
|
|||||||
|
|
||||||
nBin_ = binDict.getCheck<label>("nBin", labelMinMax::ge(1));
|
nBin_ = binDict.getCheck<label>("nBin", labelMinMax::ge(1));
|
||||||
|
|
||||||
Info<< " Employing " << nBin_ << " bins" << endl;
|
Info<< " Employing " << nBin_ << " bins" << nl;
|
||||||
if (binDict.readIfPresent("min", binMin_))
|
|
||||||
|
if (binDict.readIfPresent("min", binLimits_.min()))
|
||||||
{
|
{
|
||||||
Info<< " - min : " << binMin_ << endl;
|
Info<< " - min : " << binLimits_.min() << nl;
|
||||||
}
|
}
|
||||||
if (binDict.readIfPresent("max", binMax_))
|
if (binDict.readIfPresent("max", binLimits_.max()))
|
||||||
{
|
{
|
||||||
Info<< " - max : " << binMax_ << endl;
|
Info<< " - max : " << binLimits_.max() << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
cumulative_ = binDict.getOrDefault<bool>("cumulative", false);
|
cumulative_ = binDict.getOrDefault<bool>("cumulative", false);
|
||||||
Info<< " - cumulative : " << cumulative_ << endl;
|
Info<< " - cumulative : " << cumulative_ << nl
|
||||||
Info<< " - decomposePatchValues : " << decomposePatchValues_ << endl;
|
<< " - decomposePatchValues : " << decomposePatchValues_ << nl;
|
||||||
|
|
||||||
binDir_ = binDict.get<vector>("direction");
|
binDir_ = binDict.get<vector>("direction");
|
||||||
binDir_.normalise();
|
if (binDir_.mag() < SMALL)
|
||||||
|
|
||||||
if (mag(binDir_) == 0)
|
|
||||||
{
|
{
|
||||||
FatalIOErrorInFunction(dict)
|
FatalIOErrorInFunction(dict)
|
||||||
<< "Input direction should not be zero valued" << nl
|
<< "Input direction should not be zero valued" << nl
|
||||||
<< " direction = " << binDir_ << nl
|
<< " direction = " << binDir_ << nl
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
|
binDir_.normalise();
|
||||||
|
|
||||||
Info<< " - direction : " << binDir_ << nl << endl;
|
Info<< " - direction : " << binDir_ << nl << endl;
|
||||||
|
|
||||||
@ -163,11 +185,13 @@ void Foam::binModels::singleDirectionUniformBin::apply()
|
|||||||
forAll(fieldNames_, i)
|
forAll(fieldNames_, i)
|
||||||
{
|
{
|
||||||
const bool ok =
|
const bool ok =
|
||||||
|
(
|
||||||
processField<scalar>(i)
|
processField<scalar>(i)
|
||||||
|| processField<vector>(i)
|
|| processField<vector>(i)
|
||||||
|| processField<sphericalTensor>(i)
|
|| processField<sphericalTensor>(i)
|
||||||
|| processField<symmTensor>(i)
|
|| processField<symmTensor>(i)
|
||||||
|| processField<tensor>(i);
|
|| processField<tensor>(i)
|
||||||
|
);
|
||||||
|
|
||||||
if (!ok)
|
if (!ok)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2021-2022 OpenCFD Ltd.
|
Copyright (C) 2021-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -105,13 +105,10 @@ protected:
|
|||||||
// Protected Data
|
// Protected Data
|
||||||
|
|
||||||
//- Distance between bin divisions
|
//- Distance between bin divisions
|
||||||
scalar binDx_;
|
scalar binWidth_;
|
||||||
|
|
||||||
//- Minimum bin bound
|
//- The min/max bounds for the bins
|
||||||
scalar binMin_;
|
MinMax<scalar> binLimits_;
|
||||||
|
|
||||||
//- Maximum bin bound
|
|
||||||
scalar binMax_;
|
|
||||||
|
|
||||||
//- Binning direction
|
//- Binning direction
|
||||||
vector binDir_;
|
vector binDir_;
|
||||||
|
|||||||
@ -25,7 +25,6 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::binModels::singleDirectionUniformBin::writeFileHeader
|
void Foam::binModels::singleDirectionUniformBin::writeFileHeader
|
||||||
(
|
(
|
||||||
@ -33,9 +32,9 @@ void Foam::binModels::singleDirectionUniformBin::writeFileHeader
|
|||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
writeHeaderValue(os, "bins", nBin_);
|
writeHeaderValue(os, "bins", nBin_);
|
||||||
writeHeaderValue(os, "start", binMin_);
|
writeHeaderValue(os, "start", binLimits_.min());
|
||||||
writeHeaderValue(os, "end", binMax_);
|
writeHeaderValue(os, "end", binLimits_.max());
|
||||||
writeHeaderValue(os, "delta", binDx_);
|
writeHeaderValue(os, "delta", binWidth_);
|
||||||
writeHeaderValue(os, "direction", binDir_);
|
writeHeaderValue(os, "direction", binDir_);
|
||||||
|
|
||||||
// Compute and print bin end points in the binning direction
|
// Compute and print bin end points in the binning direction
|
||||||
@ -43,7 +42,7 @@ void Foam::binModels::singleDirectionUniformBin::writeFileHeader
|
|||||||
writeCommented(os, "x co-ords :");
|
writeCommented(os, "x co-ords :");
|
||||||
forAll(binPoints, pointi)
|
forAll(binPoints, pointi)
|
||||||
{
|
{
|
||||||
binPoints[pointi] = (binMin_ + (pointi + 1)*binDx_)*binDir_;
|
binPoints[pointi] = (binLimits_.min() + (pointi + 1)*binWidth_)*binDir_;
|
||||||
os << tab << binPoints[pointi].x();
|
os << tab << binPoints[pointi].x();
|
||||||
}
|
}
|
||||||
os << nl;
|
os << nl;
|
||||||
@ -80,7 +79,6 @@ void Foam::binModels::singleDirectionUniformBin::writeFileHeader
|
|||||||
{
|
{
|
||||||
writeTabbed(os, writeComponents<Type>("patch" + ibin));
|
writeTabbed(os, writeComponents<Type>("patch" + ibin));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
os << endl;
|
os << endl;
|
||||||
@ -130,55 +128,63 @@ bool Foam::binModels::singleDirectionUniformBin::processField
|
|||||||
List<List<Type>> data(nField);
|
List<List<Type>> data(nField);
|
||||||
for (auto& binList : data)
|
for (auto& binList : data)
|
||||||
{
|
{
|
||||||
binList.setSize(nBin_, Zero);
|
binList.resize(nBin_, Zero);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto whichBin = [&](const scalar d) -> label
|
||||||
|
{
|
||||||
|
if (d >= binLimits_.min() && d <= binLimits_.max())
|
||||||
|
{
|
||||||
|
// Find the bin division
|
||||||
|
label bini = floor
|
||||||
|
(
|
||||||
|
(d - binLimits_.min())/binWidth_
|
||||||
|
);
|
||||||
|
return min(max(bini, 0), nBin_ - 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
for (const label zonei : cellZoneIDs_)
|
for (const label zonei : cellZoneIDs_)
|
||||||
{
|
{
|
||||||
const cellZone& cZone = mesh_.cellZones()[zonei];
|
const cellZone& cZone = mesh_.cellZones()[zonei];
|
||||||
|
|
||||||
for (const label celli : cZone)
|
for (const label celli : cZone)
|
||||||
{
|
{
|
||||||
const scalar dd = mesh_.C()[celli] & binDir_;
|
const label bini = whichBin(mesh_.C()[celli] & binDir_);
|
||||||
|
|
||||||
if (dd < binMin_ || dd > binMax_)
|
if (bini >= 0)
|
||||||
{
|
{
|
||||||
continue;
|
data[0][bini] += fld[celli];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the bin division corresponding to the cell
|
|
||||||
const label bini =
|
|
||||||
min(max(floor((dd - binMin_)/binDx_), 0), nBin_ - 1);
|
|
||||||
|
|
||||||
data[0][bini] += fld[celli];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
forAllIters(patchSet_, iter)
|
for (const label patchi : patchIDs_)
|
||||||
{
|
{
|
||||||
const label patchi = iter();
|
|
||||||
const polyPatch& pp = mesh_.boundaryMesh()[patchi];
|
const polyPatch& pp = mesh_.boundaryMesh()[patchi];
|
||||||
const vectorField np(mesh_.boundary()[patchi].nf());
|
const vectorField np(mesh_.boundary()[patchi].nf());
|
||||||
|
|
||||||
|
const auto& pts = pp.faceCentres();
|
||||||
|
|
||||||
const scalarField dd(pp.faceCentres() & binDir_);
|
const scalarField dd(pp.faceCentres() & binDir_);
|
||||||
|
|
||||||
forAll(dd, facei)
|
forAll(pts, facei)
|
||||||
{
|
{
|
||||||
// Avoid faces outside of the bin
|
const label bini = whichBin(pts[facei] & binDir_);
|
||||||
if (dd[facei] < binMin_ || dd[facei] > binMax_)
|
|
||||||
|
if (bini >= 0)
|
||||||
{
|
{
|
||||||
continue;
|
const Type& v = fld.boundaryField()[patchi][facei];
|
||||||
}
|
|
||||||
|
|
||||||
// Find the bin division corresponding to the face
|
if (!decomposePatchValues(data, bini, v, np[facei]))
|
||||||
const label bini =
|
{
|
||||||
min(max(floor((dd[facei] - binMin_)/binDx_), 0), nBin_ - 1);
|
data[1][bini] += v;
|
||||||
|
}
|
||||||
const Type& v = fld.boundaryField()[patchi][facei];
|
|
||||||
|
|
||||||
if (!decomposePatchValues(data, bini, v, np[facei]))
|
|
||||||
{
|
|
||||||
data[1][bini] += v;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2021-2022 OpenCFD Ltd.
|
Copyright (C) 2021-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -45,70 +45,87 @@ void Foam::binModels::uniformBin::initialise()
|
|||||||
{
|
{
|
||||||
const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
|
const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
|
||||||
|
|
||||||
// Determine extents of patches in a given coordinate system
|
// Use geometry limits if not specified by the user
|
||||||
vector geomMin(GREAT, GREAT, GREAT);
|
|
||||||
vector geomMax(-GREAT, -GREAT, -GREAT);
|
|
||||||
|
|
||||||
for (const label patchi : patchSet_)
|
|
||||||
{
|
{
|
||||||
const polyPatch& pp = pbm[patchi];
|
// Determine extents of patches/cells
|
||||||
const vectorField ppcs(coordSysPtr_->localPosition(pp.faceCentres()));
|
boundBox geomLimits;
|
||||||
|
|
||||||
for (direction i = 0; i < vector::nComponents; ++i)
|
for (const label patchi : patchIDs_)
|
||||||
{
|
{
|
||||||
geomMin[i] = min(min(ppcs.component(i)), geomMin[i]);
|
vectorField pts
|
||||||
geomMax[i] = max(max(ppcs.component(i)), geomMax[i]);
|
(
|
||||||
|
coordSysPtr_->localPosition(pbm[patchi].faceCentres())
|
||||||
|
);
|
||||||
|
|
||||||
|
MinMax<vector> limits(pts);
|
||||||
|
|
||||||
|
geomLimits.add(limits.min());
|
||||||
|
geomLimits.add(limits.max());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
for (const label zonei : cellZoneIDs_)
|
for (const label zonei : cellZoneIDs_)
|
||||||
{
|
|
||||||
const cellZone& cZone = mesh_.cellZones()[zonei];
|
|
||||||
const vectorField d
|
|
||||||
(
|
|
||||||
coordSysPtr_->localPosition(vectorField(mesh_.C(), cZone))
|
|
||||||
);
|
|
||||||
|
|
||||||
for (direction i = 0; i < vector::nComponents; ++i)
|
|
||||||
{
|
{
|
||||||
geomMin[i] = min(min(d.component(i)), geomMin[i]);
|
const cellZone& cZone = mesh_.cellZones()[zonei];
|
||||||
geomMax[i] = max(max(d.component(i)), geomMax[i]);
|
const vectorField pts
|
||||||
|
(
|
||||||
|
coordSysPtr_->localPosition(vectorField(mesh_.C(), cZone))
|
||||||
|
);
|
||||||
|
|
||||||
|
MinMax<vector> limits(pts);
|
||||||
|
|
||||||
|
geomLimits.add(limits.min());
|
||||||
|
geomLimits.add(limits.max());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
reduce(geomMin, minOp<vector>());
|
// Globally consistent
|
||||||
reduce(geomMax, maxOp<vector>());
|
geomLimits.reduce();
|
||||||
|
|
||||||
for (direction i = 0; i < vector::nComponents; ++i)
|
|
||||||
{
|
|
||||||
// Slightly boost max so that region of interest is fully within bounds
|
// Slightly boost max so that region of interest is fully within bounds
|
||||||
geomMax[i] = 1.0001*(geomMax[i] - geomMin[i]) + geomMin[i];
|
// TBD: could also adjust min?
|
||||||
|
const vector adjust(1e-4*geomLimits.span());
|
||||||
|
geomLimits.max() += adjust;
|
||||||
|
|
||||||
// Use geometry limits if not specified by the user
|
for (direction cmpt = 0; cmpt < vector::nComponents; ++cmpt)
|
||||||
if (binMinMax_[i][0] == GREAT) binMinMax_[i][0] = geomMin[i];
|
{
|
||||||
if (binMinMax_[i][1] == GREAT) binMinMax_[i][1] = geomMax[i];
|
// Use geometry limits if not specified by the user
|
||||||
|
if (binLimits_.min()[cmpt] == GREAT)
|
||||||
|
{
|
||||||
|
binLimits_.min()[cmpt] = geomLimits.min()[cmpt];
|
||||||
|
}
|
||||||
|
if (binLimits_.max()[cmpt] == GREAT)
|
||||||
|
{
|
||||||
|
binLimits_.max()[cmpt] = geomLimits.max()[cmpt];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (binMinMax_[i][0] > binMinMax_[i][1])
|
for (direction cmpt = 0; cmpt < vector::nComponents; ++cmpt)
|
||||||
|
{
|
||||||
|
if (binLimits_.min()[cmpt] > binLimits_.max()[cmpt])
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Max bounds must be greater than min bounds" << nl
|
<< "Max bounds must be greater than min bounds" << nl
|
||||||
<< " direction = " << i << nl
|
<< " direction = " << cmpt << nl
|
||||||
<< " min = " << binMinMax_[i][0] << nl
|
<< " min = " << binLimits_.min()[cmpt] << nl
|
||||||
<< " max = " << binMinMax_[i][1] << nl
|
<< " max = " << binLimits_.max()[cmpt] << nl
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Compute bin widths in binning directions
|
//- Compute bin widths in binning directions
|
||||||
binW_[i] = (binMinMax_[i][1] - binMinMax_[i][0])/scalar(nBins_[i]);
|
binWidth_[cmpt] =
|
||||||
|
(
|
||||||
|
(binLimits_.max()[cmpt] - binLimits_.min()[cmpt])
|
||||||
|
/ scalar(nBins_[cmpt])
|
||||||
|
);
|
||||||
|
|
||||||
if (binW_[i] <= 0)
|
if (binWidth_[cmpt] <= 0)
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Bin widths must be greater than zero" << nl
|
<< "Bin widths must be greater than zero" << nl
|
||||||
<< " direction = " << i << nl
|
<< " direction = " << cmpt << nl
|
||||||
<< " min bound = " << binMinMax_[i][0] << nl
|
<< " min bound = " << binLimits_.min()[cmpt] << nl
|
||||||
<< " max bound = " << binMinMax_[i][1] << nl
|
<< " max bound = " << binLimits_.max()[cmpt] << nl
|
||||||
<< " bin width = " << binW_[i]
|
<< " bin width = " << binWidth_[cmpt] << nl
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -125,9 +142,13 @@ Foam::labelList Foam::binModels::uniformBin::binAddr(const vectorField& d) const
|
|||||||
{
|
{
|
||||||
// Avoid elements outside of the bin
|
// Avoid elements outside of the bin
|
||||||
bool faceInside = true;
|
bool faceInside = true;
|
||||||
for (direction j = 0; j < vector::nComponents; ++j)
|
for (direction cmpt = 0; cmpt < vector::nComponents; ++cmpt)
|
||||||
{
|
{
|
||||||
if (d[i][j] < binMinMax_[j][0] || d[i][j] > binMinMax_[j][1])
|
if
|
||||||
|
(
|
||||||
|
d[i][cmpt] < binLimits_.min()[cmpt]
|
||||||
|
|| d[i][cmpt] > binLimits_.max()[cmpt]
|
||||||
|
)
|
||||||
{
|
{
|
||||||
faceInside = false;
|
faceInside = false;
|
||||||
break;
|
break;
|
||||||
@ -138,14 +159,18 @@ Foam::labelList Foam::binModels::uniformBin::binAddr(const vectorField& d) const
|
|||||||
{
|
{
|
||||||
// Find the bin division corresponding to the element
|
// Find the bin division corresponding to the element
|
||||||
Vector<label> n(Zero);
|
Vector<label> n(Zero);
|
||||||
for (direction j = 0; j < vector::nComponents; ++j)
|
for (direction cmpt = 0; cmpt < vector::nComponents; ++cmpt)
|
||||||
{
|
{
|
||||||
n[j] = floor((d[i][j] - binMinMax_[j][0])/binW_[j]);
|
label bini = floor
|
||||||
n[j] = min(max(n[j], 0), nBins_[j] - 1);
|
(
|
||||||
|
(d[i][cmpt] - binLimits_.min()[cmpt])/binWidth_[cmpt]
|
||||||
|
);
|
||||||
|
|
||||||
|
n[cmpt] = min(max(bini, 0), nBins_[cmpt] - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Order: (e1, e2, e3), the first varies the fastest
|
// Order: (e1, e2, e3), the first varies the fastest
|
||||||
binIndices[i] = n[0] + nBins_[0]*n[1] + nBins_[0]*nBins_[1]*n[2];
|
binIndices[i] = n.x() + nBins_[0]*n.y() + nBins_[0]*nBins_[1]*n.z();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -159,19 +184,19 @@ Foam::labelList Foam::binModels::uniformBin::binAddr(const vectorField& d) const
|
|||||||
|
|
||||||
void Foam::binModels::uniformBin::setBinsAddressing()
|
void Foam::binModels::uniformBin::setBinsAddressing()
|
||||||
{
|
{
|
||||||
faceToBin_.setSize(mesh_.nBoundaryFaces());
|
faceToBin_.resize_nocopy(mesh_.nBoundaryFaces());
|
||||||
faceToBin_ = -1;
|
faceToBin_ = -1;
|
||||||
|
|
||||||
forAllIters(patchSet_, iter)
|
for (const label patchi : patchIDs_)
|
||||||
{
|
{
|
||||||
const polyPatch& pp = mesh_.boundaryMesh()[iter()];
|
const polyPatch& pp = mesh_.boundaryMesh()[patchi];
|
||||||
const label i0 = pp.start() - mesh_.nInternalFaces();
|
const label i0 = pp.start() - mesh_.nInternalFaces();
|
||||||
|
|
||||||
SubList<label>(faceToBin_, pp.size(), i0) =
|
SubList<label>(faceToBin_, pp.size(), i0) =
|
||||||
binAddr(coordSysPtr_->localPosition(pp.faceCentres()));
|
binAddr(coordSysPtr_->localPosition(pp.faceCentres()));
|
||||||
}
|
}
|
||||||
|
|
||||||
cellToBin_.setSize(mesh_.nCells());
|
cellToBin_.resize_nocopy(mesh_.nCells());
|
||||||
cellToBin_ = -1;
|
cellToBin_ = -1;
|
||||||
|
|
||||||
for (const label zonei : cellZoneIDs_)
|
for (const label zonei : cellZoneIDs_)
|
||||||
@ -202,13 +227,8 @@ Foam::binModels::uniformBin::uniformBin
|
|||||||
:
|
:
|
||||||
binModel(dict, mesh, outputPrefix),
|
binModel(dict, mesh, outputPrefix),
|
||||||
nBins_(Zero),
|
nBins_(Zero),
|
||||||
binW_(Zero),
|
binWidth_(Zero),
|
||||||
binMinMax_
|
binLimits_(vector::uniform(GREAT))
|
||||||
(
|
|
||||||
vector2D(GREAT, GREAT),
|
|
||||||
vector2D(GREAT, GREAT),
|
|
||||||
vector2D(GREAT, GREAT)
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
read(dict);
|
read(dict);
|
||||||
}
|
}
|
||||||
@ -238,36 +258,40 @@ bool Foam::binModels::uniformBin::read(const dictionary& dict)
|
|||||||
{
|
{
|
||||||
FatalIOErrorInFunction(binDict)
|
FatalIOErrorInFunction(binDict)
|
||||||
<< "Number of bins must be greater than zero" << nl
|
<< "Number of bins must be greater than zero" << nl
|
||||||
<< " e1 bins = " << nBins_[0] << nl
|
<< " e1 bins = " << nBins_.x() << nl
|
||||||
<< " e2 bins = " << nBins_[1] << nl
|
<< " e2 bins = " << nBins_.y() << nl
|
||||||
<< " e3 bins = " << nBins_[2]
|
<< " e3 bins = " << nBins_.z()
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< " - Employing:" << nl
|
Info<< " - Employing:" << nl
|
||||||
<< " " << nBins_[0] << " e1 bins," << nl
|
<< " " << nBins_.x() << " e1 bins," << nl
|
||||||
<< " " << nBins_[1] << " e2 bins," << nl
|
<< " " << nBins_.y() << " e2 bins," << nl
|
||||||
<< " " << nBins_[2] << " e3 bins"
|
<< " " << nBins_.z() << " e3 bins"
|
||||||
<< endl;
|
<< endl;
|
||||||
|
|
||||||
cumulative_ = binDict.getOrDefault<bool>("cumulative", false);
|
cumulative_ = binDict.getOrDefault<bool>("cumulative", false);
|
||||||
Info<< " - cumulative : " << cumulative_ << endl;
|
Info<< " - cumulative : " << cumulative_ << endl;
|
||||||
Info<< " - decomposePatchValues : " << decomposePatchValues_ << endl;
|
Info<< " - decomposePatchValues : " << decomposePatchValues_ << endl;
|
||||||
|
|
||||||
if (binDict.found("minMax"))
|
const dictionary* minMaxDictPtr = binDict.findDict("minMax");
|
||||||
|
|
||||||
|
if (minMaxDictPtr)
|
||||||
{
|
{
|
||||||
const dictionary& minMaxDict = binDict.subDict("minMax");
|
const auto& minMaxDict = *minMaxDictPtr;
|
||||||
|
|
||||||
for (direction i = 0; i < vector::nComponents; ++i)
|
for (direction cmpt = 0; cmpt < vector::nComponents; ++cmpt)
|
||||||
{
|
{
|
||||||
const word ei("e" + Foam::name(i));
|
const word ei("e" + Foam::name(cmpt));
|
||||||
|
|
||||||
if (minMaxDict.readIfPresent(ei, binMinMax_[i]))
|
scalarMinMax range;
|
||||||
|
|
||||||
|
if (minMaxDict.readIfPresent(ei, range))
|
||||||
{
|
{
|
||||||
Info<< " - " << ei << " min : "
|
binLimits_.min()[cmpt] = range.min();
|
||||||
<< binMinMax_[i][0] << nl
|
binLimits_.max()[cmpt] = range.max();
|
||||||
<< " - " << ei << " max : "
|
|
||||||
<< binMinMax_[i][1] << endl;
|
Info<< " - " << ei << " min/max : " << range << nl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -284,17 +308,18 @@ void Foam::binModels::uniformBin::apply()
|
|||||||
forAll(fieldNames_, i)
|
forAll(fieldNames_, i)
|
||||||
{
|
{
|
||||||
const bool ok =
|
const bool ok =
|
||||||
|
(
|
||||||
processField<scalar>(i)
|
processField<scalar>(i)
|
||||||
|| processField<vector>(i)
|
|| processField<vector>(i)
|
||||||
|| processField<sphericalTensor>(i)
|
|| processField<sphericalTensor>(i)
|
||||||
|| processField<symmTensor>(i)
|
|| processField<symmTensor>(i)
|
||||||
|| processField<tensor>(i);
|
|| processField<tensor>(i)
|
||||||
|
);
|
||||||
|
|
||||||
if (!ok)
|
if (!ok)
|
||||||
{
|
{
|
||||||
WarningInFunction
|
WarningInFunction
|
||||||
<< "Unable to find field " << fieldNames_[i]
|
<< "Unable to find field " << fieldNames_[i] << endl;
|
||||||
<< endl;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2021-2022 OpenCFD Ltd.
|
Copyright (C) 2021-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -129,10 +129,10 @@ protected:
|
|||||||
Vector<label> nBins_;
|
Vector<label> nBins_;
|
||||||
|
|
||||||
//- Equidistant bin widths in binning directions
|
//- Equidistant bin widths in binning directions
|
||||||
vector binW_;
|
vector binWidth_;
|
||||||
|
|
||||||
//- Min-max bounds of bins in binning directions
|
//- The geometric min/max bounds for the bins
|
||||||
Vector<vector2D> binMinMax_;
|
MinMax<vector> binLimits_;
|
||||||
|
|
||||||
//- Face index to bin index addressing
|
//- Face index to bin index addressing
|
||||||
labelList faceToBin_;
|
labelList faceToBin_;
|
||||||
|
|||||||
@ -39,9 +39,9 @@ void Foam::binModels::uniformBin::writeFileHeader
|
|||||||
for (direction i = 0; i < vector::nComponents; ++i)
|
for (direction i = 0; i < vector::nComponents; ++i)
|
||||||
{
|
{
|
||||||
writeHeaderValue(os, "e" + Foam::name(i) + " bins", nBins_[i]);
|
writeHeaderValue(os, "e" + Foam::name(i) + " bins", nBins_[i]);
|
||||||
writeHeaderValue(os, " start", binMinMax_[i][0]);
|
writeHeaderValue(os, " start", binLimits_.min()[i]);
|
||||||
writeHeaderValue(os, " end", binMinMax_[i][1]);
|
writeHeaderValue(os, " end", binLimits_.max()[i]);
|
||||||
writeHeaderValue(os, " delta", binW_[i]);
|
writeHeaderValue(os, " delta", binWidth_[i]);
|
||||||
writeHeaderValue(os, " direction", R.col(i));
|
writeHeaderValue(os, " direction", R.col(i));
|
||||||
}
|
}
|
||||||
writeCommented(os, "bin end co-ordinates:");
|
writeCommented(os, "bin end co-ordinates:");
|
||||||
@ -50,12 +50,12 @@ void Foam::binModels::uniformBin::writeFileHeader
|
|||||||
// Compute and print bin end points in binning directions
|
// Compute and print bin end points in binning directions
|
||||||
for (direction i = 0; i < vector::nComponents; ++i)
|
for (direction i = 0; i < vector::nComponents; ++i)
|
||||||
{
|
{
|
||||||
scalar binEnd = binMinMax_[i][0];
|
scalar binEnd = binLimits_.min()[i];
|
||||||
|
|
||||||
writeCommented(os, "e"+Foam::name(i)+" co-ords :");
|
writeCommented(os, "e"+Foam::name(i)+" co-ords :");
|
||||||
for (label j = 0; j < nBins_[i]; ++j)
|
for (label j = 0; j < nBins_[i]; ++j)
|
||||||
{
|
{
|
||||||
binEnd += binW_[i];
|
binEnd += binWidth_[i];
|
||||||
os << tab << binEnd;
|
os << tab << binEnd;
|
||||||
}
|
}
|
||||||
os << nl;
|
os << nl;
|
||||||
@ -124,7 +124,7 @@ bool Foam::binModels::uniformBin::processField(const label fieldi)
|
|||||||
List<List<Type>> data(nField);
|
List<List<Type>> data(nField);
|
||||||
for (auto& binList : data)
|
for (auto& binList : data)
|
||||||
{
|
{
|
||||||
binList.setSize(nBin_, Zero);
|
binList.resize(nBin_, Zero);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const label zonei : cellZoneIDs_)
|
for (const label zonei : cellZoneIDs_)
|
||||||
@ -135,16 +135,15 @@ bool Foam::binModels::uniformBin::processField(const label fieldi)
|
|||||||
{
|
{
|
||||||
const label bini = cellToBin_[celli];
|
const label bini = cellToBin_[celli];
|
||||||
|
|
||||||
if (bini != -1)
|
if (bini >= 0)
|
||||||
{
|
{
|
||||||
data[0][bini] += fld[celli];
|
data[0][bini] += fld[celli];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
forAllIters(patchSet_, iter)
|
for (const label patchi : patchIDs_)
|
||||||
{
|
{
|
||||||
const label patchi = iter();
|
|
||||||
const polyPatch& pp = mesh_.boundaryMesh()[patchi];
|
const polyPatch& pp = mesh_.boundaryMesh()[patchi];
|
||||||
const vectorField np(mesh_.boundary()[patchi].nf());
|
const vectorField np(mesh_.boundary()[patchi].nf());
|
||||||
|
|
||||||
@ -154,7 +153,7 @@ bool Foam::binModels::uniformBin::processField(const label fieldi)
|
|||||||
pp.start() - mesh_.nInternalFaces() + facei;
|
pp.start() - mesh_.nInternalFaces() + facei;
|
||||||
const label bini = faceToBin_[localFacei];
|
const label bini = faceToBin_[localFacei];
|
||||||
|
|
||||||
if (bini != -1)
|
if (bini >= 0)
|
||||||
{
|
{
|
||||||
const Type& v = fld.boundaryField()[patchi][facei];
|
const Type& v = fld.boundaryField()[patchi][facei];
|
||||||
|
|
||||||
|
|||||||
@ -568,7 +568,7 @@ bool Foam::functionObjects::externalCoupled::read(const dictionary& dict)
|
|||||||
// Leave trigger intact
|
// Leave trigger intact
|
||||||
|
|
||||||
// Get names of all fvMeshes (and derived types)
|
// Get names of all fvMeshes (and derived types)
|
||||||
wordList allRegionNames(time_.lookupClass<fvMesh>().sortedToc());
|
wordList allRegionNames(time_.sortedNames<fvMesh>());
|
||||||
|
|
||||||
const dictionary& allRegionsDict = dict.subDict("regions");
|
const dictionary& allRegionsDict = dict.subDict("regions");
|
||||||
for (const entry& dEntry : allRegionsDict)
|
for (const entry& dEntry : allRegionsDict)
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2018-2020 OpenCFD Ltd.
|
Copyright (C) 2018-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -111,8 +111,7 @@ Foam::functionObjects::fieldExtents::fieldExtents
|
|||||||
internalField_(true),
|
internalField_(true),
|
||||||
threshold_(0),
|
threshold_(0),
|
||||||
C0_(Zero),
|
C0_(Zero),
|
||||||
fieldSet_(mesh_),
|
fieldSet_(mesh_)
|
||||||
patchIDs_()
|
|
||||||
{
|
{
|
||||||
read(dict);
|
read(dict);
|
||||||
|
|
||||||
@ -125,6 +124,8 @@ Foam::functionObjects::fieldExtents::fieldExtents
|
|||||||
|
|
||||||
bool Foam::functionObjects::fieldExtents::read(const dictionary& dict)
|
bool Foam::functionObjects::fieldExtents::read(const dictionary& dict)
|
||||||
{
|
{
|
||||||
|
const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
|
||||||
|
|
||||||
if (fvMeshFunctionObject::read(dict) && writeFile::read(dict))
|
if (fvMeshFunctionObject::read(dict) && writeFile::read(dict))
|
||||||
{
|
{
|
||||||
dict.readIfPresent<bool>("internalField", internalField_);
|
dict.readIfPresent<bool>("internalField", internalField_);
|
||||||
@ -133,28 +134,31 @@ bool Foam::functionObjects::fieldExtents::read(const dictionary& dict)
|
|||||||
|
|
||||||
dict.readIfPresent<vector>("referencePosition", C0_);
|
dict.readIfPresent<vector>("referencePosition", C0_);
|
||||||
|
|
||||||
patchIDs_.clear();
|
|
||||||
const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
|
|
||||||
|
|
||||||
wordRes patchNames;
|
wordRes patchNames;
|
||||||
if (dict.readIfPresent("patches", patchNames))
|
if (dict.readIfPresent("patches", patchNames))
|
||||||
{
|
{
|
||||||
for (const wordRe& name : patchNames)
|
patchIDs_ = pbm.indices(patchNames);
|
||||||
{
|
|
||||||
patchIDs_.insert(pbm.indices(name));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Add all non-processor and non-empty patches
|
labelHashSet patchSet(2*pbm.size());
|
||||||
|
|
||||||
|
// All non-processor and non-empty patches
|
||||||
forAll(pbm, patchi)
|
forAll(pbm, patchi)
|
||||||
{
|
{
|
||||||
const polyPatch& pp = pbm[patchi];
|
const polyPatch& pp = pbm[patchi];
|
||||||
if (!isA<processorPolyPatch>(pp) && !isA<emptyPolyPatch>(pp))
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
!isA<processorPolyPatch>(pp)
|
||||||
|
&& !isA<emptyPolyPatch>(pp)
|
||||||
|
)
|
||||||
{
|
{
|
||||||
patchIDs_.insert(patchi);
|
patchSet.insert(patchi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
patchIDs_ = patchSet.sortedToc();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!internalField_ && patchIDs_.empty())
|
if (!internalField_ && patchIDs_.empty())
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user