ENH: add mergeMeshes -resultTime option (as per subsetMesh)

This commit is contained in:
Mark Olesen
2017-10-10 12:46:40 +02:00
parent 00b94c4a40
commit 874452717a
6 changed files with 59 additions and 52 deletions

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -84,6 +84,12 @@ int main(int argc, char *argv[])
"name",
"specify alternative mesh region for the additional mesh"
);
argList::addOption
(
"resultTime",
"time",
"specify a time for the resulting mesh"
);
argList args(argc, argv);
if (!args.check())
@ -94,20 +100,29 @@ int main(int argc, char *argv[])
const bool overwrite = args.optionFound("overwrite");
fileName masterCase = args[1];
word masterRegion = polyMesh::defaultRegion;
args.optionReadIfPresent("masterRegion", masterRegion);
fileName addCase = args[2];
word addRegion = polyMesh::defaultRegion;
args.optionReadIfPresent("addRegion", addRegion);
const word masterRegion =
args.optionLookupOrDefault<word>
(
"masterRegion",
polyMesh::defaultRegion
);
const word addRegion =
args.optionLookupOrDefault<word>
(
"masterRegion",
polyMesh::defaultRegion
);
// Since we don't use argList processor directory detection, add it to
// the casename ourselves so it triggers the logic inside TimePath.
const fileName& cName = args.caseName();
std::string::size_type pos = cName.find("processor");
const auto pos = cName.find("processor");
if (pos != string::npos && pos != 0)
{
fileName processorName = cName.substr(pos, cName.size()-pos);
fileName processorName = cName.substr(pos);
masterCase += '/' + processorName;
addCase += '/' + processorName;
}
@ -133,11 +148,8 @@ int main(int argc, char *argv[])
runTimeMaster
)
);
const word oldInstance = masterMesh.pointsInstance();
Info<< "Reading mesh to add for time = " << runTimeToAdd.timeName() << nl;
Info<< "Create mesh\n" << endl;
polyMesh meshToAdd
(
@ -149,7 +161,19 @@ int main(int argc, char *argv[])
)
);
if (!overwrite)
word meshInstance = masterMesh.pointsInstance();
const bool specifiedInstance =
(
!overwrite
&& args.optionReadIfPresent("resultTime", meshInstance)
);
if (specifiedInstance)
{
runTimeMaster.setTime(instant(meshInstance), 0);
}
else if (!overwrite)
{
runTimeMaster++;
}
@ -159,9 +183,9 @@ int main(int argc, char *argv[])
masterMesh.addMesh(meshToAdd);
masterMesh.merge();
if (overwrite)
if (overwrite || specifiedInstance)
{
masterMesh.setInstance(oldInstance);
masterMesh.setInstance(meshInstance);
}
masterMesh.write();

View File

@ -229,35 +229,23 @@ Foam::mergePolyMesh::mergePolyMesh(const IOobject& io)
if (curPointZoneNames.size())
{
pointZoneNames_.setCapacity(2*curPointZoneNames.size());
}
forAll(curPointZoneNames, zoneI)
{
pointZoneNames_.append(curPointZoneNames[zoneI]);
pointZoneNames_.append(curPointZoneNames);
}
// Face zones
wordList curFaceZoneNames = faceZones().names();
if (curFaceZoneNames.size())
{
faceZoneNames_.setCapacity(2*curFaceZoneNames.size());
}
forAll(curFaceZoneNames, zoneI)
{
faceZoneNames_.append(curFaceZoneNames[zoneI]);
faceZoneNames_.append(curFaceZoneNames);
}
// Cell zones
wordList curCellZoneNames = cellZones().names();
if (curCellZoneNames.size())
{
cellZoneNames_.setCapacity(2*curCellZoneNames.size());
}
forAll(curCellZoneNames, zoneI)
{
cellZoneNames_.append(curCellZoneNames[zoneI]);
cellZoneNames_.append(curCellZoneNames);
}
}

View File

