Merge branch 'master' of /home/noisy2/OpenFOAM/OpenFOAM-dev/

This commit is contained in:
henry
2008-05-15 15:42:35 +01:00
7 changed files with 136 additions and 112 deletions

View File

@ -23,9 +23,10 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Application Application
rasCavitatingFoam lesCavitatingFoam
Description Description
Transient cavitation code with LES turbulence.
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/

View File

@ -26,6 +26,7 @@ Application
rasCavitatingFoam rasCavitatingFoam
Description Description
Transient cavitation code with RAS turbulence.
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/

View File

@ -56,18 +56,14 @@ NOTE:
always. Might use some geometric check instead. always. Might use some geometric check instead.
- marked faces might not actually be boundary faces of mesh. This is not handled - 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) 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 "argList.H"
#include "Time.H" #include "Time.H"
#include "polyMesh.H" #include "polyMesh.H"
#include "IFstream.H" #include "IFstream.H"
#include "polyPatch.H"
#include "cellModeller.H" #include "cellModeller.H"
#include "ListOps.H"
#include <fstream>
using namespace Foam; using namespace Foam;
@ -79,7 +75,6 @@ int main(int argc, char *argv[])
{ {
argList::validArgs.append("file prefix"); argList::validArgs.append("file prefix");
argList::validOptions.insert("noFaceFile", ""); argList::validOptions.insert("noFaceFile", "");
argList::validOptions.insert("startAt0", "");
# include "setRootCase.H" # include "setRootCase.H"
# include "createTime.H" # include "createTime.H"
@ -87,34 +82,29 @@ int main(int argc, char *argv[])
bool readFaceFile = !args.options().found("noFaceFile"); bool readFaceFile = !args.options().found("noFaceFile");
bool startAt1 = !args.options().found("startAt0");
fileName prefix(args.additionalArgs()[0]); fileName prefix(args.additionalArgs()[0]);
fileName nodeFile(prefix + ".node"); fileName nodeFile(prefix + ".node");
fileName eleFile(prefix + ".ele"); fileName eleFile(prefix + ".ele");
fileName faceFile(prefix + ".face"); fileName faceFile(prefix + ".face");
Info<< "Files:" << endl if (!readFaceFile)
<< " nodes : " << nodeFile << endl
<< " elems : " << eleFile << endl
<< " faces : " << faceFile << endl
<< endl;
if (readFaceFile)
{ {
Info<< "Reading .file for boundary information" << nl << endl; Info<< "Files:" << endl
} << " nodes : " << nodeFile << endl
if (startAt1) << " elems : " << eleFile << endl
{ << endl;
Info<< "Numbering in files starts at 1" << nl << endl;
} }
else 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)) 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. // Read nodes.
@ -145,7 +135,7 @@ int main(int argc, char *argv[])
do do
{ {
std::getline(nodeStream, line); nodeStream.getLine(line);
} }
while((line.size() > 0) && (line[0] == '#')); while((line.size() > 0) && (line[0] == '#'));
@ -169,61 +159,60 @@ int main(int argc, char *argv[])
// //
pointField points(nNodes); 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; if ((line.size() > 0) && (line[0] != '#'))
scalar x, y, z;
label dummy;
nodeLine >> nodeI >> x >> y >> z;
for (label i = 0; i < nNodeAttr; i++)
{ {
nodeLine >> dummy; IStringStream nodeLine(line);
}
if (hasRegion) label nodeI;
{ scalar x, y, z;
nodeLine >> dummy; label dummy;
}
// Store point and node number. nodeLine >> nodeI >> x >> y >> z;
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);
}
points[pointI++] = point(x, y, z); for (label i = 0; i < nNodeAttr; i++)
{
nodeLine >> dummy;
}
if (hasRegion)
{
nodeLine >> dummy;
}
// 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 // read elements
// //
std::ifstream eleStream(eleFile.c_str()); IFstream eleStream(eleFile);
do do
{ {
std::getline(eleStream, line); eleStream.getLine(line);
} }
while((line.size() > 0) && (line[0] == '#')); while((line.size() > 0) && (line[0] == '#'));
@ -242,10 +231,11 @@ int main(int argc, char *argv[])
if (nPtsPerTet != 4) 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 << nPtsPerTet << " points per tetrahedron in .ele file" << endl
<< "Can only handle tetrahedra with four points" << "Can only handle tetrahedra with four points"
<< exit(FatalError); << exit(FatalIOError);
} }
if (nElemAttr != 0) if (nElemAttr != 0)
@ -262,39 +252,27 @@ int main(int argc, char *argv[])
labelList tetPoints(4); labelList tetPoints(4);
cellShapeList cells(nTets); cellShapeList cells(nTets);
label cellI = 0;
while (eleStream.good()) while (eleStream.good())
{ {
std::getline(eleStream, line); eleStream.getLine(line);
if ((line.size() > 0) && (line[0] != '#')) if ((line.size() > 0) && (line[0] != '#'))
{ {
IStringStream eleLine(line); IStringStream eleLine(line);
label elemI; label elemI;
eleLine >> elemI; eleLine >> elemI;
if (startAt1)
{
--elemI;
}
for (label i = 0; i < 4; i++) for (label i = 0; i < 4; i++)
{ {
label nodeI; label nodeI;
eleLine >> nodeI; eleLine >> nodeI;
tetPoints[i] = nodeToPoint[nodeI];
if (startAt1)
{
--nodeI;
}
tetPoints[i] = nodeI;
} }
cells[elemI] = cellShape(tet, tetPoints); cells[cellI++] = cellShape(tet, tetPoints);
// Skip attributes // Skip attributes
for (label i = 0; i < nElemAttr; i++) for (label i = 0; i < nElemAttr; i++)
@ -321,11 +299,11 @@ int main(int argc, char *argv[])
// read boundary faces // read boundary faces
// //
std::ifstream faceStream(faceFile.c_str()); IFstream faceStream(faceFile);
do do
{ {
std::getline(faceStream, line); faceStream.getLine(line);
} }
while((line.size() > 0) && (line[0] == '#')); while((line.size() > 0) && (line[0] == '#'));
@ -344,10 +322,11 @@ int main(int argc, char *argv[])
if (nFaceAttr != 1) 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 << " present in .face file." << endl
<< "This is the second number in the header which is now:" << "This is the second number in the header which is now:"
<< nFaceAttr << exit(FatalError); << nFaceAttr << exit(FatalIOError);
} }
// List of Foam vertices per boundary face // List of Foam vertices per boundary face
@ -357,6 +336,8 @@ int main(int argc, char *argv[])
boundaryPatch.setSize(nFaces); boundaryPatch.setSize(nFaces);
boundaryPatch = -1; boundaryPatch = -1;
label faceI = 0;
// Region to patch conversion // Region to patch conversion
Map<label> regionToPatch; Map<label> regionToPatch;
@ -364,35 +345,23 @@ int main(int argc, char *argv[])
while (faceStream.good()) while (faceStream.good())
{ {
std::getline(faceStream, line); faceStream.getLine(line);
if ((line.size() > 0) && (line[0] != '#')) if ((line.size() > 0) && (line[0] != '#'))
{ {
IStringStream faceLine(line); IStringStream faceLine(line);
label faceI, dummy, region; label tetGenFaceI, dummy, region;
faceLine >> faceI; faceLine >> tetGenFaceI;
if (startAt1)
{
--faceI;
}
// Read face and reverse orientation (Foam needs outwards // Read face and reverse orientation (Foam needs outwards
// pointing) // pointing)
for (label i = 0; i < 3; i++) for (label i = 0; i < 3; i++)
{ {
label nodeI; label nodeI;
faceLine >> nodeI; faceLine >> nodeI;
f[2-i] = nodeToPoint[nodeI];
if (startAt1)
{
--nodeI;
}
f[2-i] = nodeI;
} }
boundaryFaces[faceI] = f; boundaryFaces[faceI] = f;
@ -431,6 +400,8 @@ int main(int argc, char *argv[])
faceLine >> dummy; faceLine >> dummy;
} }
} }
faceI++;
} }
} }

