Merging master, fixing conflict in searchableBox.C

This commit is contained in:
graham
2009-06-18 15:26:01 +01:00
775 changed files with 31691 additions and 7312 deletions

View File

@ -23,7 +23,8 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Extrude mesh from existing patch or from patch read from file.
Extrude mesh from existing patch (flipped so has inwards pointing
normals) or from patch read from file.
Note: Merges close points so be careful.
Type of extrusion prescribed by run-time selectable model.
@ -52,43 +53,34 @@ using namespace Foam;
int main(int argc, char *argv[])
{
#include "setRoots.H"
#include "setRootCase.H"
#include "createTimeExtruded.H"
if (args.optionFound("sourceCase") == args.optionFound("surface"))
{
FatalErrorIn(args.executable())
<< "Specify either -sourceCase and -sourcePatch"
" or -surface options\n"
" to specify the source of the patch to extrude"
<< exit(FatalError);
}
autoPtr<extrudedMesh> meshPtr(NULL);
autoPtr<extrudeModel> model
IOdictionary dict
(
extrudeModel::New
IOobject
(
IOdictionary
(
IOobject
(
"extrudeProperties",
runTimeExtruded.constant(),
runTimeExtruded,
IOobject::MUST_READ
)
)
"extrudeProperties",
runTimeExtruded.constant(),
runTimeExtruded,
IOobject::MUST_READ
)
);
if (args.optionFound("sourceCase"))
autoPtr<extrudeModel> model(extrudeModel::New(dict));
const word sourceType(dict.lookup("constructFrom"));
autoPtr<faceMesh> fMesh;
if (sourceType == "patch")
{
fileName sourceCasePath(args.option("sourceCase"));
fileName sourceCasePath(dict.lookup("sourceCase"));
fileName sourceRootDir = sourceCasePath.path();
fileName sourceCaseDir = sourceCasePath.name();
word patchName(args.option("sourcePatch"));
word patchName(dict.lookup("sourcePatch"));
Info<< "Extruding patch " << patchName
<< " on mesh " << sourceCasePath << nl
@ -114,75 +106,69 @@ int main(int argc, char *argv[])
}
const polyPatch& pp = mesh.boundaryMesh()[patchID];
fMesh.reset(new faceMesh(pp.localFaces(), pp.localPoints()));
fMesh().flip();
{
fileName surfName(patchName + ".sMesh");
Info<< "Writing patch as surfaceMesh to " << surfName << nl << endl;
faceMesh fMesh(pp.localFaces(), pp.localPoints());
Info<< "Writing (flipped) patch as surfaceMesh to "
<< surfName << nl << endl;
OFstream os(surfName);
os << fMesh << nl;
os << fMesh() << nl;
}
meshPtr.reset
(
new extrudedMesh
(
IOobject
(
extrudedMesh::defaultRegion,
runTimeExtruded.constant(),
runTimeExtruded
),
pp,
model()
)
);
}
else
else if (sourceType == "surface")
{
// Read from surface
fileName surfName(args.option("surface"));
fileName surfName(dict.lookup("surface"));
Info<< "Extruding surfaceMesh read from file " << surfName << nl
<< endl;
IFstream is(surfName);
faceMesh fMesh(is);
fMesh.reset(new faceMesh(is));
Info<< "Read patch from file " << surfName << ':' << nl
<< " points : " << fMesh.points().size() << nl
<< " faces : " << fMesh.size() << nl
Info<< "Read patch from file " << surfName << nl
<< endl;
}
else
{
FatalErrorIn(args.executable())
<< "Illegal 'constructFrom' specification. Should either be "
<< "patch or surface." << exit(FatalError);
}
Info<< "Extruding patch with :" << nl
<< " points : " << fMesh().points().size() << nl
<< " faces : " << fMesh().size() << nl
<< " normals[0] : " << fMesh().faceNormals()[0]
<< nl
<< endl;
meshPtr.reset
extrudedMesh mesh
(
IOobject
(
new extrudedMesh
(
IOobject
(
extrudedMesh::defaultRegion,
runTimeExtruded.constant(),
runTimeExtruded
),
fMesh,
model()
)
);
}
extrudedMesh& mesh = meshPtr();
extrudedMesh::defaultRegion,
runTimeExtruded.constant(),
runTimeExtruded
),
fMesh(),
model()
);
const boundBox& bb = mesh.globalData().bb();
const vector span = bb.span();
const scalar mergeDim = 1E-4 * bb.minDim();
Info<< "Mesh bounding box:" << bb << nl
<< " with span:" << span << nl
<< "Merge distance :" << mergeDim << nl
Info<< "Mesh bounding box : " << bb << nl
<< " with span : " << span << nl
<< "Merge distance : " << mergeDim << nl
<< endl;
const polyBoundaryMesh& patches = mesh.boundaryMesh();
@ -250,7 +236,8 @@ int main(int argc, char *argv[])
// Merging front and back patch faces
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if (args.optionFound("mergeFaces"))
Switch mergeFaces(dict.lookup("mergeFaces"));
if (mergeFaces)
{
Info<< "Assuming full 360 degree axisymmetric case;"
<< " stitching faces on patches "

View File

@ -88,7 +88,8 @@ point wedge::operator()
}
else
{
sliceAngle = angle_*(layer + 1)/nLayers_;
//sliceAngle = angle_*(layer + 1)/nLayers_;
sliceAngle = angle_*layer/nLayers_;
}
// Find projection onto axis (or rather decompose surfacePoint

