Merge commit 'OpenCFD/master' into olesenm

This commit is contained in:
Mark Olesen
2010-02-03 17:40:37 +01:00
258 changed files with 9316 additions and 2597 deletions

View File

@ -441,6 +441,19 @@ int main(int argc, char *argv[])
// Layer addition parameters
layerParameters layerParams(layerDict, mesh.boundaryMesh());
//!!! Temporary hack to get access to maxLocalCells
bool preBalance;
{
refinementParameters refineParams(refineDict);
preBalance = returnReduce
(
(mesh.nCells() >= refineParams.maxLocalCells()),
orOp<bool>()
);
}
if (!overwrite)
{
const_cast<Time&>(mesh.time())++;
@ -451,6 +464,7 @@ int main(int argc, char *argv[])
layerDict,
motionDict,
layerParams,
preBalance,
decomposer,
distributor
);

View File

@ -10,7 +10,7 @@ FoamFile
version 2.0;
format ascii;
class dictionary;
object autoHexMeshDict;
object snappyHexMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -40,7 +40,7 @@ geometry
{
type triSurfaceMesh;
//tolerance 1E-6; // optional:non-default tolerance on intersections
//tolerance 1E-5; // optional:non-default tolerance on intersections
//maxTreeDepth 10; // optional:depth of octree. Decrease only in case
// of memory limitations.
@ -71,9 +71,9 @@ castellatedMeshControls
// Refinement parameters
// ~~~~~~~~~~~~~~~~~~~~~
// While refining maximum number of cells per processor. This is basically
// the number of cells that fit on a processor. If you choose this too small
// it will do just more refinement iterations to obtain a similar mesh.
// If local number of cells is >= maxLocalCells on any processor
// switches from from refinement followed by balancing
// (current method) to (weighted) balancing before refinement.
maxLocalCells 1000000;
// Overall cell limit (approximately). Refinement will stop immediately
@ -89,6 +89,13 @@ castellatedMeshControls
// (unless the number of cells to refine is 0)
minRefinementCells 0;
// Allow a certain level of imbalance during refining
// (since balancing is quite expensive)
// Expressed as fraction of perfect balance (= overall number of cells /
// nProcs). 0=balance always.
maxLoadUnbalance 0.10;
// Number of buffer layers between different levels.
// 1 means normal 2:1 refinement restriction, larger means slower
// refinement.

View File

@ -47,6 +47,7 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry)
Info<< " <<Writing " << nNonAligned
<< " points on non-aligned edges to set "
<< nonAlignedPoints.name() << endl;
nonAlignedPoints.instance() = mesh.pointsInstance();
nonAlignedPoints.write();
}
}
@ -67,6 +68,7 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry)
{
Info<< " <<Writing " << nNonClosed
<< " non closed cells to set " << cells.name() << endl;
cells.instance() = mesh.pointsInstance();
cells.write();
}
}
@ -78,6 +80,7 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry)
Info<< " <<Writing " << nHighAspect
<< " cells with high aspect ratio to set "
<< aspectCells.name() << endl;
aspectCells.instance() = mesh.pointsInstance();
aspectCells.write();
}
}
@ -94,6 +97,7 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry)
{
Info<< " <<Writing " << nFaces
<< " zero area faces to set " << faces.name() << endl;
faces.instance() = mesh.pointsInstance();
faces.write();
}
}
@ -111,6 +115,7 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry)
{
Info<< " <<Writing " << nCells
<< " zero volume cells to set " << cells.name() << endl;
cells.instance() = mesh.pointsInstance();
cells.write();
}
}
@ -129,6 +134,7 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry)
{
Info<< " <<Writing " << nFaces
<< " non-orthogonal faces to set " << faces.name() << endl;
faces.instance() = mesh.pointsInstance();
faces.write();
}
}
@ -147,6 +153,7 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry)
Info<< " <<Writing " << nFaces
<< " faces with incorrect orientation to set "
<< faces.name() << endl;
faces.instance() = mesh.pointsInstance();
faces.write();
}
}
@ -164,6 +171,7 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry)
{
Info<< " <<Writing " << nFaces
<< " skew faces to set " << faces.name() << endl;
faces.instance() = mesh.pointsInstance();
faces.write();
}
}
@ -184,6 +192,7 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry)
Info<< " <<Writing " << nPoints
<< " points on short edges to set " << points.name()
<< endl;
points.instance() = mesh.pointsInstance();
points.write();
}
}
@ -202,6 +211,7 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry)
Info<< " <<Writing " << nPoints
<< " near (closer than " << Foam::sqrt(minDistSqr)
<< " apart) points to set " << nearPoints.name() << endl;
nearPoints.instance() = mesh.pointsInstance();
nearPoints.write();
}
}
@ -221,6 +231,7 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry)
Info<< " <<Writing " << nFaces
<< " faces with concave angles to set " << faces.name()
<< endl;
faces.instance() = mesh.pointsInstance();
faces.write();
}
}
@ -239,6 +250,7 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry)
{
Info<< " <<Writing " << nFaces
<< " warped faces to set " << faces.name() << endl;
faces.instance() = mesh.pointsInstance();
faces.write();
}
}
@ -255,6 +267,7 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry)
Info<< " <<Writing " << nCells
<< " under-determined cells to set " << cells.name() << endl;
cells.instance() = mesh.pointsInstance();
cells.write();
}
}

