mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Changed all reading to IOobjects and using the time controls for run control. Printing the tet vertex locations before calculating the dual to see assertion failure cause.
This commit is contained in:
@ -26,7 +26,6 @@ License
|
||||
|
||||
#include "CV3D.H"
|
||||
#include "Random.H"
|
||||
#include "IFstream.H"
|
||||
#include "uint.H"
|
||||
#include "ulong.H"
|
||||
|
||||
@ -49,7 +48,7 @@ void Foam::CV3D::insertBoundingBox()
|
||||
|
||||
void Foam::CV3D::reinsertPoints(const pointField& points)
|
||||
{
|
||||
Info<< "Reinserting points after motion. ";
|
||||
Info<< nl << "Reinserting points after motion. ";
|
||||
|
||||
startOfInternalPoints_ = number_of_vertices();
|
||||
label nVert = startOfInternalPoints_;
|
||||
@ -70,14 +69,43 @@ void Foam::CV3D::reinsertPoints(const pointField& points)
|
||||
|
||||
Foam::CV3D::CV3D
|
||||
(
|
||||
const dictionary& controlDict,
|
||||
const Time& runTime,
|
||||
const querySurface& qSurf
|
||||
)
|
||||
:
|
||||
HTriangulation(),
|
||||
qSurf_(qSurf),
|
||||
controls_(controlDict),
|
||||
tols_(controlDict, controls_.minCellSize, qSurf.bb()),
|
||||
runTime_(runTime),
|
||||
controls_
|
||||
(
|
||||
IOdictionary
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"CV3DMesherDict",
|
||||
runTime_.system(),
|
||||
runTime_,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
)
|
||||
),
|
||||
tols_
|
||||
(
|
||||
IOdictionary
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"CV3DMesherDict",
|
||||
runTime_.system(),
|
||||
runTime_,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
),
|
||||
controls_.minCellSize,
|
||||
qSurf.bb()
|
||||
),
|
||||
startOfInternalPoints_(0),
|
||||
startOfSurfacePointPairs_(0),
|
||||
featureConstrainingVertices_(0)
|
||||
@ -137,18 +165,19 @@ void Foam::CV3D::insertPoints
|
||||
|
||||
void Foam::CV3D::insertPoints(const fileName& pointFileName)
|
||||
{
|
||||
IFstream pointsFile(pointFileName);
|
||||
pointIOField points
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
pointFileName.name(),
|
||||
pointFileName.path(),
|
||||
runTime_,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
);
|
||||
|
||||
if (pointsFile.good())
|
||||
{
|
||||
insertPoints(pointField(pointsFile), 0.5*controls_.minCellSize2);
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorIn("insertInitialPoints")
|
||||
<< "Could not open pointsFile " << pointFileName
|
||||
<< exit(FatalError);
|
||||
}
|
||||
insertPoints(points, 0.5*controls_.minCellSize2);
|
||||
}
|
||||
|
||||
|
||||
@ -262,7 +291,15 @@ void Foam::CV3D::relaxPoints(const scalar relaxation)
|
||||
)
|
||||
{
|
||||
cit->cellIndex() = dualVerti;
|
||||
|
||||
Info<< nl << topoint(cit->vertex(0)->point())
|
||||
<< nl << topoint(cit->vertex(1)->point())
|
||||
<< nl << topoint(cit->vertex(2)->point())
|
||||
<< nl << topoint(cit->vertex(3)->point())
|
||||
<< endl;
|
||||
|
||||
dualVertices[dualVerti] = topoint(dual(cit));
|
||||
|
||||
dualVerti++;
|
||||
}
|
||||
else
|
||||
@ -369,6 +406,12 @@ void Foam::CV3D::relaxPoints(const scalar relaxation)
|
||||
startOfInternalPoints_
|
||||
);
|
||||
|
||||
// Write the mesh before clearing it
|
||||
if (runTime_.outputTime())
|
||||
{
|
||||
writeMesh(true);
|
||||
}
|
||||
|
||||
// Remove the entire triangulation
|
||||
this->clear();
|
||||
|
||||
@ -426,18 +469,18 @@ void Foam::CV3D::removeSurfacePointPairs()
|
||||
}
|
||||
|
||||
|
||||
void Foam::CV3D::write() const
|
||||
void Foam::CV3D::write()
|
||||
{
|
||||
if (controls_.writeFinalTriangulation)
|
||||
{
|
||||
writePoints("allPoints.obj", false);
|
||||
writePoints("points.obj", true);
|
||||
// writeFaces("allFaces.obj", false);
|
||||
// writeFaces("faces.obj", true);
|
||||
writeTriangles("allTriangles.obj", false);
|
||||
writeTriangles("triangles.obj", true);
|
||||
// writeMesh();
|
||||
writeDual("dualMesh.obj");
|
||||
}
|
||||
|
||||
writeMesh();
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -49,7 +49,9 @@ SourceFiles
|
||||
#include "CGALTriangulation3Ddefs.H"
|
||||
|
||||
#include "querySurface.H"
|
||||
#include "dictionary.H"
|
||||
#include "IOdictionary.H"
|
||||
#include "pointIOField.H"
|
||||
#include "argList.H"
|
||||
#include "DynamicList.H"
|
||||
#include "Switch.H"
|
||||
#include "Time.H"
|
||||
@ -132,7 +134,7 @@ public:
|
||||
Switch randomiseInitialGrid;
|
||||
scalar randomPerturbation;
|
||||
|
||||
controls(const dictionary& controlDict);
|
||||
controls(const IOdictionary& controlDict);
|
||||
};
|
||||
|
||||
class tolerances
|
||||
@ -178,7 +180,7 @@ public:
|
||||
|
||||
tolerances
|
||||
(
|
||||
const dictionary& controlDict,
|
||||
const IOdictionary& controlDict,
|
||||
scalar minCellSize,
|
||||
const boundBox&
|
||||
);
|
||||
@ -191,6 +193,9 @@ private:
|
||||
//- The surface to mesh
|
||||
const querySurface& qSurf_;
|
||||
|
||||
//- The time registry of the application
|
||||
const Time& runTime_;
|
||||
|
||||
//- Meshing controls
|
||||
controls controls_;
|
||||
|
||||
@ -330,7 +335,11 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct for given surface
|
||||
CV3D(const dictionary& controlDict, const querySurface& qSurf);
|
||||
CV3D
|
||||
(
|
||||
const Time& runTime,
|
||||
const querySurface& qSurf
|
||||
);
|
||||
|
||||
// Destructor
|
||||
|
||||
@ -415,9 +424,9 @@ public:
|
||||
void writeDual(const fileName& fName) const;
|
||||
|
||||
//- Write polyMesh
|
||||
void writeMesh(const Time& runTime);
|
||||
void writeMesh(bool writeToTimestep = false);
|
||||
|
||||
void write() const;
|
||||
void write();
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -187,10 +187,8 @@ void Foam::CV3D::writeTriangles(const fileName& fName, bool internalOnly) const
|
||||
}
|
||||
}
|
||||
|
||||
void Foam::CV3D::writeMesh(const Time& runTime)
|
||||
void Foam::CV3D::writeMesh(bool writeToTimestep)
|
||||
{
|
||||
Info<< nl << "Writing polyMesh." << endl;
|
||||
|
||||
pointField points(0);
|
||||
faceList faces(0);
|
||||
labelList owner(0);
|
||||
@ -210,15 +208,35 @@ void Foam::CV3D::writeMesh(const Time& runTime)
|
||||
patchStarts
|
||||
);
|
||||
|
||||
|
||||
IOobject io
|
||||
(
|
||||
Foam::polyMesh::defaultRegion,
|
||||
runTime.constant(),
|
||||
runTime,
|
||||
runTime_.constant(),
|
||||
runTime_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
);
|
||||
|
||||
if (writeToTimestep)
|
||||
{
|
||||
Info<< nl << "Writing polyMesh to time directory "
|
||||
<< runTime_.timeName() << endl;
|
||||
|
||||
io = IOobject
|
||||
(
|
||||
Foam::polyMesh::defaultRegion,
|
||||
runTime_.path()/runTime_.timeName(),
|
||||
runTime_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< nl << "Writing polyMesh to constant." << endl;
|
||||
}
|
||||
|
||||
polyMesh pMesh
|
||||
(
|
||||
io,
|
||||
@ -246,7 +264,7 @@ void Foam::CV3D::writeMesh(const Time& runTime)
|
||||
|
||||
if (!pMesh.write())
|
||||
{
|
||||
FatalErrorIn("CV3D::writeMesh(const Time& runTime)")
|
||||
FatalErrorIn("CV3D::writeMesh()")
|
||||
<< "Failed writing polyMesh."
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
@ -49,22 +49,24 @@ int main(int argc, char *argv[])
|
||||
# include "setRootCase.H"
|
||||
# include "createTime.H"
|
||||
|
||||
// Read control dictionary
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
dictionary controlDict
|
||||
IOdictionary CV3DMesherDict
|
||||
(
|
||||
IFstream(runTime.system()/args.executable() + "Dict")()
|
||||
IOobject
|
||||
(
|
||||
"CV3DMesherDict",
|
||||
runTime.system(),
|
||||
runTime,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
);
|
||||
|
||||
label nIterations(readLabel(controlDict.lookup("nIterations")));
|
||||
|
||||
// Read the surface to conform to
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
querySurface surf
|
||||
(
|
||||
args.args()[1],
|
||||
readScalar(controlDict.lookup("includedAngle"))
|
||||
readScalar(CV3DMesherDict.lookup("includedAngle"))
|
||||
);
|
||||
|
||||
Info<< nl
|
||||
@ -74,7 +76,7 @@ int main(int argc, char *argv[])
|
||||
// Read and triangulation
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
CV3D mesh(controlDict, surf);
|
||||
CV3D mesh(runTime, surf);
|
||||
|
||||
if (args.options().found("pointsFile"))
|
||||
{
|
||||
@ -93,6 +95,12 @@ int main(int argc, char *argv[])
|
||||
scalar relaxation =
|
||||
mesh.meshingControls().relaxationFactorStart;
|
||||
|
||||
label nIterations = label
|
||||
(
|
||||
(runTime.endTime().value() - runTime.startTime().value())
|
||||
/runTime.deltaT().value()
|
||||
);
|
||||
|
||||
scalar relaxationDelta =
|
||||
(
|
||||
mesh.meshingControls().relaxationFactorStart
|
||||
@ -100,10 +108,12 @@ int main(int argc, char *argv[])
|
||||
)
|
||||
/max(nIterations, 1);
|
||||
|
||||
for (label iter = 0; iter < nIterations; iter++)
|
||||
while (runTime.run())
|
||||
{
|
||||
runTime++;
|
||||
|
||||
Info<< nl
|
||||
<< "Relaxation iteration " << iter << nl
|
||||
<< "Relaxation iteration " << runTime.timeIndex() << nl
|
||||
<< "~~~~~~~~~~~~~~~~~~~~~~~~" << endl;
|
||||
|
||||
Info<< "relaxation = " << relaxation << endl;
|
||||
@ -119,10 +129,6 @@ int main(int argc, char *argv[])
|
||||
|
||||
mesh.write();
|
||||
|
||||
mesh.writeDual("dualMesh.obj");
|
||||
|
||||
mesh.writeMesh(runTime);
|
||||
|
||||
Info << nl << "End\n" << endl;
|
||||
|
||||
return 0;
|
||||
|
||||
@ -39,8 +39,6 @@ void Foam::CV3D::calcDualMesh
|
||||
labelList& patchStarts
|
||||
)
|
||||
{
|
||||
Info << nl << "Calculating Voronoi diagram." << endl;
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ dual points ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
points.setSize(number_of_cells());
|
||||
|
||||
@ -28,7 +28,7 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::CV3D::controls::controls(const dictionary& controlDict)
|
||||
Foam::CV3D::controls::controls(const IOdictionary& controlDict)
|
||||
:
|
||||
relaxationFactorStart
|
||||
(
|
||||
|
||||
@ -30,7 +30,7 @@ License
|
||||
|
||||
Foam::CV3D::tolerances::tolerances
|
||||
(
|
||||
const dictionary& controlDict,
|
||||
const IOdictionary& controlDict,
|
||||
const scalar minCellSize,
|
||||
const boundBox& bb
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user