diff --git a/applications/utilities/mesh/generation/cvMesh/Make/options b/applications/utilities/mesh/generation/cvMesh/Make/options index 38d9f28fd3..ba06a95ed4 100644 --- a/applications/utilities/mesh/generation/cvMesh/Make/options +++ b/applications/utilities/mesh/generation/cvMesh/Make/options @@ -13,6 +13,7 @@ EXE_INC = \ -I$(LIB_SRC)/conformalVoronoiMesh/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/edgeMesh/lnInclude \ -I$(LIB_SRC)/dynamicMesh/lnInclude \ -I$(LIB_SRC)/triSurface/lnInclude @@ -21,6 +22,7 @@ EXE_LIBS = \ -L$(WM_THIRD_PARTY_DIR)/mpfr-2.4.1/platforms/$(WM_ARCH)$(WM_COMPILER_ARCH)/lib \ -lconformalVoronoiMesh \ -lmeshTools \ + -ledgeMesh \ -ltriSurface \ -ldynamicMesh \ -lboost_thread-gcc43-mt-1_38 \ diff --git a/src/conformalVoronoiMesh/Make/files b/src/conformalVoronoiMesh/Make/files index 87c7993414..25eae8c5a4 100644 --- a/src/conformalVoronoiMesh/Make/files +++ b/src/conformalVoronoiMesh/Make/files @@ -1,10 +1,11 @@ #include CGAL_FILES conformalVoronoiMesh/conformalVoronoiMesh.C +conformalVoronoiMesh/conformalVoronoiMeshIO.C cvControls/cvControls.C -cvSearchableSurfaces/cvSearchableSurfaces.C +conformationSurfaces/conformationSurfaces.C initialPointsMethod/initialPointsMethod/initialPointsMethod.C initialPointsMethod/uniformGrid/uniformGrid.C diff --git a/src/conformalVoronoiMesh/Make/options b/src/conformalVoronoiMesh/Make/options index d58ae360fd..c0f96a7b9a 100644 --- a/src/conformalVoronoiMesh/Make/options +++ b/src/conformalVoronoiMesh/Make/options @@ -12,6 +12,7 @@ EXE_INC = \ -I$(WM_THIRD_PARTY_DIR)/mpfr-2.4.1 \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/edgeMesh/lnInclude \ -I$(LIB_SRC)/dynamicMesh/lnInclude \ -I$(LIB_SRC)/triSurface/lnInclude @@ -19,6 +20,7 @@ EXE_LIBS = \ -L$(BOOST_ROOT)/lib \ -L$(WM_THIRD_PARTY_DIR)/mpfr-2.4.1/platforms/$(WM_ARCH)$(WM_COMPILER_ARCH)/lib \ -lmeshTools \ + -ledgeMesh \ -ltriSurface \ -ldynamicMesh \ -lboost_thread-gcc43-mt-1_38 \ diff --git a/src/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C b/src/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C index 2d87019cb9..cefe9ad26f 100644 --- a/src/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C +++ b/src/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C @@ -39,7 +39,25 @@ Foam::conformalVoronoiMesh::conformalVoronoiMesh : HTriangulation(), runTime_(runTime), - cvSurfaces_(*this, cvMeshDict.subDict("geometry")), + allGeometry_ + ( + IOobject + ( + "cvSearchableSurfacesDirectory", + runTime_.constant(), + "triSurface", + runTime_, + IOobject::MUST_READ, + IOobject::NO_WRITE + ), + cvMeshDict.subDict("geometry") + ), + geometryToConformTo_ + ( + *this, + allGeometry_, + cvMeshDict.subDict("surfaceConformation") + ), cvMeshControls_(*this, cvMeshDict), startOfInternalPoints_(0), startOfSurfacePointPairs_(0), @@ -47,7 +65,7 @@ Foam::conformalVoronoiMesh::conformalVoronoiMesh ( initialPointsMethod::New ( - cvMeshDict.subDict("surfaceConformation").subDict("initialPoints"), + cvMeshDict.subDict("initialPoints"), *this ) ) @@ -123,6 +141,8 @@ void Foam::conformalVoronoiMesh::insertInitialPoints() vit->index() = nVert++; } } + + writePoints("initialPoints.obj", true); } diff --git a/src/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H b/src/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H index 43d89b67b6..17a15205c1 100644 --- a/src/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H +++ b/src/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H @@ -42,11 +42,13 @@ SourceFiles #include "CGALTriangulation3Ddefs.H" -#include "cvSearchableSurfaces.H" +#include "searchableSurfaces.H" +#include "conformationSurfaces.H" #include "cvControls.H" #include "DynamicList.H" #include "Time.H" #include "polyMesh.H" +#include "meshTools.H" #include "triSurfaceTools.H" #include "mathematicalConstants.H" #include "transform.H" @@ -73,8 +75,12 @@ class conformalVoronoiMesh //- The time registry of the application const Time& runTime_; - //- The surfaces to conform to and to use for refinement - cvSearchableSurfaces cvSurfaces_; + //- All geometry of the meshing process, including surfaces to be + // conformed to and those to be used for refinement + searchableSurfaces allGeometry_; + + //- The surfaces to conform to + conformationSurfaces geometryToConformTo_; //- Controls for the conformal Voronoi meshing process cvControls cvMeshControls_; @@ -170,6 +176,9 @@ public: //- Return the Time object inline const Time& time() const; + //- Return the conformationSurfaces object + inline const conformationSurfaces& geometryToConformTo() const; + //- Return the cvMeshControls object inline const cvControls& cvMeshControls() const; @@ -179,6 +188,8 @@ public: // Write + //- Write Delaunay points to .obj file + void writePoints(const fileName& fName, bool internalOnly) const; }; diff --git a/src/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshI.H b/src/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshI.H index 3966417b4e..617bed6788 100644 --- a/src/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshI.H +++ b/src/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshI.H @@ -28,14 +28,69 @@ License // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +#ifdef CGAL_INEXACT + +inline Foam::conformalVoronoiMesh::pointFromPoint +Foam::conformalVoronoiMesh::topoint +( + const Point& P +) const +{ + return reinterpret_cast(P); +} + +inline Foam::conformalVoronoiMesh::PointFrompoint +Foam::conformalVoronoiMesh::toPoint +( + const point& p +) const +{ + return reinterpret_cast(p); +} + +#else + +inline Foam::conformalVoronoiMesh::pointFromPoint +Foam::conformalVoronoiMesh::topoint +( + const Point& P +) const +{ + return point + ( + CGAL::to_double(P.x()), + CGAL::to_double(P.y()), + CGAL::to_double(P.z()) + ); +} + +inline Foam::conformalVoronoiMesh::PointFrompoint +Foam::conformalVoronoiMesh::toPoint +( + const point& p +) const +{ + return Point(p.x(), p.y(), p.z()); +} + +#endif + + inline const Foam::Time& Foam::conformalVoronoiMesh::time() const { return runTime_; } -inline const Foam::cvControls& Foam::conformalVoronoiMesh::cvMeshControls() - const +inline const Foam::conformationSurfaces& +Foam::conformalVoronoiMesh::geometryToConformTo() const +{ + return geometryToConformTo_; +} + + +inline const Foam::cvControls& +Foam::conformalVoronoiMesh::cvMeshControls() const { return cvMeshControls_; } diff --git a/src/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C b/src/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C index 3d70168e3c..3c81334eae 100644 --- a/src/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C +++ b/src/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C @@ -26,45 +26,32 @@ License #include "conformalVoronoiMesh.H" #include "IOstreams.H" +#include "OFstream.H" -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -Foam::conformalVoronoiMesh::conformalVoronoiMesh(Istream& is) -: - base1(is), - base2(is), - member1(is), - member2(is) +void Foam::conformalVoronoiMesh::writePoints +( + const fileName& fName, + bool internalOnly +) const { - // Check state of Istream - is.check("Foam::conformalVoronoiMesh::conformalVoronoiMesh(Foam::Istream&)"); -} + Info<< nl << "Writing points to " << fName << endl; + OFstream str(fName); -// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // - -Foam::Istream& Foam::operator>>(Istream& is, conformalVoronoiMesh&) -{ - // Check state of Istream - is.check + for ( - "Foam::Istream& Foam::operator>>(Foam::Istream&, Foam::conformalVoronoiMesh&)" - ); - - return is; -} - - -Foam::Ostream& Foam::operator<<(Ostream& os, const conformalVoronoiMesh&) -{ - // Check state of Ostream - os.check - ( - "Foam::Ostream& Foam::operator<<(Foam::Ostream&, " - "const Foam::conformalVoronoiMesh&)" - ); - - return os; + Triangulation::Finite_vertices_iterator vit = finite_vertices_begin(); + vit != finite_vertices_end(); + ++vit + ) + { + if (!internalOnly || vit->internalOrBoundaryPoint()) + { + meshTools::writeOBJ(str, topoint(vit->point())); + } + } } diff --git a/src/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C b/src/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C new file mode 100644 index 0000000000..59edd86484 --- /dev/null +++ b/src/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C @@ -0,0 +1,237 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "conformationSurfaces.H" +#include "conformalVoronoiMesh.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::conformationSurfaces::conformationSurfaces +( + const conformalVoronoiMesh& cvMesh, + const searchableSurfaces& allGeometry, + const dictionary& surfaceConformationDict +) +: + cvMesh_(cvMesh), + allGeometry_(allGeometry), + features_ + ( + IOobject + ( + "features", + cvMesh_.time().constant(), + "featureEdgeMesh", + cvMesh_.time(), + IOobject::NO_READ, + IOobject::NO_WRITE + ), + pointField(0), + edgeList(0) + ), + locationInMesh_(surfaceConformationDict.lookup("locationInMesh")), + surfaces_(0), + bounds_() +{ + const dictionary& surfacesDict + ( + surfaceConformationDict.subDict("geometryToConformTo") + ); + + surfaces_.setSize(surfacesDict.size()); + + label surfI = 0; + + forAllConstIter(dictionary, surfacesDict, iter) + { + surfaces_[surfI] = allGeometry_.findSurfaceID(iter().keyword()); + + if (surfaces_[surfI] < 0) + { + FatalErrorIn("Foam::conformationSurfaces::conformationSurfaces") + << "No surface " << iter().keyword() << " found. " + << "Valid geometry is " << nl << allGeometry_.names() + << exit(FatalError); + } + + surfI++; + } + + bounds_ = searchableSurfacesQueries::bounds(allGeometry_, surfaces_); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::conformationSurfaces::~conformationSurfaces() +{} + + +// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // + + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +Foam::Field Foam::conformationSurfaces::inside +( + const pointField& samplePts +) const +{ + return wellInside(samplePts, 0.0); +} + + +Foam::Field Foam::conformationSurfaces::outside +( + const pointField& samplePts +) const +{ + return wellOutside(samplePts, 0.0); +} + + +Foam::Field Foam::conformationSurfaces::wellInside +( + const pointField& samplePts, + const scalar dist2 +) const +{ + // Look at all surfaces at determine whether the locationInMesh point is + // inside or outside each, to establish a signature for the domain to be + // meshed. + + List referenceVolumeTypes + ( + surfaces_.size(), + searchableSurface::UNKNOWN + ); + + forAll(surfaces_, s) + { + const searchableSurface& surface(allGeometry_[surfaces_[s]]); + + if (surface.hasVolumeType()) + { + pointField pts(1, locationInMesh_); + + List vTypes + ( + pts.size(), + searchableSurface::UNKNOWN + ); + + surface.getVolumeType(pts, vTypes); + + referenceVolumeTypes[s] = vTypes[0]; + } + } + + List > surfaceVolumeTests + ( + surfaces_.size(), + List + ( + samplePts.size(), + searchableSurface::UNKNOWN + ) + ); + + // Get lists for the volumeTypes for each sample wrt each surface + forAll(surfaces_, s) + { + const searchableSurface& surface(allGeometry_[surfaces_[s]]); + + if (surface.hasVolumeType()) + { + surface.getVolumeType(samplePts, surfaceVolumeTests[s]); + } + } + + // Compare the volumeType result for each point wrt to each surface with the + // reference value and if the points are inside the surface by a given + // distanceSquared + + Field insidePoints(samplePts.size(), true); + + //Check if the points are inside the surface by the given distance squared + + scalarField testDistSqr(insidePoints.size(), dist2); + + labelList hitSurfaces; + + List hitInfo; + + searchableSurfacesQueries::findNearest + ( + allGeometry_, + surfaces_, + samplePts, + testDistSqr, + hitSurfaces, + hitInfo + ); + + forAll(samplePts, i) + { + const pointIndexHit& pHit = hitInfo[i]; + + if (pHit.hit()) + { + insidePoints[i] = false; + + continue; + } + + forAll(surfaces_, s) + { + if (surfaceVolumeTests[s][i] != referenceVolumeTypes[s]) + { + insidePoints[i] = false; + + break; + } + } + } + + return insidePoints; +} + + +Foam::Field Foam::conformationSurfaces::wellOutside +( + const pointField& samplePts, + const scalar dist2 +) const +{ + notImplemented("Field Foam::conformationSurfaces::wellOutside"); + + return Field(samplePts.size(), true); +} + + + +// ************************************************************************* // diff --git a/src/conformalVoronoiMesh/cvSearchableSurfaces/cvSearchableSurfaces.H b/src/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.H similarity index 50% rename from src/conformalVoronoiMesh/cvSearchableSurfaces/cvSearchableSurfaces.H rename to src/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.H index 9188e37721..ff3203b1f2 100644 --- a/src/conformalVoronoiMesh/cvSearchableSurfaces/cvSearchableSurfaces.H +++ b/src/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.H @@ -23,22 +23,23 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Class - Foam::cvSearchableSurfaces + Foam::conformationSurfaces Description - The surface geometry to be meshed with a conformalVoronoiMesh, adding - inside/outside queries and features of the surface SourceFiles - cvSearchableSurfaces.C + conformationSurfacesI.H + conformationSurfaces.C + conformationSurfacesIO.C \*---------------------------------------------------------------------------*/ -#ifndef cvSearchableSurfaces_H -#define cvSearchableSurfaces_H +#ifndef conformationSurfaces_H +#define conformationSurfaces_H #include "searchableSurfaces.H" -#include "surfaceFeatures.H" +#include "searchableSurfacesQueries.H" +#include "featureEdgeMesh.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -48,60 +49,101 @@ namespace Foam // Forward declaration of classes class conformalVoronoiMesh; + /*---------------------------------------------------------------------------*\ - Class cvSearchableSurfaces Declaration + Class conformationSurfaces Declaration \*---------------------------------------------------------------------------*/ -class cvSearchableSurfaces -: - public searchableSurfaces +class conformationSurfaces { // Private data //- Reference to the conformalVoronoiMesh holding this cvControls object const conformalVoronoiMesh& cvMesh_; + //- Reference to the searchableSurfaces object holding all geometry data + const searchableSurfaces& allGeometry_; + + //- Feature Edges and points + featureEdgeMesh features_; + + //- The location in the mesh that specifies which portion of surfaces is + // to be meshed. + point locationInMesh_; + + //- Indices of surfaces in allGeometry that are to be conformed to + labelList surfaces_; + + //- The overall boundBox of all of the surfaces to be conformed to + boundBox bounds_; + + // Private Member Functions //- Disallow default bitwise copy construct - cvSearchableSurfaces(const cvSearchableSurfaces&); + conformationSurfaces(const conformationSurfaces&); //- Disallow default bitwise assignment - void operator=(const cvSearchableSurfaces&); + void operator=(const conformationSurfaces&); public: // Constructors - //- Construct from components - cvSearchableSurfaces + //- Construct from references to conformalVoronoiMesh and + //- searchableSurfaces + conformationSurfaces ( const conformalVoronoiMesh& cvMesh, - const dictionary& geometryDict + const searchableSurfaces& allGeometry, + const dictionary& surfaceConformationDict ); //- Destructor - ~cvSearchableSurfaces(); + ~conformationSurfaces(); // Member Functions // Access + //- Return reference to the searchableSurfaces object containing all + // of the geometry + inline const searchableSurfaces& geometry() const; + + //- Return the surface indices + inline const labelList& surfaces() const; + + //- Return the boundBox + inline const boundBox& bounds() const; + + // Query - //- Check if point is inside surfacesToConformTo - bool inside(const point& pt) const; + //- Check if point is inside surfaces to conform to + Field inside(const pointField& samplePts) const; - //- Check if point is outside surfacesToConformTo - bool outside(const point& pt) const; + //- Check if point is outside surfaces to conform to + Field outside(const pointField& samplePts) const; - //- Check if point is inside surfacesToConformTo by at least dist2 - bool wellInside(const point& pt, const scalar dist2) const; + //- Check if point is inside surfaces to conform to by at least + // dist2 + Field wellInside + ( + const pointField& samplePts, + const scalar dist2 + ) const; - //- Check if point is outside surfacesToConformTo by at least dist2 - bool wellOutside(const point& pt, const scalar dist2) const; + //- Check if point is outside surfaces to conform to by at least + // dist2 + Field wellOutside + ( + const pointField& samplePts, + const scalar dist2 + ) const; + + // Member Operators }; @@ -112,7 +154,7 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#include "cvSearchableSurfacesI.H" +#include "conformationSurfacesI.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/conformalVoronoiMesh/cvSearchableSurfaces/cvSearchableSurfacesI.H b/src/conformalVoronoiMesh/conformationSurfaces/conformationSurfacesI.H similarity index 70% rename from src/conformalVoronoiMesh/cvSearchableSurfaces/cvSearchableSurfacesI.H rename to src/conformalVoronoiMesh/conformationSurfaces/conformationSurfacesI.H index 42bc929311..0b2538aa42 100644 --- a/src/conformalVoronoiMesh/cvSearchableSurfaces/cvSearchableSurfacesI.H +++ b/src/conformalVoronoiMesh/conformationSurfaces/conformationSurfacesI.H @@ -26,31 +26,24 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - - -// * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * // - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - - // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // - -// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * // +const Foam::searchableSurfaces& Foam::conformationSurfaces::geometry() const +{ + return allGeometry_; +} -// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // +const Foam::labelList& Foam::conformationSurfaces::surfaces() const +{ + return surfaces_; +} -// * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * * // - - -// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * // +const Foam::boundBox& Foam::conformationSurfaces::bounds() const +{ + return bounds_; +} // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/conformalVoronoiMesh/cvSearchableSurfaces/cvSearchableSurfaces.C b/src/conformalVoronoiMesh/cvSearchableSurfaces/cvSearchableSurfaces.C deleted file mode 100644 index f01781726f..0000000000 --- a/src/conformalVoronoiMesh/cvSearchableSurfaces/cvSearchableSurfaces.C +++ /dev/null @@ -1,99 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM; if not, write to the Free Software Foundation, - Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -\*---------------------------------------------------------------------------*/ - -#include "cvSearchableSurfaces.H" -#include "conformalVoronoiMesh.H" - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::cvSearchableSurfaces::cvSearchableSurfaces -( - const conformalVoronoiMesh& cvMesh, - const dictionary& geometryDict -) -: - searchableSurfaces - ( - IOobject - ( - "cvSearchableSurfacesDirectory", - cvMesh.time().constant(), - "triSurface", - cvMesh.time(), - IOobject::MUST_READ, - IOobject::NO_WRITE - ), - geometryDict - ), - cvMesh_(cvMesh) -{} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::cvSearchableSurfaces::~cvSearchableSurfaces() -{} - - -// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // - - - -// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // - -bool Foam::cvSearchableSurfaces::inside(const point& pt) const -{ - -} - - -bool Foam::cvSearchableSurfaces::outside(const point& pt) const -{ - -} - - -bool Foam::cvSearchableSurfaces::wellInside -( - const point& pt, - const scalar dist2 -) const -{ - -} - - -bool Foam::cvSearchableSurfaces::wellOutside -( - const point& pt, - const scalar dist2 -) const -{ - -} - - -// ************************************************************************* // diff --git a/src/conformalVoronoiMesh/initialPointsMethod/pointFile/pointFile.C b/src/conformalVoronoiMesh/initialPointsMethod/pointFile/pointFile.C index 97ebb3d688..0d72fda33a 100644 --- a/src/conformalVoronoiMesh/initialPointsMethod/pointFile/pointFile.C +++ b/src/conformalVoronoiMesh/initialPointsMethod/pointFile/pointFile.C @@ -68,13 +68,20 @@ std::vector pointFile::initialPoints() const std::vector initialPoints; - forAll(points, i) + Field insidePoints = cvMesh_.geometryToConformTo().wellInside + ( + points, + minimumSurfaceDistance_*minimumSurfaceDistance_ + ); + + forAll(insidePoints, i) { - const point& p = points[i]; + if (insidePoints[i]) + { + const point& p(points[i]); - // TODO Check if inside the surface - - initialPoints.push_back(Vb::Point(p.x(), p.y(), p.z())); + initialPoints.push_back(Vb::Point(p.x(), p.y(), p.z())); + } } label nPointsRejected = points.size() - initialPoints.size(); @@ -85,7 +92,6 @@ std::vector pointFile::initialPoints() const << pointFileName_.name() << endl; } - return initialPoints; } diff --git a/src/conformalVoronoiMesh/initialPointsMethod/uniformGrid/uniformGrid.C b/src/conformalVoronoiMesh/initialPointsMethod/uniformGrid/uniformGrid.C index 40dcf9c237..0ac9fb53b7 100644 --- a/src/conformalVoronoiMesh/initialPointsMethod/uniformGrid/uniformGrid.C +++ b/src/conformalVoronoiMesh/initialPointsMethod/uniformGrid/uniformGrid.C @@ -48,10 +48,9 @@ uniformGrid::uniformGrid initialPointsMethod(typeName, initialPointsDict, cvMesh), initialCellSize_(readScalar(detailsDict().lookup("initialCellSize"))), randomiseInitialGrid_(detailsDict().lookup("randomiseInitialGrid")), - randomPerturbation_ + randomPerturbationCoeff_ ( readScalar(detailsDict().lookup("randomPerturbationCoeff")) - *initialCellSize_ ) {} @@ -60,47 +59,41 @@ uniformGrid::uniformGrid std::vector uniformGrid::initialPoints() const { - // scalar x0 = qSurf_.bb().min().x(); - // scalar xR = qSurf_.bb().max().x() - x0; - // int ni = int(xR/controls_.minCellSize) + 1; + const boundBox& bb = cvMesh_.geometryToConformTo().bounds(); - // scalar y0 = qSurf_.bb().min().y(); - // scalar yR = qSurf_.bb().max().y() - y0; - // int nj = int(yR/controls_.minCellSize) + 1; + Info<< bb << endl; - // scalar z0 = qSurf_.bb().min().z(); - // scalar zR = qSurf_.bb().max().z() - z0; - // int nk = int(zR/controls_.minCellSize) + 1; + scalar x0 = bb.min().x(); + scalar xR = bb.max().x() - x0; + int ni = int(xR/initialCellSize_) + 1; + + scalar y0 = bb.min().y(); + scalar yR = bb.max().y() - y0; + int nj = int(yR/initialCellSize_) + 1; + + scalar z0 = bb.min().z(); + scalar zR = bb.max().z() - z0; + int nk = int(zR/initialCellSize_) + 1; Info<< " Is this actually uniform? or is it fitting the span with an " << "integer number?" << endl; - scalar x0 = 0.0; - scalar xR = 1.0 - x0; - int ni = int(xR/initialCellSize_) + 1; - - scalar y0 = 0.0; - scalar yR = 1.0 - y0; - int nj = int(yR/initialCellSize_) + 1; - - scalar z0 = 0.0; - scalar zR = 1.0 - z0; - int nk = int(zR/initialCellSize_) + 1; - vector delta(xR/ni, yR/nj, zR/nk); delta *= pow((1.0),-(1.0/3.0)); Random rndGen(1735621); - scalar pert = randomPerturbation_*cmptMin(delta); + scalar pert = randomPerturbationCoeff_*cmptMin(delta); - std::vector initialPoints; + pointField points(ni*nj*nk); - for (int i=0; i uniformGrid::initialPoints() const p.z() += pert*(rndGen.scalar01() - 0.5); } - // if (qSurf_.wellInside(p, 0.5*initialCellSize_2)) - // { - initialPoints.push_back(Vb::Point(p.x(), p.y(), p.z())); - // } + points[pI++] = p; } } } + std::vector initialPoints; + + Field insidePoints = cvMesh_.geometryToConformTo().wellInside + ( + points, + minimumSurfaceDistance_*minimumSurfaceDistance_ + ); + + forAll(insidePoints, i) + { + if (insidePoints[i]) + { + const point& p(points[i]); + + initialPoints.push_back(Vb::Point(p.x(), p.y(), p.z())); + } + } + return initialPoints; } diff --git a/src/conformalVoronoiMesh/initialPointsMethod/uniformGrid/uniformGrid.H b/src/conformalVoronoiMesh/initialPointsMethod/uniformGrid/uniformGrid.H index ca10d5e86d..70f36e4417 100644 --- a/src/conformalVoronoiMesh/initialPointsMethod/uniformGrid/uniformGrid.H +++ b/src/conformalVoronoiMesh/initialPointsMethod/uniformGrid/uniformGrid.H @@ -66,7 +66,7 @@ private: Switch randomiseInitialGrid_; //- Randomise the initial positions by fraction of the initialCellSize_ - scalar randomPerturbation_; + scalar randomPerturbationCoeff_; public: