Skip to content

Commit

Permalink
Move surface mesh creation to ViennaLS
Browse files Browse the repository at this point in the history
  • Loading branch information
tobre1 committed Nov 18, 2024
1 parent 20bea7f commit fea82ac
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 550 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ CPMFindPackage(

CPMFindPackage(
NAME ViennaLS
VERSION 4.0.1
# VERSION 4.0.1
GIT_TAG refined-surface-mesh
GIT_REPOSITORY "https://github.com/ViennaTools/ViennaLS"
EXCLUDE_FROM_ALL ${VIENNAPS_BUILD_PYTHON})

Expand Down
5 changes: 3 additions & 2 deletions gpu/benchmark/GPU_Benchmark.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <context.hpp>

#include <culsToSurfaceMesh.hpp>
#include <curtTracer.hpp>
#include <lsToSurfaceMeshRefined.hpp>
#include <pscuDeposition.hpp>

#include <psMakeTrench.hpp>
Expand Down Expand Up @@ -32,7 +32,8 @@ int main() {

{
auto mesh = SmartPointer<viennals::Mesh<NumericType>>::New();
viennaps::gpu::ToSurfaceMesh<NumericType, D> mesher(domain, mesh, tree);
viennals::ToSurfaceMeshRefined<NumericType, NumericType, D> mesher(
domain, mesh, tree);

Timer timer;
timer.start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
#include <CGAL/Surface_mesh.h>

#include <psDomain.hpp>
#include <psSmartPointer.hpp>

// WARNING: THIS ONLY WORK FOR GEOMETRIES WHICH PROJECT NICELY ON THE XY PLANE.
template <class NumericType> class culsRefineMesh {
namespace viennaps {

using namespace viennacore;

template <class NumericType> class RefineMesh {
typedef CGAL::Simple_cartesian<double> K;
typedef CGAL::Surface_mesh<K::Point_3> SM;
typedef boost::property_map<SM, CGAL::vertex_point_t>::type VPMap;
Expand All @@ -21,14 +23,14 @@ template <class NumericType> class culsRefineMesh {
typedef boost::graph_traits<SM>::face_descriptor face_descriptor;
typedef boost::graph_traits<SM>::halfedge_descriptor halfedge_descriptor;

psSmartPointer<lsMesh<NumericType>> mesh = nullptr;
SmartPointer<viennals::Mesh<NumericType>> mesh = nullptr;
double length = 1.;
unsigned iterations = 100;

public:
culsRefineMesh() {}
culsRefineMesh(psSmartPointer<lsMesh<NumericType>> passedMesh,
const NumericType passedLength)
RefineMesh() {}
RefineMesh(SmartPointer<viennals::Mesh<NumericType>> passedMesh,
const NumericType passedLength)
: mesh(passedMesh), length(passedLength) {}

void apply() {
Expand Down Expand Up @@ -73,7 +75,7 @@ template <class NumericType> class culsRefineMesh {
sm.remove_vertex(isolated_vertices[i]);

if (!is_triangle_mesh(sm)) {
psLogger::getInstance()
Logger::getInstance()
.addWarning("The surface mesh must be triangulated.")
.print();
return;
Expand Down Expand Up @@ -114,4 +116,5 @@ template <class NumericType> class culsRefineMesh {
mesh->insertNextTriangle(triangle);
}
}
};
};
} // namespace viennaps
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

#include <lsDomain.hpp>
#include <lsToDiskMesh.hpp>

#include <psDomain.hpp>

#include <vtkCellArray.h>
#include <vtkCellLocator.h>
#include <vtkDelaunay2D.h>
Expand All @@ -12,40 +15,41 @@
#include <vtkPolyData.h>
#include <vtkTriangle.h>

#include <psDomain.hpp>
#include <psSmartPointer.hpp>
namespace viennaps {

// WARNING: THIS ONLY WORK FOR GEOMETRIES WHICH PROJECT NICELY ON THE XY PLANE.
template <class NumericType> class culsDelaunayMesh {
psSmartPointer<lsDomain<NumericType, 3>> levelSet = nullptr;
psSmartPointer<lsMesh<NumericType>> surfaceMesh = nullptr;
using namespace viennacore;

// WARNING: THIS ONLY WORKS FOR GEOMETRIES WHICH PROJECT NICELY ON THE XY PLANE.
template <class NumericType> class DelaunaySurfaceMesh {
using lsDomainType = SmartPointer<viennals::Domain<NumericType, 3>>;
using psDomainType = SmartPointer<::viennaps::Domain<NumericType, 3>>;
using MeshType = SmartPointer<viennals::Mesh<NumericType>>;

lsDomainType levelSet = nullptr;
MeshType surfaceMesh = nullptr;

public:
culsDelaunayMesh() {}
culsDelaunayMesh(psSmartPointer<lsDomain<NumericType, 3>> passedLevelSet,
psSmartPointer<lsMesh<NumericType>> passedMesh)
DelaunaySurfaceMesh() {}
DelaunaySurfaceMesh(lsDomainType passedLevelSet, MeshType passedMesh)
: levelSet(passedLevelSet), surfaceMesh(passedMesh) {}
culsDelaunayMesh(psSmartPointer<psDomain<NumericType, 3>> passedDomain,
psSmartPointer<lsMesh<NumericType>> passedMesh)
DelaunaySurfaceMesh(psDomainType passedDomain, MeshType passedMesh)
: levelSet(passedDomain->getLevelSets().back()), surfaceMesh(passedMesh) {
}

void setLevelSet(psSmartPointer<lsDomain<NumericType, 3>> passedLevelSet) {
levelSet = passedLevelSet;
}
void setLevelSet(lsDomainType passedLevelSet) { levelSet = passedLevelSet; }

void setLevelSet(psSmartPointer<psDomain<NumericType, 3>> passedDomain) {
void setLevelSet(psDomainType passedDomain) {
levelSet = passedDomain->getLevelSets()->back();
}

void apply() {
surfaceMesh->clear();
const double gridDelta = levelSet->getGrid().getGridDelta();

auto pointCloud = psSmartPointer<lsMesh<NumericType>>::New();
lsToDiskMesh<NumericType, 3>(levelSet, pointCloud).apply();
auto pointCloud = MeshType::New();
viennals::ToDiskMesh<NumericType, 3>(levelSet, pointCloud).apply();

lsVTKWriter<NumericType>(pointCloud, "pointCloud.vtp").apply();
// lsVTKWriter<NumericType>(pointCloud, "pointCloud.vtp").apply();

vtkNew<vtkPoints> points;
for (auto it = pointCloud->getNodes().begin();
Expand Down Expand Up @@ -88,4 +92,5 @@ template <class NumericType> class culsDelaunayMesh {
static_cast<unsigned>(cellIds->GetId(2))});
}
}
};
};
} // namespace viennaps
Loading

0 comments on commit fea82ac

Please sign in to comment.