diff --git a/applications/solvers/multiphase/interFoam/overInterDyMFoam/interDyMFoam.C b/applications/solvers/multiphase/interFoam/overInterDyMFoam/interDyMFoam.C index 075676da77..4a986ef175 100644 --- a/applications/solvers/multiphase/interFoam/overInterDyMFoam/interDyMFoam.C +++ b/applications/solvers/multiphase/interFoam/overInterDyMFoam/interDyMFoam.C @@ -65,7 +65,7 @@ int main(int argc, char *argv[]) #include "createTime.H" #include "createDynamicFvMesh.H" #include "initContinuityErrs.H" - #include "createControl.H" + pimpleControl pimple(mesh); #include "createTimeControls.H" #include "createDyMControls.H" #include "createFields.H" diff --git a/applications/solvers/multiphase/interFoam/overInterDyMFoam/pEqn.H b/applications/solvers/multiphase/interFoam/overInterDyMFoam/pEqn.H index c11ce1dba5..0c63e22006 100644 --- a/applications/solvers/multiphase/interFoam/overInterDyMFoam/pEqn.H +++ b/applications/solvers/multiphase/interFoam/overInterDyMFoam/pEqn.H @@ -46,6 +46,13 @@ phiHbyA += phig; + if (adjustFringe) + { + fvc::makeRelative(phiHbyA, U); + oversetAdjustPhi(phiHbyA, U); + fvc::makeAbsolute(phiHbyA, U); + } + // Update the pressure BCs to ensure flux consistency constrainPressure(p_rgh, U, phiHbyA, rAUf, MRF); @@ -72,7 +79,8 @@ "minGradP", fvc::reconstruct((phig - p_rghEqn.flux())/rAUf) ); - U = HbyA + rAU*cellMask*minGradP; + //U = HbyA + rAU*cellMask*minGradP; + U = fvc::reconstruct(phi); U.correctBoundaryConditions(); fvOptions.correct(U); } diff --git a/applications/solvers/multiphase/interFoam/overInterDyMFoam/readControls.H b/applications/solvers/multiphase/interFoam/overInterDyMFoam/readControls.H index 0df2a74f30..d8481c8870 100644 --- a/applications/solvers/multiphase/interFoam/overInterDyMFoam/readControls.H +++ b/applications/solvers/multiphase/interFoam/overInterDyMFoam/readControls.H @@ -11,5 +11,6 @@ moveMeshOuterCorrectors = massFluxInterpolation = pimple.dict().lookupOrDefault("massFluxInterpolation", false); -ddtCorr = - pimple.dict().lookupOrDefault("ddtCorr", true); \ No newline at end of file +ddtCorr = pimple.dict().lookupOrDefault("ddtCorr", true); + +adjustFringe = pimple.dict().lookupOrDefault("oversetAdjustPhi", false); diff --git a/applications/test/surfaceIntersection/Test-surfaceIntersection.C b/applications/test/surfaceIntersection/Test-surfaceIntersection.C index ddf122f60a..b841663790 100644 --- a/applications/test/surfaceIntersection/Test-surfaceIntersection.C +++ b/applications/test/surfaceIntersection/Test-surfaceIntersection.C @@ -41,10 +41,15 @@ using namespace Foam; autoPtr loadSurface ( const Foam::Time& runTime, - const fileName& surfName + const fileName& surfName, + const scalar scaleFactor ) { - Info<< "Reading surface " << surfName << endl; + Info<< "Reading surface " << surfName << nl; + if (scaleFactor > 0) + { + Info<<"Scaling : " << scaleFactor << nl; + } const fileName fallback = runTime.constantPath()/triSurfaceMesh::meshSubDir/surfName; @@ -52,11 +57,11 @@ autoPtr loadSurface autoPtr surfPtr; if (isFile(surfName)) { - surfPtr.set(new triSurface(surfName)); + surfPtr.set(new triSurface(surfName, scaleFactor)); } else if (isFile(fallback)) { - surfPtr.set(new triSurface(fallback)); + surfPtr.set(new triSurface(fallback, scaleFactor)); } else { @@ -102,6 +107,12 @@ int main(int argc, char *argv[]) "mergeTol", "merge points (and edges) using the specified tolerance" ); + argList::addOption + ( + "scale", + "factor", + "geometry scaling factor" + ); #include "addDictOption.H" @@ -117,16 +128,18 @@ int main(int argc, char *argv[]) #include "setRootCase.H" #include "createTime.H" + const scalar scaleFactor = args.optionLookupOrDefault("scale", -1); + const word outputFile(args.executable() + ".obj"); const fileName surf1Name(args[1]); - triSurface surf1 = loadSurface(runTime, surf1Name)(); + triSurface surf1 = loadSurface(runTime, surf1Name, scaleFactor)(); Info<< surf1Name << " statistics:" << endl; surf1.writeStats(Info); Info<< endl; const fileName surf2Name(args[2]); - triSurface surf2 = loadSurface(runTime, surf2Name)(); + triSurface surf2 = loadSurface(runTime, surf2Name, scaleFactor)(); Info<< surf2Name << " statistics:" << endl; surf2.writeStats(Info); Info<< endl; diff --git a/applications/test/surfaceMeshConvert/Make/files b/applications/test/surfaceMeshConvert/Make/files new file mode 100644 index 0000000000..91a99b3fef --- /dev/null +++ b/applications/test/surfaceMeshConvert/Make/files @@ -0,0 +1,3 @@ +Test-surfaceMeshConvert.C + +EXE = $(FOAM_APPBIN)/Test-surfaceMeshConvert diff --git a/applications/utilities/surface/surfaceMeshConvertTesting/Make/options b/applications/test/surfaceMeshConvert/Make/options similarity index 100% rename from applications/utilities/surface/surfaceMeshConvertTesting/Make/options rename to applications/test/surfaceMeshConvert/Make/options diff --git a/applications/utilities/surface/surfaceMeshConvertTesting/surfaceMeshConvertTesting.C b/applications/test/surfaceMeshConvert/Test-surfaceMeshConvert.C similarity index 98% rename from applications/utilities/surface/surfaceMeshConvertTesting/surfaceMeshConvertTesting.C rename to applications/test/surfaceMeshConvert/Test-surfaceMeshConvert.C index 2db1c32b11..39cc729ba3 100644 --- a/applications/utilities/surface/surfaceMeshConvertTesting/surfaceMeshConvertTesting.C +++ b/applications/test/surfaceMeshConvert/Test-surfaceMeshConvert.C @@ -22,17 +22,16 @@ License along with OpenFOAM. If not, see . Application - surfaceMeshConvertTesting + Test-surfaceMeshConvert Group grpSurfaceUtilities Description - Converts from one surface mesh format to another, but primarily - used for testing functionality. + Test conversions from one surface mesh format to another. Usage - \b surfaceMeshConvertTesting inputFile outputFile [OPTION] + \b Test-surfaceMeshConvert inputFile outputFile [OPTION] Options: - \par -clean diff --git a/applications/utilities/mesh/conversion/foamToFireMesh/foamToFireMesh.C b/applications/utilities/mesh/conversion/foamToFireMesh/foamToFireMesh.C index 87ddd4dff9..216f253d5f 100644 --- a/applications/utilities/mesh/conversion/foamToFireMesh/foamToFireMesh.C +++ b/applications/utilities/mesh/conversion/foamToFireMesh/foamToFireMesh.C @@ -91,7 +91,7 @@ int main(int argc, char *argv[]) // ~~~~~~~~~~~~~~~~~~~~~ fileFormats::FIREMeshWriter::binary = !args.optionFound("ascii"); - // default: rescale from [m] to [mm] + // Default: no rescaling scalar scaleFactor = 1; if (args.optionReadIfPresent("scale", scaleFactor)) { diff --git a/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C b/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C index db2f571043..b082bf39c2 100644 --- a/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C +++ b/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C @@ -43,8 +43,8 @@ Usage or -yawPitchRoll (yawdegrees pitchdegrees rolldegrees) or -rollPitchYaw (rolldegrees pitchdegrees yawdegrees) - -scale vector - Scales the points by the given vector. + -scale scalar|vector + Scales the points by the given scalar or vector. The any or all of the three options may be specified and are processed in the above order. @@ -182,9 +182,9 @@ int main(int argc, char *argv[]) argList::addOption ( "scale", - "vector", - "scale by the specified amount - eg, '(0.001 0.001 0.001)' for a " - "uniform [mm] to [m] scaling" + "scalar | vector", + "scale by the specified amount - eg, for a uniform [mm] to [m] scaling " + "use either (0.001 0.001 0.001)' or simply '0.001'" ); #include "addRegionOption.H" @@ -262,10 +262,10 @@ int main(int argc, char *argv[]) << " pitch " << v.y() << nl << " yaw " << v.z() << nl; - // Convert to radians + // degToRad v *= pi/180.0; - quaternion R(quaternion::rotationSequence::XYZ, v); + const quaternion R(quaternion::rotationSequence::XYZ, v); Info<< "Rotating points by quaternion " << R << endl; points = transform(R, points); @@ -282,16 +282,10 @@ int main(int argc, char *argv[]) << " pitch " << v.y() << nl << " roll " << v.z() << nl; - // Convert to radians + // degToRad v *= pi/180.0; - scalar yaw = v.x(); - scalar pitch = v.y(); - scalar roll = v.z(); - - quaternion R = quaternion(vector(0, 0, 1), yaw); - R *= quaternion(vector(0, 1, 0), pitch); - R *= quaternion(vector(1, 0, 0), roll); + const quaternion R(quaternion::rotationSequence::ZYX, v); Info<< "Rotating points by quaternion " << R << endl; points = transform(R, points); @@ -302,13 +296,34 @@ int main(int argc, char *argv[]) } } - if (args.optionReadIfPresent("scale", v)) + if (args.optionFound("scale")) { - Info<< "Scaling points by " << v << endl; + // Use readList to handle single or multiple values + const List scaling = args.optionReadList("scale"); - points.replace(vector::X, v.x()*points.component(vector::X)); - points.replace(vector::Y, v.y()*points.component(vector::Y)); - points.replace(vector::Z, v.z()*points.component(vector::Z)); + if (scaling.size() == 1) + { + Info<< "Scaling points uniformly by " << scaling[0] << nl; + points *= scaling[0]; + } + else if (scaling.size() == 3) + { + Info<< "Scaling points by (" + << scaling[0] << " " + << scaling[1] << " " + << scaling[2] << ")" << nl; + + points.replace(vector::X, scaling[0]*points.component(vector::X)); + points.replace(vector::Y, scaling[1]*points.component(vector::Y)); + points.replace(vector::Z, scaling[2]*points.component(vector::Z)); + } + else + { + FatalError + << "-scale with 1 or 3 components only" << nl + << "given: " << args["scale"] << endl + << exit(FatalError); + } } // Set the precision of the points data to 10 diff --git a/applications/utilities/postProcessing/graphics/PVReaders/foamPv/foamPvCore.H b/applications/utilities/postProcessing/graphics/PVReaders/foamPv/foamPvCore.H index 3bbc92855e..e7feca1f90 100644 --- a/applications/utilities/postProcessing/graphics/PVReaders/foamPv/foamPvCore.H +++ b/applications/utilities/postProcessing/graphics/PVReaders/foamPv/foamPvCore.H @@ -160,13 +160,59 @@ public: const std::string& datasetName ); + //- Add names to array selection + template + static label addToArray + ( + vtkDataArraySelection* select, + const std::string& prefix, + const UList& names + ); + + //- Add names to array selection + template + static label addToArray + ( + vtkDataArraySelection* select, + const UList& names, + const std::string& suffix = string::null + ); + + //- Add objects of Type to array selection + template + static label addToSelection + ( + vtkDataArraySelection* select, + const std::string& prefix, + const IOobjectList& objects + ); + //- Add objects of Type to array selection template static label addToSelection ( vtkDataArraySelection* select, const IOobjectList& objects, - const std::string& prefix = string::null + const std::string& suffix = string::null + ); + + //- Add objects of Type to array selection + template + static label addToSelection + ( + vtkDataArraySelection* select, + const std::string& prefix, + const HashTable& objects + ); + + + //- Add objects of Type to array selection + template + static label addToSelection + ( + vtkDataArraySelection* select, + const HashTable& objects, + const std::string& suffix = string::null ); diff --git a/applications/utilities/postProcessing/graphics/PVReaders/foamPv/foamPvCoreTemplates.C b/applications/utilities/postProcessing/graphics/PVReaders/foamPv/foamPvCoreTemplates.C index 54eeee88c0..cd9e2302b2 100644 --- a/applications/utilities/postProcessing/graphics/PVReaders/foamPv/foamPvCoreTemplates.C +++ b/applications/utilities/postProcessing/graphics/PVReaders/foamPv/foamPvCoreTemplates.C @@ -28,29 +28,119 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +template +Foam::label Foam::foamPvCore::addToArray +( + vtkDataArraySelection *select, + const std::string& prefix, + const UList& names +) +{ + if (prefix.empty()) + { + for (const auto& name : names) + { + select->AddArray(name.c_str()); + } + } + else + { + for (const auto& name : names) + { + select->AddArray((prefix + name).c_str()); + } + } + + return names.size(); +} + + +template +Foam::label Foam::foamPvCore::addToArray +( + vtkDataArraySelection *select, + const UList& names, + const std::string& suffix +) +{ + if (suffix.empty()) + { + for (const auto& name : names) + { + select->AddArray(name.c_str()); + } + } + else + { + for (const auto& name : names) + { + select->AddArray((name + suffix).c_str()); + } + } + + return names.size(); +} + + +template +Foam::label Foam::foamPvCore::addToSelection +( + vtkDataArraySelection *select, + const std::string& prefix, + const IOobjectList& objects +) +{ + return addToArray(select, prefix, objects.sortedNames(Type::typeName)); +} + + template Foam::label Foam::foamPvCore::addToSelection ( vtkDataArraySelection *select, const IOobjectList& objects, - const std::string& prefix + const std::string& suffix ) { - const wordList names = objects.sortedNames(Type::typeName); + return addToArray(select, objects.sortedNames(Type::typeName), suffix); +} - forAll(names, i) + +template +Foam::label Foam::foamPvCore::addToSelection +( + vtkDataArraySelection *select, + const std::string& prefix, + const HashTable& objects +) +{ + auto iter = objects.cfind(Type::typeName); + + if (iter.found()) { - if (prefix.empty()) - { - select->AddArray(names[i].c_str()); - } - else - { - select->AddArray((prefix + names[i]).c_str()); - } + return addToArray(select, prefix, iter.object().sortedToc()); } - return names.size(); + return 0; +} + + +template +Foam::label Foam::foamPvCore::addToSelection +( + vtkDataArraySelection *select, + const HashTable& objects, + const std::string& suffix +) +{ + auto iter = objects.cfind(Type::typeName); + + if (iter.found()) + { + return addToArray(select, iter.object().sortedToc(), suffix); + } + + return 0; } diff --git a/applications/utilities/postProcessing/graphics/PVReaders/vtkPVFoam/vtkPVFoam.H b/applications/utilities/postProcessing/graphics/PVReaders/vtkPVFoam/vtkPVFoam.H index 55ec9d73e1..226ff6b9bd 100644 --- a/applications/utilities/postProcessing/graphics/PVReaders/vtkPVFoam/vtkPVFoam.H +++ b/applications/utilities/postProcessing/graphics/PVReaders/vtkPVFoam/vtkPVFoam.H @@ -155,7 +155,10 @@ class vtkPVFoam vtkSmartPointer getCopy() const { auto copy = vtkSmartPointer::New(); - copy->ShallowCopy(vtkgeom); + if (vtkgeom) + { + copy->ShallowCopy(vtkgeom); + } return copy; } @@ -163,7 +166,10 @@ class vtkPVFoam void reuse() { dataset = vtkSmartPointer::New(); - dataset->ShallowCopy(vtkgeom); + if (vtkgeom) + { + dataset->ShallowCopy(vtkgeom); + } } //- Set the geometry and make a shallow copy to dataset diff --git a/applications/utilities/postProcessing/graphics/PVReaders/vtkPVFoam/vtkPVFoamUpdateInfo.C b/applications/utilities/postProcessing/graphics/PVReaders/vtkPVFoam/vtkPVFoamUpdateInfo.C index 335a975fc8..9e61618cab 100644 --- a/applications/utilities/postProcessing/graphics/PVReaders/vtkPVFoam/vtkPVFoamUpdateInfo.C +++ b/applications/utilities/postProcessing/graphics/PVReaders/vtkPVFoam/vtkPVFoamUpdateInfo.C @@ -85,11 +85,11 @@ Foam::wordList Foam::vtkPVFoam::getZoneNames wordList names(zmesh.size()); label nZone = 0; - forAll(zmesh, zonei) + for (const auto& zn : zmesh) { - if (!zmesh[zonei].empty()) + if (!zn.empty()) { - names[nZone++] = zmesh[zonei].name(); + names[nZone++] = zn.name(); } } names.setSize(nZone); @@ -100,8 +100,6 @@ Foam::wordList Foam::vtkPVFoam::getZoneNames Foam::wordList Foam::vtkPVFoam::getZoneNames(const word& zoneType) const { - wordList names; - // mesh not loaded - read from file IOobject ioObj ( @@ -119,14 +117,17 @@ Foam::wordList Foam::vtkPVFoam::getZoneNames(const word& zoneType) const false ); + wordList names; if (ioObj.typeHeaderOk(false, false)) { zonesEntries zones(ioObj); names.setSize(zones.size()); - forAll(zones, zonei) + label nZone = 0; + + for (const auto& zn : zones) { - names[zonei] = zones[zonei].keyword(); + names[nZone++] = zn.keyword(); } } @@ -167,7 +168,7 @@ void Foam::vtkPVFoam::updateInfoLagrangian << " " << dbPtr_->timePath()/cloud::prefix << endl; } - // use the db directly since this might be called without a mesh, + // Use the db directly since this might be called without a mesh, // but the region must get added back in fileName lagrangianPrefix(cloud::prefix); if (meshRegion_ != polyMesh::defaultRegion) @@ -175,22 +176,23 @@ void Foam::vtkPVFoam::updateInfoLagrangian lagrangianPrefix = meshRegion_/cloud::prefix; } - // Search for list of lagrangian objects for this time - fileNameList cloudDirs - ( - readDir(dbPtr_->timePath()/lagrangianPrefix, fileName::DIRECTORY) - ); + // List of lagrangian objects across all times + HashSet names; + + for (const instant& t : dbPtr_().times()) + { + names.insert + ( + readDir + ( + dbPtr_->path()/t.name()/lagrangianPrefix, + fileName::DIRECTORY + ) + ); + } rangeLagrangian_.reset(select->GetNumberOfArrays()); - forAll(cloudDirs, cloudi) - { - // Add cloud to GUI list - select->AddArray - ( - ("lagrangian/" + cloudDirs[cloudi]).c_str() - ); - ++rangeLagrangian_; - } + rangeLagrangian_ += addToArray(select, "lagrangian/", names.sortedToc()); if (debug) { @@ -257,39 +259,26 @@ void Foam::vtkPVFoam::updateInfoPatches const polyPatch& pp = patches[patchId]; if (pp.size()) { - enabledEntries.insert - ( - "patch/" + pp.name() - ); + enabledEntries.insert("patch/" + pp.name()); } } } } - // Sort group names - Foam::sort(displayNames); - for (const auto& name : displayNames) - { - select->AddArray(name.c_str()); - ++rangePatches_; - } + Foam::sort(displayNames); // Sorted group names + rangePatches_ += addToArray(select, displayNames); // Add (non-zero) patches to the list of mesh parts // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (!reader_->GetShowGroupsOnly()) { - forAll(patches, patchi) + for (const polyPatch& pp : patches) { - const polyPatch& pp = patches[patchi]; - if (pp.size()) { // Add patch to GUI list - select->AddArray - ( - ("patch/" + pp.name()).c_str() - ); + select->AddArray(("patch/" + pp.name()).c_str()); ++rangePatches_; } } @@ -339,9 +328,9 @@ void Foam::vtkPVFoam::updateInfoPatches && patchDict.readIfPresent("inGroups", groupNames) ) { - forAll(groupNames, groupI) + for (const auto& groupName : groupNames) { - groups(groupNames[groupI]).insert(patchi); + groups(groupName).insert(patchi); } } } @@ -370,21 +359,13 @@ void Foam::vtkPVFoam::updateInfoPatches { for (auto patchId : patchIDs) { - enabledEntries.insert - ( - "patch/" + names[patchId] - ); + enabledEntries.insert("patch/" + names[patchId]); } } } - // Sort group names - Foam::sort(displayNames); - for (const auto& name : displayNames) - { - select->AddArray(name.c_str()); - ++rangePatches_; - } + Foam::sort(displayNames); // Sorted group names + rangePatches_ += addToArray(select, displayNames); // Add (non-zero) patches to the list of mesh parts // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -396,10 +377,7 @@ void Foam::vtkPVFoam::updateInfoPatches // Valid patch if nFace > 0 - add patch to GUI list if (sizes[patchi]) { - select->AddArray - ( - ("patch/" + names[patchi]).c_str() - ); + select->AddArray(("patch/" + names[patchi]).c_str()); ++rangePatches_; } } @@ -430,74 +408,44 @@ void Foam::vtkPVFoam::updateInfoZones << " [meshPtr=" << (meshPtr_ ? "set" : "null") << "]" << endl; } - wordList namesLst; - // - // cellZones information - // ~~~~~~~~~~~~~~~~~~~~~ - if (meshPtr_) + // cellZones { - namesLst = getZoneNames(meshPtr_->cellZones()); - } - else - { - namesLst = getZoneNames("cellZones"); - } - - rangeCellZones_.reset(select->GetNumberOfArrays()); - forAll(namesLst, elemI) - { - select->AddArray + const wordList names = ( - ("cellZone/" + namesLst[elemI]).c_str() + meshPtr_ + ? getZoneNames(meshPtr_->cellZones()) + : getZoneNames("cellZones") ); - ++rangeCellZones_; + + rangeCellZones_.reset(select->GetNumberOfArrays()); + rangeCellZones_ += addToArray(select, "cellZone/", names); } - - // - // faceZones information - // ~~~~~~~~~~~~~~~~~~~~~ - if (meshPtr_) + // faceZones { - namesLst = getZoneNames(meshPtr_->faceZones()); - } - else - { - namesLst = getZoneNames("faceZones"); - } - - rangeFaceZones_.reset(select->GetNumberOfArrays()); - forAll(namesLst, elemI) - { - select->AddArray + const wordList names = ( - ("faceZone/" + namesLst[elemI]).c_str() + meshPtr_ + ? getZoneNames(meshPtr_->faceZones()) + : getZoneNames("faceZones") ); - ++rangeFaceZones_; + + rangeFaceZones_.reset(select->GetNumberOfArrays()); + rangeFaceZones_ += addToArray(select, "faceZone/", names); } - - // - // pointZones information - // ~~~~~~~~~~~~~~~~~~~~~~ - if (meshPtr_) + // pointZones { - namesLst = getZoneNames(meshPtr_->pointZones()); - } - else - { - namesLst = getZoneNames("pointZones"); - } - - rangePointZones_.reset(select->GetNumberOfArrays()); - forAll(namesLst, elemI) - { - select->AddArray + const wordList names = ( - ("pointZone/" + namesLst[elemI]).c_str() + meshPtr_ + ? getZoneNames(meshPtr_->pointZones()) + : getZoneNames("pointZones") ); - ++rangePointZones_; + + rangePointZones_.reset(select->GetNumberOfArrays()); + rangePointZones_ += addToArray(select, "pointZone/", names); } if (debug) @@ -525,14 +473,14 @@ void Foam::vtkPVFoam::updateInfoSets // Add names of sets. Search for last time directory with a sets // subdirectory. Take care not to search beyond the last mesh. - word facesInstance = dbPtr_().findInstance + const word facesInstance = dbPtr_().findInstance ( meshDir_, "faces", IOobject::READ_IF_PRESENT ); - word setsInstance = dbPtr_().findInstance + const word setsInstance = dbPtr_().findInstance ( meshDir_/"sets", word::null, @@ -540,7 +488,7 @@ void Foam::vtkPVFoam::updateInfoSets facesInstance ); - IOobjectList objects(dbPtr_(), setsInstance, meshDir_/"sets"); + const IOobjectList objects(dbPtr_(), setsInstance, meshDir_/"sets"); if (debug) { @@ -553,24 +501,24 @@ void Foam::vtkPVFoam::updateInfoSets rangeCellSets_ += addToSelection ( select, - objects, - "cellSet/" + "cellSet/", + objects ); rangeFaceSets_.reset(select->GetNumberOfArrays()); rangeFaceSets_ += addToSelection ( select, - objects, - "faceSet/" + "faceSet/", + objects ); rangePointSets_.reset(select->GetNumberOfArrays()); rangePointSets_ += addToSelection ( select, - objects, - "pointSet/" + "pointSet/", + objects ); if (debug) @@ -594,21 +542,20 @@ void Foam::vtkPVFoam::updateInfoLagrangianFields HashSet enabled = getSelectedArraySet(select); select->RemoveAllArrays(); - // TODO - currently only get fields from ONE cloud - // have to decide if the second set of fields get mixed in - // or dealt with separately - const arrayRange& range = rangeLagrangian_; if (range.empty()) { return; } - // Add Lagrangian fields even if particles are not enabled? - const int partId = range.start(); - const word cloudName = getReaderPartName(partId); + // Reuse the previously determined cloud information. + DynamicList cloudNames(range.size()); + for (auto partId : range) + { + cloudNames.append(getReaderPartName(partId)); + } - // use the db directly since this might be called without a mesh, + // Use the db directly since this might be called without a mesh, // but the region must get added back in fileName lagrangianPrefix(cloud::prefix); if (meshRegion_ != polyMesh::defaultRegion) @@ -616,19 +563,37 @@ void Foam::vtkPVFoam::updateInfoLagrangianFields lagrangianPrefix = meshRegion_/cloud::prefix; } - IOobjectList objects - ( - dbPtr_(), - dbPtr_().timeName(), - lagrangianPrefix/cloudName - ); + // List of lagrangian fields across all clouds and all times. + // ParaView displays "(partial)" after field names that only apply + // to some of the clouds. + HashTable fields; - addToSelection>(select, objects); - addToSelection>(select, objects); - addToSelection>(select, objects); - addToSelection>(select, objects); - addToSelection>(select, objects); - addToSelection>(select, objects); + for (const instant& t : dbPtr_().times()) + { + for (const auto& cloudName : cloudNames) + { + const HashTable localFields = + IOobjectList + ( + dbPtr_(), + t.name(), + lagrangianPrefix/cloudName + ).classes(); + + forAllConstIters(localFields, iter) + { + fields(iter.key()) |= iter.object(); + } + } + } + + // Known/supported field-types + addToSelection>(select, fields); + addToSelection>(select, fields); + addToSelection>(select, fields); + addToSelection>(select, fields); + addToSelection>(select, fields); + addToSelection>(select, fields); // Restore the enabled selections setSelectedArrayEntries(select, enabled); diff --git a/applications/utilities/surface/surfaceAdd/surfaceAdd.C b/applications/utilities/surface/surfaceAdd/surfaceAdd.C index 5caa3e0703..0be9024ebd 100644 --- a/applications/utilities/surface/surfaceAdd/surfaceAdd.C +++ b/applications/utilities/surface/surfaceAdd/surfaceAdd.C @@ -71,6 +71,12 @@ int main(int argc, char *argv[]) "mergeRegions", "combine regions from both surfaces" ); + argList::addOption + ( + "scale", + "factor", + "geometry scaling factor on input surfaces" + ); argList args(argc, argv); @@ -81,6 +87,8 @@ int main(int argc, char *argv[]) const bool addPoint = args.optionFound("points"); const bool mergeRegions = args.optionFound("mergeRegions"); + const scalar scaleFactor = args.optionLookupOrDefault("scale", -1); + if (addPoint) { Info<< "Reading a surface and adding points from a file" @@ -117,8 +125,12 @@ int main(int argc, char *argv[]) << "Writing : " << outFileName << nl << endl; } - const triSurface surface1(inFileName1); + if (scaleFactor > 0) + { + Info<< "Scaling : " << scaleFactor << nl; + } + const triSurface surface1(inFileName1, scaleFactor); Info<< "Surface1:" << endl; surface1.writeStats(Info); Info<< endl; @@ -131,7 +143,7 @@ int main(int argc, char *argv[]) if (addPoint) { IFstream pointsFile(args["points"]); - pointField extraPoints(pointsFile); + const pointField extraPoints(pointsFile); Info<< "Additional Points:" << extraPoints.size() << endl; @@ -139,17 +151,16 @@ int main(int argc, char *argv[]) label pointi = pointsAll.size(); pointsAll.setSize(pointsAll.size() + extraPoints.size()); - forAll(extraPoints, i) + for (const auto& pt : extraPoints) { - pointsAll[pointi++] = extraPoints[i]; + pointsAll[pointi++] = pt; } combinedSurf = triSurface(surface1, surface1.patches(), pointsAll); } else { - const triSurface surface2(inFileName2); - + const triSurface surface2(inFileName2, scaleFactor); Info<< "Surface2:" << endl; surface2.writeStats(Info); Info<< endl; @@ -165,21 +176,19 @@ int main(int argc, char *argv[]) label pointi = 0; // Copy points1 into pointsAll - forAll(points1, point1i) + for (const auto& pt : points1) { - pointsAll[pointi++] = points1[point1i]; + pointsAll[pointi++] = pt; } // Add surface2 points - forAll(points2, point2i) + for (const auto& pt : points2) { - pointsAll[pointi++] = points2[point2i]; + pointsAll[pointi++] = pt; } label trianglei = 0; - - // Determine map for both regions label nNewPatches = 0; labelList patch1Map(surface1.patches().size()); @@ -192,17 +201,17 @@ int main(int argc, char *argv[]) forAll(surface1.patches(), i) { const word& name = surface1.patches()[i].name(); - HashTable