@ -77,10 +77,10 @@ class mergePolyMesh
// Private Member Functions
//- Disallow default bitwise copy construct
mergePolyMesh(const mergePolyMesh&);
mergePolyMesh(const mergePolyMesh&) = delete;
//- Disallow default bitwise assignment
void operator=(const mergePolyMesh&);
void operator=(const mergePolyMesh&) = delete;
//- Return patch index given a name and type

View File

@ -369,9 +369,6 @@ int main(int argc, char *argv[])
#include "createTime.H"
runTime.functionObjects().off();
Foam::word meshRegionName = polyMesh::defaultRegion;
args.optionReadIfPresent("region", meshRegionName);
#include "createNamedMesh.H"
const word setName = args[1];

View File

@ -35,7 +35,7 @@ Usage
Options are:
-translate vector
Translates the points by the given vector,
Translates the points by the given vector before rotations
-rotate (vector vector)
Rotates the points from the first vector to the second,
@ -145,45 +145,44 @@ int main(int argc, char *argv[])
{
argList::addNote
(
"Transform (translate/rotate/scale) mesh points.\n"
"Note: roll=rotation about x, pitch=rotation about y, "
"yaw=rotation about z"
"Transform (translate / rotate / scale) mesh points.\n"
"Note: roll=rotate about x, pitch=rotate about y, yaw=rotate about z"
);
argList::addOption
(
"translate",
"vector",
"translate by the specified <vector> - eg, '(1 0 0)'"
"Translate by specified <vector> - eg, '(1 0 0)' before rotations"
);
argList::addOption
(
"rotate",
"(vectorA vectorB)",
"transform in terms of a rotation between <vectorA> and <vectorB> "
"Transform as a rotation between <vectorA> and <vectorB> "
"- eg, '( (1 0 0) (0 0 1) )'"
);
argList::addOption
(
"rollPitchYaw",
"vector",
"rotate by '(roll pitch yaw)' in degrees"
"Rotate by '(roll pitch yaw)' in degrees"
);
argList::addOption
(
"yawPitchRoll",
"vector",
"rotate by '(yaw pitch roll)' in degrees"
"Rotate by '(yaw pitch roll)' in degrees"
);
argList::addBoolOption
(
"rotateFields",
"read and transform vector and tensor fields too"
"Read and transform vector and tensor fields too"
);
argList::addOption
(
"scale",
"scalar | vector",
"scale by the specified amount - eg, for a uniform [mm] to [m] scaling "
"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'"
);

View File

@ -60,10 +60,9 @@ int main(int argc, char *argv[])
{
argList::addNote
(
"Transform (translate/rotate/scale) a surface. "
"Transform (translate / rotate / scale) surface points.\n"
"Like transformPoints but for surfaces.\n"
"Note: roll=rotation about x, pitch=rotation about y, "
"yaw=rotation about z"
"Note: roll=rotate about x, pitch=rotate about y, yaw=rotate about z"
);
argList::noParallel();
argList::validArgs.append("surfaceFile");
@ -72,33 +71,33 @@ int main(int argc, char *argv[])
(
"translate",
"vector",
"translate by the specified <vector> - eg, '(1 0 0)'"
"Translate by specified <vector> - eg, '(1 0 0)' before rotations"
);
argList::addOption
(
"rotate",
"(vectorA vectorB)",
"transform in terms of a rotation between <vectorA> and <vectorB> "
"Transform as a rotation between <vectorA> and <vectorB> "
"- eg, '( (1 0 0) (0 0 1) )'"
);
argList::addOption
(
"scale",
"scalar | vector",
"scale by the specified amount - eg, for a uniform [mm] to [m] scaling "
"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'"
);
argList::addOption
(
"rollPitchYaw",
"vector",
"rotate by '(roll pitch yaw)' in degrees"
"Rotate by '(roll pitch yaw)' in degrees"
);
argList::addOption
(
"yawPitchRoll",
"vector",
"rotate by '(yaw pitch roll)' in degrees"
"Rotate by '(yaw pitch roll)' in degrees"
);
argList args(argc, argv);