subsetMesh: Added -noFields option

With the -noFields option the mesh is subset but the fields are not changed.
This is useful when the field fields have been created to correspond to the mesh
after the mesh subset.
This commit is contained in:
Henry Weller
2018-07-31 18:14:47 +01:00
parent 8662f99ac1
commit d57d36b30e
6 changed files with 324 additions and 291 deletions

View File

@ -208,6 +208,12 @@ int main(int argc, char *argv[])
"time", "time",
"specify a time for the resulting mesh" "specify a time for the resulting mesh"
); );
argList::addBoolOption
(
"noFields",
"do not update fields"
);
#include "setRootCase.H" #include "setRootCase.H"
#include "createTime.H" #include "createTime.H"
runTime.functionObjects().off(); runTime.functionObjects().off();
@ -234,6 +240,7 @@ int main(int argc, char *argv[])
// Set both mesh and field to this time // Set both mesh and field to this time
meshInstance = fieldsInstance; meshInstance = fieldsInstance;
} }
const bool fields = !args.optionFound("noFields");
Info<< "Reading cell set from " << setName << endl << endl; Info<< "Reading cell set from " << setName << endl << endl;
@ -268,11 +275,12 @@ int main(int argc, char *argv[])
cellSet currentSet(mesh, setName); cellSet currentSet(mesh, setName);
subsetter.setLargeCellSubset(currentSet, patchi, true); subsetter.setLargeCellSubset(currentSet, patchi, true);
IOobjectList objects(mesh, runTime.timeName());
if (fields)
{
IOobjectList objects(mesh, runTime.timeName());
// Read vol fields and subset // Read vol fields and subset
// ~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -409,7 +417,10 @@ int main(int argc, char *argv[])
subsetDimensionedFields(subsetter, vectorDimNames, vectorDimFlds); subsetDimensionedFields(subsetter, vectorDimNames, vectorDimFlds);
typedef volSphericalTensorField::Internal dimSphereType; typedef volSphericalTensorField::Internal dimSphereType;
wordList sphericalTensorDimNames(objects.names(dimSphereType::typeName)); wordList sphericalTensorDimNames
(
objects.names(dimSphereType::typeName)
);
PtrList<dimSphereType> sphericalTensorDimFlds PtrList<dimSphereType> sphericalTensorDimFlds
( (
sphericalTensorDimNames.size() sphericalTensorDimNames.size()
@ -424,7 +435,12 @@ int main(int argc, char *argv[])
typedef volSymmTensorField::Internal dimSymmTensorType; typedef volSymmTensorField::Internal dimSymmTensorType;
wordList symmTensorDimNames(objects.names(dimSymmTensorType::typeName)); wordList symmTensorDimNames(objects.names(dimSymmTensorType::typeName));
PtrList<dimSymmTensorType> symmTensorDimFlds(symmTensorDimNames.size()); PtrList<dimSymmTensorType> symmTensorDimFlds(symmTensorDimNames.size());
subsetDimensionedFields(subsetter, symmTensorDimNames, symmTensorDimFlds); subsetDimensionedFields
(
subsetter,
symmTensorDimNames,
symmTensorDimFlds
);
typedef volTensorField::Internal dimTensorType; typedef volTensorField::Internal dimTensorType;
wordList tensorDimNames(objects.names(dimTensorType::typeName)); wordList tensorDimNames(objects.names(dimTensorType::typeName));
@ -445,10 +461,10 @@ int main(int argc, char *argv[])
runTime++; runTime++;
} }
Info<< "Writing subsetted mesh and fields to time " << runTime.timeName() Info<< "Writing subsetted mesh and fields to time "
<< endl; << runTime.timeName() << endl;
subsetter.subMesh().write();
subsetter.subMesh().write();
// Subsetting adds 'subset' prefix. Rename field to be like original. // Subsetting adds 'subset' prefix. Rename field to be like original.
forAll(scalarFlds, i) forAll(scalarFlds, i)
@ -557,7 +573,27 @@ int main(int argc, char *argv[])
tensorDimFlds[i].rename(tensorDimNames[i]); tensorDimFlds[i].rename(tensorDimNames[i]);
tensorDimFlds[i].write(); tensorDimFlds[i].write();
} }
}
else
{
// Write mesh to new time
// ~~~~~~~~~~~~~~~~~~~~~~
if (overwrite || specifiedInstance)
{
runTime.setTime(instant(fieldsInstance), 0);
subsetter.subMesh().setInstance(meshInstance);
}
else
{
runTime++;
}
Info<< "Writing subsetted mesh to time "
<< runTime.timeName() << endl;
subsetter.subMesh().write();
}
Info<< "End\n" << endl; Info<< "End\n" << endl;

