mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: -exclude-fields, -no-fields options for foamToEnsight, foamToVTK
- additional verbosity option for conversions - ignore old `-finite-area` option and always convert available finiteArea mesh/fields unless `-no-finite-area` is specified (#2374) ENH: simplify point offset handling for ensight output - extend writing to include compact face/cell lists
This commit is contained in:
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -52,7 +52,6 @@ if (doLagrangian)
|
||||
// Consistent order
|
||||
Foam::sort(cloudNames);
|
||||
|
||||
|
||||
for (const word& cloudName : cloudNames)
|
||||
{
|
||||
IOobjectList cloudObjs(mesh, runTime.timeName(), cloudPrefix/cloudName);
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -43,12 +43,7 @@ Description
|
||||
{
|
||||
if (nSurfaceScalarField == -1)
|
||||
{
|
||||
sScalars = readFields<surfaceScalarField>
|
||||
(
|
||||
meshProxy,
|
||||
objects,
|
||||
selectedFields
|
||||
);
|
||||
sScalars = readFields<surfaceScalarField>(meshProxy, objects);
|
||||
|
||||
reportFields::print(" surfScalar :", Info, sScalars);
|
||||
nSurfaceScalarField = sScalars.size();
|
||||
@ -60,12 +55,7 @@ Description
|
||||
|
||||
if (nSurfaceVectorField == -1)
|
||||
{
|
||||
sVectors = readFields<surfaceVectorField>
|
||||
(
|
||||
meshProxy,
|
||||
objects,
|
||||
selectedFields
|
||||
);
|
||||
sVectors = readFields<surfaceVectorField>(meshProxy, objects);
|
||||
|
||||
reportFields::print(" surfVector :", Info, sVectors);
|
||||
nSurfaceVectorField = sVectors.size();
|
||||
@ -155,12 +145,7 @@ Description
|
||||
{
|
||||
if (nSurfaceScalarField == -1)
|
||||
{
|
||||
sScalars = readFields<surfaceScalarField>
|
||||
(
|
||||
meshProxy,
|
||||
objects,
|
||||
selectedFields
|
||||
);
|
||||
sScalars = readFields<surfaceScalarField>(meshProxy, objects);
|
||||
nSurfaceScalarField = sScalars.size();
|
||||
|
||||
reportFields::print(" surfScalar :", Info, sScalars);
|
||||
@ -172,12 +157,7 @@ Description
|
||||
|
||||
if (nSurfaceVectorField == -1)
|
||||
{
|
||||
sVectors = readFields<surfaceVectorField>
|
||||
(
|
||||
meshProxy,
|
||||
objects,
|
||||
selectedFields
|
||||
);
|
||||
sVectors = readFields<surfaceVectorField>(meshProxy, objects);
|
||||
nSurfaceVectorField = sVectors.size();
|
||||
|
||||
reportFields::print(" surfVector :", Info, sVectors);
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -48,7 +48,7 @@ Description
|
||||
: 0
|
||||
);
|
||||
|
||||
const label nPointFields =
|
||||
label nPointFields =
|
||||
(
|
||||
doPointValues
|
||||
? objects.count(stringListOps::foundOp<word>(fieldTypes::point))
|
||||
@ -82,11 +82,6 @@ Description
|
||||
|
||||
if (doInternal)
|
||||
{
|
||||
if (doPointValues)
|
||||
{
|
||||
pInterp.reset(new volPointInterpolation(mesh));
|
||||
}
|
||||
|
||||
if (vtuMeshCells.empty())
|
||||
{
|
||||
// Use the appropriate mesh (baseMesh or subMesh)
|
||||
@ -119,6 +114,11 @@ Description
|
||||
|
||||
internalWriter->writeTimeValue(mesh.time().value());
|
||||
internalWriter->writeGeometry();
|
||||
|
||||
if (doPointValues)
|
||||
{
|
||||
pInterp.reset(new volPointInterpolation(mesh));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -132,7 +132,7 @@ Description
|
||||
labelList patchIds;
|
||||
if (doBoundary)
|
||||
{
|
||||
patchIds = getSelectedPatches(patches, includePatches, excludePatches);
|
||||
patchIds = getSelectedPatches(patches, patchSelector);
|
||||
}
|
||||
|
||||
if (oneBoundary && patchIds.size())
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -112,11 +112,11 @@ Usage
|
||||
-patches '( front \".*back\" )'
|
||||
\endverbatim
|
||||
|
||||
- \par -excludePatches NAME | LIST
|
||||
- \par -exclude-patches NAME | LIST
|
||||
Exclude single or multiple patches (name or regex) from writing.
|
||||
For example,
|
||||
\verbatim
|
||||
-excludePatches '( inlet_1 inlet_2 "proc.*")'
|
||||
-exclude-patches '( inlet_1 inlet_2 "proc.*")'
|
||||
\endverbatim
|
||||
|
||||
Note
|
||||
@ -169,22 +169,28 @@ Note
|
||||
labelList getSelectedPatches
|
||||
(
|
||||
const polyBoundaryMesh& patches,
|
||||
const wordRes& allow,
|
||||
const wordRes& deny
|
||||
const autoPtr<wordRes::filter>& patchSelector
|
||||
)
|
||||
{
|
||||
// Name-based selection
|
||||
labelList indices
|
||||
(
|
||||
stringListOps::findMatching
|
||||
(
|
||||
patches,
|
||||
allow,
|
||||
deny,
|
||||
nameOp<polyPatch>()
|
||||
)
|
||||
);
|
||||
labelList indices;
|
||||
|
||||
if (patchSelector && !patchSelector().empty())
|
||||
{
|
||||
// Name-based selection
|
||||
indices =
|
||||
(
|
||||
stringListOps::findMatching
|
||||
(
|
||||
patches,
|
||||
patchSelector(),
|
||||
nameOp<polyPatch>()
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
indices = identity(patches.size());
|
||||
}
|
||||
|
||||
// Remove undesirable patches
|
||||
|
||||
@ -264,6 +270,8 @@ int main(int argc, char *argv[])
|
||||
argList::setAdvanced("decomposeParDict");
|
||||
argList::setAdvanced("noFunctionObjects");
|
||||
|
||||
argList::addVerboseOption("Additional verbosity");
|
||||
|
||||
argList::addBoolOption
|
||||
(
|
||||
"ascii",
|
||||
@ -328,7 +336,6 @@ int main(int argc, char *argv[])
|
||||
"Eg, 'cells' or '( slice \"mfp-.*\" )'.",
|
||||
true // mark as an advanced option
|
||||
);
|
||||
|
||||
argList::addOption
|
||||
(
|
||||
"fields",
|
||||
@ -336,6 +343,18 @@ int main(int argc, char *argv[])
|
||||
"Specify single or multiple fields to write (all by default)\n"
|
||||
"Eg, 'T' or '(p T U \"alpha.*\")'"
|
||||
);
|
||||
argList::addOption
|
||||
(
|
||||
"exclude-fields",
|
||||
"wordRes",
|
||||
"Exclude single or multiple fields",
|
||||
true // mark as an advanced option
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"no-fields",
|
||||
"Suppress conversion of fields"
|
||||
);
|
||||
|
||||
argList::addBoolOption
|
||||
(
|
||||
@ -351,11 +370,21 @@ int main(int argc, char *argv[])
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"finite-area",
|
||||
"Write finite area fields",
|
||||
"no-finite-area",
|
||||
"Suppress output of finite-area mesh/fields",
|
||||
true // mark as an advanced option
|
||||
);
|
||||
argList::addOptionCompat("finite-area", {"finiteAreaFields", 2012});
|
||||
argList::ignoreOptionCompat
|
||||
(
|
||||
{"finite-area", 2112}, // use -no-finite-area to disable
|
||||
false // bool option, no argument
|
||||
);
|
||||
argList::ignoreOptionCompat
|
||||
(
|
||||
{"finiteAreaFields", 2012}, // use -no-finite-area to disable
|
||||
false // bool option, no argument
|
||||
);
|
||||
|
||||
argList::addBoolOption
|
||||
(
|
||||
"nearCellValue",
|
||||
@ -418,12 +447,14 @@ int main(int argc, char *argv[])
|
||||
);
|
||||
argList::addOption
|
||||
(
|
||||
"excludePatches",
|
||||
"exclude-patches",
|
||||
"wordRes",
|
||||
"Exclude single or multiple patches from writing\n"
|
||||
"Eg, 'outlet' or '( inlet \".*Wall\" )'",
|
||||
true // mark as an advanced option
|
||||
);
|
||||
argList::addOptionCompat("exclude-patches", {"excludePatches", 2112});
|
||||
|
||||
argList::ignoreOptionCompat
|
||||
(
|
||||
{"noFaceZones", 1806}, // faceZones are only enabled on demand
|
||||
@ -453,13 +484,13 @@ int main(int argc, char *argv[])
|
||||
|
||||
#include "setRootCase.H"
|
||||
|
||||
/// const int optVerbose = args.verbose();
|
||||
const bool decomposePoly = args.found("poly-decomp");
|
||||
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("finite-area");
|
||||
const bool doFiniteArea = !args.found("no-finite-area");
|
||||
const bool doSurfaceFields = args.found("surfaceFields");
|
||||
|
||||
const bool oneBoundary = args.found("one-boundary") && doBoundary;
|
||||
const bool nearCellValue = args.found("nearCellValue") && doBoundary;
|
||||
|
||||
@ -494,7 +525,7 @@ int main(int argc, char *argv[])
|
||||
<< nl << endl;
|
||||
}
|
||||
|
||||
const bool doPointValues = !args.found("no-point-data");
|
||||
bool doPointValues = !args.found("no-point-data");
|
||||
if (!doPointValues)
|
||||
{
|
||||
Info<< "Point fields and interpolated point data"
|
||||
@ -521,25 +552,74 @@ int main(int argc, char *argv[])
|
||||
Info<< "Writing mesh ids (cell, patch, proc) requested" << nl;
|
||||
}
|
||||
|
||||
wordRes includePatches, excludePatches;
|
||||
// Patch selection/deselection
|
||||
wordRes includedPatches, excludedPatches;
|
||||
autoPtr<wordRes::filter> patchSelector(nullptr);
|
||||
if (doBoundary)
|
||||
{
|
||||
if (args.readListIfPresent<wordRe>("patches", includePatches))
|
||||
bool resetFilter = false;
|
||||
if (args.readListIfPresent<wordRe>("patches", includedPatches))
|
||||
{
|
||||
Info<< "Including patches " << flatOutput(includePatches)
|
||||
<< nl << endl;
|
||||
resetFilter = true;
|
||||
Info<< "Including patches "
|
||||
<< flatOutput(includedPatches) << nl << endl;
|
||||
}
|
||||
if (args.readListIfPresent<wordRe>("excludePatches", excludePatches))
|
||||
if (args.readListIfPresent<wordRe>("exclude-patches", excludedPatches))
|
||||
{
|
||||
Info<< "Excluding patches " << flatOutput(excludePatches)
|
||||
<< nl << endl;
|
||||
resetFilter = true;
|
||||
Info<< "Excluding patches "
|
||||
<< flatOutput(excludedPatches) << nl << endl;
|
||||
}
|
||||
|
||||
if (resetFilter)
|
||||
{
|
||||
patchSelector =
|
||||
autoPtr<wordRes::filter>::New(includedPatches, excludedPatches);
|
||||
}
|
||||
}
|
||||
|
||||
// Can be specified as empty (ie, no fields)
|
||||
wordRes selectedFields;
|
||||
const bool useFieldFilter =
|
||||
args.readListIfPresent<wordRe>("fields", selectedFields);
|
||||
// Field selection/deselection
|
||||
wordRes includedFields, excludedFields;
|
||||
autoPtr<wordRes::filter> fieldSelector(nullptr);
|
||||
bool doConvertFields = !args.found("no-fields");
|
||||
if (doConvertFields)
|
||||
{
|
||||
bool resetFilter = false;
|
||||
if (args.readListIfPresent<wordRe>("fields", includedFields))
|
||||
{
|
||||
Info<< "Including fields "
|
||||
<< flatOutput(includedFields) << nl << endl;
|
||||
|
||||
resetFilter = !includedFields.empty();
|
||||
|
||||
if (includedFields.empty())
|
||||
{
|
||||
// Compat: Can be specified as empty (ie, no fields)
|
||||
// Same as "block everything"
|
||||
|
||||
doConvertFields = false;
|
||||
Info<< "Field conversion disabled by '-fields ()' option" << nl
|
||||
<< "Should use -no-fields instead" << endl;
|
||||
}
|
||||
}
|
||||
if (args.readListIfPresent<wordRe>("exclude-fields", excludedFields))
|
||||
{
|
||||
resetFilter = true;
|
||||
Info<< "Excluding fields "
|
||||
<< flatOutput(excludedFields) << nl << endl;
|
||||
}
|
||||
|
||||
if (resetFilter && doConvertFields)
|
||||
{
|
||||
fieldSelector =
|
||||
autoPtr<wordRes::filter>::New(includedFields, excludedFields);
|
||||
}
|
||||
}
|
||||
else if (doConvertFields)
|
||||
{
|
||||
Info<< "Field conversion disabled with the '-no-fields' option" << nl;
|
||||
}
|
||||
|
||||
|
||||
// Non-mandatory
|
||||
const wordRes selectedFaceZones(args.getList<wordRe>("faceZones", false));
|
||||
@ -709,28 +789,34 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
// Search for list of objects for this time
|
||||
IOobjectList objects(meshProxy.baseMesh(), runTime.timeName());
|
||||
IOobjectList objects(0);
|
||||
|
||||
if (useFieldFilter)
|
||||
if (doConvertFields)
|
||||
{
|
||||
objects.filterObjects(selectedFields);
|
||||
}
|
||||
// List of objects for this time
|
||||
objects =
|
||||
IOobjectList(meshProxy.baseMesh(), runTime.timeName());
|
||||
|
||||
// Prune restart fields
|
||||
objects.prune_0();
|
||||
if (fieldSelector && !fieldSelector().empty())
|
||||
{
|
||||
objects.filterObjects(fieldSelector());
|
||||
}
|
||||
|
||||
if (!doPointValues)
|
||||
{
|
||||
// Prune point fields if disabled
|
||||
objects.filterClasses
|
||||
(
|
||||
[](const word& clsName)
|
||||
{
|
||||
return fieldTypes::point.found(clsName);
|
||||
},
|
||||
true // prune
|
||||
);
|
||||
// Remove "*_0" restart fields
|
||||
objects.prune_0();
|
||||
|
||||
if (!doPointValues)
|
||||
{
|
||||
// Prune point fields if disabled
|
||||
objects.filterClasses
|
||||
(
|
||||
[](const word& clsName)
|
||||
{
|
||||
return fieldTypes::point.found(clsName);
|
||||
},
|
||||
true // prune
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (processorFieldsOnly)
|
||||
|
||||
@ -94,19 +94,13 @@ template<class GeoField>
|
||||
Foam::PtrList<const GeoField> Foam::readFields
|
||||
(
|
||||
const typename GeoField::Mesh& mesh,
|
||||
const IOobjectList& objects,
|
||||
const wordRes& selection
|
||||
const IOobjectList& objects
|
||||
)
|
||||
{
|
||||
const bool syncPar = true;
|
||||
|
||||
// Available fields of type GeoField, sorted order
|
||||
const wordList fieldNames =
|
||||
(
|
||||
selection.empty()
|
||||
? objects.sortedNames<GeoField>()
|
||||
: objects.sortedNames<GeoField>(selection)
|
||||
);
|
||||
const wordList fieldNames(objects.sortedNames<GeoField>());
|
||||
|
||||
// Construct the fields
|
||||
PtrList<const GeoField> fields(fieldNames.size());
|
||||
@ -133,19 +127,13 @@ template<class GeoField>
|
||||
Foam::PtrList<const GeoField> Foam::readFields
|
||||
(
|
||||
const fvMeshSubsetProxy& proxy,
|
||||
const IOobjectList& objects,
|
||||
const wordRes& selection
|
||||
const IOobjectList& objects
|
||||
)
|
||||
{
|
||||
const bool syncPar = true;
|
||||
|
||||
// Available fields of type GeoField, sorted order
|
||||
const wordList fieldNames =
|
||||
(
|
||||
selection.empty()
|
||||
? objects.sortedNames<GeoField>()
|
||||
: objects.sortedNames<GeoField>(selection)
|
||||
);
|
||||
const wordList fieldNames(objects.sortedNames<GeoField>());
|
||||
|
||||
// Construct the fields
|
||||
PtrList<const GeoField> fields(fieldNames.size());
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -35,8 +35,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef readFields_H
|
||||
#define readFields_H
|
||||
#ifndef Foam_readFields_H
|
||||
#define Foam_readFields_H
|
||||
|
||||
#include "fvMeshSubsetProxy.H"
|
||||
#include "IOobjectList.H"
|
||||
@ -94,8 +94,7 @@ template<class GeoField>
|
||||
PtrList<const GeoField> readFields
|
||||
(
|
||||
const typename GeoField::Mesh& mesh,
|
||||
const IOobjectList& objects,
|
||||
const wordRes& selection
|
||||
const IOobjectList& objects
|
||||
);
|
||||
|
||||
|
||||
@ -104,8 +103,7 @@ template<class GeoField>
|
||||
PtrList<const GeoField> readFields
|
||||
(
|
||||
const fvMeshSubsetProxy& proxy,
|
||||
const IOobjectList& objects,
|
||||
const wordRes& selection
|
||||
const IOobjectList& objects
|
||||
);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user