diff --git a/applications/utilities/mesh/conversion/fluent3DMeshToFoam/fluent3DMeshToFoam.L b/applications/utilities/mesh/conversion/fluent3DMeshToFoam/fluent3DMeshToFoam.L index ab1143b871..ae658b0af1 100644 --- a/applications/utilities/mesh/conversion/fluent3DMeshToFoam/fluent3DMeshToFoam.L +++ b/applications/utilities/mesh/conversion/fluent3DMeshToFoam/fluent3DMeshToFoam.L @@ -1257,23 +1257,6 @@ int main(int argc, char *argv[]) ); } - // Modify cells to be in zones as required - forAll(cellZoneIDs, cellZonei) - { - label cgi = cellZoneIDs[cellZonei]; - - for - ( - label celli = cellGroupStartIndex[cgi]; - celli <= cellGroupEndIndex[cgi]; - celli++ - ) - { - meshMod.modifyCell(celli, cellZonei); - } - } - - bool doneWarning = false; // Add faceZone faces @@ -1462,6 +1445,21 @@ int main(int argc, char *argv[]) polyMeshUnMergeCyclics(mesh); } + // Add the cell zones as required + forAll(cellZoneIDs, cellZonei) + { + const label cgi = cellZoneIDs[cellZonei]; + + mesh.cellZones()[cellZonei].insert + ( + identityMap + ( + cellGroupStartIndex[cgi], + cellGroupEndIndex[cgi] + 1 - cellGroupStartIndex[cgi] + ) + ); + } + mesh.setInstance(runTime.constant()); // Set the precision of the points data to 10 diff --git a/applications/utilities/mesh/manipulation/createPatch/createPatch.C b/applications/utilities/mesh/manipulation/createPatch/createPatch.C index 502a383429..f7be711104 100644 --- a/applications/utilities/mesh/manipulation/createPatch/createPatch.C +++ b/applications/utilities/mesh/manipulation/createPatch/createPatch.C @@ -500,7 +500,7 @@ int main(int argc, char *argv[]) forAll(patchSources, addedI) { const dictionary& dict = patchSources[addedI]; - addedPatchNames.insert(dict.lookup("name")); + addedPatchNames.insert(dict.lookup("name")); } diff --git a/applications/utilities/postProcessing/foamPostProcess/foamPostProcess.C b/applications/utilities/postProcessing/foamPostProcess/foamPostProcess.C index 4649618d8c..5d22d3cf2d 100644 --- a/applications/utilities/postProcessing/foamPostProcess/foamPostProcess.C +++ b/applications/utilities/postProcessing/foamPostProcess/foamPostProcess.C @@ -305,7 +305,7 @@ int main(int argc, char *argv[]) } if (args.optionFound("field")) { - requiredFields.insert(args.optionLookup("field")()); + requiredFields.insert(word(args.optionLookup("field")())); } } diff --git a/src/OpenFOAM/containers/HashTables/HashSet/HashSet.C b/src/OpenFOAM/containers/HashTables/HashSet/HashSet.C index 73886cb9b4..251a2909a2 100644 --- a/src/OpenFOAM/containers/HashTables/HashSet/HashSet.C +++ b/src/OpenFOAM/containers/HashTables/HashSet/HashSet.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -67,12 +67,12 @@ Foam::HashSet::HashSet for ( typename HashTable::const_iterator - cit = h.cbegin(); - cit != h.cend(); - ++cit + iter = h.cbegin(); + iter != h.cend(); + ++iter ) { - this->insert(cit.key()); + this->insert(iter.key()); } } @@ -110,6 +110,22 @@ Foam::label Foam::HashSet::insert(const UList& lst) } +template +Foam::label Foam::HashSet::insert(const HashSet& set) +{ + label count = 0; + for (const_iterator iter = set.cbegin(); iter != set.cend(); ++iter) + { + if (this->insert(iter.key())) + { + ++count; + } + } + + return count; +} + + // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template diff --git a/src/OpenFOAM/containers/HashTables/HashSet/HashSet.H b/src/OpenFOAM/containers/HashTables/HashSet/HashSet.H index a51f40e7c2..43ba8fb7ab 100644 --- a/src/OpenFOAM/containers/HashTables/HashSet/HashSet.H +++ b/src/OpenFOAM/containers/HashTables/HashSet/HashSet.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -106,8 +106,6 @@ public: // Member Functions - // Edit - //- Insert a new entry bool insert(const Key& key) { @@ -118,6 +116,10 @@ public: // Return the number of new elements inserted label insert(const UList&); + //- Insert keys from a HashSet of Key + // Return the number of new elements inserted + label insert(const HashSet&); + //- Same as insert (cannot overwrite nil content) bool set(const Key& key) { diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C index 24d91f576d..0792ac92b0 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -305,6 +305,26 @@ bool Foam::HashTable::set } +template +void Foam::HashTable::insert(const HashTable& ht) +{ + for (const_iterator iter = ht.cbegin(); iter != ht.cend(); ++iter) + { + insert(iter.key(), *iter); + } +} + + +template +void Foam::HashTable::set(const HashTable& ht) +{ + for (const_iterator iter = ht.cbegin(); iter != ht.cend(); ++iter) + { + set(iter.key(), *iter); + } +} + + template bool Foam::HashTable::iteratorBase::erase() { diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H index 589b285cd9..0b1eb2577a 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -259,9 +259,16 @@ public: //- Insert a new hashedEntry inline bool insert(const Key&, const T& newElmt); - //- Assign a new hashedEntry, overwriting existing entries + //- Insert all the entries from the given HashTable + void insert(const HashTable&); + + //- Set a new hashedEntry, overwriting existing entries inline bool set(const Key&, const T& newElmt); + //- Insert all the entries from the given HashTable, + // overwriting existing entries + void set(const HashTable&); + //- Erase a hashedEntry specified by given iterator // This invalidates the iterator until the next operator++ bool erase(const iterator&); diff --git a/src/OpenFOAM/containers/Lists/ListOps/ListOps.C b/src/OpenFOAM/containers/Lists/ListOps/ListOps.C index 2e40db58d1..dc5e23350b 100644 --- a/src/OpenFOAM/containers/Lists/ListOps/ListOps.C +++ b/src/OpenFOAM/containers/Lists/ListOps/ListOps.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -113,4 +113,16 @@ Foam::labelList Foam::identityMap(const label len) } +Foam::labelList Foam::identityMap(const label start, const label len) +{ + labelList map(len); + + forAll(map, i) + { + map[i] = start + i; + } + return map; +} + + // ************************************************************************* // diff --git a/src/OpenFOAM/containers/Lists/ListOps/ListOps.H b/src/OpenFOAM/containers/Lists/ListOps/ListOps.H index 60548149f3..8c70dc7307 100644 --- a/src/OpenFOAM/containers/Lists/ListOps/ListOps.H +++ b/src/OpenFOAM/containers/Lists/ListOps/ListOps.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -169,6 +169,9 @@ List invertManyToMany(const label len, const UList& in) //- Create identity map (map[i] == i) of given length labelList identityMap(const label len); +//- Create identity map (map[i] == start + i) of given length +labelList identityMap(const label start, const label len); + //- Count the number of occurrences of a value in a list template label count(const ListType& l, typename ListType::const_reference x); diff --git a/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.H b/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.H index 49d89e16c8..a728f7d548 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.H +++ b/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.H @@ -49,12 +49,6 @@ SourceFiles namespace Foam { -// Forward declaration of friend functions and operators - -class cellZone; -Ostream& operator<<(Ostream&, const cellZone&); - - /*---------------------------------------------------------------------------*\ Class cellZone Declaration \*---------------------------------------------------------------------------*/ @@ -77,7 +71,7 @@ public: // Static Data Members //- The name associated with the zone-labels dictionary entry - static const char * const labelsName; + static const char* const labelsName; //- Runtime type information @@ -219,12 +213,6 @@ public: //- Move assignment to zone, clearing demand-driven data void operator=(cellZone&&); - - - // I-O - - //- Ostream Operator - friend Ostream& operator<<(Ostream&, const cellZone&); }; diff --git a/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.H b/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.H index 61af4a7f0c..9dab0e5b07 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.H +++ b/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.H @@ -117,7 +117,7 @@ public: // Static Data Members //- The name associated with the zone-labels dictionary entry - static const char * const labelsName; + static const char* const labelsName; //- Runtime type information diff --git a/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.C b/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.C index b832239303..e02e8c42f2 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.C +++ b/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.C @@ -207,14 +207,4 @@ void Foam::pointZone::operator=(pointZone&& zn) } -// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * // - -Foam::Ostream& Foam::operator<<(Ostream& os, const pointZone& zn) -{ - zn.write(os); - os.check("Ostream& operator<<(Ostream&, const pointZone&"); - return os; -} - - // ************************************************************************* // diff --git a/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.H b/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.H index fad4e97e5f..29bc4d5ffe 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.H +++ b/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.H @@ -50,12 +50,6 @@ SourceFiles namespace Foam { -// Forward declaration of friend functions and operators - -class pointZone; -Ostream& operator<<(Ostream&, const pointZone&); - - /*---------------------------------------------------------------------------*\ Class pointZone Declaration \*---------------------------------------------------------------------------*/ @@ -78,7 +72,7 @@ public: // Static Data Members //- The name associated with the zone-labels dictionary entry - static const char * const labelsName; + static const char* const labelsName; //- Runtime type information @@ -217,12 +211,6 @@ public: //- Move assignment to zone, clearing demand-driven data void operator=(pointZone&&); - - - // I-O - - //- Ostream Operator - friend Ostream& operator<<(Ostream&, const pointZone&); }; diff --git a/src/OpenFOAM/meshes/polyMesh/zones/zone/zone.C b/src/OpenFOAM/meshes/polyMesh/zones/zone/zone.C index 711d4583d5..325574d1a4 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/zone/zone.C +++ b/src/OpenFOAM/meshes/polyMesh/zones/zone/zone.C @@ -63,14 +63,14 @@ void Foam::zone::calcLookupMap() const << abort(FatalError); } - const labelList& addr = *this; + const labelList& indices = *this; - lookupMapPtr_ = new Map