Merge branch 'master' of /home/noisy2/OpenFOAM/OpenFOAM-dev/
This commit is contained in:
commit
fc3978e4c8
@ -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.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
|
@ -26,6 +26,7 @@ Application
|
||||
rasCavitatingFoam
|
||||
|
||||
Description
|
||||
Transient cavitation code with RAS turbulence.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
|
@ -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)
|
||||
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<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;
|
||||
|
||||
nodeLine >> nodeI >> x >> y >> z;
|
||||
|
||||
for (label i = 0; i < nNodeAttr; i++)
|
||||
if ((line.size() > 0) && (line[0] != '#'))
|
||||
{
|
||||
nodeLine >> dummy;
|
||||
}
|
||||
IStringStream nodeLine(line);
|
||||
|
||||
if (hasRegion)
|
||||
{
|
||||
nodeLine >> dummy;
|
||||
}
|
||||
label nodeI;
|
||||
scalar x, y, z;
|
||||
label 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);
|
||||
}
|
||||
nodeLine >> nodeI >> x >> y >> z;
|
||||
|
||||
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
|
||||
//
|
||||
|
||||
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++;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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", "");
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user