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

This commit is contained in:
andy
2012-05-25 13:50:57 +01:00
18 changed files with 538 additions and 325 deletions

View File

@ -96,8 +96,9 @@ bool Foam::cellSizeControlSurfaces::evalCellSizeFunctions
if (cellSizeFunctions_.size())
{
// Initialise to the last (lowest) priority
label previousPriority = cellSizeFunctions_.last().priority();
// Maintain priority of current hit. Initialise so it always goes
// through at least once.
label previousPriority = -1;
forAll(cellSizeFunctions_, i)
{

View File

@ -196,7 +196,7 @@ void Foam::conformalVoronoiMesh::buildSurfaceConformation
{
if (vit->internalPoint() && !vit->nearBoundary())
{
const Foam::point& pt = topoint(vit->point());
pointFromPoint pt = topoint(vit->point());
const scalar range = sqr(2.0*targetCellSize(pt));
pointIndexHit pHit;

View File

@ -238,6 +238,25 @@ int main(int argc, char *argv[])
dict.lookup("constructFrom")
);
// Any merging of small edges
const scalar mergeTol(dict.lookupOrDefault<scalar>("mergeTol", 1e-4));
Info<< "Extruding from " << ExtrudeModeNames[mode]
<< " using model " << model().type() << endl;
if (flipNormals)
{
Info<< "Flipping normals before extruding" << endl;
}
if (mergeTol > 0)
{
Info<< "Collapsing edges < " << mergeTol << " of bounding box" << endl;
}
else
{
Info<< "Not collapsing any edges after extrusion" << endl;
}
Info<< endl;
// Generated mesh (one of either)
autoPtr<fvMesh> meshFromMesh;
@ -715,7 +734,7 @@ int main(int argc, char *argv[])
const boundBox& bb = mesh.bounds();
const vector span = bb.span();
const scalar mergeDim = 1e-4 * bb.minDim();
const scalar mergeDim = mergeTol * bb.minDim();
Info<< "Mesh bounding box : " << bb << nl
<< " with span : " << span << nl
@ -726,6 +745,7 @@ int main(int argc, char *argv[])
// Collapse edges
// ~~~~~~~~~~~~~~
if (mergeDim > 0)
{
Info<< "Collapsing edges < " << mergeDim << " ..." << nl << endl;

View File

@ -88,4 +88,8 @@ sigmaRadialCoeffs
// degree wedges.
mergeFaces false; //true;
// Merge small edges. Fraction of bounding box.
mergeTol 0;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -206,6 +206,14 @@ int main(int argc, char *argv[])
runTime
);
// cvMesh vertices
writeMeshObject<pointIOField>
(
"internalDelaunayVertices",
regionPrefix,
runTime
);
if (runTime.writeFormat() == IOstream::ASCII)
{
// Only do zones when converting from binary to ascii

View File

@ -51,9 +51,6 @@ Foam::autoPtr<Foam::fvMesh> Foam::loadOrCreateMesh
// Check who has a mesh
const bool haveMesh = isDir(io.time().path()/io.instance()/meshSubDir);
Pout<< "meshpath:" << io.time().path()/io.instance()/meshSubDir << endl;
Pout<< "haveMesh:" << haveMesh << endl;
if (!haveMesh)
{
// Create dummy mesh. Only used on procs that don't have mesh.
@ -293,8 +290,10 @@ Pout<< "haveMesh:" << haveMesh << endl;
if (!haveMesh)
{
// We created a dummy mesh file above. Delete it.
//Pout<< "Removing dummy mesh " << io.objectPath() << endl;
rmDir(io.objectPath());
const fileName meshFiles = io.time().path()/io.instance()/meshSubDir;
//Pout<< "Removing dummy mesh " << meshFiles << endl;
mesh.removeFiles();
rmDir(meshFiles);
}
// Force recreation of globalMeshData.

View File

@ -3,7 +3,7 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
# \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
# \\/ M anipulation |
#------------------------------------------------------------------------------
# License
@ -107,15 +107,23 @@ then
echo "pack manually" 1>&2
foamPackSource $packDir $packFile
else
echo "pack with git-archive" 1>&2
( cd $packDir && git archive --format=tar --prefix=$packDir/ HEAD) > $packBase.tar
if [ ! -f $packDir/.build ]
then
echo "Error: $packDir/.build does not exists" 1>&2
echo " Please update this by running e.g. 'wmakePrintBuild -update' in $packDir" 1>&2
exit 2
fi
echo "add in time-stamp and lnInclude directories" 1>&2
tar cf $packBase.tar2 $packDir/.timeStamp $packDir/.build `find -H $packDir -type d -name lnInclude`
tar Af $packBase.tar $packBase.tar2
echo "gzip tar file" 1>&2
gzip -c9 $packBase.tar > $packFile
echo "pack with git-archive" 1>&2 &&
( cd $packDir && git archive --format=tar --prefix=$packDir/ HEAD) > $packBase.tar &&
echo "add in time-stamp and lnInclude directories" 1>&2 &&
tar cf $packBase.tar2 $packDir/.timeStamp $packDir/.build `find -H $packDir -type d -name lnInclude` &&
tar Af $packBase.tar $packBase.tar2 &&
echo "gzip tar file" 1>&2 &&
gzip -c9 $packBase.tar > $packFile &&
rm -f $packBase.tar $packBase.tar2 2>/dev/null
fi

View File

@ -1217,7 +1217,7 @@ const Foam::globalMeshData& Foam::polyMesh::globalData() const
// Remove all files and some subdirs (eg, sets)
void Foam::polyMesh::removeFiles(const fileName& instanceDir) const
{
fileName meshFilesPath = thisDb().path()/instanceDir/meshDir();
fileName meshFilesPath = thisDb().time().path()/instanceDir/meshDir();
rm(meshFilesPath/"points");
rm(meshFilesPath/"faces");

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -58,7 +58,7 @@ void Foam::ptscotchDecomp::check(const int retVal, const char* str)
{}
Foam::label Foam::ptscotchDecomp::decomposeZeroDomains
Foam::label Foam::ptscotchDecomp::decompose
(
const fileName& meshPath,
const List<int>& initxadj,
@ -72,6 +72,7 @@ Foam::label Foam::ptscotchDecomp::decomposeZeroDomains
(
"label ptscotchDecomp::decompose"
"("
"onst fileName&,"
"const List<int>&, "
"const List<int>&, "
"const scalarField&, "
@ -84,8 +85,10 @@ Foam::label Foam::ptscotchDecomp::decomposeZeroDomains
Foam::label Foam::ptscotchDecomp::decompose
(
const fileName& meshPath,
const List<int>& adjncy,
const List<int>& xadj,
const int adjncySize,
const int adjncy[],
const int xadjSize,
const int xadj[],
const scalarField& cWeights,
List<int>& finalDecomp
) const
@ -94,9 +97,12 @@ Foam::label Foam::ptscotchDecomp::decompose
(
"label ptscotchDecomp::decompose"
"("
"const List<int>&, "
"const List<int>&, "
"const scalarField&, "
"const fileName&,"
"const int,"
"const int,"
"const int,"
"const int,"
"const scalarField&,"
"List<int>&"
")"
) << notImplementedMessage << exit(FatalError);

View File

@ -439,6 +439,86 @@ void Foam::autoLayerDriver::handleFeatureAngle
}
//Foam::tmp<Foam::scalarField> Foam::autoLayerDriver::undistortedEdgeLength
//(
// const indirectPrimitivePatch& pp,
// const bool relativeSizes,
// const bool faceSize
//)
//{
// const fvMesh& mesh = meshRefiner_.mesh();
//
// tmp<scalarField> tfld(new scalarField());
// scalarField& fld = tfld();
//
// if (faceSize)
// {
// fld.setSize(pp.size());
// }
// else
// {
// fld.setSize(pp.nPoints());
// }
//
//
// if (relativeSizes)
// {
// const scalar edge0Len = meshRefiner_.meshCutter().level0EdgeLength();
// const labelList& cellLevel = meshRefiner_.meshCutter().cellLevel();
//
// if (faceSize)
// {
// forAll(pp, i)
// {
// label faceI = pp.addressing()[i];
// label ownLevel = cellLevel[mesh.faceOwner()[faceI]];
// fld[i] = edge0Len/(1<<ownLevel);
// }
// }
// else
// {
// // Determine per point the max cell level of connected cells
// // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// labelList maxPointLevel(pp.nPoints(), labelMin);
//
// forAll(pp, i)
// {
// label faceI = pp.addressing()[i];
// label ownLevel = cellLevel[mesh.faceOwner()[faceI]];
//
// const face& f = pp.localFaces()[i];
// forAll(f, fp)
// {
// maxPointLevel[f[fp]] =
// max(maxPointLevel[f[fp]], ownLevel);
// }
// }
//
// syncTools::syncPointList
// (
// mesh,
// pp.meshPoints(),
// maxPointLevel,
// maxEqOp<label>(),
// labelMin // null value
// );
//
//
// forAll(maxPointLevel, pointI)
// {
// // Find undistorted edge size for this level.
// fld[i] = edge0Len/(1<<maxPointLevel[pointI]);
// }
// }
// }
// else
// {
// // Use actual cell size
// }
//}
// No extrusion on cells with warped faces. Calculates the thickness of the
// layer and compares it to the space the warped face takes up. Disables
// extrusion if layer thickness is more than faceRatio of the thickness of
@ -2383,22 +2463,27 @@ void Foam::autoLayerDriver::addLayers
// Disable extrusion on warped faces
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// It is hard to calculate some length scale if not in relative
// mode so disable this check.
if (layerParams.relativeSizes())
{
// Undistorted edge length
const scalar edge0Len =
meshRefiner_.meshCutter().level0EdgeLength();
const labelList& cellLevel = meshRefiner_.meshCutter().cellLevel();
// Undistorted edge length
const scalar edge0Len = meshRefiner_.meshCutter().level0EdgeLength();
const labelList& cellLevel = meshRefiner_.meshCutter().cellLevel();
handleWarpedFaces
(
pp,
layerParams.maxFaceThicknessRatio(),
edge0Len,
cellLevel,
handleWarpedFaces
(
pp,
layerParams.maxFaceThicknessRatio(),
edge0Len,
cellLevel,
patchDisp,
patchNLayers,
extrudeStatus
);
patchDisp,
patchNLayers,
extrudeStatus
);
}
//// Disable extrusion on cells with multiple patch faces
//// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -2585,6 +2670,21 @@ void Foam::autoLayerDriver::addLayers
dimensionedScalar("medialRatio", dimless, 0.0)
);
pointVectorField medialVec
(
IOobject
(
"medialVec",
meshRefiner_.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
meshMover().pMesh(),
dimensionedVector("medialVec", dimLength, vector::zero)
);
// Setup information for medial axis smoothing. Calculates medial axis
// and a smoothed displacement direction.
// - pointMedialDist : distance to medial axis
@ -2600,7 +2700,8 @@ void Foam::autoLayerDriver::addLayers
dispVec,
medialRatio,
pointMedialDist
pointMedialDist,
medialVec
);
@ -2692,6 +2793,7 @@ void Foam::autoLayerDriver::addLayers
dispVec,
medialRatio,
pointMedialDist,
medialVec,
extrudeStatus,
patchDisp,
@ -2830,7 +2932,7 @@ void Foam::autoLayerDriver::addLayers
mesh.name(),
static_cast<polyMesh&>(mesh).instance(),
mesh.time(), // register with runTime
static_cast<polyMesh&>(mesh).readOpt(),
IOobject::NO_READ,
static_cast<polyMesh&>(mesh).writeOpt()
), // io params from original mesh but new name
mesh, // original mesh

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -460,7 +460,8 @@ class autoLayerDriver
pointVectorField& dispVec,
pointScalarField& medialRatio,
pointScalarField& medialDist
pointScalarField& medialDist,
pointVectorField& medialVec
) const;
//- Main routine to shrink mesh
@ -481,6 +482,7 @@ class autoLayerDriver
const pointVectorField& dispVec,
const pointScalarField& medialRatio,
const pointScalarField& medialDist,
const pointVectorField& medialVec,
List<extrudeMode>& extrudeStatus,
pointField& patchDisp,

View File

@ -689,7 +689,8 @@ void Foam::autoLayerDriver::medialAxisSmoothingInfo
pointVectorField& dispVec,
pointScalarField& medialRatio,
pointScalarField& medialDist
pointScalarField& medialDist,
pointVectorField& medialVec
) const
{
@ -929,7 +930,7 @@ void Foam::autoLayerDriver::medialAxisSmoothingInfo
forAll(pointMedialDist, pointI)
{
medialDist[pointI] = Foam::sqrt(pointMedialDist[pointI].distSqr());
//medialVec[pointI] = pointMedialDist[pointI].origin();
medialVec[pointI] = pointMedialDist[pointI].origin();
}
}
@ -966,14 +967,14 @@ void Foam::autoLayerDriver::medialAxisSmoothingInfo
<< " : normalised direction of nearest displacement" << nl
<< " " << medialDist.name()
<< " : distance to medial axis" << nl
//<< " " << medialVec.name()
//<< " : nearest point on medial axis" << nl
<< " " << medialVec.name()
<< " : nearest point on medial axis" << nl
<< " " << medialRatio.name()
<< " : ratio of medial distance to wall distance" << nl
<< endl;
dispVec.write();
medialDist.write();
//medialVec.write();
medialVec.write();
medialRatio.write();
}
}
@ -996,7 +997,7 @@ void Foam::autoLayerDriver::shrinkMeshMedialDistance
const pointVectorField& dispVec,
const pointScalarField& medialRatio,
const pointScalarField& medialDist,
//const pointVectorField& medialVec,
const pointVectorField& medialVec,
List<extrudeMode>& extrudeStatus,
pointField& patchDisp,
@ -1066,6 +1067,24 @@ void Foam::autoLayerDriver::shrinkMeshMedialDistance
<< str().name() << endl;
}
autoPtr<OFstream> medialVecStr;
label medialVertI = 0;
if (debug)
{
medialVecStr.reset
(
new OFstream
(
mesh.time().path()
/ "thicknessRatioExcludeMedialVec_"
+ meshRefiner_.timeName()
+ ".obj"
)
);
Info<< "Writing points with too large a extrusion distance to "
<< medialVecStr().name() << endl;
}
forAll(meshPoints, patchPointI)
{
if (extrudeStatus[patchPointI] != NOEXTRUDE)
@ -1082,12 +1101,9 @@ void Foam::autoLayerDriver::shrinkMeshMedialDistance
vector n =
patchDisp[patchPointI]
/ (mag(patchDisp[patchPointI]) + VSMALL);
//vector mVec = mesh.points()[pointI]-medialVec[pointI];
//scalar mDist = mag(mVec);
//scalar thicknessRatio =
// (n&mVec)
// *thickness[patchPointI]
// /(mDist+VSMALL);
vector mVec = mesh.points()[pointI]-medialVec[pointI];
mVec /= mag(mVec)+VSMALL;
thicknessRatio *= (n&mVec);
if (thicknessRatio > maxThicknessToMedialRatio)
{
@ -1103,8 +1119,9 @@ void Foam::autoLayerDriver::shrinkMeshMedialDistance
minThickness[patchPointI]
+thickness[patchPointI]
)
//<< " since near medial at:" << medialVec[pointI]
//<< " with thicknessRatio:" << thicknessRatio
<< " medial direction:" << mVec
<< " extrusion direction:" << n
<< " with thicknessRatio:" << thicknessRatio
<< endl;
}
@ -1124,6 +1141,16 @@ void Foam::autoLayerDriver::shrinkMeshMedialDistance
vertI++;
str()<< "l " << vertI-1 << ' ' << vertI << nl;
}
if (medialVecStr.valid())
{
const point& pt = mesh.points()[pointI];
meshTools::writeOBJ(medialVecStr(), pt);
medialVertI++;
meshTools::writeOBJ(medialVecStr(), medialVec[pointI]);
medialVertI++;
medialVecStr()<< "l " << medialVertI-1
<< ' ' << medialVertI << nl;
}
}
}
}
@ -1228,6 +1255,15 @@ void Foam::autoLayerDriver::shrinkMeshMedialDistance
)
)()
);
// Above move will have changed the instance only on the points (which
// is correct).
// However the previous mesh written will be the mesh with layers
// (see autoLayerDriver.C) so we now have to force writing all files
// so we can easily step through time steps. Note that if you
// don't write the mesh with layers this is not necessary.
meshRefiner_.mesh().setInstance(meshRefiner_.timeName());
meshRefiner_.write
(
debug,

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -103,9 +103,9 @@ License
Note: writes out .dgr files for debugging. Run with e.g.
Note: writeGraph=true : writes out .dgr files for debugging. Run with e.g.
mpirun -np 4 dgpart 2 'processor%r.grf'
mpirun -np 4 dgpart 2 'region0_%r.dgr'
- %r gets replaced by current processor rank
- decompose into 2 domains
@ -167,192 +167,192 @@ void Foam::ptscotchDecomp::check(const int retVal, const char* str)
}
//- Does prevention of 0 cell domains and calls ptscotch.
Foam::label Foam::ptscotchDecomp::decomposeZeroDomains
(
const fileName& meshPath,
const List<int>& initadjncy,
const List<int>& initxadj,
const scalarField& initcWeights,
List<int>& finalDecomp
) const
{
globalIndex globalCells(initxadj.size()-1);
bool hasZeroDomain = false;
for (label procI = 0; procI < Pstream::nProcs(); procI++)
{
if (globalCells.localSize(procI) == 0)
{
hasZeroDomain = true;
break;
}
}
if (!hasZeroDomain)
{
return decompose
(
meshPath,
initadjncy,
initxadj,
initcWeights,
finalDecomp
);
}
if (debug)
{
Info<< "ptscotchDecomp : have graphs with locally 0 cells."
<< " trickling down." << endl;
}
// Make sure every domain has at least one cell
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// (scotch does not like zero sized domains)
// Trickle cells from processors that have them up to those that
// don't.
// Number of cells to send to the next processor
// (is same as number of cells next processor has to receive)
List<int> nSendCells(Pstream::nProcs(), 0);
for (label procI = nSendCells.size()-1; procI >=1; procI--)
{
label nLocalCells = globalCells.localSize(procI);
if (nLocalCells-nSendCells[procI] < 1)
{
nSendCells[procI-1] = nSendCells[procI]-nLocalCells+1;
}
}
// First receive (so increasing the sizes of all arrays)
Field<int> xadj(initxadj);
Field<int> adjncy(initadjncy);
scalarField cWeights(initcWeights);
if (Pstream::myProcNo() >= 1 && nSendCells[Pstream::myProcNo()-1] > 0)
{
// Receive cells from previous processor
IPstream fromPrevProc(Pstream::blocking, Pstream::myProcNo()-1);
Field<int> prevXadj(fromPrevProc);
Field<int> prevAdjncy(fromPrevProc);
scalarField prevCellWeights(fromPrevProc);
if (prevXadj.size() != nSendCells[Pstream::myProcNo()-1])
{
FatalErrorIn("ptscotchDecomp::decompose(..)")
<< "Expected from processor " << Pstream::myProcNo()-1
<< " connectivity for " << nSendCells[Pstream::myProcNo()-1]
<< " nCells but only received " << prevXadj.size()
<< abort(FatalError);
}
// Insert adjncy
prepend(prevAdjncy, adjncy);
// Adapt offsets and prepend xadj
xadj += prevAdjncy.size();
prepend(prevXadj, xadj);
// Weights
prepend(prevCellWeights, cWeights);
}
// Send to my next processor
if (nSendCells[Pstream::myProcNo()] > 0)
{
// Send cells to next processor
OPstream toNextProc(Pstream::blocking, Pstream::myProcNo()+1);
int nCells = nSendCells[Pstream::myProcNo()];
int startCell = xadj.size()-1 - nCells;
int startFace = xadj[startCell];
int nFaces = adjncy.size()-startFace;
// Send for all cell data: last nCells elements
// Send for all face data: last nFaces elements
toNextProc
<< Field<int>::subField(xadj, nCells, startCell)-startFace
<< Field<int>::subField(adjncy, nFaces, startFace)
<<
(
cWeights.size()
? static_cast<const scalarField&>
(
scalarField::subField(cWeights, nCells, startCell)
)
: scalarField(0)
);
// Remove data that has been sent
if (cWeights.size())
{
cWeights.setSize(cWeights.size()-nCells);
}
adjncy.setSize(adjncy.size()-nFaces);
xadj.setSize(xadj.size() - nCells);
}
// Do decomposition as normal. Sets finalDecomp.
label result = decompose(meshPath, adjncy, xadj, cWeights, finalDecomp);
if (debug)
{
Info<< "ptscotchDecomp : have graphs with locally 0 cells."
<< " trickling up." << endl;
}
// If we sent cells across make sure we undo it
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Receive back from next processor if I sent something
if (nSendCells[Pstream::myProcNo()] > 0)
{
IPstream fromNextProc(Pstream::blocking, Pstream::myProcNo()+1);
List<int> nextFinalDecomp(fromNextProc);
if (nextFinalDecomp.size() != nSendCells[Pstream::myProcNo()])
{
FatalErrorIn("parMetisDecomp::decompose(..)")
<< "Expected from processor " << Pstream::myProcNo()+1
<< " decomposition for " << nSendCells[Pstream::myProcNo()]
<< " nCells but only received " << nextFinalDecomp.size()
<< abort(FatalError);
}
append(nextFinalDecomp, finalDecomp);
}
// Send back to previous processor.
if (Pstream::myProcNo() >= 1 && nSendCells[Pstream::myProcNo()-1] > 0)
{
OPstream toPrevProc(Pstream::blocking, Pstream::myProcNo()-1);
int nToPrevious = nSendCells[Pstream::myProcNo()-1];
toPrevProc <<
SubList<int>
(
finalDecomp,
nToPrevious,
finalDecomp.size()-nToPrevious
);
// Remove locally what has been sent
finalDecomp.setSize(finalDecomp.size()-nToPrevious);
}
return result;
}
////- Does prevention of 0 cell domains and calls ptscotch.
//Foam::label Foam::ptscotchDecomp::decomposeZeroDomains
//(
// const fileName& meshPath,
// const List<int>& initadjncy,
// const List<int>& initxadj,
// const scalarField& initcWeights,
//
// List<int>& finalDecomp
//) const
//{
// globalIndex globalCells(initxadj.size()-1);
//
// bool hasZeroDomain = false;
// for (label procI = 0; procI < Pstream::nProcs(); procI++)
// {
// if (globalCells.localSize(procI) == 0)
// {
// hasZeroDomain = true;
// break;
// }
// }
//
// if (!hasZeroDomain)
// {
// return decompose
// (
// meshPath,
// initadjncy,
// initxadj,
// initcWeights,
// finalDecomp
// );
// }
//
//
// if (debug)
// {
// Info<< "ptscotchDecomp : have graphs with locally 0 cells."
// << " trickling down." << endl;
// }
//
// // Make sure every domain has at least one cell
// // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// // (scotch does not like zero sized domains)
// // Trickle cells from processors that have them up to those that
// // don't.
//
//
// // Number of cells to send to the next processor
// // (is same as number of cells next processor has to receive)
// List<int> nSendCells(Pstream::nProcs(), 0);
//
// for (label procI = nSendCells.size()-1; procI >=1; procI--)
// {
// label nLocalCells = globalCells.localSize(procI);
// if (nLocalCells-nSendCells[procI] < 1)
// {
// nSendCells[procI-1] = nSendCells[procI]-nLocalCells+1;
// }
// }
//
// // First receive (so increasing the sizes of all arrays)
//
// Field<int> xadj(initxadj);
// Field<int> adjncy(initadjncy);
// scalarField cWeights(initcWeights);
//
// if (Pstream::myProcNo() >= 1 && nSendCells[Pstream::myProcNo()-1] > 0)
// {
// // Receive cells from previous processor
// IPstream fromPrevProc(Pstream::blocking, Pstream::myProcNo()-1);
//
// Field<int> prevXadj(fromPrevProc);
// Field<int> prevAdjncy(fromPrevProc);
// scalarField prevCellWeights(fromPrevProc);
//
// if (prevXadj.size() != nSendCells[Pstream::myProcNo()-1])
// {
// FatalErrorIn("ptscotchDecomp::decompose(..)")
// << "Expected from processor " << Pstream::myProcNo()-1
// << " connectivity for " << nSendCells[Pstream::myProcNo()-1]
// << " nCells but only received " << prevXadj.size()
// << abort(FatalError);
// }
//
// // Insert adjncy
// prepend(prevAdjncy, adjncy);
// // Adapt offsets and prepend xadj
// xadj += prevAdjncy.size();
// prepend(prevXadj, xadj);
// // Weights
// prepend(prevCellWeights, cWeights);
// }
//
//
// // Send to my next processor
//
// if (nSendCells[Pstream::myProcNo()] > 0)
// {
// // Send cells to next processor
// OPstream toNextProc(Pstream::blocking, Pstream::myProcNo()+1);
//
// int nCells = nSendCells[Pstream::myProcNo()];
// int startCell = xadj.size()-1 - nCells;
// int startFace = xadj[startCell];
// int nFaces = adjncy.size()-startFace;
//
// // Send for all cell data: last nCells elements
// // Send for all face data: last nFaces elements
// toNextProc
// << Field<int>::subField(xadj, nCells, startCell)-startFace
// << Field<int>::subField(adjncy, nFaces, startFace)
// <<
// (
// cWeights.size()
// ? static_cast<const scalarField&>
// (
// scalarField::subField(cWeights, nCells, startCell)
// )
// : scalarField(0)
// );
//
// // Remove data that has been sent
// if (cWeights.size())
// {
// cWeights.setSize(cWeights.size()-nCells);
// }
// adjncy.setSize(adjncy.size()-nFaces);
// xadj.setSize(xadj.size() - nCells);
// }
//
//
// // Do decomposition as normal. Sets finalDecomp.
// label result = decompose(meshPath, adjncy, xadj, cWeights, finalDecomp);
//
//
// if (debug)
// {
// Info<< "ptscotchDecomp : have graphs with locally 0 cells."
// << " trickling up." << endl;
// }
//
//
// // If we sent cells across make sure we undo it
// // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// // Receive back from next processor if I sent something
// if (nSendCells[Pstream::myProcNo()] > 0)
// {
// IPstream fromNextProc(Pstream::blocking, Pstream::myProcNo()+1);
//
// List<int> nextFinalDecomp(fromNextProc);
//
// if (nextFinalDecomp.size() != nSendCells[Pstream::myProcNo()])
// {
// FatalErrorIn("parMetisDecomp::decompose(..)")
// << "Expected from processor " << Pstream::myProcNo()+1
// << " decomposition for " << nSendCells[Pstream::myProcNo()]
// << " nCells but only received " << nextFinalDecomp.size()
// << abort(FatalError);
// }
//
// append(nextFinalDecomp, finalDecomp);
// }
//
// // Send back to previous processor.
// if (Pstream::myProcNo() >= 1 && nSendCells[Pstream::myProcNo()-1] > 0)
// {
// OPstream toPrevProc(Pstream::blocking, Pstream::myProcNo()-1);
//
// int nToPrevious = nSendCells[Pstream::myProcNo()-1];
//
// toPrevProc <<
// SubList<int>
// (
// finalDecomp,
// nToPrevious,
// finalDecomp.size()-nToPrevious
// );
//
// // Remove locally what has been sent
// finalDecomp.setSize(finalDecomp.size()-nToPrevious);
// }
// return result;
//}
// Call scotch with options from dictionary.
@ -362,13 +362,42 @@ Foam::label Foam::ptscotchDecomp::decompose
const List<int>& adjncy,
const List<int>& xadj,
const scalarField& cWeights,
List<int>& finalDecomp
) const
{
List<int> dummyAdjncy(1);
List<int> dummyXadj(1);
dummyXadj[0] = 0;
return decompose
(
meshPath,
adjncy.size(),
(adjncy.size() ? adjncy.begin() : dummyAdjncy.begin()),
xadj.size(),
(xadj.size() ? xadj.begin() : dummyXadj.begin()),
cWeights,
finalDecomp
);
}
// Call scotch with options from dictionary.
Foam::label Foam::ptscotchDecomp::decompose
(
const fileName& meshPath,
const int adjncySize,
const int adjncy[],
const int xadjSize,
const int xadj[],
const scalarField& cWeights,
List<int>& finalDecomp
) const
{
if (debug)
{
Pout<< "ptscotchDecomp : entering with xadj:" << xadj.size() << endl;
Pout<< "ptscotchDecomp : entering with xadj:" << xadjSize << endl;
}
// Dump graph
@ -387,7 +416,7 @@ Foam::label Foam::ptscotchDecomp::decompose
Pout<< "Dumping Scotch graph file to " << str.name() << endl
<< "Use this in combination with dgpart." << endl;
globalIndex globalCells(xadj.size()-1);
globalIndex globalCells(xadjSize-1);
// Distributed graph file (.grf)
label version = 2;
@ -400,17 +429,17 @@ Foam::label Foam::ptscotchDecomp::decompose
// Total number of vertices (vertglbnbr)
str << globalCells.size();
// Total number of connections (edgeglbnbr)
str << ' ' << returnReduce(xadj[xadj.size()-1], sumOp<label>())
str << ' ' << returnReduce(xadj[xadjSize-1], sumOp<label>())
<< nl;
// Local number of vertices (vertlocnbr)
str << xadj.size()-1;
str << xadjSize-1;
// Local number of connections (edgelocnbr)
str << ' ' << xadj[xadj.size()-1] << nl;
str << ' ' << xadj[xadjSize-1] << nl;
// Numbering starts from 0
label baseval = 0;
// 100*hasVertlabels+10*hasEdgeWeights+1*hasVertWeighs
str << baseval << ' ' << "000" << nl;
for (label cellI = 0; cellI < xadj.size()-1; cellI++)
for (label cellI = 0; cellI < xadjSize-1; cellI++)
{
label start = xadj[cellI];
label end = xadj[cellI+1];
@ -462,8 +491,9 @@ Foam::label Foam::ptscotchDecomp::decompose
// Check for externally provided cellweights and if so initialise weights
scalar minWeights = gMin(cWeights);
scalar maxWeights = gMax(cWeights);
if (!cWeights.empty())
if (maxWeights > minWeights)
{
if (minWeights <= 0)
{
@ -474,13 +504,13 @@ Foam::label Foam::ptscotchDecomp::decompose
<< endl;
}
if (cWeights.size() != xadj.size()-1)
if (cWeights.size() != xadjSize-1)
{
FatalErrorIn
(
"ptscotchDecomp::decompose(..)"
) << "Number of cell weights " << cWeights.size()
<< " does not equal number of cells " << xadj.size()-1
<< " does not equal number of cells " << xadjSize-1
<< exit(FatalError);
}
}
@ -508,7 +538,7 @@ Foam::label Foam::ptscotchDecomp::decompose
Pstream::scatter(rangeScale);
if (!cWeights.empty())
if (maxWeights > minWeights)
{
// Convert to integers.
velotab.setSize(cWeights.size());
@ -532,11 +562,11 @@ Foam::label Foam::ptscotchDecomp::decompose
if (debug)
{
Pout<< "SCOTCH_dgraphBuild with:" << nl
<< "xadj.size()-1 : " << xadj.size()-1 << nl
<< "xadj : " << long(xadj.begin()) << nl
<< "xadjSize-1 : " << xadjSize-1 << nl
<< "xadj : " << long(xadj) << nl
<< "velotab : " << long(velotab.begin()) << nl
<< "adjncy.size() : " << adjncy.size() << nl
<< "adjncy : " << long(adjncy.begin()) << nl
<< "adjncySize : " << adjncySize << nl
<< "adjncy : " << long(adjncy) << nl
<< endl;
}
@ -546,19 +576,19 @@ Foam::label Foam::ptscotchDecomp::decompose
(
&grafdat, // grafdat
0, // baseval, c-style numbering
xadj.size()-1, // vertlocnbr, nCells
xadj.size()-1, // vertlocmax
const_cast<SCOTCH_Num*>(xadj.begin()),
xadjSize-1, // vertlocnbr, nCells
xadjSize-1, // vertlocmax
const_cast<SCOTCH_Num*>(xadj),
// vertloctab, start index per cell into
// adjncy
const_cast<SCOTCH_Num*>(&xadj[1]),// vendloctab, end index ,,
const_cast<SCOTCH_Num*>(xadj+1),// vendloctab, end index ,,
const_cast<SCOTCH_Num*>(velotab.begin()),// veloloctab, vtx weights
NULL, // vlblloctab
adjncy.size(), // edgelocnbr, number of arcs
adjncy.size(), // edgelocsiz
const_cast<SCOTCH_Num*>(adjncy.begin()), // edgeloctab
adjncySize, // edgelocnbr, number of arcs
adjncySize, // edgelocsiz
const_cast<SCOTCH_Num*>(adjncy), // edgeloctab
NULL, // edgegsttab
NULL // edlotab, edge weights
),
@ -620,12 +650,6 @@ Foam::label Foam::ptscotchDecomp::decompose
}
//SCOTCH_Mapping mapdat;
//SCOTCH_dgraphMapInit(&grafdat, &mapdat, &archdat, NULL);
//SCOTCH_dgraphMapCompute(&grafdat, &mapdat, &stradat); /*Perform mapping*/
//SCOTCHdgraphMapExit(&grafdat, &mapdat);
// Hack:switch off fpu error trapping
# ifdef LINUX_GNUC
int oldExcepts = fedisableexcept
@ -636,12 +660,15 @@ Foam::label Foam::ptscotchDecomp::decompose
);
# endif
// Note: always provide allocated storage even if local size 0
finalDecomp.setSize(max(1, xadjSize-1));
finalDecomp = 0;
if (debug)
{
Pout<< "SCOTCH_dgraphMap" << endl;
}
finalDecomp.setSize(xadj.size()-1);
finalDecomp = 0;
check
(
SCOTCH_dgraphMap
@ -660,7 +687,7 @@ Foam::label Foam::ptscotchDecomp::decompose
//finalDecomp.setSize(xadj.size()-1);
//finalDecomp.setSize(xadjSize-1);
//check
//(
// SCOTCH_dgraphPart
@ -719,12 +746,6 @@ Foam::labelList Foam::ptscotchDecomp::decompose
<< exit(FatalError);
}
// // For running sequential ...
// if (Pstream::nProcs() <= 1)
// {
// return scotchDecomp(decompositionDict_, mesh_)
// .decompose(points, pointWeights);
// }
// Make Metis CSR (Compressed Storage Format) storage
// adjncy : contains neighbours (= edges in graph)
@ -743,7 +764,7 @@ Foam::labelList Foam::ptscotchDecomp::decompose
// Decompose using default weights
List<int> finalDecomp;
decomposeZeroDomains
decompose
(
mesh.time().path()/mesh.name(),
cellCells.m(),
@ -753,7 +774,7 @@ Foam::labelList Foam::ptscotchDecomp::decompose
);
// Copy back to labelList
labelList decomp(finalDecomp.size());
labelList decomp(points.size());
forAll(decomp, i)
{
decomp[i] = finalDecomp[i];
@ -780,12 +801,6 @@ Foam::labelList Foam::ptscotchDecomp::decompose
<< exit(FatalError);
}
// // For running sequential ...
// if (Pstream::nProcs() <= 1)
// {
// return scotchDecomp(decompositionDict_, mesh)
// .decompose(agglom, agglomPoints, pointWeights);
// }
// Make Metis CSR (Compressed Storage Format) storage
// adjncy : contains neighbours (= edges in graph)
@ -802,7 +817,7 @@ Foam::labelList Foam::ptscotchDecomp::decompose
// Decompose using weights
List<int> finalDecomp;
decomposeZeroDomains
decompose
(
mesh.time().path()/mesh.name(),
cellCells.m(),
@ -840,13 +855,6 @@ Foam::labelList Foam::ptscotchDecomp::decompose
<< ")." << exit(FatalError);
}
// // For running sequential ...
// if (Pstream::nProcs() <= 1)
// {
// return scotchDecomp(decompositionDict_, mesh)
// .decompose(globalCellCells, cellCentres, cWeights);
// }
// Make Metis CSR (Compressed Storage Format) storage
// adjncy : contains neighbours (= edges in graph)
@ -856,7 +864,7 @@ Foam::labelList Foam::ptscotchDecomp::decompose
// Decompose using weights
List<int> finalDecomp;
decomposeZeroDomains
decompose
(
"ptscotch",
cellCells.m(),
@ -866,7 +874,7 @@ Foam::labelList Foam::ptscotchDecomp::decompose
);
// Copy back to labelList
labelList decomp(finalDecomp.size());
labelList decomp(cellCentres.size());
forAll(decomp, i)
{
decomp[i] = finalDecomp[i];

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -60,17 +60,7 @@ class ptscotchDecomp
//- Check and print error message
static void check(const int, const char*);
//- Decompose with optionally zero sized domains
label decomposeZeroDomains
(
const fileName& meshPath,
const List<int>& initadjncy,
const List<int>& initxadj,
const scalarField& initcWeights,
List<int>& finalDecomp
) const;
//- Decompose
//- Decompose. Handles size 0 arrays
label decompose
(
const fileName& meshPath,
@ -80,6 +70,18 @@ class ptscotchDecomp
List<int>& finalDecomp
) const;
//- Low level decompose
label decompose
(
const fileName& meshPath,
const int adjncySize,
const int adjncy[],
const int xadjSize,
const int xadj[],
const scalarField& cWeights,
List<int>& finalDecomp
) const;
//- Disallow default bitwise copy construct and assignment
void operator=(const ptscotchDecomp&);
ptscotchDecomp(const ptscotchDecomp&);

View File

@ -156,15 +156,24 @@ tmp<volScalarField> kkLOmega::gammaBP(const volScalarField& omega) const
{
return
(
max
min
(
kt_/nu()
/ (
omega
+ dimensionedScalar("ROTVSMALL", omega.dimensions(), ROOTVSMALL)
)
- CbpCrit_,
scalar(0)
max
(
kt_/nu()
/ (
omega
+ dimensionedScalar
(
"ROTVSMALL",
omega.dimensions(),
ROOTVSMALL
)
)
- CbpCrit_,
scalar(0)
),
scalar(50.0)
)
);
}

View File

@ -10,12 +10,14 @@ FoamFile
version 2.0;
format ascii;
class dictionary;
object extrudeProperties;
object extrudeMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// What to extrude:
// patch : from patch of another case ('sourceCase')
// mesh : as above but with original case included
// surface : from externally read surface
constructFrom patch;
sourceCase "../wingMotion_snappyHexMesh";
@ -24,7 +26,8 @@ sourcePatches (front);
// If construct from patch: patch to use for back (can be same as sourcePatch)
exposedPatchName back;
// Flip surface normals before usage.
// Flip surface normals before usage. Valid only for extrude from surface or
// patch.
flipNormals false;
//- Linear extrusion in point-normal direction
@ -41,7 +44,10 @@ linearNormalCoeffs
// Do front and back need to be merged? Usually only makes sense for 360
// degree wedges.
mergeFaces false;
mergeFaces false; //true;
// Merge small edges. Fraction of bounding box.
mergeTol 0;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -15,6 +15,8 @@ runApplication decomposePar
cp system/decomposeParDict-par system/decomposeParDict
runParallel snappyHexMesh 2 -overwrite
# *ProcAddressing files written by decomposePar no longer valid
rm -f processor*/constant/polyMesh/*ProcAddressing
# Add wildcard entries for meshed patches since not preserved
# by decomposePar. Notice -literalRE option to add wildcard itself

View File

@ -32,7 +32,7 @@ writeInterval 50;
purgeWrite 0;
writeFormat ascii;
writeFormat binary; //ascii;
writePrecision 12;