View File

@ -14,23 +14,41 @@ FoamFile
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
extrudeModel wedge;
// Where to get surface from: either from surface ('surface') or
// from (flipped) patch of existing case ('patch')
constructFrom patch; //surface;
// If construct from (flipped) patch
sourceCase "../cavity";
sourcePatch movingWall;
// If construct from surface
surface "movingWall.sMesh";
// Do front and back need to be merged?
mergeFaces false;
//- Linear extrusion in point-normal direction
//extrudeModel linearNormal;
//- Wedge extrusion. If nLayers is 1 assumes symmetry around plane.
extrudeModel wedge;
//- Extrudes into sphere around (0 0 0)
//extrudeModel linearRadial;
//extrudeModel sigmaRadial;
nLayers 1;
nLayers 6;
wedgeCoeffs
{
axisPt (0 0 0);
axis (0 -1 0);
angle 2.0;
axisPt (0 0.1 0);
axis (1 0 0);
angle 90.0; // For nLayers=1 assume symmetry so angle/2 on each side
}
linearNormalCoeffs
{
thickness 0.1;
thickness 0.05;
}
linearRadialCoeffs
@ -47,3 +65,4 @@ sigmaRadialCoeffs
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -117,7 +117,7 @@ Foam::Xfer<Foam::faceList> Foam::extrudedMesh::extrudedFaces
quad[2] = surfaceEdges[i][0] + nextLayerOffset;
quad[3] = surfaceEdges[i][1] + nextLayerOffset;
eFaces[facei++] = face(quad);
eFaces[facei++] = face(quad).reverseFace();
}
// Faces between layer and layer+1
@ -130,7 +130,7 @@ Foam::Xfer<Foam::faceList> Foam::extrudedMesh::extrudedFaces
(
surfaceFaces[i].reverseFace()
+ nextLayerOffset
);
).reverseFace();
}
}
}
@ -152,7 +152,7 @@ Foam::Xfer<Foam::faceList> Foam::extrudedMesh::extrudedFaces
label ownerFace = extrudePatch.edgeFaces()[i][0];
if (!sameOrder(surfaceFaces[ownerFace], e))
if (sameOrder(surfaceFaces[ownerFace], e))
{
reverse(quad);
}
@ -164,7 +164,7 @@ Foam::Xfer<Foam::faceList> Foam::extrudedMesh::extrudedFaces
// Top faces
forAll(surfaceFaces, i)
{
eFaces[facei++] = face(surfaceFaces[i]);
eFaces[facei++] = face(surfaceFaces[i]).reverseFace();
}
// Bottom faces
@ -175,7 +175,7 @@ Foam::Xfer<Foam::faceList> Foam::extrudedMesh::extrudedFaces
(
surfaceFaces[i].reverseFace()
+ nLayers*surfacePoints.size()
);
).reverseFace();
}
// return points for transferring

View File

@ -78,6 +78,18 @@ public:
{}
// Member Functions
void flip()
{
forAll(*this, i)
{
face& f = operator[](i);
f = f.reverseFace();
}
clearOut();
}
// IOstream Operators
friend Ostream& operator<<(Ostream& os, const faceMesh& fm)
@ -85,7 +97,8 @@ public:
return os
<< fm.points()
<< token::NL
<< static_cast<PrimitivePatch<face, Foam::List, pointField> >(fm);
<< static_cast<PrimitivePatch<face, Foam::List, pointField> >
(fm);
}
};

View File

@ -96,7 +96,7 @@ void writeMesh
const fvMesh& mesh = meshRefiner.mesh();
meshRefiner.printMeshInfo(debug, msg);
Info<< "Writing mesh to time " << mesh.time().timeName() << endl;
Info<< "Writing mesh to time " << meshRefiner.timeName() << endl;
meshRefiner.write(meshRefinement::MESH|meshRefinement::SCALARLEVELS, "");
if (debug & meshRefinement::OBJINTERSECTIONS)
@ -104,7 +104,7 @@ void writeMesh
meshRefiner.write
(
meshRefinement::OBJINTERSECTIONS,
mesh.time().path()/mesh.time().timeName()
mesh.time().path()/meshRefiner.timeName()
);
}
Info<< "Written mesh in = "
@ -115,6 +115,7 @@ void writeMesh
int main(int argc, char *argv[])
{
argList::validOptions.insert("overwrite", "");
# include "setRootCase.H"
# include "createTime.H"
runTime.functionObjects().off();
@ -123,6 +124,9 @@ int main(int argc, char *argv[])
Info<< "Read mesh in = "
<< runTime.cpuTimeIncrement() << " s" << endl;
const bool overwrite = args.optionFound("overwrite");
// Check patches and faceZones are synchronised
mesh.boundaryMesh().checkParallelSync(true);
meshRefinement::checkCoupledFaceZones(mesh);
@ -170,6 +174,13 @@ int main(int argc, char *argv[])
const dictionary& layerDict = meshDict.subDict("addLayersControls");
const scalar mergeDist = getMergeDistance
(
mesh,
readScalar(meshDict.lookup("mergeTolerance"))
);
// Debug
// ~~~~~
@ -192,8 +203,9 @@ int main(int argc, char *argv[])
IOobject
(
"abc", // dummy name
mesh.time().constant(), // directory
"triSurface", // instance
//mesh.time().constant(), // instance
mesh.time().findInstance("triSurface", word::null),// instance
"triSurface", // local
mesh.time(), // registry
IOobject::MUST_READ,
IOobject::NO_WRITE
@ -235,6 +247,34 @@ int main(int argc, char *argv[])
<< mesh.time().cpuTimeIncrement() << " s" << nl << endl;
// Refinement engine
// ~~~~~~~~~~~~~~~~~
Info<< nl
<< "Determining initial surface intersections" << nl
<< "-----------------------------------------" << nl
<< endl;
// Main refinement engine
meshRefinement meshRefiner
(
mesh,
mergeDist, // tolerance used in sorting coordinates
overwrite, // overwrite mesh files?
surfaces, // for surface intersection refinement
shells // for volume (inside/outside) refinement
);
Info<< "Calculated surface intersections in = "
<< mesh.time().cpuTimeIncrement() << " s" << nl << endl;
// Some stats
meshRefiner.printMeshInfo(debug, "Initial mesh");
meshRefiner.write
(
debug&meshRefinement::OBJINTERSECTIONS,
mesh.time().path()/meshRefiner.timeName()
);
// Add all the surface regions as patches
@ -265,9 +305,8 @@ int main(int argc, char *argv[])
forAll(regNames, i)
{
label patchI = meshRefinement::addPatch
label patchI = meshRefiner.addMeshedPatch
(
mesh,
regNames[i],
wallPolyPatch::typeName
);
@ -308,45 +347,10 @@ int main(int argc, char *argv[])
<< exit(FatalError);
}
const scalar mergeDist = getMergeDistance
(
mesh,
readScalar(meshDict.lookup("mergeTolerance"))
);
// Mesh distribution engine (uses tolerance to reconstruct meshes)
fvMeshDistribute distributor(mesh, mergeDist);
// Refinement engine
// ~~~~~~~~~~~~~~~~~
Info<< nl
<< "Determining initial surface intersections" << nl
<< "-----------------------------------------" << nl
<< endl;
// Main refinement engine
meshRefinement meshRefiner
(
mesh,
mergeDist, // tolerance used in sorting coordinates
surfaces, // for surface intersection refinement
shells // for volume (inside/outside) refinement
);
Info<< "Calculated surface intersections in = "
<< mesh.time().cpuTimeIncrement() << " s" << nl << endl;
// Some stats
meshRefiner.printMeshInfo(debug, "Initial mesh");
meshRefiner.write
(
debug&meshRefinement::OBJINTERSECTIONS,
mesh.time().path()/mesh.time().timeName()
);
@ -370,6 +374,11 @@ int main(int argc, char *argv[])
// Refinement parameters
refinementParameters refineParams(refineDict);
if (!overwrite)
{
const_cast<Time&>(mesh.time())++;
}
refineDriver.doRefine(refineDict, refineParams, wantSnap, motionDict);
writeMesh
@ -391,6 +400,11 @@ int main(int argc, char *argv[])
// Snap parameters
snapParameters snapParams(snapDict);
if (!overwrite)
{
const_cast<Time&>(mesh.time())++;
}
snapDriver.doSnap(snapDict, motionDict, snapParams);
writeMesh
@ -403,15 +417,16 @@ int main(int argc, char *argv[])
if (wantLayers)
{
autoLayerDriver layerDriver
(
meshRefiner,
globalToPatch
);
autoLayerDriver layerDriver(meshRefiner);
// Layer addition parameters
layerParameters layerParams(layerDict, mesh.boundaryMesh());
if (!overwrite)
{
const_cast<Time&>(mesh.time())++;
}
layerDriver.doLayers
(
layerDict,
@ -435,7 +450,7 @@ int main(int argc, char *argv[])
Info<< "End\n" << endl;
return 0;
return(0);
}