View File

@ -89,6 +89,7 @@ Foam::label Foam::checkTopology
Info<< " <<Writing " << nPoints
<< " unused points to set " << points.name() << endl;
points.instance() = mesh.pointsInstance();
points.write();
}
}
@ -106,6 +107,7 @@ Foam::label Foam::checkTopology
{
Info<< " <<Writing " << nFaces
<< " unordered faces to set " << faces.name() << endl;
faces.instance() = mesh.pointsInstance();
faces.write();
}
}
@ -122,6 +124,7 @@ Foam::label Foam::checkTopology
Info<< " <<Writing " << nCells
<< " cells with over used edges to set " << cells.name()
<< endl;
cells.instance() = mesh.pointsInstance();
cells.write();
}
}
@ -137,6 +140,7 @@ Foam::label Foam::checkTopology
Info<< " <<Writing " << nFaces
<< " faces with out-of-range or duplicate vertices to set "
<< faces.name() << endl;
faces.instance() = mesh.pointsInstance();
faces.write();
}
}
@ -153,6 +157,7 @@ Foam::label Foam::checkTopology
Info<< " <<Writing " << nFaces
<< " faces with incorrect edges to set " << faces.name()
<< endl;
faces.instance() = mesh.pointsInstance();
faces.write();
}
}
@ -203,6 +208,7 @@ Foam::label Foam::checkTopology
<< " cells with with single non-boundary face to set "
<< oneCells.name()
<< endl;
oneCells.instance() = mesh.pointsInstance();
oneCells.write();
}
@ -214,6 +220,7 @@ Foam::label Foam::checkTopology
<< " cells with with single non-boundary face to set "
<< twoCells.name()
<< endl;
twoCells.instance() = mesh.pointsInstance();
twoCells.write();
}
}
@ -354,6 +361,7 @@ Foam::label Foam::checkTopology
<< " conflicting points to set "
<< points.name() << endl;
points.instance() = mesh.pointsInstance();
points.write();
}

View File

@ -43,6 +43,8 @@ FoamFile
matchTolerance 1E-3;
// Do a synchronisation of coupled points after creation of any patches.
// Note: this does not work with points that are on multiple coupled patches
// with transformations.
pointSync true;
// Patches to create.

View File

@ -45,6 +45,7 @@ Description
#include "cellZoneSet.H"
#include "faceZoneSet.H"
#include "pointZoneSet.H"
#include "timeSelector.H"
#include <stdio.h>
@ -82,45 +83,6 @@ Istream& selectStream(Istream* is0Ptr, Istream* is1Ptr)
}
}
// Copy set
void backup
(
const word& setType,
const polyMesh& mesh,
const word& fromName,
const topoSet& fromSet,
const word& toName
)
{
if (fromSet.size())
{
Info<< " Backing up " << fromName << " into " << toName << endl;
topoSet::New(setType, mesh, toName, fromSet)().write();
}
}
// Read and copy set
void backup
(
const word& setType,
const polyMesh& mesh,
const word& fromName,
const word& toName
)
{
autoPtr<topoSet> fromSet = topoSet::New
(
setType,
mesh,
fromName,
IOobject::READ_IF_PRESENT
);
backup(setType, mesh, fromName, fromSet(), toName);
}
// Write set to VTK readable files
void writeVTK
@ -304,7 +266,13 @@ void printAllSets(const polyMesh& mesh, Ostream& os)
IOobjectList objects
(
mesh,
mesh.pointsInstance(),
mesh.time().findInstance
(
polyMesh::meshSubDir/"sets",
word::null,
IOobject::READ_IF_PRESENT,
mesh.facesInstance()
),
polyMesh::meshSubDir/"sets"
);
IOobjectList cellSets(objects.lookupClass(cellSet::typeName));
@ -417,7 +385,13 @@ void removeSet
IOobjectList objects
(
mesh,
mesh.pointsInstance(),
mesh.time().findInstance
(
polyMesh::meshSubDir/"sets",
word::null,
IOobject::READ_IF_PRESENT,
mesh.facesInstance()
),
polyMesh::meshSubDir/"sets"
);
@ -465,6 +439,7 @@ bool doCommand
const word& setName,
const word& actionName,
const bool writeVTKFile,
const bool writeCurrentTime,
Istream& is
)
{
@ -628,8 +603,6 @@ bool doCommand
/currentSet.name()
<< " and to vtk file " << vtkName << endl << endl;
currentSet.write();
writeVTK(mesh, currentSet, vtkName);
}
else
@ -638,9 +611,13 @@ bool doCommand
<< " (size " << currentSet.size() << ") to "
<< currentSet.instance()/currentSet.local()
/currentSet.name() << endl << endl;
currentSet.write();
}
if (writeCurrentTime)
{
currentSet.instance() = mesh.time().timeName();
}
currentSet.write();
}
}
}
@ -692,6 +669,48 @@ void printMesh(const Time& runTime, const polyMesh& mesh)
}
polyMesh::readUpdateState meshReadUpdate(polyMesh& mesh)
{
polyMesh::readUpdateState stat = mesh.readUpdate();
switch(stat)
{
case polyMesh::UNCHANGED:
{
Info<< " mesh not changed." << endl;
break;
}
case polyMesh::POINTS_MOVED:
{
Info<< " points moved; topology unchanged." << endl;
break;
}
case polyMesh::TOPO_CHANGE:
{
Info<< " topology changed; patches unchanged." << nl
<< " ";
printMesh(mesh.time(), mesh);
break;
}
case polyMesh::TOPO_PATCH_CHANGE:
{
Info<< " topology changed and patches changed." << nl
<< " ";
printMesh(mesh.time(), mesh);
break;
}
default:
{
FatalErrorIn("meshReadUpdate(polyMesh&)")
<< "Illegal mesh update state "
<< stat << abort(FatalError);
break;
}
}
return stat;
}
commandStatus parseType
(
@ -730,44 +749,10 @@ commandStatus parseType
<< " to " << Times[nearestIndex].name()
<< endl;
// Set time
runTime.setTime(Times[nearestIndex], nearestIndex);
polyMesh::readUpdateState stat = mesh.readUpdate();
switch(stat)
{
case polyMesh::UNCHANGED:
{
Info<< " mesh not changed." << endl;
break;
}
case polyMesh::POINTS_MOVED:
{
Info<< " points moved; topology unchanged." << endl;
break;
}
case polyMesh::TOPO_CHANGE:
{
Info<< " topology changed; patches unchanged." << nl
<< " ";
printMesh(runTime, mesh);
break;
}
case polyMesh::TOPO_PATCH_CHANGE:
{
Info<< " topology changed and patches changed." << nl
<< " ";
printMesh(runTime, mesh);
break;
}
default:
{
FatalErrorIn("parseType")
<< "Illegal mesh update state "
<< stat << abort(FatalError);
break;
}
}
// Optionally re-read mesh
meshReadUpdate(mesh);
return INVALID;
}
@ -840,23 +825,28 @@ commandStatus parseAction(const word& actionName)
int main(int argc, char *argv[])
{
timeSelector::addOptions(true, false);
# include "addRegionOption.H"
# include "addTimeOptions.H"
argList::addBoolOption("noVTK");
argList::addBoolOption("noVTK", "do not write VTK files");
argList::addBoolOption("loop", "execute batch commands for all timesteps");
argList::addOption("batch", "file");
# include "setRootCase.H"
# include "createTime.H"
instantList timeDirs = timeSelector::select0(runTime, args);
bool writeVTK = !args.optionFound("noVTK");
bool loop = args.optionFound("loop");
bool batch = args.optionFound("batch");
// Get times list
instantList Times = runTime.times();
# include "checkTimeOptions.H"
if (loop && !batch)
{
FatalErrorIn(args.executable())
<< "Can only loop when in batch mode."
<< exit(FatalError);
}
runTime.setTime(Times[startTime], startTime);
# include "createNamedPolyMesh.H"
@ -866,135 +856,171 @@ int main(int argc, char *argv[])
// Print current sets
printAllSets(mesh, Info);
std::ifstream* fileStreamPtr(NULL);
if (args.optionFound("batch"))
{
fileName batchFile(args.option("batch"));
Info<< "Reading commands from file " << batchFile << endl;
// we cannot handle .gz files
if (!isFile(batchFile, false))
{
FatalErrorIn(args.executable())
<< "Cannot open file " << batchFile << exit(FatalError);
}
fileStreamPtr = new std::ifstream(batchFile.c_str());
}
#if READLINE != 0
else if (!read_history(historyFile))
// Read history if interactive
# if READLINE != 0
if (!batch && !read_history(historyFile))
{
Info<< "Successfully read history from " << historyFile << endl;
}
#endif
# endif
Info<< "Please type 'help', 'quit' or a set command after prompt." << endl;
bool ok = true;
// Exit status
int status = 0;
FatalError.throwExceptions();
FatalIOError.throwExceptions();
do
forAll(timeDirs, timeI)
{
string rawLine;
runTime.setTime(timeDirs[timeI], timeI);
Info<< "Time = " << runTime.timeName() << endl;
// Type: cellSet, faceSet, pointSet
word setType;
// Name of destination set.
word setName;
// Action (new, invert etc.)
word actionName;
// Handle geometry/topology changes
meshReadUpdate(mesh);
commandStatus stat = INVALID;
if (fileStreamPtr)
// Main command read & execute loop
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
autoPtr<IFstream> fileStreamPtr(NULL);
if (batch)
{
if (!fileStreamPtr->good())
fileName batchFile(args.option("batch"));
Info<< "Reading commands from file " << batchFile << endl;
// we cannot handle .gz files
if (!isFile(batchFile, false))
{
Info<< "End of batch file" << endl;
break;
FatalErrorIn(args.executable())
<< "Cannot open file " << batchFile << exit(FatalError);
}
std::getline(*fileStreamPtr, rawLine);
if (rawLine.size())
{
Info<< "Doing:" << rawLine << endl;
}
fileStreamPtr.reset(new IFstream(batchFile));
}
else
Info<< "Please type 'help', 'quit' or a set command after prompt."
<< endl;
// Whether to quit
bool quit = false;
FatalError.throwExceptions();
FatalIOError.throwExceptions();
do
{
# if READLINE != 0
string rawLine;
// Type: cellSet, faceSet, pointSet
word setType;
// Name of destination set.
word setName;
// Action (new, invert etc.)
word actionName;
commandStatus stat = INVALID;
if (fileStreamPtr.valid())
{
char* linePtr = readline("readline>");
rawLine = string(linePtr);
if (*linePtr)
if (!fileStreamPtr().good())
{
add_history(linePtr);
write_history(historyFile);
Info<< "End of batch file" << endl;
// No error.
break;
}
free(linePtr); // readline uses malloc, not new.
}
# else
{
Info<< "Command>" << flush;
std::getline(std::cin, rawLine);
}
# endif
}
fileStreamPtr().getLine(rawLine);
if (rawLine.empty() || rawLine[0] == '#')
{
continue;
}
IStringStream is(rawLine + ' ');
// Type: cellSet, faceSet, pointSet, faceZoneSet
is >> setType;
stat = parseType(runTime, mesh, setType, is);
if (stat == VALIDSETCMD || stat == VALIDZONECMD)
{
if (is >> setName)
{
if (is >> actionName)
if (rawLine.size())
{
stat = parseAction(actionName);
Info<< "Doing:" << rawLine << endl;
}
}
}
ok = true;
else
{
# if READLINE != 0
{
char* linePtr = readline("readline>");
if (stat == QUIT)
rawLine = string(linePtr);
if (*linePtr)
{
add_history(linePtr);
write_history(historyFile);
}
free(linePtr); // readline uses malloc, not new.
}
# else
{
Info<< "Command>" << flush;
std::getline(std::cin, rawLine);
}
# endif
}
if (rawLine.empty() || rawLine[0] == '#')
{
continue;
}
IStringStream is(rawLine + ' ');
// Type: cellSet, faceSet, pointSet, faceZoneSet
is >> setType;
stat = parseType(runTime, mesh, setType, is);
if (stat == VALIDSETCMD || stat == VALIDZONECMD)
{
if (is >> setName)
{
if (is >> actionName)
{
stat = parseAction(actionName);
}
}
}
if (stat == QUIT)
{
// Make sure to quit
quit = true;
}
else if (stat == VALIDSETCMD || stat == VALIDZONECMD)
{
bool ok = doCommand
(
mesh,
setType,
setName,
actionName,
writeVTK,
loop, // if in looping mode dump sets to time directory
is
);
if (!ok)
{
// Exit with error.
quit = true;
status = 1;
}
}
} while (!quit);
if (quit)
{
break;
}
else if (stat == VALIDSETCMD || stat == VALIDZONECMD)
{
ok = doCommand(mesh, setType, setName, actionName, writeVTK, is);
}
} while (ok);
if (fileStreamPtr)
{
delete fileStreamPtr;
}
Info<< "\nEnd\n" << endl;
return 0;
return status;
}