View File

@ -6,16 +6,16 @@ cd ${0%/*} || exit 1 # Run from this directory
rm -rf 0 rm -rf 0
# create the underlying block mesh # Create the underlying block mesh
runApplication blockMesh runApplication blockMesh
# create the set for the obstacles # Create the set for the obstacles
runApplication topoSet runApplication topoSet
# create the obstacles - add obstacle patches to wallFilm patch # Create the obstacles - add obstacle patches to wallFilm patch
runApplication subsetMesh c0 -patch wallFilm -overwrite runApplication subsetMesh c0 -patch wallFilm -overwrite -noFields
# split the obstacle patches into cube[1-6]_patch[1-6] # Split the obstacle patches into cube[1-6]_patch[1-6]
runApplication ./patchifyObstacles runApplication ./patchifyObstacles
# Create the wall film region via extrusion # Create the wall film region via extrusion
@ -25,9 +25,6 @@ runApplication extrudeToRegionMesh -overwrite
rm -rf system/wallFilmRegion rm -rf system/wallFilmRegion
cp -r system/wallFilmRegion.orig system/wallFilmRegion cp -r system/wallFilmRegion.orig system/wallFilmRegion
find ./0 -maxdepth 1 -type f -exec \
sed -i -e "s/wallFilm/\"(region0_to.*)\"/g" {} \;
paraFoam -touch paraFoam -touch
paraFoam -touch -region wallFilmRegion paraFoam -touch -region wallFilmRegion

View File

@ -9,7 +9,7 @@ application=$(getApplication)
runApplication blockMesh runApplication blockMesh
runApplication topoSet runApplication topoSet
runApplication subsetMesh -overwrite c0 -patch floatingObject runApplication subsetMesh -overwrite c0 -patch floatingObject -noFields
runApplication setFields runApplication setFields
runApplication $application runApplication $application

View File

@ -6,7 +6,7 @@ cd ${0%/*} || exit 1 # Run from this directory
runApplication blockMesh runApplication blockMesh
runApplication topoSet runApplication topoSet
runApplication subsetMesh -overwrite c0 -patch walls runApplication subsetMesh -overwrite c0 -patch walls -noFields
runApplication setFields runApplication setFields
runApplication $(getApplication) runApplication $(getApplication)

View File

@ -11,7 +11,7 @@ runApplication blockMesh
runApplication -s 1 topoSet runApplication -s 1 topoSet
runApplication subsetMesh -overwrite c0 -patch floatingObject runApplication subsetMesh -overwrite c0 -patch floatingObject -noFields
runApplication -s selectBottom \ runApplication -s selectBottom \
topoSet -dict system/topoSetDict-selectBottom topoSet -dict system/topoSetDict-selectBottom

View File

@ -9,7 +9,7 @@ application=$(getApplication)
runApplication blockMesh runApplication blockMesh
runApplication topoSet runApplication topoSet
runApplication subsetMesh -overwrite c0 -patch floatingObject runApplication subsetMesh -overwrite c0 -patch floatingObject -noFields
runApplication $application runApplication $application