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