diff --git a/applications/solvers/multiphase/lesCavitatingFoam/lesCavitatingFoam.C b/applications/solvers/multiphase/lesCavitatingFoam/lesCavitatingFoam.C index b66186d43c769a0fa7c7c2fef640603262507c29..31f5b90e137491d94ef3cf65759405a8f964fa39 100644 --- a/applications/solvers/multiphase/lesCavitatingFoam/lesCavitatingFoam.C +++ b/applications/solvers/multiphase/lesCavitatingFoam/lesCavitatingFoam.C @@ -23,9 +23,10 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Application - rasCavitatingFoam + lesCavitatingFoam Description + Transient cavitation code with LES turbulence. \*---------------------------------------------------------------------------*/ diff --git a/applications/solvers/multiphase/rasCavitatingFoam/rasCavitatingFoam.C b/applications/solvers/multiphase/rasCavitatingFoam/rasCavitatingFoam.C index 9ed182be3705b187bd827b771f1fa98ab03d97b2..bcc0b5441cac5bec2d3ae1fe00a14af37a19d45e 100644 --- a/applications/solvers/multiphase/rasCavitatingFoam/rasCavitatingFoam.C +++ b/applications/solvers/multiphase/rasCavitatingFoam/rasCavitatingFoam.C @@ -26,6 +26,7 @@ Application rasCavitatingFoam Description + Transient cavitation code with RAS turbulence. \*---------------------------------------------------------------------------*/ diff --git a/applications/utilities/mesh/conversion/tetgenToFoam/tetgenToFoam.C b/applications/utilities/mesh/conversion/tetgenToFoam/tetgenToFoam.C index 6ce391ad03420c28e11cae56138bed519b8449ac..9155c5f563982e580c33196a8902721c09a3255f 100644 --- a/applications/utilities/mesh/conversion/tetgenToFoam/tetgenToFoam.C +++ b/applications/utilities/mesh/conversion/tetgenToFoam/tetgenToFoam.C @@ -56,18 +56,14 @@ NOTE: always. Might use some geometric check instead. - marked faces might not actually be boundary faces of mesh. This is not handled and you'll have to run without face file (-noFaceFile option) -- default is to have indices starting at 1. Use -startAt0 if starting at 0. -- all input is expected to be ordered. + \*---------------------------------------------------------------------------*/ #include "argList.H" #include "Time.H" #include "polyMesh.H" #include "IFstream.H" -#include "polyPatch.H" #include "cellModeller.H" -#include "ListOps.H" -#include <fstream> using namespace Foam; @@ -79,7 +75,6 @@ int main(int argc, char *argv[]) { argList::validArgs.append("file prefix"); argList::validOptions.insert("noFaceFile", ""); - argList::validOptions.insert("startAt0", ""); # include "setRootCase.H" # include "createTime.H" @@ -87,34 +82,29 @@ int main(int argc, char *argv[]) bool readFaceFile = !args.options().found("noFaceFile"); - bool startAt1 = !args.options().found("startAt0"); - fileName prefix(args.additionalArgs()[0]); fileName nodeFile(prefix + ".node"); fileName eleFile(prefix + ".ele"); fileName faceFile(prefix + ".face"); - Info<< "Files:" << endl - << " nodes : " << nodeFile << endl - << " elems : " << eleFile << endl - << " faces : " << faceFile << endl - << endl; - - - if (readFaceFile) - { - Info<< "Reading .file for boundary information" << nl << endl; - } - if (startAt1) + if (!readFaceFile) { - Info<< "Numbering in files starts at 1" << nl << endl; + Info<< "Files:" << endl + << " nodes : " << nodeFile << endl + << " elems : " << eleFile << endl + << endl; } else { - Info<< "Numbering in files starts at 0" << nl << endl; - } + Info<< "Files:" << endl + << " nodes : " << nodeFile << endl + << " elems : " << eleFile << endl + << " faces : " << faceFile << endl + << endl; + Info<< "Reading .face file for boundary information" << nl << endl; + } if (!exists(nodeFile) || !exists(eleFile)) { @@ -134,7 +124,7 @@ int main(int argc, char *argv[]) } - std::ifstream nodeStream(nodeFile.c_str()); + IFstream nodeStream(nodeFile); // // Read nodes. @@ -145,7 +135,7 @@ int main(int argc, char *argv[]) do { - std::getline(nodeStream, line); + nodeStream.getLine(line); } while((line.size() > 0) && (line[0] == '#')); @@ -169,61 +159,60 @@ int main(int argc, char *argv[]) // pointField points(nNodes); + Map<label> nodeToPoint(nNodes); - label pointI = 0; - - while (nodeStream.good()) { - std::getline(nodeStream, line); + labelList pointIndex(nNodes); - if ((line.size() > 0) && (line[0] != '#')) + label pointI = 0; + + while (nodeStream.good()) { - IStringStream nodeLine(line); + nodeStream.getLine(line); - label nodeI; - scalar x, y, z; - label dummy; + if ((line.size() > 0) && (line[0] != '#')) + { + IStringStream nodeLine(line); - nodeLine >> nodeI >> x >> y >> z; + label nodeI; + scalar x, y, z; + label dummy; - for (label i = 0; i < nNodeAttr; i++) - { - nodeLine >> dummy; - } + nodeLine >> nodeI >> x >> y >> z; - if (hasRegion) - { - nodeLine >> dummy; - } + for (label i = 0; i < nNodeAttr; i++) + { + nodeLine >> dummy; + } - // Store point and node number. - if - ( - (!startAt1 && nodeI != pointI) - || (startAt1 && nodeI-1 != pointI) - ) - { - FatalErrorIn(args.executable()) - << "point numbering not consecutive for node " << nodeI - << " or numbering starts" - << " at 0 or 1. Perhaps rerun w/o -startAt0 option?" - << exit(FatalError); - } + if (hasRegion) + { + nodeLine >> dummy; + } - points[pointI++] = point(x, y, z); + // Store point and node number. + points[pointI] = point(x, y, z); + nodeToPoint.insert(nodeI, pointI); + pointI++; + } + } + if (pointI != nNodes) + { + FatalIOErrorIn(args.executable().c_str(), nodeStream) + << "Only " << pointI << " nodes present instead of " << nNodes + << " from header." << exit(FatalIOError); } } - // // read elements // - std::ifstream eleStream(eleFile.c_str()); + IFstream eleStream(eleFile); do { - std::getline(eleStream, line); + eleStream.getLine(line); } while((line.size() > 0) && (line[0] == '#')); @@ -242,10 +231,11 @@ int main(int argc, char *argv[]) if (nPtsPerTet != 4) { - FatalErrorIn(args.executable()) << "Cannot handle tets with " + FatalIOErrorIn(args.executable().c_str(), eleStream) + << "Cannot handle tets with " << nPtsPerTet << " points per tetrahedron in .ele file" << endl << "Can only handle tetrahedra with four points" - << exit(FatalError); + << exit(FatalIOError); } if (nElemAttr != 0) @@ -262,39 +252,27 @@ int main(int argc, char *argv[]) labelList tetPoints(4); cellShapeList cells(nTets); + label cellI = 0; while (eleStream.good()) { - std::getline(eleStream, line); + eleStream.getLine(line); if ((line.size() > 0) && (line[0] != '#')) { IStringStream eleLine(line); label elemI; - eleLine >> elemI; - if (startAt1) - { - --elemI; - } - for (label i = 0; i < 4; i++) { label nodeI; - eleLine >> nodeI; - - if (startAt1) - { - --nodeI; - } - - tetPoints[i] = nodeI; + tetPoints[i] = nodeToPoint[nodeI]; } - cells[elemI] = cellShape(tet, tetPoints); + cells[cellI++] = cellShape(tet, tetPoints); // Skip attributes for (label i = 0; i < nElemAttr; i++) @@ -321,11 +299,11 @@ int main(int argc, char *argv[]) // read boundary faces // - std::ifstream faceStream(faceFile.c_str()); + IFstream faceStream(faceFile); do { - std::getline(faceStream, line); + faceStream.getLine(line); } while((line.size() > 0) && (line[0] == '#')); @@ -344,10 +322,11 @@ int main(int argc, char *argv[]) if (nFaceAttr != 1) { - FatalErrorIn(args.executable()) << "Expect boundary markers to be" + FatalIOErrorIn(args.executable().c_str(), faceStream) + << "Expect boundary markers to be" << " present in .face file." << endl << "This is the second number in the header which is now:" - << nFaceAttr << exit(FatalError); + << nFaceAttr << exit(FatalIOError); } // List of Foam vertices per boundary face @@ -357,6 +336,8 @@ int main(int argc, char *argv[]) boundaryPatch.setSize(nFaces); boundaryPatch = -1; + label faceI = 0; + // Region to patch conversion Map<label> regionToPatch; @@ -364,35 +345,23 @@ int main(int argc, char *argv[]) while (faceStream.good()) { - std::getline(faceStream, line); + faceStream.getLine(line); if ((line.size() > 0) && (line[0] != '#')) { IStringStream faceLine(line); - label faceI, dummy, region; + label tetGenFaceI, dummy, region; - faceLine >> faceI; - - if (startAt1) - { - --faceI; - } + faceLine >> tetGenFaceI; // Read face and reverse orientation (Foam needs outwards // pointing) for (label i = 0; i < 3; i++) { label nodeI; - faceLine >> nodeI; - - if (startAt1) - { - --nodeI; - } - - f[2-i] = nodeI; + f[2-i] = nodeToPoint[nodeI]; } boundaryFaces[faceI] = f; @@ -431,6 +400,8 @@ int main(int argc, char *argv[]) faceLine >> dummy; } } + + faceI++; } } diff --git a/applications/utilities/preProcessing/mapFields/mapFields.C b/applications/utilities/preProcessing/mapFields/mapFields.C index f234a89d08cd0ab4bad016769022289bc45811d9..59563aa17bf39a228b86e72845d7be0385f798e0 100644 --- a/applications/utilities/preProcessing/mapFields/mapFields.C +++ b/applications/utilities/preProcessing/mapFields/mapFields.C @@ -43,6 +43,31 @@ Description // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +int getTimeIndex +( + const instantList& times, + const scalar t +) +{ + int nearestIndex = -1; + scalar nearestDiff = Foam::GREAT; + + forAll(times, timeIndex) + { + if (times[timeIndex].name() == "constant") continue; + + scalar diff = fabs(times[timeIndex].value() - t); + if (diff < nearestDiff) + { + nearestDiff = diff; + nearestIndex = timeIndex; + } + } + + return nearestIndex; +} + + void mapConsistentMesh ( const fvMesh& meshSource, @@ -97,7 +122,7 @@ void mapConsistentMesh void mapSubMesh ( const fvMesh& meshSource, - const fvMesh& meshTarget, + const fvMesh& meshTarget, const HashTable<word>& patchMap, const wordList& cuttingPatches ) @@ -203,7 +228,7 @@ wordList addProcessorPatches { if (typeid(meshTarget.boundary()[patchi]) == typeid(processorFvPatch)) { - if + if ( !cuttingPatchTable.found ( @@ -219,7 +244,7 @@ wordList addProcessorPatches } } } - + return cuttingPatchTable.toc(); } @@ -232,7 +257,9 @@ int main(int argc, char *argv[]) # include "createTimes.H" - runTimeSource.setTime(runTimeTarget); +# include "setTimeIndex.H" + + runTimeSource.setTime(sourceTimes[sourceTimeIndex], sourceTimeIndex); Info<< "\nSource time: " << runTimeSource.value() << "\nTarget time: " << runTimeTarget.value() @@ -255,9 +282,9 @@ int main(int argc, char *argv[]) false ) ); - + mapFieldsDict.lookup("patchMap") >> patchMap; - + mapFieldsDict.lookup("cuttingPatches") >> cuttingPatches; } @@ -302,7 +329,11 @@ int main(int argc, char *argv[]) caseDirSource/fileName(word("processor") + name(procI)) ); - runTimeSource.setTime(runTimeTarget); + runTimeSource.setTime + ( + sourceTimes[sourceTimeIndex], + sourceTimeIndex + ); fvMesh meshSource ( @@ -446,7 +477,11 @@ int main(int argc, char *argv[]) caseDirSource/fileName(word("processor") + name(procISource)) ); - runTimeSource.setTime(runTimeTarget); + runTimeSource.setTime + ( + sourceTimes[sourceTimeIndex], + sourceTimeIndex + ); fvMesh meshSource ( @@ -464,7 +499,7 @@ int main(int argc, char *argv[]) for (int procITarget=0; procITarget<nProcsTarget; procITarget++) { - if + if ( !bbsTargetSet[procITarget] || ( @@ -542,7 +577,7 @@ int main(int argc, char *argv[]) runTimeTarget ) ); - + Info<< "Source mesh size: " << meshSource.nCells() << tab << "Target mesh size: " << meshTarget.nCells() << nl << endl; diff --git a/applications/utilities/preProcessing/mapFields/setRoots.H b/applications/utilities/preProcessing/mapFields/setRoots.H index 0d0f0f064cf1c4a4b5eb181d685851b77413bc7c..dad01fb8179d295bc724f6449833520040a3b2cb 100644 --- a/applications/utilities/preProcessing/mapFields/setRoots.H +++ b/applications/utilities/preProcessing/mapFields/setRoots.H @@ -1,6 +1,7 @@ argList::validArgs.clear(); argList::validOptions.insert("source", "dir"); + argList::validOptions.insert("sourceTime", "scalar"); argList::validOptions.erase(argList::validOptions.find("parallel")); argList::validOptions.insert("parallelSource", ""); diff --git a/applications/utilities/preProcessing/mapFields/setTimeIndex.H b/applications/utilities/preProcessing/mapFields/setTimeIndex.H new file mode 100644 index 0000000000000000000000000000000000000000..20e5cde3b1cf684c40a2f98ec81a24192e92d3d2 --- /dev/null +++ b/applications/utilities/preProcessing/mapFields/setTimeIndex.H @@ -0,0 +1,15 @@ + label sourceTimeIndex = runTimeSource.timeIndex(); + instantList sourceTimes = runTimeSource.times(); + if (args.options().found("sourceTime")) + { + if ((args.options()["sourceTime"]) == "latestTime") + { + sourceTimeIndex = sourceTimes.size() - 1; + } + else + { + scalar sourceTime = + readScalar(IStringStream(args.options()["sourceTime"])()); + sourceTimeIndex = getTimeIndex(sourceTimes, sourceTime); + } + } diff --git a/tutorials/rhoTurbTwinParcelFoam/simplifiedSiwek/constant/polyMesh/blockMeshDict b/tutorials/rhoTurbTwinParcelFoam/simplifiedSiwek/constant/polyMesh/blockMeshDict index 26ea6f0982bf65f1dd8c723e8dfaa507bff37fdf..04869c9a1502e484abc466eab99799b5b367cc7f 100644 --- a/tutorials/rhoTurbTwinParcelFoam/simplifiedSiwek/constant/polyMesh/blockMeshDict +++ b/tutorials/rhoTurbTwinParcelFoam/simplifiedSiwek/constant/polyMesh/blockMeshDict @@ -57,11 +57,11 @@ edges patches ( - patch top + wall top ( (13 15 14 12) ) - patch bottom + wall bottom ( (0 1 5 4) (1 8 10 5)