View File

@ -81,14 +81,17 @@ int main(int argc, char *argv[])
# include "createNamedPolyMesh.H"
// Search for list of objects for the time of the mesh
IOobjectList objects
word setsInstance = runTime.findInstance
(
mesh,
mesh.pointsInstance(),
polyMesh::meshSubDir/"sets"
polyMesh::meshSubDir/"sets",
word::null,
IOobject::MUST_READ,
mesh.facesInstance()
);
Info<< "Searched : " << mesh.pointsInstance()/polyMesh::meshSubDir/"sets"
IOobjectList objects(mesh, setsInstance, polyMesh::meshSubDir/"sets");
Info<< "Searched : " << setsInstance/polyMesh::meshSubDir/"sets"
<< nl
<< "Found : " << objects.names() << nl
<< endl;

View File

@ -64,6 +64,7 @@ Description
#include "syncTools.H"
#include "ReadFields.H"
#include "directMappedWallPolyPatch.H"
#include "zeroGradientFvPatchFields.H"
using namespace Foam;
@ -164,25 +165,24 @@ void reorderPatchFields(fvMesh& mesh, const labelList& oldToNew)
// Adds patch if not yet there. Returns patchID.
template<class PatchType>
label addPatch(fvMesh& mesh, const word& patchName)
label addPatch(fvMesh& mesh, const polyPatch& patch)
{
polyBoundaryMesh& polyPatches =
const_cast<polyBoundaryMesh&>(mesh.boundaryMesh());
label patchI = polyPatches.findPatchID(patchName);
label patchI = polyPatches.findPatchID(patch.name());
if (patchI != -1)
{
if (isA<PatchType>(polyPatches[patchI]))
if (polyPatches[patchI].type() == patch.type())
{
// Already there
return patchI;
}
else
{
FatalErrorIn("addPatch<PatchType>(fvMesh&, const word&)")
<< "Already have patch " << patchName
<< " but of type " << PatchType::typeName
FatalErrorIn("addPatch(fvMesh&, const polyPatch*)")
<< "Already have patch " << patch.name()
<< " but of type " << patch.type()
<< exit(FatalError);
}
}
@ -219,14 +219,12 @@ label addPatch(fvMesh& mesh, const word& patchName)
polyPatches.set
(
sz,
polyPatch::New
patch.clone
(
PatchType::typeName,
patchName,
0, // size
startFaceI,
insertPatchI,
polyPatches
polyPatches,
insertPatchI, //index
0, //size
startFaceI //start
)
);
fvPatches.setSize(sz+1);
@ -1086,16 +1084,37 @@ EdgeMap<label> addRegionPatches
if (interfaceSizes[e] > 0)
{
label patchI = addPatch<directMappedWallPolyPatch>
const word inter1 = regionNames[e[0]] + "_to_" + regionNames[e[1]];
const word inter2 = regionNames[e[1]] + "_to_" + regionNames[e[0]];
directMappedWallPolyPatch patch1
(
mesh,
regionNames[e[0]] + "_to_" + regionNames[e[1]]
inter1,
0, // overridden
0, // overridden
0, // overridden
regionNames[e[1]], // sampleRegion
directMappedPatchBase::NEARESTPATCHFACE,
inter2, // samplePatch
point::zero, // offset
mesh.boundaryMesh()
);
addPatch<directMappedWallPolyPatch>
label patchI = addPatch(mesh, patch1);
directMappedWallPolyPatch patch2
(
mesh,
regionNames[e[1]] + "_to_" + regionNames[e[0]]
inter2,
0,
0,
0,
regionNames[e[0]], // sampleRegion
directMappedPatchBase::NEARESTPATCHFACE,
inter1,
point::zero, // offset
mesh.boundaryMesh()
);
addPatch(mesh, patch2);
Info<< "For interface between region " << e[0]
<< " and " << e[1] << " added patch " << patchI
@ -1495,7 +1514,8 @@ int main(int argc, char *argv[])
false
),
mesh,
dimensionedScalar("zero", dimless, 0)
dimensionedScalar("zero", dimless, 0),
zeroGradientFvPatchScalarField::typeName
);
forAll(cellRegion, cellI)
{