Commit ac46f28a authored by Mark Olesen's avatar Mark Olesen

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

- reduced clutter when iterating over containers
parent 4b7ace55
...@@ -118,7 +118,7 @@ Foam::label Foam::foamPvCore::addToSelection ...@@ -118,7 +118,7 @@ Foam::label Foam::foamPvCore::addToSelection
if (iter.found()) if (iter.found())
{ {
return addToArray(select, prefix, iter.object().sortedToc()); return addToArray(select, prefix, iter.val().sortedToc());
} }
return 0; return 0;
...@@ -137,7 +137,7 @@ Foam::label Foam::foamPvCore::addToSelection ...@@ -137,7 +137,7 @@ Foam::label Foam::foamPvCore::addToSelection
if (iter.found()) if (iter.found())
{ {
return addToArray(select, iter.object().sortedToc(), suffix); return addToArray(select, iter.val().sortedToc(), suffix);
} }
return 0; return 0;
......
...@@ -144,9 +144,9 @@ bool Foam::vtkPVFoam::addOutputBlock ...@@ -144,9 +144,9 @@ bool Foam::vtkPVFoam::addOutputBlock
const word shortName = getFoamName(longName); const word shortName = getFoamName(longName);
auto iter = cache.find(longName); auto iter = cache.find(longName);
if (iter.found() && iter.object().dataset) if (iter.found() && iter.val().dataset)
{ {
auto dataset = iter.object().dataset; auto dataset = iter.val().dataset;
if (singleDataset) if (singleDataset)
{ {
...@@ -540,13 +540,13 @@ void Foam::vtkPVFoam::Update ...@@ -540,13 +540,13 @@ void Foam::vtkPVFoam::Update
// Eliminate cached values that would be unreliable // Eliminate cached values that would be unreliable
forAllIters(cachedVtp_, iter) forAllIters(cachedVtp_, iter)
{ {
iter.object().clearGeom(); iter.val().clearGeom();
iter.object().clear(); iter.val().clear();
} }
forAllIters(cachedVtu_, iter) forAllIters(cachedVtu_, iter)
{ {
iter.object().clearGeom(); iter.val().clearGeom();
iter.object().clear(); iter.val().clear();
} }
} }
else if (oldDecomp != decomposePoly_) else if (oldDecomp != decomposePoly_)
...@@ -554,8 +554,8 @@ void Foam::vtkPVFoam::Update ...@@ -554,8 +554,8 @@ void Foam::vtkPVFoam::Update
// poly-decompose changed - dispose of cached values // poly-decompose changed - dispose of cached values
forAllIters(cachedVtu_, iter) forAllIters(cachedVtu_, iter)
{ {
iter.object().clearGeom(); iter.val().clearGeom();
iter.object().clear(); iter.val().clear();
} }
} }
} }
......
...@@ -91,13 +91,13 @@ void Foam::vtkPVFoam::convertVolField ...@@ -91,13 +91,13 @@ void Foam::vtkPVFoam::convertVolField
const auto& longName = selectedPartIds_[partId]; const auto& longName = selectedPartIds_[partId];
auto iter = cachedVtp_.find(longName); auto iter = cachedVtp_.find(longName);
if (!iter.found() || !iter.object().dataset) if (!iter.found() || !iter.val().dataset)
{ {
// Should not happen, but for safety require a vtk geometry // Should not happen, but for safety require a vtk geometry
continue; continue;
} }
foamVtpData& vtpData = iter.object(); foamVtpData& vtpData = iter.val();
auto dataset = vtpData.dataset; auto dataset = vtpData.dataset;
const labelUList& patchIds = vtpData.additionalIds(); const labelUList& patchIds = vtpData.additionalIds();
...@@ -195,13 +195,13 @@ void Foam::vtkPVFoam::convertVolField ...@@ -195,13 +195,13 @@ void Foam::vtkPVFoam::convertVolField
const word zoneName = getFoamName(longName); const word zoneName = getFoamName(longName);
auto iter = cachedVtp_.find(longName); auto iter = cachedVtp_.find(longName);
if (!iter.found() || !iter.object().dataset) if (!iter.found() || !iter.val().dataset)
{ {
// Should not happen, but for safety require a vtk geometry // Should not happen, but for safety require a vtk geometry
continue; continue;
} }
foamVtpData& vtpData = iter.object(); foamVtpData& vtpData = iter.val();
auto dataset = vtpData.dataset; auto dataset = vtpData.dataset;
const faceZoneMesh& zMesh = mesh.faceZones(); const faceZoneMesh& zMesh = mesh.faceZones();
...@@ -236,12 +236,12 @@ void Foam::vtkPVFoam::convertVolField ...@@ -236,12 +236,12 @@ void Foam::vtkPVFoam::convertVolField
const word selectName = getFoamName(longName); const word selectName = getFoamName(longName);
auto iter = cachedVtp_.find(longName); auto iter = cachedVtp_.find(longName);
if (!iter.found() || !iter.object().dataset) if (!iter.found() || !iter.val().dataset)
{ {
// Should not happen, but for safety require a vtk geometry // Should not happen, but for safety require a vtk geometry
continue; continue;
} }
foamVtpData& vtpData = iter.object(); foamVtpData& vtpData = iter.val();
auto dataset = vtpData.dataset; auto dataset = vtpData.dataset;
vtkSmartPointer<vtkFloatArray> cdata = convertFaceFieldToVTK vtkSmartPointer<vtkFloatArray> cdata = convertFaceFieldToVTK
...@@ -270,7 +270,7 @@ void Foam::vtkPVFoam::convertVolFields ...@@ -270,7 +270,7 @@ void Foam::vtkPVFoam::convertVolFields
forAllConstIters(objects, iter) forAllConstIters(objects, iter)
{ {
// Restrict to GeometricField<Type, ...> // Restrict to GeometricField<Type, ...>
const auto& ioobj = *(iter.object()); const auto& ioobj = *(iter.val());
if (ioobj.headerClassName() == FieldType::typeName) if (ioobj.headerClassName() == FieldType::typeName)
{ {
...@@ -320,7 +320,7 @@ void Foam::vtkPVFoam::convertDimFields ...@@ -320,7 +320,7 @@ void Foam::vtkPVFoam::convertDimFields
forAllConstIters(objects, iter) forAllConstIters(objects, iter)
{ {
// Restrict to DimensionedField<Type, ...> // Restrict to DimensionedField<Type, ...>
const auto& ioobj = *(iter.object()); const auto& ioobj = *(iter.val());
if (ioobj.headerClassName() != FieldType::typeName) if (ioobj.headerClassName() != FieldType::typeName)
{ {
...@@ -404,13 +404,13 @@ void Foam::vtkPVFoam::convertVolFieldBlock ...@@ -404,13 +404,13 @@ void Foam::vtkPVFoam::convertVolFieldBlock
const auto& longName = selectedPartIds_[partId]; const auto& longName = selectedPartIds_[partId];
auto iter = cachedVtu_.find(longName); auto iter = cachedVtu_.find(longName);
if (!iter.found() || !iter.object().dataset) if (!iter.found() || !iter.val().dataset)
{ {
// Should not happen, but for safety require a vtk geometry // Should not happen, but for safety require a vtk geometry
continue; continue;
} }
foamVtuData& vtuData = iter.object(); foamVtuData& vtuData = iter.val();
auto dataset = vtuData.dataset; auto dataset = vtuData.dataset;
vtkSmartPointer<vtkFloatArray> cdata = convertVolFieldToVTK vtkSmartPointer<vtkFloatArray> cdata = convertVolFieldToVTK
...@@ -459,7 +459,7 @@ void Foam::vtkPVFoam::convertAreaFields ...@@ -459,7 +459,7 @@ void Foam::vtkPVFoam::convertAreaFields
forAllConstIters(objects, iter) forAllConstIters(objects, iter)
{ {
// Restrict to GeometricField<Type, ...> // Restrict to GeometricField<Type, ...>
const auto& ioobj = *(iter.object()); const auto& ioobj = *(iter.val());
if (ioobj.headerClassName() == FieldType::typeName) if (ioobj.headerClassName() == FieldType::typeName)
{ {
...@@ -478,14 +478,14 @@ void Foam::vtkPVFoam::convertAreaFields ...@@ -478,14 +478,14 @@ void Foam::vtkPVFoam::convertAreaFields
const auto& longName = selectedPartIds_[partId]; const auto& longName = selectedPartIds_[partId];
auto iter = cachedVtp_.find(longName); auto iter = cachedVtp_.find(longName);
if (!iter.found() || !iter.object().dataset) if (!iter.found() || !iter.val().dataset)
{ {
// Should not happen, but for safety require a vtk // Should not happen, but for safety require a vtk
// geometry // geometry
continue; continue;
} }
foamVtpData& vtpData = iter.object(); foamVtpData& vtpData = iter.val();
auto dataset = vtpData.dataset; auto dataset = vtpData.dataset;
vtkSmartPointer<vtkFloatArray> cdata = convertFieldToVTK vtkSmartPointer<vtkFloatArray> cdata = convertFieldToVTK
...@@ -535,7 +535,7 @@ void Foam::vtkPVFoam::convertPointFields ...@@ -535,7 +535,7 @@ void Foam::vtkPVFoam::convertPointFields
forAllConstIters(objects, iter) forAllConstIters(objects, iter)
{ {
// Restrict to this GeometricField<Type, ...> // Restrict to this GeometricField<Type, ...>
const auto& ioobj = *(iter.object()); const auto& ioobj = *(iter.val());
const word& fieldName = ioobj.name(); const word& fieldName = ioobj.name();
if (ioobj.headerClassName() != FieldType::typeName) if (ioobj.headerClassName() != FieldType::typeName)
...@@ -568,13 +568,13 @@ void Foam::vtkPVFoam::convertPointFields ...@@ -568,13 +568,13 @@ void Foam::vtkPVFoam::convertPointFields
const auto& longName = selectedPartIds_[partId]; const auto& longName = selectedPartIds_[partId];
auto iter = cachedVtp_.find(longName); auto iter = cachedVtp_.find(longName);
if (!iter.found() || !iter.object().dataset) if (!iter.found() || !iter.val().dataset)
{ {
// Should not happen, but for safety require a vtk geometry // Should not happen, but for safety require a vtk geometry
continue; continue;
} }
foamVtpData& vtpData = iter.object(); foamVtpData& vtpData = iter.val();
auto dataset = vtpData.dataset; auto dataset = vtpData.dataset;
const labelUList& patchIds = vtpData.additionalIds(); const labelUList& patchIds = vtpData.additionalIds();
...@@ -605,13 +605,13 @@ void Foam::vtkPVFoam::convertPointFields ...@@ -605,13 +605,13 @@ void Foam::vtkPVFoam::convertPointFields
const word zoneName = getFoamName(longName); const word zoneName = getFoamName(longName);
auto iter = cachedVtp_.find(longName); auto iter = cachedVtp_.find(longName);
if (!iter.found() || !iter.object().dataset) if (!iter.found() || !iter.val().dataset)
{ {
// Should not happen, but for safety require a vtk geometry // Should not happen, but for safety require a vtk geometry
continue; continue;
} }
foamVtpData& vtpData = iter.object(); foamVtpData& vtpData = iter.val();
auto dataset = vtpData.dataset; auto dataset = vtpData.dataset;
const label zoneId = mesh.faceZones().findZoneID(zoneName); const label zoneId = mesh.faceZones().findZoneID(zoneName);
...@@ -673,13 +673,13 @@ void Foam::vtkPVFoam::convertPointFieldBlock ...@@ -673,13 +673,13 @@ void Foam::vtkPVFoam::convertPointFieldBlock
const auto& longName = selectedPartIds_[partId]; const auto& longName = selectedPartIds_[partId];
auto iter = cachedVtu_.find(longName); auto iter = cachedVtu_.find(longName);
if (!iter.found() || !iter.object().dataset) if (!iter.found() || !iter.val().dataset)
{ {
// Should not happen, but for safety require a vtk geometry // Should not happen, but for safety require a vtk geometry
continue; continue;
} }
foamVtuData& vtuData = iter.object(); foamVtuData& vtuData = iter.val();
auto dataset = vtuData.dataset; auto dataset = vtuData.dataset;
vtkSmartPointer<vtkFloatArray> pdata = convertPointField vtkSmartPointer<vtkFloatArray> pdata = convertPointField
...@@ -794,7 +794,7 @@ void Foam::vtkPVFoam::convertLagrangianFields ...@@ -794,7 +794,7 @@ void Foam::vtkPVFoam::convertLagrangianFields
forAllConstIters(objects, iter) forAllConstIters(objects, iter)
{ {
// Restrict to IOField<Type> // Restrict to IOField<Type>
const auto& ioobj = *(iter.object()); const auto& ioobj = *(iter.val());
if (ioobj.headerClassName() == IOField<Type>::typeName) if (ioobj.headerClassName() == IOField<Type>::typeName)
{ {
......
...@@ -255,12 +255,12 @@ void Foam::vtkPVFoam::convertLagrangianFields() ...@@ -255,12 +255,12 @@ void Foam::vtkPVFoam::convertLagrangianFields()
const word cloudName = getFoamName(longName); const word cloudName = getFoamName(longName);
auto iter = cachedVtp_.find(longName); auto iter = cachedVtp_.find(longName);
if (!iter.found() || !iter.object().dataset) if (!iter.found() || !iter.val().dataset)
{ {
// Should not happen, but for safety require a vtk geometry // Should not happen, but for safety require a vtk geometry
continue; continue;
} }
auto dataset = iter.object().dataset; auto dataset = iter.val().dataset;
// Get the Lagrangian fields for this time and this cloud // Get the Lagrangian fields for this time and this cloud
// but only keep selected fields // but only keep selected fields
......
...@@ -80,9 +80,9 @@ vtkSmartPointer<vtkPolyData> Foam::vtkPVFoam::lagrangianVTKMesh ...@@ -80,9 +80,9 @@ vtkSmartPointer<vtkPolyData> Foam::vtkPVFoam::lagrangianVTKMesh
vtkpoints->SetNumberOfPoints(parcels.size()); vtkpoints->SetNumberOfPoints(parcels.size());
vtkIdType particleId = 0; vtkIdType particleId = 0;
forAllConstIters(parcels, iter) for (const passiveParticle& p : parcels)
{ {
vtkpoints->SetPoint(particleId, iter().position().v_); vtkpoints->SetPoint(particleId, p.position().v_);
++particleId; ++particleId;
} }
......
...@@ -276,7 +276,7 @@ void Foam::vtkPVFoam::updateInfoPatches ...@@ -276,7 +276,7 @@ void Foam::vtkPVFoam::updateInfoPatches
forAllConstIters(groups, iter) forAllConstIters(groups, iter)
{ {
const auto& groupName = iter.key(); const auto& groupName = iter.key();
const auto& patchIDs = iter.object(); const auto& patchIDs = iter.val();
label nFaces = 0; label nFaces = 0;
for (auto patchId : patchIDs) for (auto patchId : patchIDs)
...@@ -392,7 +392,7 @@ void Foam::vtkPVFoam::updateInfoPatches ...@@ -392,7 +392,7 @@ void Foam::vtkPVFoam::updateInfoPatches
forAllConstIters(groups, iter) forAllConstIters(groups, iter)
{ {
const auto& groupName = iter.key(); const auto& groupName = iter.key();
const auto& patchIDs = iter.object(); const auto& patchIDs = iter.val();
const string dpyName = "group/" + groupName; const string dpyName = "group/" + groupName;
displayNames.append(dpyName); displayNames.append(dpyName);
...@@ -715,7 +715,7 @@ void Foam::vtkPVFoam::updateInfoLagrangianFields ...@@ -715,7 +715,7 @@ void Foam::vtkPVFoam::updateInfoLagrangianFields
forAllConstIters(localFields, iter) forAllConstIters(localFields, iter)
{ {
fields(iter.key()) |= iter.object(); fields(iter.key()) |= iter.val();
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment