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

This commit is contained in:
andy
2013-06-13 13:00:10 +01:00
27 changed files with 582 additions and 318 deletions

View File

@ -16,7 +16,7 @@ wmakeCheckPwd "$WM_PROJECT_DIR/applications" || {
set -x
wmake all utilities
wmake all solvers
wmake all utilities $*
wmake all solvers $*
# ----------------------------------------------------------------- end-of-file

View File

@ -254,47 +254,85 @@ void Foam::DistributedDelaunayMesh<Triangulation>::findProcessorBoundaryCells
/Pstream::nProcs()
);
std::list<Cell_handle> infinite_cells;
Triangulation::incident_cells
(
Triangulation::infinite_vertex(),
std::back_inserter(infinite_cells)
);
for
(
typename std::list<Cell_handle>::iterator vcit = infinite_cells.begin();
vcit != infinite_cells.end();
++vcit
)
{
Cell_handle cit = *vcit;
// Index of infinite vertex in this cell.
int i = cit->index(Triangulation::infinite_vertex());
Cell_handle c = cit->neighbor(i);
if (c->unassigned())
{
c->cellIndex() = this->getNewCellIndex();
if (checkProcBoundaryCell(c, circumsphereOverlaps))
{
cellToCheck.insert(c->cellIndex());
}
}
}
// std::list<Cell_handle> infinite_cells;
// Triangulation::incident_cells
// (
// Triangulation::infinite_vertex(),
// std::back_inserter(infinite_cells)
// );
//
// for
// (
// typename std::list<Cell_handle>::iterator vcit
// = infinite_cells.begin();
// vcit != infinite_cells.end();
// ++vcit
// )
// {
// Cell_handle cit = *vcit;
//
// // Index of infinite vertex in this cell.
// int i = cit->index(Triangulation::infinite_vertex());
//
// Cell_handle c = cit->neighbor(i);
//
// if (c->unassigned())
// {
// c->cellIndex() = this->getNewCellIndex();
//
// if (checkProcBoundaryCell(c, circumsphereOverlaps))
// {
// cellToCheck.insert(c->cellIndex());
// }
// }
// }
//
//
// for
// (
// Finite_cells_iterator cit = Triangulation::finite_cells_begin();
// cit != Triangulation::finite_cells_end();
// ++cit
// )
// {
// if (cit->parallelDualVertex())
// {
// if (cit->unassigned())
// {
// if (checkProcBoundaryCell(cit, circumsphereOverlaps))
// {
// cellToCheck.insert(cit->cellIndex());
// }
// }
// }
// }
for
(
Finite_cells_iterator cit = Triangulation::finite_cells_begin();
cit != Triangulation::finite_cells_end();
All_cells_iterator cit = Triangulation::all_cells_begin();
cit != Triangulation::all_cells_end();
++cit
)
{
if (cit->parallelDualVertex())
if (Triangulation::is_infinite(cit))
{
// Index of infinite vertex in this cell.
int i = cit->index(Triangulation::infinite_vertex());
Cell_handle c = cit->neighbor(i);
if (c->unassigned())
{
c->cellIndex() = this->getNewCellIndex();
if (checkProcBoundaryCell(c, circumsphereOverlaps))
{
cellToCheck.insert(c->cellIndex());
}
}
}
else if (cit->parallelDualVertex())
{
if (cit->unassigned())
{

View File

@ -1046,6 +1046,18 @@ Foam::conformalVoronoiMesh::conformalVoronoiMesh
)
),
decomposition_()
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::conformalVoronoiMesh::~conformalVoronoiMesh()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void Foam::conformalVoronoiMesh::initialiseForMotion()
{
if (foamyHexMeshControls().objOutput())
{
@ -1061,7 +1073,10 @@ Foam::conformalVoronoiMesh::conformalVoronoiMesh
runTime_,
rndGen_,
geometryToConformTo_,
foamyHexMeshDict.subDict("backgroundMeshDecomposition")
foamyHexMeshControls().foamyHexMeshDict().subDict
(
"backgroundMeshDecomposition"
)
)
);
}
@ -1125,13 +1140,53 @@ Foam::conformalVoronoiMesh::conformalVoronoiMesh
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
void Foam::conformalVoronoiMesh::initialiseForConformation()
{
if (Pstream::parRun())
{
decomposition_.reset
(
new backgroundMeshDecomposition
(
runTime_,
rndGen_,
geometryToConformTo_,
foamyHexMeshControls().foamyHexMeshDict().subDict
(
"backgroundMeshDecomposition"
)
)
);
}
Foam::conformalVoronoiMesh::~conformalVoronoiMesh()
{}
insertInitialPoints();
insertFeaturePoints();
// Improve the guess that the backgroundMeshDecomposition makes with the
// initial positions. Use before building the surface conformation to
// better balance the surface conformation load.
distributeBackground(*this);
buildSurfaceConformation();
// The introduction of the surface conformation may have distorted the
// balance of vertices, distribute if necessary.
distributeBackground(*this);
if (Pstream::parRun())
{
sync(decomposition_().procBounds());
}
cellSizeMeshOverlapsBackground();
if (foamyHexMeshControls().printVertexInfo())
{
printVertexInfo(Info);
}
}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void Foam::conformalVoronoiMesh::move()
{

View File

@ -1038,6 +1038,10 @@ public:
// Member Functions
void initialiseForMotion();
void initialiseForConformation();
//- Move the vertices according to the controller, re-conforming to the
// surface as required
void move();

View File

@ -1787,6 +1787,11 @@ void Foam::conformalVoronoiMesh::indexDualVertices
}
}
OBJstream snapping1("snapToSurface1.obj");
OBJstream snapping2("snapToSurface2.obj");
OFstream tetToSnapTo("tetsToSnapTo.obj");
label offset = 0;
for
(
Delaunay::Finite_cells_iterator cit = finite_cells_begin();
@ -1892,6 +1897,88 @@ void Foam::conformalVoronoiMesh::indexDualVertices
}
}
{
// Snapping points far outside
if (cit->boundaryDualVertex() && !cit->parallelDualVertex())
{
pointFromPoint dual = cit->dual();
pointIndexHit hitInfo;
label surfHit;
// Find nearest surface point
geometryToConformTo_.findSurfaceNearest
(
dual,
sqr(targetCellSize(dual)),
hitInfo,
surfHit
);
if (!hitInfo.hit())
{
// Project dual to nearest point on tet
tetPointRef tet
(
topoint(cit->vertex(0)->point()),
topoint(cit->vertex(1)->point()),
topoint(cit->vertex(2)->point()),
topoint(cit->vertex(3)->point())
);
pointFromPoint nearestPointOnTet =
tet.nearestPoint(dual).rawPoint();
// Get nearest point on surface from tet.
geometryToConformTo_.findSurfaceNearest
(
nearestPointOnTet,
sqr(targetCellSize(nearestPointOnTet)),
hitInfo,
surfHit
);
vector snapDir = nearestPointOnTet - dual;
snapDir /= mag(snapDir) + SMALL;
drawDelaunayCell(tetToSnapTo, cit, offset);
offset += 1;
vectorField norm(1);
allGeometry_[surfHit].getNormal
(
List<pointIndexHit>(1, hitInfo),
norm
);
norm[0] /= mag(norm[0]) + SMALL;
if
(
hitInfo.hit()
&& (mag(snapDir & norm[0]) > 0.5)
)
{
snapping1.write
(
linePointRef(dual, nearestPointOnTet)
);
snapping2.write
(
linePointRef
(
nearestPointOnTet,
hitInfo.hitPoint()
)
);
pts[cit->cellIndex()] = hitInfo.hitPoint();
}
}
}
}
if (cit->boundaryDualVertex())
{
if (cit->featureEdgeDualVertex())

View File

@ -58,7 +58,7 @@ List<Vb::Point> pointFile::initialPoints() const
IOobject
(
pointFileName_.name(),
foamyHexMesh_.time().constant(),
foamyHexMesh_.time().timeName(),
foamyHexMesh_.time(),
IOobject::MUST_READ,
IOobject::NO_WRITE

View File

@ -45,12 +45,22 @@ int main(int argc, char *argv[])
"check all surface geometry for quality"
);
Foam::argList::addBoolOption
(
"conformationOnly",
"conform to the initial points without any point motion"
);
#include "addOverwriteOption.H"
#include "setRootCase.H"
#include "createTime.H"
runTime.functionObjects().off();
const bool checkGeometry = args.optionFound("checkGeometry");
const bool conformationOnly = args.optionFound("conformationOnly");
const bool overwrite = args.optionFound("overwrite");
IOdictionary foamyHexMeshDict
(
@ -104,16 +114,33 @@ int main(int argc, char *argv[])
conformalVoronoiMesh mesh(runTime, foamyHexMeshDict);
while (runTime.loop())
if (conformationOnly)
{
Info<< nl << "Time = " << runTime.timeName() << endl;
mesh.initialiseForConformation();
mesh.move();
if (!overwrite)
{
runTime++;
}
Info<< nl << "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< endl;
mesh.writeMesh(runTime.timeName());
}
else
{
mesh.initialiseForMotion();
while (runTime.loop())
{
Info<< nl << "Time = " << runTime.timeName() << endl;
mesh.move();
Info<< nl << "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< endl;
}
}
Info<< nl << "End" << nl << endl;