ENH: for-range, forAllIters() ... in dynamicMesh/

- reduced clutter when iterating over containers
This commit is contained in:
Mark Olesen
2019-01-07 09:20:51 +01:00
committed by Andrew Heather
parent f5163e50ff
commit 45590671ac
31 changed files with 417 additions and 549 deletions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd. \\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -105,16 +105,14 @@ void Foam::dynamicRefineFvMesh::mapNewInternalFaces
typedef GeometricField<T, fvsPatchField, surfaceMesh> GeoField; typedef GeometricField<T, fvsPatchField, surfaceMesh> GeoField;
HashTable<GeoField*> sFlds(this->objectRegistry::lookupClass<GeoField>()); HashTable<GeoField*> sFlds(this->objectRegistry::lookupClass<GeoField>());
forAllIter(typename HashTable<GeoField*>, sFlds, iter) forAllIters(sFlds, iter)
{ {
//if (mapSurfaceFields_.found(iter.key())) //if (mapSurfaceFields_.found(iter.key()))
{ {
if (debug) DebugInfo
{ << "dynamicRefineFvMesh::mapNewInternalFaces():"
Info<< "dynamicRefineFvMesh::mapNewInternalFaces():"
<< " Mapping new internal faces by interpolation on " << " Mapping new internal faces by interpolation on "
<< iter.key()<< endl; << iter.key()<< endl;
}
GeoField& sFld = *iter(); GeoField& sFld = *iter();
@ -143,27 +141,23 @@ void Foam::dynamicRefineFvMesh::mapNewInternalFaces
typedef GeometricField<T, fvsPatchField, surfaceMesh> GeoField; typedef GeometricField<T, fvsPatchField, surfaceMesh> GeoField;
HashTable<GeoField*> sFlds(this->objectRegistry::lookupClass<GeoField>()); HashTable<GeoField*> sFlds(this->objectRegistry::lookupClass<GeoField>());
forAllIter(typename HashTable<GeoField*>, sFlds, iter) forAllIters(sFlds, iter)
{ {
//if (mapSurfaceFields_.found(iter.key())) //if (mapSurfaceFields_.found(iter.key()))
{ {
if (debug) DebugInfo
{ << "dynamicRefineFvMesh::mapNewInternalFaces():"
Info<< "dynamicRefineFvMesh::mapNewInternalFaces():"
<< " Mapping new internal faces by interpolation on " << " Mapping new internal faces by interpolation on "
<< iter.key() << endl; << iter.key() << endl;
}
GeoField& sFld = *iter(); GeoField& sFld = *iter();
if (sFld.oriented()()) if (sFld.oriented()())
{ {
if (debug) DebugInfo
{ << "dynamicRefineFvMesh::mapNewInternalFaces(): "
Info<< "dynamicRefineFvMesh::mapNewInternalFaces(): "
<< "Converting oriented field " << iter.key() << "Converting oriented field " << iter.key()
<< " 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.

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation | Copyright (C) 2011-2016 OpenFOAM Foundation
@ -196,10 +196,9 @@ void Foam::attachDetach::attachInterface
forAll(newFace, pointi) forAll(newFace, pointi)
{ {
Map<label>::const_iterator rpmIter = const auto rpmIter = removedPointMap.cfind(newFace[pointi]);
removedPointMap.find(newFace[pointi]);
if (rpmIter != removedPointMap.end()) if (rpmIter.found())
{ {
// Point mapped. Replace it // Point mapped. Replace it
newFace[pointi] = rpmIter(); newFace[pointi] = rpmIter();
@ -225,7 +224,7 @@ void Foam::attachDetach::attachInterface
} }
label patchID = mesh.boundaryMesh().whichPatch(curFaceID); const label patchID = mesh.boundaryMesh().whichPatch(curFaceID);
label neiCell; label neiCell;
if (patchID == -1) if (patchID == -1)
{ {

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation | Copyright (C) 2011-2016 OpenFOAM Foundation
@ -398,9 +398,9 @@ void Foam::createShellMesh::calcPointRegions
{ {
label globalRegionI = pointGlobalRegions[facei][fp]; label globalRegionI = pointGlobalRegions[facei][fp];
Map<label>::iterator fnd = globalToLocalRegion.find(globalRegionI); const auto fnd = globalToLocalRegion.cfind(globalRegionI);
if (fnd != globalToLocalRegion.end()) if (fnd.found())
{ {
// Already encountered this global region. Assign same local one // Already encountered this global region. Assign same local one
pRegions[fp] = fnd(); pRegions[fp] = fnd();

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2015-2016 OpenCFD Ltd. \\ / A nd | Copyright (C) 2015-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation | Copyright (C) 2011-2016 OpenFOAM Foundation
@ -64,8 +64,7 @@ void Foam::fvMeshAdder::MapVolField
// Patch fields from old mesh // Patch fields from old mesh
// ~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~
typename GeometricField<Type, fvPatchField, volMesh>:: auto& bfld = fld.boundaryFieldRef();
Boundary& bfld = fld.boundaryFieldRef();
{ {
const labelList& oldPatchMap = meshMap.oldPatchMap(); const labelList& oldPatchMap = meshMap.oldPatchMap();
@ -93,7 +92,7 @@ void Foam::fvMeshAdder::MapVolField
forAll(oldPatchMap, patchi) forAll(oldPatchMap, patchi)
{ {
label newPatchi = oldPatchMap[patchi]; const label newPatchi = oldPatchMap[patchi];
if (newPatchi != -1) if (newPatchi != -1)
{ {
@ -270,18 +269,16 @@ void Foam::fvMeshAdder::MapVolFields
const bool fullyMapped const bool fullyMapped
) )
{ {
HashTable<const GeometricField<Type, fvPatchField, volMesh>*> fields typedef GeometricField<Type, fvPatchField, volMesh> fldType;
HashTable<const fldType*> fields
( (
mesh.objectRegistry::lookupClass mesh.objectRegistry::lookupClass<fldType>()
<GeometricField<Type, fvPatchField, volMesh>>
()
); );
HashTable<const GeometricField<Type, fvPatchField, volMesh>*> fieldsToAdd HashTable<const fldType*> fieldsToAdd
( (
meshToAdd.objectRegistry::lookupClass meshToAdd.objectRegistry::lookupClass<fldType>()
<GeometricField<Type, fvPatchField, volMesh>>
()
); );
// It is necessary to enforce that all old-time fields are stored // It is necessary to enforce that all old-time fields are stored
@ -289,41 +286,25 @@ 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 forAllIters(fields, fieldIter)
(
typename HashTable<const GeometricField<Type, fvPatchField, volMesh>*>::
iterator fieldIter = fields.begin();
fieldIter != fields.end();
++fieldIter
)
{ {
fldType& fld = const_cast<fldType&>(*fieldIter());
DebugPout DebugPout
<< "MapVolFields : Storing old time for " << fieldIter()->name() << "MapVolFields : Storing old time for " << fld.name()
<< endl; << endl;
const_cast<GeometricField<Type, fvPatchField, volMesh>*>(fieldIter()) fld.storeOldTimes();
->storeOldTimes();
} }
for forAllIters(fields, fieldIter)
(
typename HashTable<const GeometricField<Type, fvPatchField, volMesh>*>::
iterator fieldIter = fields.begin();
fieldIter != fields.end();
++fieldIter
)
{ {
GeometricField<Type, fvPatchField, volMesh>& fld = fldType& fld = const_cast<fldType&>(*fieldIter());
const_cast<GeometricField<Type, fvPatchField, volMesh>&>
(
*fieldIter()
);
if (fieldsToAdd.found(fld.name())) if (fieldsToAdd.found(fld.name()))
{ {
const GeometricField<Type, fvPatchField, volMesh>& fldToAdd = const fldType& fldToAdd = *fieldsToAdd[fld.name()];
*fieldsToAdd[fld.name()];
DebugPout DebugPout
<< "MapVolFields : mapping " << fld.name() << "MapVolFields : mapping " << fld.name()
@ -355,8 +336,7 @@ void Foam::fvMeshAdder::MapSurfaceField
const fvMesh& mesh = fld.mesh(); const fvMesh& mesh = fld.mesh();
const labelList& oldPatchStarts = meshMap.oldPatchStarts(); const labelList& oldPatchStarts = meshMap.oldPatchStarts();
typename GeometricField<Type, fvsPatchField, surfaceMesh>:: auto& bfld = fld.boundaryFieldRef();
Boundary& bfld = fld.boundaryFieldRef();
// Internal field // Internal field
// ~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~
@ -424,7 +404,7 @@ void Foam::fvMeshAdder::MapSurfaceField
forAll(oldPatchMap, patchi) forAll(oldPatchMap, patchi)
{ {
label newPatchi = oldPatchMap[patchi]; const label newPatchi = oldPatchMap[patchi];
if (newPatchi != -1) if (newPatchi != -1)
{ {
@ -618,29 +598,19 @@ 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 forAllIters(fields, fieldIter)
(
typename HashTable<const fldType*>::
iterator fieldIter = fields.begin();
fieldIter != fields.end();
++fieldIter
)
{ {
fldType& fld = const_cast<fldType&>(*fieldIter());
DebugPout DebugPout
<< "MapSurfaceFields : Storing old time for " << "MapSurfaceFields : Storing old time for "
<< fieldIter()->name() << endl; << fld.name() << endl;
const_cast<fldType*>(fieldIter())->storeOldTimes(); fld.storeOldTimes();
} }
for forAllIters(fields, fieldIter)
(
typename HashTable<const fldType*>::
iterator fieldIter = fields.begin();
fieldIter != fields.end();
++fieldIter
)
{ {
fldType& fld = const_cast<fldType&>(*fieldIter()); fldType& fld = const_cast<fldType&>(*fieldIter());
@ -708,13 +678,7 @@ void Foam::fvMeshAdder::MapDimFields
meshToAdd.objectRegistry::lookupClass<fldType>(true) meshToAdd.objectRegistry::lookupClass<fldType>(true)
); );
for forAllIters(fields, fieldIter)
(
typename HashTable<const fldType*>::
iterator fieldIter = fields.begin();
fieldIter != fields.end();
++fieldIter
)
{ {
fldType& fld = const_cast<fldType&>(*fieldIter()); fldType& fld = const_cast<fldType&>(*fieldIter());

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2015-2018 OpenCFD Ltd. \\ / A nd | Copyright (C) 2015-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2018 OpenFOAM Foundation | Copyright (C) 2011-2018 OpenFOAM Foundation
@ -713,21 +713,18 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::fvMeshDistribute::mergeSharedPoints
label globali = pointToGlobalMaster[pointi]; label globali = pointToGlobalMaster[pointi];
if (globali != -1) if (globali != -1)
{ {
Map<label>::const_iterator iter = globalMasterToLocalMaster.find const auto iter = globalMasterToLocalMaster.cfind(globali);
(
globali
);
if (iter == globalMasterToLocalMaster.end()) if (iter.found())
{
pointToMaster.insert(pointi, *iter);
}
else
{ {
// Found first point. Designate as master // Found first point. Designate as master
globalMasterToLocalMaster.insert(globali, pointi); globalMasterToLocalMaster.insert(globali, pointi);
pointToMaster.insert(pointi, pointi); pointToMaster.insert(pointi, pointi);
} }
else
{
pointToMaster.insert(pointi, iter());
}
} }
} }
@ -1097,11 +1094,11 @@ void Foam::fvMeshDistribute::findCouples
{ {
labelPair myData(sourceFace[bFacei], sourceProc[bFacei]); labelPair myData(sourceFace[bFacei], sourceProc[bFacei]);
labelPairLookup::const_iterator iter = map.find(myData); const auto iter = map.cfind(myData);
if (iter != map.end()) if (iter.found())
{ {
label nbrBFacei = iter(); label nbrBFacei = *iter;
masterCoupledFaces[coupledI] = mesh.nInternalFaces() + bFacei; masterCoupledFaces[coupledI] = mesh.nInternalFaces() + bFacei;
slaveCoupledFaces[coupledI] = slaveCoupledFaces[coupledI] =

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2015-2017 OpenCFD Ltd. \\ / A nd | Copyright (C) 2015-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation | Copyright (C) 2011-2016 OpenFOAM Foundation
@ -37,7 +37,7 @@ void Foam::fvMeshDistribute::printFieldInfo(const fvMesh& mesh)
mesh.objectRegistry::lookupClass<GeoField>() mesh.objectRegistry::lookupClass<GeoField>()
); );
forAllConstIter(typename HashTable<const GeoField*>, flds, iter) forAllConstIters(flds, iter)
{ {
const GeoField& fld = *iter(); const GeoField& fld = *iter();
@ -69,20 +69,19 @@ void Foam::fvMeshDistribute::saveBoundaryFields
HashTable<const fldType*> flds HashTable<const fldType*> flds
( (
static_cast<const fvMesh&>(mesh_).objectRegistry::lookupClass<fldType>() mesh_.objectRegistry::lookupClass<const fldType>()
); );
bflds.setSize(flds.size()); bflds.setSize(flds.size());
label i = 0; label i = 0;
forAllConstIters(flds, iter)
forAllConstIter(typename HashTable<const fldType*>, flds, iter)
{ {
const fldType& fld = *iter(); const fldType& fld = *iter();
bflds.set(i, fld.boundaryField().clone().ptr()); bflds.set(i, fld.boundaryField().clone().ptr());
i++; ++i;
} }
} }
@ -114,10 +113,10 @@ void Foam::fvMeshDistribute::mapBoundaryFields
label fieldi = 0; label fieldi = 0;
forAllIter(typename HashTable<fldType*>, flds, iter) forAllIters(flds, iter)
{ {
fldType& fld = *iter(); fldType& fld = *iter();
typename fldType::Boundary& bfld = fld.boundaryFieldRef(); auto& bfld = fld.boundaryFieldRef();
const FieldField<fvsPatchField, T>& oldBfld = oldBflds[fieldi++]; const FieldField<fvsPatchField, T>& oldBfld = oldBflds[fieldi++];
@ -158,20 +157,20 @@ void Foam::fvMeshDistribute::saveInternalFields
HashTable<const fldType*> flds HashTable<const fldType*> flds
( (
static_cast<const fvMesh&>(mesh_).objectRegistry::lookupClass<fldType>() mesh_.objectRegistry::lookupClass<const fldType>()
); );
iflds.setSize(flds.size()); iflds.setSize(flds.size());
label i = 0; label i = 0;
forAllConstIter(typename HashTable<const fldType*>, flds, iter) forAllConstIters(flds, iter)
{ {
const fldType& fld = *iter(); const fldType& fld = *iter();
iflds.set(i, fld.primitiveField().clone()); iflds.set(i, fld.primitiveField().clone());
i++; ++i;
} }
} }
@ -204,7 +203,7 @@ void Foam::fvMeshDistribute::mapExposedFaces
label fieldI = 0; label fieldI = 0;
forAllIter(typename HashTable<fldType*>, flds, iter) forAllIters(flds, iter)
{ {
fldType& fld = *iter(); fldType& fld = *iter();
const bool oriented = fld.oriented()(); const bool oriented = fld.oriented()();
@ -253,11 +252,11 @@ void Foam::fvMeshDistribute::initPatchFields
mesh_.objectRegistry::lookupClass<GeoField>() mesh_.objectRegistry::lookupClass<GeoField>()
); );
forAllIter(typename HashTable<GeoField*>, flds, iter) forAllIters(flds, iter)
{ {
GeoField& fld = *iter(); GeoField& fld = *iter();
typename GeoField::Boundary& bfld = fld.boundaryFieldRef(); auto& bfld = fld.boundaryFieldRef();
forAll(bfld, patchi) forAll(bfld, patchi)
{ {
@ -280,9 +279,9 @@ void Foam::fvMeshDistribute::correctBoundaryConditions()
mesh_.objectRegistry::lookupClass<GeoField>() mesh_.objectRegistry::lookupClass<GeoField>()
); );
forAllIter(typename HashTable<GeoField*>, flds, iter) forAllIters(flds, iter)
{ {
const GeoField& fld = *iter(); GeoField& fld = *iter();
fld.correctBoundaryConditions(); fld.correctBoundaryConditions();
} }
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation | Copyright (C) 2011-2016 OpenFOAM Foundation
@ -465,11 +465,11 @@ Foam::fvMeshSubset::interpolate
// Get mesh point on original mesh. // Get mesh point on original mesh.
label meshPointi = pointMap[subMeshPoints[localI]]; label meshPointi = pointMap[subMeshPoints[localI]];
Map<label>::const_iterator iter = meshPointMap.find(meshPointi); const auto iter = meshPointMap.cfind(meshPointi);
if (iter != meshPointMap.end()) if (iter.found())
{ {
directAddressing[localI] = iter(); directAddressing[localI] = *iter;
} }
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2012-2016 OpenFOAM Foundation | Copyright (C) 2012-2016 OpenFOAM Foundation
@ -45,12 +45,11 @@ void Foam::fvMeshTools::addPatchFields
mesh.objectRegistry::lookupClass<GeoField>() mesh.objectRegistry::lookupClass<GeoField>()
); );
forAllIter(typename HashTable<GeoField*>, flds, iter) forAllIters(flds, iter)
{ {
GeoField& fld = *iter(); GeoField& fld = *iter();
typename GeoField::Boundary& bfld = auto& bfld = fld.boundaryFieldRef();
fld.boundaryFieldRef();
label sz = bfld.size(); label sz = bfld.size();
bfld.setSize(sz+1); bfld.setSize(sz+1);
@ -99,12 +98,11 @@ void Foam::fvMeshTools::setPatchFields
mesh.objectRegistry::lookupClass<GeoField>() mesh.objectRegistry::lookupClass<GeoField>()
); );
forAllIter(typename HashTable<GeoField*>, flds, iter) forAllIters(flds, iter)
{ {
GeoField& fld = *iter(); GeoField& fld = *iter();
typename GeoField::Boundary& bfld = auto& bfld = fld.boundaryFieldRef();
fld.boundaryFieldRef();
if (patchFieldDict.found(fld.name())) if (patchFieldDict.found(fld.name()))
{ {
@ -138,12 +136,11 @@ void Foam::fvMeshTools::setPatchFields
mesh.objectRegistry::lookupClass<GeoField>() mesh.objectRegistry::lookupClass<GeoField>()
); );
forAllIter(typename HashTable<GeoField*>, flds, iter) forAllIters(flds, iter)
{ {
GeoField& fld = *iter(); GeoField& fld = *iter();
typename GeoField::Boundary& bfld = auto& bfld = fld.boundaryFieldRef();
fld.boundaryFieldRef();
bfld[patchi] == value; bfld[patchi] == value;
} }
@ -159,7 +156,7 @@ void Foam::fvMeshTools::trimPatchFields(fvMesh& mesh, const label nPatches)
mesh.objectRegistry::lookupClass<GeoField>() mesh.objectRegistry::lookupClass<GeoField>()
); );
forAllIter(typename HashTable<GeoField*>, flds, iter) forAllIters(flds, iter)
{ {
GeoField& fld = *iter(); GeoField& fld = *iter();
fld.boundaryFieldRef().setSize(nPatches); fld.boundaryFieldRef().setSize(nPatches);
@ -180,12 +177,11 @@ void Foam::fvMeshTools::reorderPatchFields
mesh.objectRegistry::lookupClass<GeoField>() mesh.objectRegistry::lookupClass<GeoField>()
); );
forAllIter(typename HashTable<GeoField*>, flds, iter) forAllIters(flds, iter)
{ {
GeoField& fld = *iter(); GeoField& fld = *iter();
typename GeoField::Boundary& bfld = auto& bfld = fld.boundaryFieldRef();
fld.boundaryFieldRef();
bfld.reorder(oldToNew); bfld.reorder(oldToNew);
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd. \\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation | Copyright (C) 2011-2016 OpenFOAM Foundation
@ -221,10 +221,9 @@ void Foam::layerAdditionRemoval::removeCellLayer
forAll(newFace, pointi) forAll(newFace, pointi)
{ {
Map<label>::iterator rpmIter = const auto rpmIter = removedPointMap.cfind(newFace[pointi]);
removedPointMap.find(newFace[pointi]);
if (rpmIter != removedPointMap.end()) if (rpmIter.found())
{ {
// Point mapped. Replace it // Point mapped. Replace it
newFace[pointi] = rpmIter(); newFace[pointi] = rpmIter();

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd. \\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation | Copyright (C) 2011-2017 OpenFOAM Foundation
@ -178,13 +178,13 @@ void Foam::cellCuts::syncProc()
label facei = pp.start()+i; label facei = pp.start()+i;
label bFacei = facei-mesh().nInternalFaces(); label bFacei = facei-mesh().nInternalFaces();
const Map<edge>::const_iterator iter = const auto iter = faceSplitCut_.cfind(facei);
faceSplitCut_.find(facei);
if (iter != faceSplitCut_.end()) if (iter.found())
{ {
const face& f = mesh().faces()[facei]; const face& f = mesh().faces()[facei];
const labelList& fEdges = mesh().faceEdges()[facei]; const labelList& fEdges = mesh().faceEdges()[facei];
const edge& cuts = iter(); const edge& cuts = iter.val();
forAll(cuts, i) forAll(cuts, i)
{ {
@ -1489,13 +1489,13 @@ bool Foam::cellCuts::calcAnchors
DynamicList<label> connectedPoints(cPoints.size()); DynamicList<label> connectedPoints(cPoints.size());
DynamicList<label> otherPoints(cPoints.size()); DynamicList<label> otherPoints(cPoints.size());
forAllConstIter(Map<label>, pointStatus, iter) forAllConstIters(pointStatus, iter)
{ {
if (iter() == 1) if (iter.val() == 1)
{ {
connectedPoints.append(iter.key()); connectedPoints.append(iter.key());
} }
else if (iter() == 2) else if (iter.val() == 2)
{ {
otherPoints.append(iter.key()); otherPoints.append(iter.key());
} }
@ -1525,13 +1525,13 @@ bool Foam::cellCuts::calcAnchors
labelHashSet connectedFaces(2*cFaces.size()); labelHashSet connectedFaces(2*cFaces.size());
labelHashSet otherFaces(2*cFaces.size()); labelHashSet otherFaces(2*cFaces.size());
forAllConstIter(Map<label>, pointStatus, iter) forAllConstIters(pointStatus, iter)
{ {
label pointi = iter.key(); const label pointi = iter.key();
const labelList& pFaces = mesh().pointFaces()[pointi]; const labelList& pFaces = mesh().pointFaces()[pointi];
if (iter() == 1) if (iter.val() == 1)
{ {
forAll(pFaces, pFacei) forAll(pFaces, pFacei)
{ {
@ -1541,7 +1541,7 @@ bool Foam::cellCuts::calcAnchors
} }
} }
} }
else if (iter() == 2) else if (iter.val() == 2)
{ {
forAll(pFaces, pFacei) forAll(pFaces, pFacei)
{ {
@ -2106,9 +2106,9 @@ bool Foam::cellCuts::validLoop
// edge). Check if this is compatible with existing pattern. // edge). Check if this is compatible with existing pattern.
edge cutEdge(cut, nextCut); edge cutEdge(cut, nextCut);
Map<edge>::const_iterator iter = faceSplitCut_.find(meshFacei); const auto iter = faceSplitCut_.cfind(meshFacei);
if (iter == faceSplitCut_.end()) if (!iter.found())
{ {
// Face not yet cut so insert. // Face not yet cut so insert.
newFaceSplitCut.insert(meshFacei, cutEdge); newFaceSplitCut.insert(meshFacei, cutEdge);
@ -2116,7 +2116,7 @@ bool Foam::cellCuts::validLoop
else else
{ {
// Face already cut. Ok if same edge. // Face already cut. Ok if same edge.
if (iter() != cutEdge) if (iter.val() != cutEdge)
{ {
return false; return false;
} }
@ -2204,9 +2204,9 @@ void Foam::cellCuts::setFromCellLoops()
cellAnchorPoints_[celli].transfer(anchorPoints); cellAnchorPoints_[celli].transfer(anchorPoints);
// Copy faceSplitCuts into overall faceSplit info. // Copy faceSplitCuts into overall faceSplit info.
forAllConstIter(Map<edge>, faceSplitCuts, iter) forAllConstIters(faceSplitCuts, iter)
{ {
faceSplitCut_.insert(iter.key(), iter()); faceSplitCut_.insert(iter.key(), iter.val());
} }
// Update edgeIsCut, pointIsCut information // Update edgeIsCut, pointIsCut information
@ -2305,20 +2305,20 @@ bool Foam::cellCuts::setFromCellLoop
cellAnchorPoints_[celli].transfer(anchorPoints); cellAnchorPoints_[celli].transfer(anchorPoints);
// Copy split cuts // Copy split cuts
forAllConstIter(Map<edge>, faceSplitCuts, iter) forAllConstIters(faceSplitCuts, iter)
{ {
faceSplitCut_.insert(iter.key(), iter()); faceSplitCut_.insert(iter.key(), iter.val());
} }
// Update edgeIsCut, pointIsCut information // Update edgeIsCut, pointIsCut information
forAll(loop, cutI) forAll(loop, cutI)
{ {
label cut = loop[cutI]; const label cut = loop[cutI];
if (isEdge(cut)) if (isEdge(cut))
{ {
label edgeI = getEdge(cut); const label edgeI = getEdge(cut);
edgeIsCut_[edgeI] = true; edgeIsCut_[edgeI] = true;
@ -2326,7 +2326,7 @@ bool Foam::cellCuts::setFromCellLoop
} }
else else
{ {
label vertI = getVertex(cut); const label vertI = getVertex(cut);
pointIsCut_[vertI] = true; pointIsCut_[vertI] = true;
} }
@ -2352,7 +2352,7 @@ void Foam::cellCuts::setFromCellLoops
forAll(cellLabels, cellLabelI) forAll(cellLabels, cellLabelI)
{ {
label celli = cellLabels[cellLabelI]; const label celli = cellLabels[cellLabelI];
const labelList& loop = cellLoops[cellLabelI]; const labelList& loop = cellLoops[cellLabelI];
@ -2399,7 +2399,7 @@ void Foam::cellCuts::setFromCellCutter
{ {
const refineCell& refCell = refCells[refCelli]; const refineCell& refCell = refCells[refCelli];
label celli = refCell.cellNo(); const label celli = refCell.cellNo();
const vector& refDir = refCell.direction(); const vector& refDir = refCell.direction();
@ -2524,7 +2524,7 @@ void Foam::cellCuts::setFromCellCutter
forAll(cellLabels, i) forAll(cellLabels, i)
{ {
label celli = cellLabels[i]; const label celli = cellLabels[i];
// Cut cell. Determines cellLoop and cellLoopWeights // Cut cell. Determines cellLoop and cellLoopWeights
bool goodCut = bool goodCut =
@ -2827,9 +2827,9 @@ void Foam::cellCuts::check() const
syncTools::swapBoundaryCellList(mesh(), cellIsCut, nbrCellIsCut); syncTools::swapBoundaryCellList(mesh(), cellIsCut, nbrCellIsCut);
} }
forAllConstIter(Map<edge>, faceSplitCut_, iter) forAllConstIters(faceSplitCut_, iter)
{ {
label facei = iter.key(); const label facei = iter.key();
if (mesh().isInternalFace(facei)) if (mesh().isInternalFace(facei))
{ {
@ -2839,7 +2839,7 @@ void Foam::cellCuts::check() const
if (cellLoops_[own].empty() && cellLoops_[nei].empty()) if (cellLoops_[own].empty() && cellLoops_[nei].empty())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Internal face:" << facei << " cut by " << iter() << "Internal face:" << facei << " cut by " << iter.val()
<< " has owner:" << own << " has owner:" << own
<< " and neighbour:" << nei << " and neighbour:" << nei
<< " that are both uncut" << " that are both uncut"
@ -2855,7 +2855,7 @@ void Foam::cellCuts::check() const
if (cellLoops_[own].empty() && !nbrCellIsCut[bFacei]) if (cellLoops_[own].empty() && !nbrCellIsCut[bFacei])
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Boundary face:" << facei << " cut by " << iter() << "Boundary face:" << facei << " cut by " << iter.val()
<< " has owner:" << own << " has owner:" << own
<< " that is uncut" << " that is uncut"
<< abort(FatalError); << abort(FatalError);
@ -3161,7 +3161,7 @@ Foam::pointField Foam::cellCuts::loopPoints(const label celli) const
forAll(loop, fp) forAll(loop, fp)
{ {
label cut = loop[fp]; const label cut = loop[fp];
if (isEdge(cut)) if (isEdge(cut))
{ {

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd. \\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation | Copyright (C) 2011-2016 OpenFOAM Foundation
@ -69,18 +69,18 @@ void Foam::edgeVertex::updateLabels
// Iterate over map to see if anything changed // Iterate over map to see if anything changed
bool changed = false; bool changed = false;
forAllConstIter(Map<label>, cellPairs, iter) forAllConstIters(cellPairs, iter)
{ {
label newMaster = map[iter.key()]; label newMaster = map[iter.key()];
label newSlave = -1; label newSlave = -1;
if (iter() != -1) if (iter.val() != -1)
{ {
newSlave = map[iter()]; newSlave = map[iter.val()];
} }
if ((newMaster != iter.key()) || (newSlave != iter())) if ((newMaster != iter.key()) || (newSlave != iter.val()))
{ {
changed = true; changed = true;
@ -93,15 +93,15 @@ void Foam::edgeVertex::updateLabels
{ {
Map<label> newCellPairs(2*cellPairs.size()); Map<label> newCellPairs(2*cellPairs.size());
forAllConstIter(Map<label>, cellPairs, iter) forAllConstIters(cellPairs, iter)
{ {
label newMaster = map[iter.key()]; label newMaster = map[iter.key()];
label newSlave = -1; label newSlave = -1;
if (iter() != -1) if (iter.val() != -1)
{ {
newSlave = map[iter()]; newSlave = map[iter.val()];
} }
if (newMaster == -1) if (newMaster == -1)

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation | Copyright (C) 2011-2016 OpenFOAM Foundation
@ -99,9 +99,9 @@ Foam::face Foam::boundaryCutter::addEdgeCutsToFace
label edgeI = meshTools::findEdge(edges, fEdges, f[fp], v1); label edgeI = meshTools::findEdge(edges, fEdges, f[fp], v1);
Map<labelList>::const_iterator fnd = edgeToAddedPoints.find(edgeI); const auto fnd = edgeToAddedPoints.cfind(edgeI);
if (fnd != edgeToAddedPoints.end()) if (fnd.found())
{ {
// edge has been cut. Introduce new vertices. Check order. // edge has been cut. Introduce new vertices. Check order.
const labelList& addedPoints = fnd(); const labelList& addedPoints = fnd();
@ -228,9 +228,9 @@ bool Foam::boundaryCutter::splitFace
label edgeI = meshTools::findEdge(edges, fEdges, f[fp], nextV); label edgeI = meshTools::findEdge(edges, fEdges, f[fp], nextV);
Map<labelList>::const_iterator fnd = edgeToAddedPoints.find(edgeI); const auto fnd = edgeToAddedPoints.cfind(edgeI);
if (fnd != edgeToAddedPoints.end()) if (fnd.found())
{ {
nSplitEdges++; nSplitEdges++;
nTotalSplits += fnd().size(); nTotalSplits += fnd().size();
@ -422,14 +422,14 @@ void Foam::boundaryCutter::setRefinement
// Note: could just as well be handled outside of setRefinement. // Note: could just as well be handled outside of setRefinement.
// //
forAllConstIter(Map<point>, pointToPos, iter) forAllConstIters(pointToPos, iter)
{ {
meshMod.setAction meshMod.setAction
( (
polyModifyPoint polyModifyPoint
( (
iter.key(), // point iter.key(), // point
iter(), // position iter.val(), // position
false, // no zone false, // no zone
-1, // zone for point -1, // zone for point
true // supports a cell true // supports a cell
@ -445,14 +445,14 @@ void Foam::boundaryCutter::setRefinement
// Map from edge label to sorted list of points // Map from edge label to sorted list of points
Map<labelList> edgeToAddedPoints(edgeToCuts.size()); Map<labelList> edgeToAddedPoints(edgeToCuts.size());
forAllConstIter(Map<List<point>>, edgeToCuts, iter) forAllConstIters(edgeToCuts, iter)
{ {
label edgeI = iter.key(); const label edgeI = iter.key();
const List<point>& cuts = iter.val();
const edge& e = mesh_.edges()[edgeI]; const edge& e = mesh_.edges()[edgeI];
// Sorted (from start to end) list of cuts on edge // Sorted (from start to end) list of cuts on edge
const List<point>& cuts = iter();
forAll(cuts, cutI) forAll(cuts, cutI)
{ {
@ -471,9 +471,9 @@ void Foam::boundaryCutter::setRefinement
) )
); );
Map<labelList>::iterator fnd = edgeToAddedPoints.find(edgeI); auto fnd = edgeToAddedPoints.find(edgeI);
if (fnd != edgeToAddedPoints.end()) if (fnd.found())
{ {
labelList& addedPoints = fnd(); labelList& addedPoints = fnd();
@ -499,9 +499,9 @@ void Foam::boundaryCutter::setRefinement
// Introduce feature points. // Introduce feature points.
// //
forAllConstIter(Map<point>, faceToFeaturePoint, iter) forAllConstIters(faceToFeaturePoint, iter)
{ {
label facei = iter.key(); const label facei = iter.key();
const face& f = mesh_.faces()[facei]; const face& f = mesh_.faces()[facei];
@ -527,18 +527,19 @@ void Foam::boundaryCutter::setRefinement
( (
polyAddPoint polyAddPoint
( (
iter(), // point iter.val(), // point
f[0], // master point f[0], // master point
-1, // zone for point -1, // zone for point
true // supports a cell true // supports a cell
) )
); );
faceAddedPoint_.insert(facei, addedPointi); faceAddedPoint_.insert(facei, addedPointi);
if (debug) if (debug)
{ {
Pout<< "Added point " << addedPointi << " for feature point " Pout<< "Added point " << addedPointi << " for feature point "
<< iter() << " on face " << facei << " with centre " << iter.val() << " on face " << facei << " with centre "
<< mesh_.faceCentres()[facei] << endl; << mesh_.faceCentres()[facei] << endl;
} }
} }
@ -555,15 +556,14 @@ void Foam::boundaryCutter::setRefinement
// Triangulate faces containing feature points // Triangulate faces containing feature points
forAllConstIter(Map<label>, faceAddedPoint_, iter) forAllConstIters(faceAddedPoint_, iter)
{ {
label facei = iter.key(); const label facei = iter.key();
const label addedPointi = iter.val();
// Get face with new points on cut edges. // Get face with new points on cut edges.
face newFace(addEdgeCutsToFace(facei, edgeToAddedPoints)); face newFace(addEdgeCutsToFace(facei, edgeToAddedPoints));
label addedPointi = iter();
// Information about old face // Information about old face
label patchID, zoneID, zoneFlip; label patchID, zoneID, zoneFlip;
getFaceInfo(facei, patchID, zoneID, zoneFlip); getFaceInfo(facei, patchID, zoneID, zoneFlip);
@ -628,9 +628,9 @@ void Foam::boundaryCutter::setRefinement
// Diagonally split faces // Diagonally split faces
forAllConstIter(Map<labelPair>, faceToSplit, iter) forAllConstIters(faceToSplit, iter)
{ {
label facei = iter.key(); const label facei = iter.key();
const face& f = mesh_.faces()[facei]; const face& f = mesh_.faces()[facei];
@ -654,7 +654,7 @@ void Foam::boundaryCutter::setRefinement
label masterPoint = mesh_.faces()[facei][0]; label masterPoint = mesh_.faces()[facei][0];
// Split face from one side of diagonal to other. // Split face from one side of diagonal to other.
const labelPair& diag = iter(); const labelPair& diag = iter.val();
label fp0 = newFace.find(f[diag[0]]); label fp0 = newFace.find(f[diag[0]]);
label fp1 = newFace.find(f[diag[1]]); label fp1 = newFace.find(f[diag[1]]);
@ -743,9 +743,9 @@ void Foam::boundaryCutter::setRefinement
// Split external faces without feature point but using cut edges. // Split external faces without feature point but using cut edges.
// Does right handed walk but not really. // Does right handed walk but not really.
forAllConstIter(Map<labelList>, edgeToAddedPoints, iter) forAllConstIters(edgeToAddedPoints, iter)
{ {
label edgeI = iter.key(); const label edgeI = iter.key();
const labelList& eFaces = mesh_.edgeFaces()[edgeI]; const labelList& eFaces = mesh_.edgeFaces()[edgeI];
@ -769,9 +769,9 @@ void Foam::boundaryCutter::setRefinement
// Add cut edges (but don't split) any other faces using any cut edge. // Add cut edges (but don't split) any other faces using any cut edge.
// These can be external faces where splitFace hasn't cut them or // These can be external faces where splitFace hasn't cut them or
// internal faces. // internal faces.
forAllConstIter(Map<labelList>, edgeToAddedPoints, iter) forAllConstIters(edgeToAddedPoints, iter)
{ {
label edgeI = iter.key(); const label edgeI = iter.key();
const labelList& eFaces = mesh_.edgeFaces()[edgeI]; const labelList& eFaces = mesh_.edgeFaces()[edgeI];
@ -784,7 +784,7 @@ void Foam::boundaryCutter::setRefinement
// Renumber face to include split edges. // Renumber face to include split edges.
face newFace(addEdgeCutsToFace(facei, edgeToAddedPoints)); face newFace(addEdgeCutsToFace(facei, edgeToAddedPoints));
label own = mesh_.faceOwner()[facei]; const label own = mesh_.faceOwner()[facei];
label nei = -1; label nei = -1;
@ -821,9 +821,9 @@ void Foam::boundaryCutter::setRefinement
// to point labels // to point labels
edgeAddedPoints_.resize(edgeToCuts.size()); edgeAddedPoints_.resize(edgeToCuts.size());
forAllConstIter(Map<labelList>, edgeToAddedPoints, iter) forAllConstIters(edgeToAddedPoints, iter)
{ {
edgeAddedPoints_.insert(mesh_.edges()[iter.key()], iter()); edgeAddedPoints_.insert(mesh_.edges()[iter.key()], iter.val());
} }
} }
@ -840,15 +840,13 @@ void Foam::boundaryCutter::updateMesh(const mapPolyMesh& morphMap)
// Create copy since we're deleting entries. // Create copy since we're deleting entries.
Map<label> newAddedPoints(faceAddedPoint_.size()); Map<label> newAddedPoints(faceAddedPoint_.size());
forAllConstIter(Map<label>, faceAddedPoint_, iter) forAllConstIters(faceAddedPoint_, iter)
{ {
label oldFacei = iter.key(); const label oldFacei = iter.key();
const label oldPointi = iter.val();
label newFacei = morphMap.reverseFaceMap()[oldFacei]; const label newFacei = morphMap.reverseFaceMap()[oldFacei];
const label newPointi = morphMap.reversePointMap()[oldPointi];
label oldPointi = iter();
label newPointi = morphMap.reversePointMap()[oldPointi];
if (newFacei >= 0 && newPointi >= 0) if (newFacei >= 0 && newPointi >= 0)
{ {

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation | Copyright (C) 2011-2016 OpenFOAM Foundation
@ -706,9 +706,9 @@ void Foam::meshCutAndRemove::setRefinement
// Check // Check
const Map<edge>& faceSplitCut = cuts.faceSplitCut(); const Map<edge>& faceSplitCut = cuts.faceSplitCut();
forAllConstIter(Map<edge>, faceSplitCut, iter) forAllConstIters(faceSplitCut, iter)
{ {
const edge& fCut = iter(); const edge& fCut = iter.val();
forAll(fCut, i) forAll(fCut, i)
{ {
@ -854,16 +854,16 @@ void Foam::meshCutAndRemove::setRefinement
const Map<edge>& faceSplitCuts = cuts.faceSplitCut(); const Map<edge>& faceSplitCuts = cuts.faceSplitCut();
forAllConstIter(Map<edge>, faceSplitCuts, iter) forAllConstIters(faceSplitCuts, iter)
{ {
label facei = iter.key(); const label facei = iter.key();
const edge& splitEdge = iter.val();
// Renumber face to include split edges. // Renumber face to include split edges.
face newFace(addEdgeCutsToFace(facei)); face newFace(addEdgeCutsToFace(facei));
// Edge splitting the face. Convert edge to new vertex numbering. // Edge splitting the face. Convert edge to new vertex numbering.
const edge& splitEdge = iter();
label cut0 = splitEdge[0]; label cut0 = splitEdge[0];
label v0; label v0;
@ -1272,14 +1272,13 @@ void Foam::meshCutAndRemove::updateMesh(const mapPolyMesh& map)
{ {
Map<label> newAddedFaces(addedFaces_.size()); Map<label> newAddedFaces(addedFaces_.size());
forAllConstIter(Map<label>, addedFaces_, iter) forAllConstIters(addedFaces_, iter)
{ {
label celli = iter.key(); const label celli = iter.key();
label newCelli = map.reverseCellMap()[celli]; const label addedFacei = iter.val();
label addedFacei = iter(); const label newCelli = map.reverseCellMap()[celli];
const label newAddedFacei = map.reverseFaceMap()[addedFacei];
label newAddedFacei = map.reverseFaceMap()[addedFacei];
if ((newCelli >= 0) && (newAddedFacei >= 0)) if ((newCelli >= 0) && (newAddedFacei >= 0))
{ {
@ -1311,15 +1310,13 @@ void Foam::meshCutAndRemove::updateMesh(const mapPolyMesh& map)
const edge& e = iter.key(); const edge& e = iter.key();
const label addedPointi = iter.val(); const label addedPointi = iter.val();
label newStart = map.reversePointMap()[e.start()]; const label newStart = map.reversePointMap()[e.start()];
const label newEnd = map.reversePointMap()[e.end()];
label newEnd = map.reversePointMap()[e.end()]; const label newAddedPointi = map.reversePointMap()[addedPointi];
label newAddedPointi = map.reversePointMap()[addedPointi];
if ((newStart >= 0) && (newEnd >= 0) && (newAddedPointi >= 0)) if ((newStart >= 0) && (newEnd >= 0) && (newAddedPointi >= 0))
{ {
edge newE = edge(newStart, newEnd); edge newE(newStart, newEnd);
if if
( (

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation | Copyright (C) 2011-2017 OpenFOAM Foundation
@ -736,16 +736,16 @@ void Foam::meshCutter::setRefinement
const Map<edge>& faceSplitCuts = cuts.faceSplitCut(); const Map<edge>& faceSplitCuts = cuts.faceSplitCut();
forAllConstIter(Map<edge>, faceSplitCuts, iter) forAllConstIters(faceSplitCuts, iter)
{ {
label facei = iter.key(); const label facei = iter.key();
const edge& splitEdge = iter.val();
// Renumber face to include split edges. // Renumber face to include split edges.
face newFace(addEdgeCutsToFace(facei)); face newFace(addEdgeCutsToFace(facei));
// Edge splitting the face. Convert cuts to new vertex numbering. // Edge splitting the face. Convert cuts to new vertex numbering.
const edge& splitEdge = iter();
label cut0 = splitEdge[0]; label cut0 = splitEdge[0];
label v0; label v0;
@ -1006,14 +1006,13 @@ void Foam::meshCutter::updateMesh(const mapPolyMesh& morphMap)
// key. // key.
Map<label> newAddedCells(addedCells_.size()); Map<label> newAddedCells(addedCells_.size());
forAllConstIter(Map<label>, addedCells_, iter) forAllConstIters(addedCells_, iter)
{ {
label celli = iter.key(); const label celli = iter.key();
label newCelli = morphMap.reverseCellMap()[celli]; const label addedCelli = iter.val();
label addedCelli = iter(); const label newCelli = morphMap.reverseCellMap()[celli];
const label newAddedCelli = morphMap.reverseCellMap()[addedCelli];
label newAddedCelli = morphMap.reverseCellMap()[addedCelli];
if (newCelli >= 0 && newAddedCelli >= 0) if (newCelli >= 0 && newAddedCelli >= 0)
{ {
@ -1039,14 +1038,13 @@ void Foam::meshCutter::updateMesh(const mapPolyMesh& morphMap)
{ {
Map<label> newAddedFaces(addedFaces_.size()); Map<label> newAddedFaces(addedFaces_.size());
forAllConstIter(Map<label>, addedFaces_, iter) forAllConstIters(addedFaces_, iter)
{ {
label celli = iter.key(); const label celli = iter.key();
label newCelli = morphMap.reverseCellMap()[celli]; const label addedFacei = iter.val();
label addedFacei = iter(); const label newCelli = morphMap.reverseCellMap()[celli];
const label newAddedFacei = morphMap.reverseFaceMap()[addedFacei];
label newAddedFacei = morphMap.reverseFaceMap()[addedFacei];
if ((newCelli >= 0) && (newAddedFacei >= 0)) if ((newCelli >= 0) && (newAddedFacei >= 0))
{ {

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd. \\ / A nd | Copyright (C) 2015-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation | Copyright (C) 2011-2016 OpenFOAM Foundation
@ -65,16 +65,17 @@ void Foam::multiDirRefinement::addCells
{ {
const refineCell& refCell = refCells[refI]; const refineCell& refCell = refCells[refI];
Map<label>::const_iterator iter = splitMap.find(refCell.cellNo()); const auto iter = splitMap.cfind(refCell.cellNo());
if (iter == splitMap.end()) if (!iter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Problem : cannot find added cell for cell " << "Problem : cannot find added cell for cell "
<< refCell.cellNo() << abort(FatalError); << refCell.cellNo() << endl
<< abort(FatalError);
} }
refCells[newRefI++] = refineCell(iter(), refCell.direction()); refCells[newRefI++] = refineCell(iter.val(), refCell.direction());
} }
} }
@ -89,9 +90,9 @@ void Foam::multiDirRefinement::update
{ {
field.setSize(field.size() + splitMap.size()); field.setSize(field.size() + splitMap.size());
forAllConstIter(Map<label>, splitMap, iter) forAllConstIters(splitMap, iter)
{ {
field[iter()] = field[iter.key()]; field[iter.val()] = field[iter.key()];
} }
} }
@ -107,9 +108,9 @@ void Foam::multiDirRefinement::addCells
labels.setSize(labels.size() + splitMap.size()); labels.setSize(labels.size() + splitMap.size());
forAllConstIter(Map<label>, splitMap, iter) forAllConstIters(splitMap, iter)
{ {
labels[newCelli++] = iter(); labels[newCelli++] = iter.val();
} }
} }
@ -148,10 +149,10 @@ void Foam::multiDirRefinement::addCells
} }
forAllConstIter(Map<label>, splitMap, iter) forAllConstIters(splitMap, iter)
{ {
label masterI = iter.key(); label masterI = iter.key();
label newCelli = iter(); const label newCelli = iter.val();
while (origCell[masterI] != -1 && origCell[masterI] != masterI) while (origCell[masterI] != -1 && origCell[masterI] != masterI)
{ {
@ -178,7 +179,7 @@ void Foam::multiDirRefinement::addCells
} }
else if (!added.found(newCelli)) else if (!added.found(newCelli))
{ {
label sz = added.size(); const label sz = added.size();
added.setSize(sz + 1); added.setSize(sz + 1);
added[sz] = newCelli; added[sz] = newCelli;
} }
@ -285,25 +286,25 @@ void Foam::multiDirRefinement::refineHex8
{ {
const label celli = consistentCells[i]; const label celli = consistentCells[i];
Map<label>::iterator iter = hexCellSet.find(celli); auto iter = hexCellSet.find(celli);
if (iter == hexCellSet.end()) if (iter.found())
{
iter.val() = 2;
}
else
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Resulting mesh would not satisfy 2:1 ratio" << "Resulting mesh would not satisfy 2:1 ratio"
<< " when refining cell " << celli << abort(FatalError); << " when refining cell " << celli << abort(FatalError);
} }
else
{
iter() = 2;
}
} }
// Check if all been visited (should always be since // Check if all been visited (should always be since
// consistentRefinement set up to extend set. // consistentRefinement set up to extend set.
forAllConstIter(Map<label>, hexCellSet, iter) forAllConstIters(hexCellSet, iter)
{ {
if (iter() != 2) if (iter.val() != 2)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Resulting mesh would not satisfy 2:1 ratio" << "Resulting mesh would not satisfy 2:1 ratio"
@ -399,7 +400,7 @@ void Foam::multiDirRefinement::refineAllDirs
forAll(refCells, refI) forAll(refCells, refI)
{ {
label celli = cellLabels_[refI]; const label celli = cellLabels_[refI];
refCells[refI] = refineCell(celli, dirField[0]); refCells[refI] = refineCell(celli, dirField[0]);
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation | Copyright (C) 2011-2017 OpenFOAM Foundation
@ -212,14 +212,14 @@ Foam::Map<Foam::label> Foam::refinementIterator::setRefinement
// from meshRefiner.updateMesh call) and add to global list of added // from meshRefiner.updateMesh call) and add to global list of added
const Map<label>& addedNow = meshRefiner_.addedCells(); const Map<label>& addedNow = meshRefiner_.addedCells();
forAllConstIter(Map<label>, addedNow, iter) forAllConstIters(addedNow, iter)
{ {
if (!addedCells.insert(iter.key(), iter())) if (!addedCells.insert(iter.key(), iter.val()))
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Master cell " << iter.key() << "Master cell " << iter.key()
<< " already has been refined" << endl << " already has been refined" << endl
<< "Added cell:" << iter() << abort(FatalError); << "Added cell:" << iter.val() << abort(FatalError);
} }
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation | Copyright (C) 2011-2016 OpenFOAM Foundation
@ -70,9 +70,9 @@ void Foam::undoableMeshCutter::printCellRefTree
// For debugging // For debugging
void Foam::undoableMeshCutter::printRefTree(Ostream& os) const void Foam::undoableMeshCutter::printRefTree(Ostream& os) const
{ {
forAllConstIter(Map<splitCell*>, liveSplitCells_, iter) forAllConstIters(liveSplitCells_, iter)
{ {
const splitCell* splitPtr = iter(); const splitCell* splitPtr = iter.val();
// Walk to top (master path only) // Walk to top (master path only)
while (splitPtr->parent()) while (splitPtr->parent())
@ -111,9 +111,9 @@ void Foam::undoableMeshCutter::updateLabels
bool changed = false; bool changed = false;
forAllConstIter(Map<splitCell*>, liveSplitCells, iter) forAllConstIters(liveSplitCells, iter)
{ {
const splitCell* splitPtr = iter(); const splitCell* splitPtr = iter.val();
if (!splitPtr) if (!splitPtr)
{ {
@ -141,13 +141,13 @@ void Foam::undoableMeshCutter::updateLabels
// since new labels (= keys in Map) might clash with existing ones. // since new labels (= keys in Map) might clash with existing ones.
Map<splitCell*> newLiveSplitCells(2*liveSplitCells.size()); Map<splitCell*> newLiveSplitCells(2*liveSplitCells.size());
forAllIter(Map<splitCell*>, liveSplitCells, iter) forAllIters(liveSplitCells, iter)
{ {
splitCell* splitPtr = iter(); splitCell* splitPtr = iter.val();
label celli = splitPtr->cellLabel(); const label celli = splitPtr->cellLabel();
label newCelli = map[celli]; const label newCelli = map[celli];
if (debug && (celli != newCelli)) if (debug && (celli != newCelli))
{ {
@ -197,9 +197,9 @@ Foam::undoableMeshCutter::~undoableMeshCutter()
{ {
// Clean split cell tree. // Clean split cell tree.
forAllIter(Map<splitCell*>, liveSplitCells_, iter) forAllIters(liveSplitCells_, iter)
{ {
splitCell* splitPtr = iter(); splitCell* splitPtr = iter.val();
while (splitPtr) while (splitPtr)
{ {
@ -247,10 +247,9 @@ void Foam::undoableMeshCutter::setRefinement
// Newly created split cell. (celli -> celli + addedCelli) // Newly created split cell. (celli -> celli + addedCelli)
// Check if celli already part of split. // Check if celli already part of split.
Map<splitCell*>::iterator findCell = auto findCell = liveSplitCells_.find(celli);
liveSplitCells_.find(celli);
if (findCell == liveSplitCells_.end()) if (!findCell.found())
{ {
// Celli not yet split. It cannot be unlive split cell // Celli not yet split. It cannot be unlive split cell
// since that would be illegal to split in the first // since that would be illegal to split in the first
@ -350,9 +349,9 @@ Foam::labelList Foam::undoableMeshCutter::getSplitFaces() const
DynamicList<label> liveSplitFaces(liveSplitCells_.size()); DynamicList<label> liveSplitFaces(liveSplitCells_.size());
forAllConstIter(Map<splitCell*>, liveSplitCells_, iter) forAllConstIters(liveSplitCells_, iter)
{ {
const splitCell* splitPtr = iter(); const splitCell* splitPtr = iter.val();
if (!splitPtr->parent()) if (!splitPtr->parent())
{ {
@ -411,9 +410,9 @@ Foam::Map<Foam::label> Foam::undoableMeshCutter::getAddedCells() const
Map<label> addedCells(liveSplitCells_.size()); Map<label> addedCells(liveSplitCells_.size());
forAllConstIter(Map<splitCell*>, liveSplitCells_, iter) forAllConstIters(liveSplitCells_, iter)
{ {
const splitCell* splitPtr = iter(); const splitCell* splitPtr = iter.val();
if (!splitPtr->parent()) if (!splitPtr->parent())
{ {
@ -497,29 +496,18 @@ Foam::labelList Foam::undoableMeshCutter::removeSplitFaces
} }
label own = mesh().faceOwner()[facei]; label own = mesh().faceOwner()[facei];
label nbr = mesh().faceNeighbour()[facei]; label nbr = mesh().faceNeighbour()[facei];
Map<splitCell*>::iterator ownFind = liveSplitCells_.find(own); auto ownFind = liveSplitCells_.find(own);
auto nbrFind = liveSplitCells_.find(nbr);
Map<splitCell*>::iterator nbrFind = liveSplitCells_.find(nbr); if (ownFind.found() && nbrFind.found())
if
(
(ownFind == liveSplitCells_.end())
|| (nbrFind == liveSplitCells_.end())
)
{
// Can happen because of removeFaces adding extra faces to
// original splitFaces
}
else
{ {
// Face is original splitFace. // Face is original splitFace.
splitCell* ownPtr = ownFind(); splitCell* ownPtr = ownFind.val();
splitCell* nbrPtr = nbrFind(); splitCell* nbrPtr = nbrFind.val();
splitCell* parentPtr = ownPtr->parent(); splitCell* parentPtr = ownPtr->parent();
@ -586,7 +574,6 @@ Foam::labelList Foam::undoableMeshCutter::removeSplitFaces
delete ownPtr; delete ownPtr;
delete nbrPtr; delete nbrPtr;
//
// Update parent: // Update parent:
// - has parent itself: is part of split cell. Update cellLabel // - has parent itself: is part of split cell. Update cellLabel
// with merged cell one. // with merged cell one.

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation | Copyright (C) 2011-2017 OpenFOAM Foundation
@ -55,10 +55,12 @@ void Foam::faceCoupleInfo::writeOBJ
{ {
OFstream str(fName); OFstream str(fName);
labelList pointMap(points.size(), -1); labelList pointMap;
if (compact) if (compact)
{ {
pointMap.resize(points.size(), -1);
label newPointi = 0; label newPointi = 0;
forAll(edges, edgeI) forAll(edges, edgeI)
@ -67,7 +69,7 @@ void Foam::faceCoupleInfo::writeOBJ
forAll(e, eI) forAll(e, eI)
{ {
label pointi = e[eI]; const label pointi = e[eI];
if (pointMap[pointi] == -1) if (pointMap[pointi] == -1)
{ {
@ -80,12 +82,12 @@ void Foam::faceCoupleInfo::writeOBJ
} }
else else
{ {
pointMap = identity(points.size());
forAll(points, pointi) forAll(points, pointi)
{ {
meshTools::writeOBJ(str, points[pointi]); meshTools::writeOBJ(str, points[pointi]);
} }
pointMap = identity(points.size());
} }
forAll(edges, edgeI) forAll(edges, edgeI)
@ -243,8 +245,7 @@ void Foam::faceCoupleInfo::writeEdges
{ {
if (cutToMasterEdges[cutEdgeI] != -1) if (cutToMasterEdges[cutEdgeI] != -1)
{ {
const edge& masterEdge = const edge& masterEdge = m.edges()[cutToMasterEdges[cutEdgeI]];
m.edges()[cutToMasterEdges[cutEdgeI]];
const edge& cutEdge = c.edges()[cutEdgeI]; const edge& cutEdge = c.edges()[cutEdgeI];
meshTools::writeOBJ(str, m.localPoints()[masterEdge[0]]); meshTools::writeOBJ(str, m.localPoints()[masterEdge[0]]);
@ -1284,9 +1285,9 @@ Foam::label Foam::faceCoupleInfo::matchEdgeFaces
// Combine master faces with current set of candidate // Combine master faces with current set of candidate
// master faces. // master faces.
Map<labelList>::iterator fnd = candidates.find(cutFacei); auto fnd = candidates.find(cutFacei);
if (fnd == candidates.end()) if (!fnd.found())
{ {
// No info yet for cutFacei. Add all master faces as // No info yet for cutFacei. Add all master faces as
// candidates // candidates
@ -1297,7 +1298,7 @@ Foam::label Foam::faceCoupleInfo::matchEdgeFaces
// From some other cutEdgeI there are already some // From some other cutEdgeI there are already some
// candidate master faces. Check the overlap with // candidate master faces. Check the overlap with
// the current set of master faces. // the current set of master faces.
const labelList& masterFaces = fnd(); const labelList& masterFaces = fnd.val();
DynamicList<label> newCandidates(masterFaces.size()); DynamicList<label> newCandidates(masterFaces.size());
@ -1311,8 +1312,7 @@ Foam::label Foam::faceCoupleInfo::matchEdgeFaces
if (newCandidates.size() == 1) if (newCandidates.size() == 1)
{ {
// We found a perfect match. Delete entry from // Perfect match. Delete entry from candidates map.
// candidates map.
cutToMasterFaces_[cutFacei] = newCandidates[0]; cutToMasterFaces_[cutFacei] = newCandidates[0];
candidates.erase(cutFacei); candidates.erase(cutFacei);
nChanged++; nChanged++;
@ -1368,16 +1368,15 @@ Foam::label Foam::faceCoupleInfo::geometricMatchEdgeFaces
) )
); );
forAllConstIter(Map<labelList>, candidates, iter) forAllConstIters(candidates, iter)
{ {
label cutFacei = iter.key(); label cutFacei = iter.key();
const labelList& masterFaces = iter.val();
const face& cutF = cutFaces()[cutFacei]; const face& cutF = cutFaces()[cutFacei];
if (cutToMasterFaces_[cutFacei] == -1) if (cutToMasterFaces_[cutFacei] == -1)
{ {
const labelList& masterFaces = iter();
// Find the best matching master face. // Find the best matching master face.
scalar minDist = GREAT; scalar minDist = GREAT;
label minMasterFacei = -1; label minMasterFacei = -1;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation | Copyright (C) 2011-2016 OpenFOAM Foundation
@ -53,7 +53,7 @@ Foam::label Foam::polyMeshAdder::patchIndex
const word& pType = p.type(); const word& pType = p.type();
const word& pName = p.name(); const word& pName = p.name();
label patchi = allPatchNames.find(pName); const label patchi = allPatchNames.find(pName);
if (patchi == -1) if (patchi == -1)
{ {
@ -98,7 +98,7 @@ Foam::label Foam::polyMeshAdder::zoneIndex
DynamicList<word>& names DynamicList<word>& names
) )
{ {
label zoneI = names.find(curName); const label zoneI = names.find(curName);
if (zoneI != -1) if (zoneI != -1)
{ {
@ -336,7 +336,7 @@ Foam::labelList Foam::polyMeshAdder::getFaceOrder
forAll(cFaces, i) forAll(cFaces, i)
{ {
label facei = cFaces[i]; const label facei = cFaces[i];
label nbrCelli = neighbour[facei]; label nbrCelli = neighbour[facei];
@ -422,11 +422,11 @@ void Foam::polyMeshAdder::insertVertices
// See if any edge between v0,v1 // See if any edge between v0,v1
Map<label>::const_iterator v0Fnd = meshToMaster.find(v0); const auto v0Fnd = meshToMaster.cfind(v0);
if (v0Fnd != meshToMaster.end()) if (v0Fnd.found())
{ {
Map<label>::const_iterator v1Fnd = meshToMaster.find(v1); const auto v1Fnd = meshToMaster.cfind(v1);
if (v1Fnd != meshToMaster.end()) if (v1Fnd.found())
{ {
// Get edge in cutPoint numbering // Get edge in cutPoint numbering
edge cutEdge edge cutEdge
@ -435,12 +435,12 @@ void Foam::polyMeshAdder::insertVertices
masterToCutPoints[v1Fnd()] masterToCutPoints[v1Fnd()]
); );
edgeLookup::const_iterator iter = cutEdgeToPoints.find(cutEdge); const auto iter = cutEdgeToPoints.cfind(cutEdge);
if (iter != cutEdgeToPoints.end()) if (iter.found())
{ {
const edge& e = iter.key(); const edge& e = iter.key();
const labelList& addedPoints = iter(); const labelList& addedPoints = iter.val();
// cutPoints first in allPoints so no need for renumbering // cutPoints first in allPoints so no need for renumbering
if (e[0] == cutEdge[0]) if (e[0] == cutEdge[0])
@ -2021,15 +2021,15 @@ Foam::Map<Foam::label> Foam::polyMeshAdder::findSharedPoints
label sharedI = sharedPointAddr[i]; label sharedI = sharedPointAddr[i];
Map<labelList>::iterator iter = sharedToMesh.find(sharedI); auto iter = sharedToMesh.find(sharedI);
if (iter != sharedToMesh.end()) if (iter.found())
{ {
// sharedI already used by other point. Add this one. // sharedI already used by other point. Add this one.
nMultiple++; nMultiple++;
labelList& connectedPointLabels = iter(); labelList& connectedPointLabels = iter.val();
label sz = connectedPointLabels.size(); label sz = connectedPointLabels.size();
@ -2059,9 +2059,9 @@ Foam::Map<Foam::label> Foam::polyMeshAdder::findSharedPoints
Map<label> pointToMaster(nMultiple); Map<label> pointToMaster(nMultiple);
forAllConstIter(Map<labelList>, sharedToMesh, iter) forAllConstIters(sharedToMesh, iter)
{ {
const labelList& connectedPointLabels = iter(); const labelList& connectedPointLabels = iter.val();
//Pout<< "For shared:" << iter.key() //Pout<< "For shared:" << iter.key()
// << " found points:" << connectedPointLabels // << " found points:" << connectedPointLabels
@ -2217,13 +2217,13 @@ void Foam::polyMeshAdder::mergePoints
// Remove all non-master points. // Remove all non-master points.
forAll(mesh.points(), pointi) forAll(mesh.points(), pointi)
{ {
Map<label>::const_iterator iter = pointToMaster.find(pointi); const auto iter = pointToMaster.cfind(pointi);
if (iter != pointToMaster.end()) if (iter.found())
{ {
if (iter() != pointi) if (iter.val() != pointi)
{ {
meshMod.removePoint(pointi, iter()); meshMod.removePoint(pointi, iter.val());
} }
} }
} }
@ -2242,11 +2242,11 @@ void Foam::polyMeshAdder::mergePoints
{ {
label pointi = f[fp]; label pointi = f[fp];
Map<label>::const_iterator iter = pointToMaster.find(pointi); const auto iter = pointToMaster.cfind(pointi);
if (iter != pointToMaster.end()) if (iter.found())
{ {
if (iter() != pointi) if (iter.val() != pointi)
{ {
hasMerged = true; hasMerged = true;
break; break;
@ -2262,11 +2262,11 @@ void Foam::polyMeshAdder::mergePoints
{ {
label pointi = f[fp]; label pointi = f[fp];
Map<label>::const_iterator iter = pointToMaster.find(pointi); const auto iter = pointToMaster.cfind(pointi);
if (iter != pointToMaster.end()) if (iter.found())
{ {
newF[fp] = iter(); newF[fp] = iter.val();
} }
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2013-2016 OpenFOAM Foundation | Copyright (C) 2013-2016 OpenFOAM Foundation
@ -38,21 +38,21 @@ void Foam::polyMeshFilter::updateSets(const mapPolyMesh& map)
HashTable<const SetType*> sets = HashTable<const SetType*> sets =
map.mesh().objectRegistry::lookupClass<const SetType>(); map.mesh().objectRegistry::lookupClass<const SetType>();
forAllIter(typename HashTable<const SetType*>, sets, iter) forAllIters(sets, iter)
{ {
SetType& set = const_cast<SetType&>(*iter()); SetType& set = const_cast<SetType&>(*iter());
set.updateMesh(map); set.updateMesh(map);
set.sync(map.mesh()); set.sync(map.mesh());
} }
IOobjectList Objects IOobjectList objs
( (
map.mesh().time(), map.mesh().time(),
map.mesh().facesInstance(), map.mesh().facesInstance(),
"polyMesh/sets" "polyMesh/sets"
); );
IOobjectList fileSets(Objects.lookupClass(SetType::typeName)); IOobjectList fileSets(objs.lookupClass<SetType>());
forAllConstIters(fileSets, iter) forAllConstIters(fileSets, iter)
{ {
@ -78,17 +78,17 @@ void Foam::polyMeshFilter::copySets
HashTable<const SetType*> sets = HashTable<const SetType*> sets =
oldMesh.objectRegistry::lookupClass<const SetType>(); oldMesh.objectRegistry::lookupClass<const SetType>();
forAllConstIter(typename HashTable<const SetType*>, sets, iter) forAllConstIters(sets, iter)
{ {
const SetType& set = *iter(); const SetType& set = *iter();
if (newMesh.objectRegistry::foundObject<SetType>(set.name())) SetType* origSet =
{ newMesh.objectRegistry::getObjectPtr<SetType>(set.name());
const SetType& origSet =
newMesh.objectRegistry::lookupObject<SetType>(set.name());
const_cast<SetType&>(origSet) = set; if (origSet)
const_cast<SetType&>(origSet).sync(newMesh); {
(*origSet) = set;
(*origSet).sync(newMesh);
} }
else else
{ {

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd. \\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation | Copyright (C) 2011-2016 OpenFOAM Foundation
@ -138,45 +138,32 @@ void Foam::combineFaces::regioniseFaces
forAll(cEdges, i) forAll(cEdges, i)
{ {
label edgeI = cEdges[i]; const label edgeI = cEdges[i];
label f0, f1; label f0, f1;
meshTools::getEdgeFaces(mesh_, celli, edgeI, f0, f1); meshTools::getEdgeFaces(mesh_, celli, edgeI, f0, f1);
label p0 = patches.whichPatch(f0); const label p0 = patches.whichPatch(f0);
label p1 = patches.whichPatch(f1); const label p1 = patches.whichPatch(f1);
// Face can be merged if // Face can be merged if
// - same non-coupled patch // - same non-coupled patch
// - small angle // - small angle
if (p0 != -1 && p0 == p1 && !patches[p0].coupled()) if (p0 != -1 && p0 == p1 && !patches[p0].coupled())
{ {
vector f0Normal = normalised(mesh_.faceAreas()[f0]); const vector f0Normal = normalised(mesh_.faceAreas()[f0]);
vector f1Normal = normalised(mesh_.faceAreas()[f1]); const vector f1Normal = normalised(mesh_.faceAreas()[f1]);
if ((f0Normal & f1Normal) > minCos) if ((f0Normal & f1Normal) > minCos)
{ {
Map<label>::const_iterator f0Fnd = faceRegion.find(f0); const label region0 = faceRegion.lookup(f0, -1);
const label region1 = faceRegion.lookup(f1, -1);
label region0 = -1;
if (f0Fnd != faceRegion.end())
{
region0 = f0Fnd();
}
Map<label>::const_iterator f1Fnd = faceRegion.find(f1);
label region1 = -1;
if (f1Fnd != faceRegion.end())
{
region1 = f1Fnd();
}
if (region0 == -1) if (region0 == -1)
{ {
if (region1 == -1) if (region1 == -1)
{ {
label useRegion = faceRegion.size(); const label useRegion = faceRegion.size();
faceRegion.insert(f0, useRegion); faceRegion.insert(f0, useRegion);
faceRegion.insert(f1, useRegion); faceRegion.insert(f1, useRegion);
} }
@ -194,14 +181,14 @@ void Foam::combineFaces::regioniseFaces
else if (region0 != region1) else if (region0 != region1)
{ {
// Merge the two regions // Merge the two regions
label useRegion = min(region0, region1); const label useRegion = min(region0, region1);
label freeRegion = max(region0, region1); const label freeRegion = max(region0, region1);
forAllIter(Map<label>, faceRegion, iter) forAllIters(faceRegion, iter)
{ {
if (iter() == freeRegion) if (iter.val() == freeRegion)
{ {
iter() = useRegion; iter.val() = useRegion;
} }
} }
} }
@ -246,22 +233,22 @@ bool Foam::combineFaces::faceNeighboursValid
forAll(fEdges, i) forAll(fEdges, i)
{ {
label edgeI = fEdges[i]; const label edgeI = fEdges[i];
label nbrI = meshTools::otherFace(mesh_, celli, facei, edgeI); label nbrI = meshTools::otherFace(mesh_, celli, facei, edgeI);
Map<label>::const_iterator iter = faceRegion.find(nbrI); const auto iter = faceRegion.cfind(nbrI);
if (iter == faceRegion.end()) if (iter.found())
{
neighbourRegions.insert(iter.val());
}
else
{ {
if (!neighbourFaces.found(nbrI)) if (!neighbourFaces.found(nbrI))
{ {
neighbourFaces.append(nbrI); neighbourFaces.append(nbrI);
} }
} }
else
{
neighbourRegions.insert(iter());
}
} }
if ((neighbourFaces.size()+neighbourRegions.size()) < 3) if ((neighbourFaces.size()+neighbourRegions.size()) < 3)
@ -329,14 +316,14 @@ Foam::labelListList Foam::combineFaces::getMergeSets
// Create region-to-faces addressing // Create region-to-faces addressing
Map<labelList> regionToFaces(faceRegion.size()); Map<labelList> regionToFaces(faceRegion.size());
forAllConstIter(Map<label>, faceRegion, iter) forAllConstIters(faceRegion, iter)
{ {
label facei = iter.key(); const label facei = iter.key();
label region = iter(); const label region = iter.val();
Map<labelList>::iterator regionFnd = regionToFaces.find(region); auto regionFnd = regionToFaces.find(region);
if (regionFnd != regionToFaces.end()) if (regionFnd.found())
{ {
labelList& setFaces = regionFnd(); labelList& setFaces = regionFnd();
label sz = setFaces.size(); label sz = setFaces.size();
@ -351,7 +338,7 @@ Foam::labelListList Foam::combineFaces::getMergeSets
// For every set check if it forms a valid convex face // For every set check if it forms a valid convex face
forAllConstIter(Map<labelList>, regionToFaces, iter) forAllConstIters(regionToFaces, iter)
{ {
// Make face out of setFaces // Make face out of setFaces
indirectPrimitivePatch bigFace indirectPrimitivePatch bigFace
@ -359,7 +346,7 @@ Foam::labelListList Foam::combineFaces::getMergeSets
IndirectList<face> IndirectList<face>
( (
mesh_.faces(), mesh_.faces(),
iter() iter.val()
), ),
mesh_.points() mesh_.points()
); );
@ -367,7 +354,7 @@ Foam::labelListList Foam::combineFaces::getMergeSets
// Only store if -only one outside loop -which forms convex face // Only store if -only one outside loop -which forms convex face
if (validFace(minConcaveCos, bigFace)) if (validFace(minConcaveCos, bigFace))
{ {
allFaceSets.append(iter()); allFaceSets.append(iter.val());
} }
} }
} }
@ -843,11 +830,11 @@ void Foam::combineFaces::setUnrefinement
forAll(masterFaces, i) forAll(masterFaces, i)
{ {
label masterFacei = masterFaces[i]; const label masterFacei = masterFaces[i];
Map<label>::const_iterator iter = masterToSet.find(masterFacei); const auto iter = masterToSet.cfind(masterFacei);
if (iter == masterToSet.end()) if (!iter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Master face " << masterFacei << "Master face " << masterFacei
@ -856,7 +843,7 @@ void Foam::combineFaces::setUnrefinement
<< abort(FatalError); << abort(FatalError);
} }
label setI = iter(); const label setI = iter.val();
// Update faces of the merge setI for reintroduced vertices // Update faces of the merge setI for reintroduced vertices

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation | Copyright (C) 2011-2016 OpenFOAM Foundation
@ -39,9 +39,7 @@ License
namespace Foam namespace Foam
{ {
defineTypeNameAndDebug(duplicatePoints, 0); defineTypeNameAndDebug(duplicatePoints, 0);
} }
@ -75,10 +73,10 @@ void Foam::duplicatePoints::setRefinement
// Per point-to-be-duplicated, in order of the regions the point added. // Per point-to-be-duplicated, in order of the regions the point added.
duplicates_.setSize(meshPointMap.size()); duplicates_.setSize(meshPointMap.size());
forAllConstIter(Map<label>, meshPointMap, iter) forAllConstIters(meshPointMap, iter)
{ {
label pointi = iter.key(); const label pointi = iter.key();
label localI = iter(); const label localI = iter.val();
const labelList& regions = pointRegions[localI]; const labelList& regions = pointRegions[localI];
duplicates_[localI].setSize(regions.size()); duplicates_[localI].setSize(regions.size());
@ -111,10 +109,10 @@ void Foam::duplicatePoints::setRefinement
face newFace; face newFace;
forAllConstIter(Map<label>, meshFaceMap, iter) forAllConstIters(meshFaceMap, iter)
{ {
label facei = iter.key(); const label facei = iter.key();
label localI = iter(); const label localI = iter.val();
// Replace points with duplicated ones. // Replace points with duplicated ones.
const face& fRegion = faceRegions[localI]; const face& fRegion = faceRegions[localI];
@ -193,9 +191,9 @@ void Foam::duplicatePoints::setRefinement
// Output duplicated points // Output duplicated points
{ {
OFstream str(mesh_.time().path()/"duplicatedPoints.obj"); OFstream str(mesh_.time().path()/"duplicatedPoints.obj");
forAllConstIter(Map<label>, meshPointMap, iter) forAllConstIters(meshPointMap, iter)
{ {
label localI = iter(); const label localI = iter.val();
const labelList& dups = duplicates_[localI]; const labelList& dups = duplicates_[localI];
forAll(dups, i) forAll(dups, i)

View File

@ -57,11 +57,11 @@ Foam::labelHashSet Foam::edgeCollapser::checkBadFaces
scalar faceAreaLimit = SMALL; scalar faceAreaLimit = SMALL;
forAll(fAreas, fI) forAll(fAreas, facei)
{ {
if (mag(fAreas[fI]) > faceAreaLimit) if (mag(fAreas[facei]) > faceAreaLimit)
{ {
checkFaces.append(fI); checkFaces.append(facei);
} }
} }
@ -1310,23 +1310,15 @@ bool Foam::edgeCollapser::setRefinement
if (collapseIndex != -1 && collapseIndex != -2) if (collapseIndex != -1 && collapseIndex != -2)
{ {
Map<label>::iterator fnd = nPerIndex.find(collapseIndex); ++(nPerIndex(collapseIndex, 0));
if (fnd != nPerIndex.end())
{
fnd()++;
}
else
{
nPerIndex.insert(collapseIndex, 1);
}
} }
} }
// 2. Size // 2. Size
collapseStrings.resize(2*nPerIndex.size()); collapseStrings.resize(2*nPerIndex.size());
forAllConstIter(Map<label>, nPerIndex, iter) forAllConstIters(nPerIndex, iter)
{ {
collapseStrings.insert(iter.key(), DynamicList<label>(iter())); collapseStrings.insert(iter.key(), DynamicList<label>(iter.val()));
} }
// 3. Fill // 3. Fill
@ -1346,7 +1338,7 @@ bool Foam::edgeCollapser::setRefinement
// OFstream str2("collapseStrings_" + name(count) + ".obj"); // OFstream str2("collapseStrings_" + name(count) + ".obj");
// // Dump point collapses // // Dump point collapses
// forAllConstIter(Map<DynamicList<label>>, collapseStrings, iter) // forAllConstIters(collapseStrings, iter)
// { // {
// const label masterPoint = iter.key(); // const label masterPoint = iter.key();
// const DynamicList<label>& edgeCollapses = iter(); // const DynamicList<label>& edgeCollapses = iter();

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd. \\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation | Copyright (C) 2011-2016 OpenFOAM Foundation
@ -35,7 +35,6 @@ License
#include "meshTools.H" #include "meshTools.H"
#include "OFstream.H" #include "OFstream.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
// Insert labelList into labelHashSet. Optional excluded element. // Insert labelList into labelHashSet. Optional excluded element.
@ -464,12 +463,13 @@ void Foam::faceCollapser::setRefinement
} }
} }
forAllConstIter(Map<labelList>, splitEdges, iter) forAllConstIters(splitEdges, iter)
{ {
Pout<< "Split edge:" << iter.key() Pout<< "Split edge:" << iter.key()
<< " verts:" << mesh_.edges()[iter.key()] << " verts:" << mesh_.edges()[iter.key()]
<< " in:" << nl; << " in:" << nl;
const labelList& edgePoints = iter();
const labelList& edgePoints = iter.val();
forAll(edgePoints, i) forAll(edgePoints, i)
{ {

View File

@ -55,9 +55,8 @@ namespace Foam
//- Reduction class. If x and y are not equal assign value. //- Reduction class. If x and y are not equal assign value.
template<label value> template<label value>
class ifEqEqOp struct ifEqEqOp
{ {
public:
void operator()(label& x, const label y) const void operator()(label& x, const label y) const
{ {
x = (x == y) ? x : value; x = (x == y) ? x : value;
@ -970,15 +969,15 @@ Foam::label Foam::hexRef8::storeMidPointInfo
bool changed = false; bool changed = false;
bool haveTwoAnchors = false; bool haveTwoAnchors = false;
Map<edge>::iterator edgeMidFnd = midPointToAnchors.find(edgeMidPointi); auto edgeMidFnd = midPointToAnchors.find(edgeMidPointi);
if (edgeMidFnd == midPointToAnchors.end()) if (!edgeMidFnd.found())
{ {
midPointToAnchors.insert(edgeMidPointi, edge(anchorPointi, -1)); midPointToAnchors.insert(edgeMidPointi, edge(anchorPointi, -1));
} }
else else
{ {
edge& e = edgeMidFnd(); edge& e = edgeMidFnd.val();
if (anchorPointi != e[0]) if (anchorPointi != e[0])
{ {
@ -997,15 +996,15 @@ Foam::label Foam::hexRef8::storeMidPointInfo
bool haveTwoFaceMids = false; bool haveTwoFaceMids = false;
Map<edge>::iterator faceMidFnd = midPointToFaceMids.find(edgeMidPointi); auto faceMidFnd = midPointToFaceMids.find(edgeMidPointi);
if (faceMidFnd == midPointToFaceMids.end()) if (!faceMidFnd.found())
{ {
midPointToFaceMids.insert(edgeMidPointi, edge(faceMidPointi, -1)); midPointToFaceMids.insert(edgeMidPointi, edge(faceMidPointi, -1));
} }
else else
{ {
edge& e = faceMidFnd(); edge& e = faceMidFnd.val();
if (faceMidPointi != e[0]) if (faceMidPointi != e[0])
{ {
@ -1844,11 +1843,11 @@ bool Foam::hexRef8::matchHexShape
label pointi = f[fp]; label pointi = f[fp];
if (pointLevel_[pointi] == cellLevel+1) if (pointLevel_[pointi] == cellLevel+1)
{ {
Map<labelList>::iterator iter = auto iter = pointFaces.find(pointi);
pointFaces.find(pointi);
if (iter != pointFaces.end()) if (iter.found())
{ {
labelList& pFaces = iter(); labelList& pFaces = iter.val();
if (!pFaces.found(facei)) if (!pFaces.found(facei))
{ {
pFaces.append(facei); pFaces.append(facei);
@ -1868,9 +1867,9 @@ bool Foam::hexRef8::matchHexShape
} }
// 2. Check if we've collected any midPoints. // 2. Check if we've collected any midPoints.
forAllConstIter(Map<labelList>, pointFaces, iter) forAllConstIters(pointFaces, iter)
{ {
const labelList& pFaces = iter(); const labelList& pFaces = iter.val();
if (pFaces.size() == 4) if (pFaces.size() == 4)
{ {
@ -2651,10 +2650,10 @@ Foam::labelList Foam::hexRef8::consistentSlowRefinement
seedFaces.setCapacity(changedFacesInfo.size()); seedFaces.setCapacity(changedFacesInfo.size());
seedFacesInfo.setCapacity(changedFacesInfo.size()); seedFacesInfo.setCapacity(changedFacesInfo.size());
forAllConstIter(Map<refinementData>, changedFacesInfo, iter) forAllConstIters(changedFacesInfo, iter)
{ {
seedFaces.append(iter.key()); seedFaces.append(iter.key());
seedFacesInfo.append(iter()); seedFacesInfo.append(iter.val());
} }
} }
@ -4313,14 +4312,14 @@ void Foam::hexRef8::updateMesh
// See if any cells to restore. This will be for some new cells // See if any cells to restore. This will be for some new cells
// the corresponding old cell. // the corresponding old cell.
forAllConstIter(Map<label>, cellsToRestore, iter) forAllConstIters(cellsToRestore, iter)
{ {
label newCelli = iter.key(); const label newCelli = iter.key();
label storedCelli = iter(); const label storedCelli = iter.val();
Map<label>::iterator fnd = savedCellLevel_.find(storedCelli); const auto fnd = savedCellLevel_.cfind(storedCelli);
if (fnd == savedCellLevel_.end()) if (!fnd.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Problem : trying to restore old value for new cell " << "Problem : trying to restore old value for new cell "
@ -4328,7 +4327,7 @@ void Foam::hexRef8::updateMesh
<< " in map of stored values " << savedCellLevel_ << " in map of stored values " << savedCellLevel_
<< abort(FatalError); << abort(FatalError);
} }
cellLevel_[newCelli] = fnd(); cellLevel_[newCelli] = fnd.val();
} }
//if (cellLevel_.found(-1)) //if (cellLevel_.found(-1))
@ -4363,7 +4362,7 @@ void Foam::hexRef8::updateMesh
forAll(pointMap, newPointi) forAll(pointMap, newPointi)
{ {
label oldPointi = pointMap[newPointi]; const label oldPointi = pointMap[newPointi];
if (oldPointi == -1) if (oldPointi == -1)
{ {
@ -4386,14 +4385,14 @@ void Foam::hexRef8::updateMesh
// See if any points to restore. This will be for some new points // See if any points to restore. This will be for some new points
// the corresponding old point (the one from the call to storeData) // the corresponding old point (the one from the call to storeData)
forAllConstIter(Map<label>, pointsToRestore, iter) forAllConstIters(pointsToRestore, iter)
{ {
label newPointi = iter.key(); const label newPointi = iter.key();
label storedPointi = iter(); const label storedPointi = iter.val();
Map<label>::iterator fnd = savedPointLevel_.find(storedPointi); auto fnd = savedPointLevel_.find(storedPointi);
if (fnd == savedPointLevel_.end()) if (!fnd.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Problem : trying to restore old value for new point " << "Problem : trying to restore old value for new point "
@ -4402,7 +4401,7 @@ void Foam::hexRef8::updateMesh
<< " in map of stored values " << savedPointLevel_ << " in map of stored values " << savedPointLevel_
<< abort(FatalError); << abort(FatalError);
} }
pointLevel_[newPointi] = fnd(); pointLevel_[newPointi] = fnd.val();
} }
//if (pointLevel_.found(-1)) //if (pointLevel_.found(-1))

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011 OpenFOAM Foundation | Copyright (C) 2011 OpenFOAM Foundation
@ -43,15 +43,13 @@ void Foam::setUpdater::updateSets(const mapPolyMesh& morphMap) const
HashTable<const Type*> memSets = HashTable<const Type*> memSets =
morphMap.mesh().objectRegistry::lookupClass<Type>(); morphMap.mesh().objectRegistry::lookupClass<Type>();
forAllIter(typename HashTable<const Type*>, memSets, iter) forAllIters(memSets, iter)
{ {
Type& set = const_cast<Type&>(*iter()); Type& set = const_cast<Type&>(*iter());
if (debug) DebugPout
{ << "Set:" << set.name() << " size:" << set.size()
Pout<< "Set:" << set.name() << " size:" << set.size()
<< " updated in memory" << endl; << " updated in memory" << endl;
}
set.updateMesh(morphMap); set.updateMesh(morphMap);
@ -65,14 +63,14 @@ 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 Objects IOobjectList objs
( (
morphMap.mesh().time(), morphMap.mesh().time(),
morphMap.mesh().facesInstance(), morphMap.mesh().facesInstance(),
"polyMesh/sets" "polyMesh/sets"
); );
IOobjectList fileSets(Objects.lookupClass(Type::typeName)); IOobjectList fileSets(objs.lookupClass<Type>());
forAllConstIters(fileSets, iter) forAllConstIters(fileSets, iter)
{ {
@ -93,14 +91,12 @@ void Foam::setUpdater::updateSets(const mapPolyMesh& morphMap) const
} }
else else
{ {
if (debug) DebugPout
{ << "Set:" << iter.key() << " already updated from memory"
Pout<< "Set:" << iter.key() << " already updated from memory"
<< endl; << endl;
} }
} }
} }
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd. \\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation | Copyright (C) 2011-2016 OpenFOAM Foundation
@ -92,7 +92,7 @@ void Foam::enrichedPatch::calcMasterPointFaces() const
forAllIters(mpf, mpfIter) forAllIters(mpf, mpfIter)
{ {
masterPointFaceMap(mpfIter.key()).transfer(mpfIter.object()); masterPointFaceMap(mpfIter.key()).transfer(mpfIter.val());
} }
// Pout<< "masterPointFaceMap: " << masterPointFaceMap << endl; // Pout<< "masterPointFaceMap: " << masterPointFaceMap << endl;
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation | Copyright (C) 2011-2016 OpenFOAM Foundation
@ -49,8 +49,6 @@ void Foam::enrichedPatch::calcPointPoints() const
const faceList& lf = localFaces(); const faceList& lf = localFaces();
bool found = false;
for (const face& curFace : lf) for (const face& curFace : lf)
{ {
forAll(curFace, pointi) forAll(curFace, pointi)
@ -60,36 +58,15 @@ void Foam::enrichedPatch::calcPointPoints() const
// Do next label // Do next label
const label next = curFace.nextLabel(pointi); const label next = curFace.nextLabel(pointi);
found = false; if (!curPp.found(next))
forAll(curPp, i)
{
if (curPp[i] == next)
{
found = true;
break;
}
}
if (!found)
{ {
curPp.append(next); curPp.append(next);
} }
// Do previous label // Do previous label
const label prev = curFace.prevLabel(pointi); const label prev = curFace.prevLabel(pointi);
found = false;
forAll(curPp, i) if (!curPp.found(prev))
{
if (curPp[i] == prev)
{
found = true;
break;
}
}
if (!found)
{ {
curPp.append(prev); curPp.append(prev);
} }

View File

@ -445,12 +445,12 @@ void Foam::slidingInterface::modifyMotionPoints(pointField& motionPoints) const
const pointField& slaveLocalPoints = slavePatch.localPoints(); const pointField& slaveLocalPoints = slavePatch.localPoints();
const vectorField& slavePointNormals = slavePatch.pointNormals(); const vectorField& slavePointNormals = slavePatch.pointNormals();
forAll(cutPoints, pointi) for (const label pointi : cutPoints)
{ {
// Try to find the cut point in retired points // Try to find the cut point in retired points
Map<label>::const_iterator rpmIter = rpm.find(cutPoints[pointi]); const auto rpmIter = rpm.cfind(pointi);
if (rpmIter != rpm.end()) if (rpmIter.found())
{ {
if (debug) if (debug)
{ {
@ -466,10 +466,9 @@ void Foam::slidingInterface::modifyMotionPoints(pointField& motionPoints) const
// A cut point is not a projected slave point. Therefore, it // A cut point is not a projected slave point. Therefore, it
// must be an edge-to-edge intersection. // must be an edge-to-edge intersection.
Map<Pair<edge>>::const_iterator cpepmIter = const auto cpepmIter = cpepm.cfind(pointi);
cpepm.find(cutPoints[pointi]);
if (cpepmIter != cpepm.end()) if (cpepmIter.found())
{ {
// Pout<< "Need to re-create hit for point " // Pout<< "Need to re-create hit for point "
// << cutPoints[pointi] // << cutPoints[pointi]
@ -592,8 +591,7 @@ void Foam::slidingInterface::modifyMotionPoints(pointField& motionPoints) const
) )
{ {
// Cut both master and slave. // Cut both master and slave.
motionPoints[cutPoints[pointi]] = motionPoints[pointi] = masterCutPoint;
masterCutPoint;
} }
} }
else else

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd. \\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation | Copyright (C) 2011-2016 OpenFOAM Foundation
@ -380,23 +380,18 @@ void Foam::slidingInterface::renumberAttachedAddressing
Map<label>* newRpmPtr = new Map<label>(rpm.size()); Map<label>* newRpmPtr = new Map<label>(rpm.size());
Map<label>& newRpm = *newRpmPtr; Map<label>& newRpm = *newRpmPtr;
const labelList rpmToc = rpm.toc();
// Get reference to point renumbering // Get reference to point renumbering
const labelList& reversePointMap = m.reversePointMap(); const labelList& reversePointMap = m.reversePointMap();
label key, value; forAllConstIters(rpm, iter)
forAll(rpmToc, rpmTocI)
{ {
key = reversePointMap[rpmToc[rpmTocI]]; const label key = reversePointMap[iter.key()];
const label val = reversePointMap[iter.val()];
value = reversePointMap[rpm.find(rpmToc[rpmTocI])()];
if (debug) if (debug)
{ {
// Check if all the mapped cells are live // Check if all the mapped cells are live
if (key < 0 || value < 0) if (key < 0 || val < 0)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Error in retired point numbering for object " << "Error in retired point numbering for object "
@ -406,7 +401,7 @@ void Foam::slidingInterface::renumberAttachedAddressing
} }
} }
newRpm.insert(key, value); newRpm.insert(key, val);
} }
// Renumber the cut point edge pair map. Need to take a copy! // Renumber the cut point edge pair map. Need to take a copy!
@ -415,13 +410,11 @@ void Foam::slidingInterface::renumberAttachedAddressing
Map<Pair<edge>>* newCpepmPtr = new Map<Pair<edge>>(cpepm.size()); Map<Pair<edge>>* newCpepmPtr = new Map<Pair<edge>>(cpepm.size());
Map<Pair<edge>>& newCpepm = *newCpepmPtr; Map<Pair<edge>>& newCpepm = *newCpepmPtr;
const labelList cpepmToc = cpepm.toc(); forAllConstIters(cpepm, iter)
forAll(cpepmToc, cpepmTocI)
{ {
key = reversePointMap[cpepmToc[cpepmTocI]]; const label key = reversePointMap[iter.key()];
const Pair<edge>& oldPe = cpepm.find(cpepmToc[cpepmTocI])(); const Pair<edge>& oldPe = iter.val();
// Re-do the edges in global addressing // Re-do the edges in global addressing
const label ms = reversePointMap[oldPe.first().start()]; const label ms = reversePointMap[oldPe.first().start()];

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2012-2016 OpenFOAM Foundation | Copyright (C) 2012-2016 OpenFOAM Foundation
@ -73,12 +73,12 @@ uniformInterpolatedDisplacementPointPatchVectorField
DynamicList<word> names(allTimes.size()); DynamicList<word> names(allTimes.size());
DynamicList<scalar> values(allTimes.size()); DynamicList<scalar> values(allTimes.size());
forAll(allTimes, i) for (const instant& inst : allTimes)
{ {
IOobject io IOobject io
( (
fieldName_, fieldName_,
allTimes[i].name(), inst.name(),
pMesh(), pMesh(),
IOobject::MUST_READ, IOobject::MUST_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
@ -86,8 +86,8 @@ uniformInterpolatedDisplacementPointPatchVectorField
); );
if (io.typeHeaderOk<pointVectorField>(false)) if (io.typeHeaderOk<pointVectorField>(false))
{ {
names.append(allTimes[i].name()); names.append(inst.name());
values.append(allTimes[i].value()); values.append(inst.value());
} }
} }
timeNames_.transfer(names); timeNames_.transfer(names);
@ -187,7 +187,7 @@ void uniformInterpolatedDisplacementPointPatchVectorField::updateCoeffs()
( (
pMesh.thisDb().subRegistry("fieldsCache", true) pMesh.thisDb().subRegistry("fieldsCache", true)
); );
// Save old times so we now which ones have been loaded and need // Save old times so we know which ones have been loaded and need
// 'correctBoundaryConditions'. Bit messy. // 'correctBoundaryConditions'. Bit messy.
wordHashSet oldTimes(fieldsCache.toc()); wordHashSet oldTimes(fieldsCache.toc());
@ -198,7 +198,7 @@ void uniformInterpolatedDisplacementPointPatchVectorField::updateCoeffs()
currentTimeNames currentTimeNames
); );
forAllConstIter(objectRegistry, fieldsCache, fieldsCacheIter) forAllConstIters(fieldsCache, fieldsCacheIter)
{ {
if (!oldTimes.found(fieldsCacheIter.key())) if (!oldTimes.found(fieldsCacheIter.key()))
{ {