View File

@ -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 void mapConsistentMesh
( (
const fvMesh& meshSource, const fvMesh& meshSource,
@ -97,7 +122,7 @@ void mapConsistentMesh
void mapSubMesh void mapSubMesh
( (
const fvMesh& meshSource, const fvMesh& meshSource,
const fvMesh& meshTarget, const fvMesh& meshTarget,
const HashTable<word>& patchMap, const HashTable<word>& patchMap,
const wordList& cuttingPatches const wordList& cuttingPatches
) )
@ -203,7 +228,7 @@ wordList addProcessorPatches
{ {
if (typeid(meshTarget.boundary()[patchi]) == typeid(processorFvPatch)) if (typeid(meshTarget.boundary()[patchi]) == typeid(processorFvPatch))
{ {
if if
( (
!cuttingPatchTable.found !cuttingPatchTable.found
( (
@ -219,7 +244,7 @@ wordList addProcessorPatches
} }
} }
} }
return cuttingPatchTable.toc(); return cuttingPatchTable.toc();
} }
@ -232,7 +257,9 @@ int main(int argc, char *argv[])
# include "createTimes.H" # include "createTimes.H"
runTimeSource.setTime(runTimeTarget); # include "setTimeIndex.H"
runTimeSource.setTime(sourceTimes[sourceTimeIndex], sourceTimeIndex);
Info<< "\nSource time: " << runTimeSource.value() Info<< "\nSource time: " << runTimeSource.value()
<< "\nTarget time: " << runTimeTarget.value() << "\nTarget time: " << runTimeTarget.value()
@ -255,9 +282,9 @@ int main(int argc, char *argv[])
false false
) )
); );
mapFieldsDict.lookup("patchMap") >> patchMap; mapFieldsDict.lookup("patchMap") >> patchMap;
mapFieldsDict.lookup("cuttingPatches") >> cuttingPatches; mapFieldsDict.lookup("cuttingPatches") >> cuttingPatches;
} }
@ -302,7 +329,11 @@ int main(int argc, char *argv[])
caseDirSource/fileName(word("processor") + name(procI)) caseDirSource/fileName(word("processor") + name(procI))
); );
runTimeSource.setTime(runTimeTarget); runTimeSource.setTime
(
sourceTimes[sourceTimeIndex],
sourceTimeIndex
);
fvMesh meshSource fvMesh meshSource
( (
@ -446,7 +477,11 @@ int main(int argc, char *argv[])
caseDirSource/fileName(word("processor") + name(procISource)) caseDirSource/fileName(word("processor") + name(procISource))
); );
runTimeSource.setTime(runTimeTarget); runTimeSource.setTime
(
sourceTimes[sourceTimeIndex],
sourceTimeIndex
);
fvMesh meshSource fvMesh meshSource
( (
@ -464,7 +499,7 @@ int main(int argc, char *argv[])
for (int procITarget=0; procITarget<nProcsTarget; procITarget++) for (int procITarget=0; procITarget<nProcsTarget; procITarget++)
{ {
if if
( (
!bbsTargetSet[procITarget] !bbsTargetSet[procITarget]
|| ( || (
@ -542,7 +577,7 @@ int main(int argc, char *argv[])
runTimeTarget runTimeTarget
) )
); );
Info<< "Source mesh size: " << meshSource.nCells() << tab Info<< "Source mesh size: " << meshSource.nCells() << tab
<< "Target mesh size: " << meshTarget.nCells() << nl << endl; << "Target mesh size: " << meshTarget.nCells() << nl << endl;

View File

@ -1,6 +1,7 @@
argList::validArgs.clear(); argList::validArgs.clear();
argList::validOptions.insert("source", "dir"); argList::validOptions.insert("source", "dir");
argList::validOptions.insert("sourceTime", "scalar");
argList::validOptions.erase(argList::validOptions.find("parallel")); argList::validOptions.erase(argList::validOptions.find("parallel"));
argList::validOptions.insert("parallelSource", ""); argList::validOptions.insert("parallelSource", "");

View File

@ -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);
}
}

View File

@ -57,11 +57,11 @@ edges
patches patches
( (
patch top wall top
( (
(13 15 14 12) (13 15 14 12)
) )
patch bottom wall bottom
( (
(0 1 5 4) (0 1 5 4)
(1 8 10 5) (1 8 10 5)