From 0bd12e060167a86ea3f1b0aa322873f43d347631 Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 13 May 2008 16:33:29 +0100 Subject: [PATCH 1/6] added sourceTime option to mapFields --- .../preProcessing/mapFields/mapFields.C | 55 +++++++++++++++---- .../preProcessing/mapFields/setRoots.H | 1 + 2 files changed, 46 insertions(+), 10 deletions(-) diff --git a/applications/utilities/preProcessing/mapFields/mapFields.C b/applications/utilities/preProcessing/mapFields/mapFields.C index f234a89d08..59563aa17b 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& 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 Date: Tue, 13 May 2008 16:33:58 +0100 Subject: [PATCH 2/6] added sourceTime option to mapFields (2) --- .../preProcessing/mapFields/setTimeIndex.H | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 applications/utilities/preProcessing/mapFields/setTimeIndex.H diff --git a/applications/utilities/preProcessing/mapFields/setTimeIndex.H b/applications/utilities/preProcessing/mapFields/setTimeIndex.H new file mode 100644 index 0000000000..3a36340aaf --- /dev/null +++ b/applications/utilities/preProcessing/mapFields/setTimeIndex.H @@ -0,0 +1,15 @@ + label sourceTimeIndex = 0; + 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); + } + } From 43a7de786200b025da6accf2c0bd5ed4573aae59 Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 14 May 2008 09:47:01 +0100 Subject: [PATCH 3/6] restoring default behaviour of mapFields re: time --- applications/utilities/preProcessing/mapFields/setTimeIndex.H | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/utilities/preProcessing/mapFields/setTimeIndex.H b/applications/utilities/preProcessing/mapFields/setTimeIndex.H index 3a36340aaf..20e5cde3b1 100644 --- a/applications/utilities/preProcessing/mapFields/setTimeIndex.H +++ b/applications/utilities/preProcessing/mapFields/setTimeIndex.H @@ -1,4 +1,4 @@ - label sourceTimeIndex = 0; + label sourceTimeIndex = runTimeSource.timeIndex(); instantList sourceTimes = runTimeSource.times(); if (args.options().found("sourceTime")) { From 238b126c6cd87a3bedef0608120c44e04493878a Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 14 May 2008 09:47:51 +0100 Subject: [PATCH 4/6] added small description line to solvers --- .../solvers/multiphase/lesCavitatingFoam/lesCavitatingFoam.C | 3 ++- .../solvers/multiphase/rasCavitatingFoam/rasCavitatingFoam.C | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/applications/solvers/multiphase/lesCavitatingFoam/lesCavitatingFoam.C b/applications/solvers/multiphase/lesCavitatingFoam/lesCavitatingFoam.C index b66186d43c..31f5b90e13 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 9ed182be37..bcc0b5441c 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. \*---------------------------------------------------------------------------*/ From aac95d1038b436cca10abf464ab59d0a5849ad58 Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 14 May 2008 12:42:26 +0100 Subject: [PATCH 5/6] Handling starting from 0 or 1 on indexing --- .../conversion/tetgenToFoam/tetgenToFoam.C | 169 ++++++++---------- 1 file changed, 70 insertions(+), 99 deletions(-) diff --git a/applications/utilities/mesh/conversion/tetgenToFoam/tetgenToFoam.C b/applications/utilities/mesh/conversion/tetgenToFoam/tetgenToFoam.C index 6ce391ad03..9155c5f563 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 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) + if (!readFaceFile) { - Info<< "Reading .file for boundary information" << nl << endl; - } - if (startAt1) - { - 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