From b5432011faedd923aabbddea9fc26152556d4b57 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Sun, 25 Nov 2018 10:47:00 +0100 Subject: [PATCH] ENH: improve option naming consistency in - foamToVTK, foamToEnsight, foamToEnsightParts --- .../foamToEnsight/foamToEnsight.C | 69 ++++++++------- .../foamToEnsightParts/findFields.H | 2 +- .../foamToEnsightParts/foamToEnsightParts.C | 36 ++++---- .../dataConversion/foamToVTK/foamToVTK.C | 88 +++++++++++-------- 4 files changed, 110 insertions(+), 85 deletions(-) diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/foamToEnsight.C b/applications/utilities/postProcessing/dataConversion/foamToEnsight/foamToEnsight.C index f27a0081e0..cb05347ac2 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/foamToEnsight.C +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/foamToEnsight.C @@ -42,24 +42,26 @@ Usage - \par -noZero Exclude the often incomplete initial conditions. - - \par -noLagrangian - Suppress writing lagrangian positions and fields. - - - \par -noPatches + - \par -no-boundary Suppress writing any patches. - - \par -patches patchList - Specify particular patches to write. - Specifying an empty list suppresses writing the internalMesh. + - \par -no-internal + Suppress writing the internal mesh. - - \par -faceZones zoneList + - \par -no-lagrangian + Suppress writing lagrangian positions and fields. + + - \par -patches patch or patch list + Specify particular patches to write. + + - \par -faceZones patch or zone list Specify faceZones to write, with wildcards - \par -cellZone zoneName Specify single cellZone to write (not lagrangian) - \par -width \ - Width of EnSight data subdir (default: 8) + Width of Ensight data subdir (default: 8) Note Writes to \a EnSight directory to avoid collisions with @@ -124,42 +126,47 @@ int main(int argc, char *argv[]) argList::addBoolOption ( "nodeValues", - "Write values in nodes" + "Write values at nodes" ); argList::addBoolOption ( - "noLagrangian", - "Suppress writing lagrangian positions and fields" - ); - argList::addBoolOption - ( - "noInternal", - "Do not generate file for mesh, only for patches" - ); - argList::addBoolOption - ( - "noBoundary", + "no-boundary", // noPatches "Suppress writing any patches" ); - argList::addOptionCompat("noBoundary", {"noPatches", 1806}); + argList::addOptionCompat("no-boundary", {"noPatches", 1806}); + + argList::addBoolOption + ( + "no-internal", + "Suppress writing the internal mesh" + ); + argList::addBoolOption + ( + "no-lagrangian", // noLagrangian + "Suppress writing lagrangian positions and fields" + ); + argList::addOptionCompat("no-lagrangian", {"noLagrangian", 1806}); argList::addOption ( "patches", "wordRes", - "Specify particular patches to write - eg '(outlet \"inlet.*\")'." + "Specify single patch or multiple patches to write\n" + "Eg, 'inlet' or '(outlet \"inlet.*\")'" ); argList::addOption ( "faceZones", "wordRes", - "Specify faceZones to write - eg '( slice \"mfp-.*\" )'." + "Specify single or multiple faceZones to write\n" + "Eg, 'cells' or '( slice \"mfp-.*\" )'." ); argList::addOption ( "fields", "wordRes", - "Specify fields to export (all by default) - eg '( \"U.*\" )'." + "Specify single or multiple fields to write (all by default)\n" + "Eg, 'T' or '( \"U.*\" )'" ); argList::addOption ( @@ -171,13 +178,13 @@ int main(int argc, char *argv[]) ( "name", "subdir", - "Sub-directory name for ensight output (default: 'EnSight')" + "Sub-directory name for Ensight output (default: 'EnSight')" ); argList::addOption ( "width", "n", - "Width of ensight data subdir" + "Width of Ensight data subdir" ); #include "setRootCase.H" @@ -235,8 +242,9 @@ int main(int argc, char *argv[]) // Output configuration (geometry related) // ensightMesh::options writeOpts(format); - writeOpts.useInternalMesh(!args.found("noInternal")); - writeOpts.useBoundaryMesh(!args.found("noBoundary")); + writeOpts.useBoundaryMesh(!args.found("no-boundary")); + writeOpts.useInternalMesh(!args.found("no-internal")); + const bool doLagrangian = !args.found("no-lagrangian"); if (args.found("patches")) { @@ -248,9 +256,8 @@ int main(int argc, char *argv[]) } // - // output configuration (field related) + // Output configuration (field related) // - const bool doLagrangian = !args.found("noLagrangian"); wordRes fieldPatterns; args.readListIfPresent("fields", fieldPatterns); diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/findFields.H b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/findFields.H index 81559c69f1..f43584b4f6 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/findFields.H +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/findFields.H @@ -31,7 +31,7 @@ if (timeDirs.size()) // Now check for lagrangian/ // fileNameList cloudDirs; - if (!noLagrangian) + if (doLagrangian) { cloudDirs = readDir ( diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/foamToEnsightParts.C b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/foamToEnsightParts.C index 4509beece3..a294e3c708 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/foamToEnsightParts.C +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/foamToEnsightParts.C @@ -48,10 +48,10 @@ Usage Ignore the time index contained in the time file and use a simple indexing when creating the \c Ensight/data/######## files. - - \par -noLagrangian + - \par -no-lagrangian Suppress writing lagrangian positions and fields. - - \par -noMesh + - \par -no-mesh Suppress writing the geometry. Can be useful for converting partial results for a static geometry. @@ -104,25 +104,29 @@ int main(int argc, char *argv[]) ( "index", "start", - "Ignore the time index contained in the uniform/time file " - "and use simple indexing when creating the files" + "Ignore the time index contained in the uniform/time file" + " and use simple indexing when creating files" ); argList::addBoolOption ( - "noLagrangian", + "no-lagrangian", // noLagrangian "Suppress writing lagrangian positions and fields" ); + argList::addOptionCompat("no-lagrangian", {"noLagrangian", 1806}); + argList::addBoolOption ( - "noMesh", - "Suppress writing the geometry. " - "Can be useful for converting partial results for a static geometry" + "no-mesh", // noMesh + "Suppress writing the geometry." + " Can be useful for converting partial results for a static geometry" ); + argList::addOptionCompat("no-mesh", {"noMesh", 1806}); + argList::addOption ( "name", "subdir", - "Sub-directory name for ensight output (default: 'Ensight')" + "Sub-directory name for Ensight output (default: 'Ensight')" ); argList::addOption ( @@ -213,10 +217,10 @@ int main(int argc, char *argv[]) // Control for renumbering iterations label indexingNumber = 0; const bool optIndex = args.readIfPresent("index", indexingNumber); - const bool noLagrangian = args.found("noLagrangian"); + const bool doLagrangian = !args.found("no-lagrangian"); - // Always write the geometry, unless the -noMesh option is specified - bool optNoMesh = args.found("noMesh"); + // Write the geometry, unless otherwise specified + bool doGeometry = !args.found("no-mesh"); // Construct the list of ensight parts for the entire mesh @@ -237,10 +241,10 @@ int main(int argc, char *argv[]) #include "checkMeshMoving.H" #include "findFields.H" - if (meshMoving && optNoMesh) + if (meshMoving && !doGeometry) { - Info<< "mesh is moving: ignoring '-noMesh' option" << endl; - optNoMesh = false; + Info<< "mesh is moving: ignoring '-no-mesh' option" << endl; + doGeometry = true; } @@ -264,7 +268,7 @@ int main(int argc, char *argv[]) partsList.recalculate(mesh); } - if (!optNoMesh) + if (doGeometry) { autoPtr os = ensCase.newGeometry(meshMoving); partsList.write(os.ref()); diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C index 269099f194..ce456db48d 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C @@ -34,7 +34,7 @@ Description - Handles volFields, pointFields, surfaceScalarField, surfaceVectorField fields. - Mesh topo changes. - - Both ascii and binary. + - Output legacy or xml VTK format in ascii or binary. - Single time step writing. - Write subset only. - Optional decomposition of cells. @@ -50,9 +50,11 @@ Usage Write VTK data in legacy format instead of XML format - \par -fields \ - Convert selected fields only. For example, + Specify single or multiple fields to write (all by default) + For example, \verbatim - -fields '( p T U )' + -fields T + -fields '(p T U \"alpha.*\")' \endverbatim The quoting is required to avoid shell expansions and to pass the information as a single argument. @@ -71,32 +73,37 @@ Usage - \par -nearCellValue Output cell value on patches instead of patch value itself - - \par -noBoundary + - \par -no-boundary Suppress output for all boundary patches - - \par -noInternal + - \par -no-internal Suppress output for internal (volume) mesh - - \par -noLagrangian + - \par -no-lagrangian Suppress writing Lagrangian positions and fields. - - \par -noPointValues - No pointFields + - \par -no-point-data + Suppress conversion of pointFields. No interpolated PointData. - \par -noFaceZones - No faceZones + Suppress conversion of surface fields on faceZones - \par -poly-decomp Decompose polyhedral cells into tets/pyramids - - \par -allPatches + - \par -one-boundary Combine all patches into a single boundary file - - \par -patch \ - Specify which patch or patches (name or regex) to convert. + - \par -patches NAME | LIST + Specify single patch or multiple patches (name or regex) to write + For example, + \verbatim + -patches top + -patches '( front \".*back\" )' + \endverbatim - - \par -excludePatches \ - Specify which patch or patches (name or regex) not to convert. + - \par -excludePatches NAME | LIST + Specify single or multiple patches (name or regex) not to convert. For example, \verbatim -excludePatches '( inlet_1 inlet_2 "proc.*")' @@ -306,8 +313,8 @@ int main(int argc, char *argv[]) ( "fields", "wordRes", - "Only convert specified fields\n" - "Eg, '(p T U \"alpha.*\")'" + "Specify single or multiple fields to write (all by default)\n" + "Eg, 'T' or '(p T U \"alpha.*\")'" ); argList::addBoolOption @@ -330,30 +337,35 @@ int main(int argc, char *argv[]) ); argList::addBoolOption ( - "noBoundary", // no-boundary + "no-boundary", "Suppress output for boundary patches" ); argList::addBoolOption ( - "noInternal", // no-internal + "no-internal", "Suppress output for internal volume mesh" ); argList::addBoolOption ( - "noLagrangian", // no-lagrangian + "no-lagrangian", // noLagrangian "Suppress writing lagrangian positions and fields" ); + argList::addOptionCompat("no-lagrangian", {"noLagrangian", 1806}); + argList::addBoolOption ( - "noPointValues", // no-point-data - "No pointFields and no interpolated PointData" + "no-point-data", // noPointValues + "Suppress conversion of pointFields. No interpolated PointData." ); + argList::addOptionCompat("no-point-data", {"noPointValues", 1806}); + argList::addBoolOption ( - "allPatches", // one-boundary + "one-boundary", // allPatches "Combine all patches into a single file", true // mark as an advanced option ); + argList::addOptionCompat("one-boundary", {"allPatches", 1806}); #include "addRegionOption.H" @@ -374,21 +386,22 @@ int main(int argc, char *argv[]) ( "patches", "wordRes", - "A list of patches to include.\n" - "Eg, '( front \".*back\" )'" + "Specify single patch or multiple patches to write\n" + "Eg, 'top' or '( front \".*back\" )'" ); argList::addOption ( "excludePatches", "wordRes", - "A list of patches to exclude\n" - "Eg, '( inlet \".*Wall\" )'" + "Specify single patch or multiple patches to exclude from writing." + " Eg, 'outlet' or '( inlet \".*Wall\" )'", + true // mark as an advanced option ); argList::addBoolOption ( "noFaceZones", - "No faceZones", + "Suppress conversion of surface fields on faceZones", true // mark as an advanced option ); argList::ignoreOptionCompat @@ -416,14 +429,14 @@ int main(int argc, char *argv[]) #include "setRootCase.H" const bool decomposePoly = args.found("poly-decomp"); - const bool doBoundary = !args.found("noBoundary"); - const bool doInternal = !args.found("noInternal"); - const bool doLagrangian = !args.found("noLagrangian"); + const bool doBoundary = !args.found("no-boundary"); + const bool doInternal = !args.found("no-internal"); + const bool doLagrangian = !args.found("no-lagrangian"); const bool doFiniteArea = args.found("finiteAreaFields"); const bool doSurfaceFields = args.found("surfaceFields"); const bool doFaceZones = !args.found("noFaceZones") && doInternal; - const bool oneBoundary = args.found("allPatches") && doBoundary; + const bool oneBoundary = args.found("one-boundary") && doBoundary; const bool nearCellValue = args.found("nearCellValue") && doBoundary; const bool allRegions = args.found("allRegions"); @@ -435,11 +448,11 @@ int main(int argc, char *argv[]) << nl << endl; } - const bool noPointValues = args.found("noPointValues"); + const bool noPointValues = args.found("no-point-data"); if (noPointValues) { - Info<< "Outputting cell values only." - << " Point fields disabled by '-noPointValues' option" + Info<< "Point fields and interpolated point data" + << " disabled with the '-no-point-data' option" << nl; } @@ -478,7 +491,7 @@ int main(int argc, char *argv[]) if (regionNames.empty()) { - Info<<"Warning: " + Info<< "Warning: " << "No regionProperties - assuming default region" << nl << endl; @@ -500,9 +513,10 @@ int main(int argc, char *argv[]) } else if ( - selectRegions.size() == 1 && !selectRegions.first().isPattern() + selectRegions.size() == 1 && selectRegions.first().isLiteral() ) { + // Identical to -region NAME regionNames.resize(1); regionNames.first() = selectRegions.first(); } @@ -513,7 +527,7 @@ int main(int argc, char *argv[]) if (regionNames.empty()) { - Info<<"Warning: " + Info<< "Warning: " << "No regionProperties - assuming default region" << nl << endl;