From 655ec5b4d24b3e143e00ed145aef1c2b2fc038bf Mon Sep 17 00:00:00 2001 From: Tobias Reiter Date: Fri, 24 May 2024 17:10:54 -0400 Subject: [PATCH 01/11] refactor with namespace viennals --- CMakeLists.txt | 4 +- .../AirGapDeposition/AirGapDeposition.cpp | 52 +- examples/Deposition/Deposition.cpp | 50 +- .../GeometricAdvection/GeometricAdvection.cpp | 43 +- .../PatternedSubstrate/PatternedSubstrate.cpp | 103 +- .../PeriodicBoundary/PeriodicBoundary.cpp | 52 +- examples/SharedLib/SharedLib.cpp | 38 +- examples/SquareEtch/SquareEtch.cpp | 77 +- examples/VoidEtching/VoidEtching.cpp | 55 +- .../VolumeToLevelSets/VolumeToLevelSets.cpp | 27 +- include/viennals/lsAdvect.hpp | 254 ++-- include/viennals/lsBooleanOperation.hpp | 111 +- include/viennals/lsCalculateCurvatures.hpp | 54 +- include/viennals/lsCalculateNormalVectors.hpp | 50 +- include/viennals/lsCheck.hpp | 43 +- include/viennals/lsConcepts.hpp | 5 +- include/viennals/lsConvexHull.hpp | 47 +- include/viennals/lsCurvatureFormulas.hpp | 11 +- include/viennals/lsDetectFeatures.hpp | 57 +- include/viennals/lsDomain.hpp | 89 +- include/viennals/lsEnquistOsher.hpp | 29 +- include/viennals/lsExpand.hpp | 50 +- include/viennals/lsExtrude.hpp | 59 +- include/viennals/lsFileFormats.hpp | 9 +- include/viennals/lsFiniteDifferences.hpp | 55 +- include/viennals/lsFromMesh.hpp | 51 +- include/viennals/lsFromSurfaceMesh.hpp | 39 +- include/viennals/lsFromVolumeMesh.hpp | 54 +- include/viennals/lsGeometricAdvect.hpp | 137 ++- .../lsGeometricAdvectDistributions.hpp | 61 +- include/viennals/lsGeometries.hpp | 78 +- include/viennals/lsGraph.hpp | 15 +- include/viennals/lsLaxFriedrichs.hpp | 31 +- include/viennals/lsLocalLaxFriedrichs.hpp | 33 +- .../lsLocalLaxFriedrichsAnalytical.hpp | 31 +- .../viennals/lsLocalLocalLaxFriedrichs.hpp | 30 +- include/viennals/lsMakeGeometry.hpp | 164 +-- include/viennals/lsMarchingCubes.hpp | 7 +- include/viennals/lsMarkVoidPoints.hpp | 45 +- include/viennals/lsMaterialMap.hpp | 14 +- include/viennals/lsMesh.hpp | 51 +- include/viennals/lsMessage.hpp | 67 -- include/viennals/lsPointData.hpp | 46 +- include/viennals/lsPreCompileMacros.hpp | 5 +- include/viennals/lsPrune.hpp | 43 +- include/viennals/lsReader.hpp | 34 +- include/viennals/lsReduce.hpp | 51 +- include/viennals/lsRemoveStrayPoints.hpp | 43 +- include/viennals/lsSmartPointer.hpp | 26 - .../lsStencilLocalLaxFriedrichsScalar.hpp | 77 +- include/viennals/lsTestAsserts.hpp | 2 +- include/viennals/lsToDiskMesh.hpp | 71 +- include/viennals/lsToMesh.hpp | 51 +- include/viennals/lsToSurfaceMesh.hpp | 46 +- include/viennals/lsToVoxelMesh.hpp | 59 +- include/viennals/lsTransformMesh.hpp | 55 +- include/viennals/lsVTKReader.hpp | 117 +- include/viennals/lsVTKWriter.hpp | 92 +- include/viennals/lsVelocityField.hpp | 34 +- include/viennals/lsWriteVisualizationMesh.hpp | 47 +- include/viennals/lsWriter.hpp | 34 +- python/pyWrap.cpp | 1068 ++++++++--------- tests/Advection/Advection.cpp | 44 +- tests/Advection2D/Advection2D.cpp | 56 +- .../AdvectionBenchmark/AdvectionBenchmark.cpp | 29 +- tests/AdvectionPlane/AdvectionPlane.cpp | 42 +- tests/BooleanOperation/BooleanOperation.cpp | 55 +- .../BooleanOperationExactZero.cpp | 38 +- .../BooleanOperationExactZero1.cpp | 42 +- .../BoundaryConditions/BoundaryConditions.cpp | 23 +- .../CalculateCurvatures.cpp | 26 +- .../CalculateNormalVectors.cpp | 30 +- tests/ConvexHull/ConvexHull.cpp | 26 +- tests/ConvexHull3D/ConvexHull3D.cpp | 46 +- tests/DiskMesh/DiskMesh.cpp | 35 +- tests/Expand/Expand.cpp | 36 +- tests/Extrude/Extrude.cpp | 53 +- tests/FeatureDetection/FeatureDetection.cpp | 44 +- tests/FileWriter/FileWriter.cpp | 33 +- tests/FromMesh/FromMesh.cpp | 36 +- .../GenerateHoleGeometry.cpp | 42 +- tests/GeometricAdvect/GeometricAdvect.cpp | 63 +- .../GeometricAdvectMask.cpp | 91 +- .../GeometricAdvectPerformance.cpp | 79 +- .../GeometricAdvectTrench.cpp | 65 +- tests/HullMesh/HullMesh.cpp | 13 +- tests/Make3DSphere/Make3DSphere.cpp | 38 +- tests/MakeBox/MakeBox.cpp | 26 +- tests/MakeGeometry/MakeGeometry.cpp | 33 +- tests/MakePlane/MakePlane.cpp | 28 +- tests/MakeSphere/MakeSphere.cpp | 40 +- tests/MarkVoidPoints/MarkVoidPoints.cpp | 51 +- .../MultiMaterialAdvection.cpp | 45 +- tests/MultiMaterialEtch/MultiMaterialEtch.cpp | 115 +- .../PeriodicBoundary2D/PeriodicBoundary2D.cpp | 79 +- tests/ReadFromFile/ReadFromFile.cpp | 8 +- tests/ReadVolume/ReadVolume.cpp | 24 +- tests/RemoveStrayPoints/RemoveStrayPoints.cpp | 45 +- tests/RotateMesh/RotateMesh.cpp | 26 +- tests/Serialize/Serialize.cpp | 23 +- tests/SmartPointer/SmartPointer.cpp | 17 +- tests/VisualizationMesh/VisualizationMesh.cpp | 53 +- tests/VoidDetection/VoidDetection.cpp | 61 +- 103 files changed, 3095 insertions(+), 2997 deletions(-) delete mode 100644 include/viennals/lsMessage.hpp delete mode 100644 include/viennals/lsSmartPointer.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a20c7dd..d3d328da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -102,7 +102,7 @@ include(cmake/cpm.cmake) include(cmake/vtk.cmake) CPMAddPackage( - NAME Core + NAME ViennaCore GIT_TAG main # TODO: Create Tag GIT_REPOSITORY "https://github.com/ViennaTools/ViennaCore" OPTIONS "VIENNA_CORE_FORMAT_EXCLUDE docs/") @@ -120,7 +120,7 @@ CPMFindPackage( EXCLUDE_FROM_ALL ${VIENNALS_BUILD_PYTHON}) find_package(OpenMP REQUIRED) -target_link_libraries(${PROJECT_NAME} INTERFACE OpenMP::OpenMP_CXX ViennaHRLE) +target_link_libraries(${PROJECT_NAME} INTERFACE OpenMP::OpenMP_CXX ViennaHRLE ViennaCore) if(VIENNALS_USE_VTK AND VIENNALS_VTK_PYTHON_LIBS) import_vtk_python() diff --git a/examples/AirGapDeposition/AirGapDeposition.cpp b/examples/AirGapDeposition/AirGapDeposition.cpp index 6effee3a..d214041d 100644 --- a/examples/AirGapDeposition/AirGapDeposition.cpp +++ b/examples/AirGapDeposition/AirGapDeposition.cpp @@ -16,10 +16,12 @@ then grown directionally on top. \example AirGapDeposition.cpp */ +namespace ls = viennals; + using NumericType = float; // implement own velocity field -class velocityField : public lsVelocityField { +class velocityField : public ls::VelocityField { public: NumericType getScalarVelocity(const std::array & /*coordinate*/, @@ -50,11 +52,12 @@ int main() { NumericType gridDelta = 0.5; hrleCoordType bounds[2 * D] = {-extent, extent, -extent, extent}; - lsDomain::BoundaryType boundaryCons[D]; - boundaryCons[0] = lsDomain::BoundaryType::REFLECTIVE_BOUNDARY; - boundaryCons[1] = lsDomain::BoundaryType::INFINITE_BOUNDARY; + ls::Domain::BoundaryType boundaryCons[D]; + boundaryCons[0] = + ls::Domain::BoundaryType::REFLECTIVE_BOUNDARY; + boundaryCons[1] = ls::Domain::BoundaryType::INFINITE_BOUNDARY; - auto substrate = lsSmartPointer>::New( + auto substrate = ls::SmartPointer>::New( bounds, boundaryCons, gridDelta); NumericType origin[2] = {0., 0.}; @@ -62,39 +65,40 @@ int main() { { auto plane = - lsSmartPointer>::New(origin, planeNormal); - lsMakeGeometry(substrate, plane).apply(); + ls::SmartPointer>::New(origin, planeNormal); + ls::MakeGeometry(substrate, plane).apply(); } { std::cout << "Extracting..." << std::endl; - auto mesh = lsSmartPointer>::New(); - lsToSurfaceMesh(substrate, mesh).apply(); - lsVTKWriter(mesh, "plane.vtp").apply(); + auto mesh = ls::SmartPointer>::New(); + ls::ToSurfaceMesh(substrate, mesh).apply(); + ls::VTKWriter(mesh, "plane.vtp").apply(); } { // create layer used for booling std::cout << "Creating box..." << std::endl; - auto trench = lsSmartPointer>::New( + auto trench = ls::SmartPointer>::New( bounds, boundaryCons, gridDelta); NumericType xlimit = extent / 6.; NumericType minCorner[D] = {-xlimit, -25.}; NumericType maxCorner[D] = {xlimit, 1.}; - auto box = lsSmartPointer>::New(minCorner, maxCorner); - lsMakeGeometry(trench, box).apply(); + auto box = + ls::SmartPointer>::New(minCorner, maxCorner); + ls::MakeGeometry(trench, box).apply(); { std::cout << "Extracting..." << std::endl; - auto mesh = lsSmartPointer>::New(); - lsToMesh(trench, mesh).apply(); - lsVTKWriter(mesh, "box.vtp").apply(); + auto mesh = ls::SmartPointer>::New(); + ls::ToMesh(trench, mesh).apply(); + ls::VTKWriter(mesh, "box.vtp").apply(); } // Create trench geometry std::cout << "Booling trench..." << std::endl; - lsBooleanOperation( - substrate, trench, lsBooleanOperationEnum::RELATIVE_COMPLEMENT) + ls::BooleanOperation( + substrate, trench, ls::BooleanOperationEnum::RELATIVE_COMPLEMENT) .apply(); } @@ -103,12 +107,12 @@ int main() { // create new levelset for new material, which will be grown // since it has to wrap around the substrate, just copy it std::cout << "Creating new layer..." << std::endl; - auto newLayer = lsSmartPointer>::New(substrate); + auto newLayer = ls::SmartPointer>::New(substrate); - auto velocities = lsSmartPointer::New(); + auto velocities = ls::SmartPointer::New(); std::cout << "Advecting" << std::endl; - lsAdvect advectionKernel; + ls::Advect advectionKernel; // the level set to be advected has to be inserted last // the other could be taken as a mask layer for advection @@ -129,9 +133,9 @@ int main() { std::cout << "\rAdvection step " + std::to_string(i) + " / " << numberOfSteps << std::flush; - auto mesh = lsSmartPointer>::New(); - lsToSurfaceMesh(newLayer, mesh).apply(); - lsVTKWriter(mesh, "trench" + std::to_string(i) + ".vtp") + auto mesh = ls::SmartPointer>::New(); + ls::ToSurfaceMesh(newLayer, mesh).apply(); + ls::VTKWriter(mesh, "trench" + std::to_string(i) + ".vtp") .apply(); } std::cout << std::endl; diff --git a/examples/Deposition/Deposition.cpp b/examples/Deposition/Deposition.cpp index cdbed7d6..b34101b5 100644 --- a/examples/Deposition/Deposition.cpp +++ b/examples/Deposition/Deposition.cpp @@ -17,10 +17,12 @@ \example Deposition.cpp */ +namespace ls = viennals; + using NumericType = float; // implement own velocity field -class velocityField : public lsVelocityField { +class velocityField : public ls::VelocityField { public: NumericType getScalarVelocity(const std::array & /*coordinate*/, @@ -51,13 +53,13 @@ int main() { NumericType gridDelta = 0.5; double bounds[2 * D] = {-extent, extent, -extent, extent, -extent, extent}; - lsDomain::BoundaryType boundaryCons[D]; + ls::Domain::BoundaryType boundaryCons[D]; for (unsigned i = 0; i < D - 1; ++i) boundaryCons[i] = - lsDomain::BoundaryType::REFLECTIVE_BOUNDARY; - boundaryCons[2] = lsDomain::BoundaryType::INFINITE_BOUNDARY; + ls::Domain::BoundaryType::REFLECTIVE_BOUNDARY; + boundaryCons[2] = ls::Domain::BoundaryType::INFINITE_BOUNDARY; - auto substrate = lsSmartPointer>::New( + auto substrate = ls::SmartPointer>::New( bounds, boundaryCons, gridDelta); NumericType origin[3] = {0., 0., 0.}; @@ -65,43 +67,44 @@ int main() { { auto plane = - lsSmartPointer>::New(origin, planeNormal); - lsMakeGeometry(substrate, plane).apply(); + ls::SmartPointer>::New(origin, planeNormal); + ls::MakeGeometry(substrate, plane).apply(); } { - auto trench = lsSmartPointer>::New( + auto trench = ls::SmartPointer>::New( bounds, boundaryCons, gridDelta); // make -x and +x greater than domain for numerical stability NumericType ylimit = extent / 4.; NumericType minCorner[D] = {-extent - 1, -ylimit, -15.}; NumericType maxCorner[D] = {extent + 1, ylimit, 1.}; - auto box = lsSmartPointer>::New(minCorner, maxCorner); - lsMakeGeometry(trench, box).apply(); + auto box = + ls::SmartPointer>::New(minCorner, maxCorner); + ls::MakeGeometry(trench, box).apply(); // Create trench geometry - lsBooleanOperation( - substrate, trench, lsBooleanOperationEnum::RELATIVE_COMPLEMENT) + ls::BooleanOperation( + substrate, trench, ls::BooleanOperationEnum::RELATIVE_COMPLEMENT) .apply(); } { std::cout << "Extracting..." << std::endl; - auto mesh = lsSmartPointer>::New(); - lsToSurfaceMesh(substrate, mesh).apply(); - lsVTKWriter(mesh, "trench-0.vtp").apply(); + auto mesh = ls::SmartPointer>::New(); + ls::ToSurfaceMesh(substrate, mesh).apply(); + ls::VTKWriter(mesh, "trench-0.vtp").apply(); } // Now grow new material isotropically // create new levelset for new material, which will be grown // since it has to wrap around the substrate, just copy it - auto newLayer = lsSmartPointer>::New(substrate); + auto newLayer = ls::SmartPointer>::New(substrate); - auto velocities = lsSmartPointer::New(); + auto velocities = ls::SmartPointer::New(); std::cout << "Advecting" << std::endl; - lsAdvect advectionKernel; + ls::Advect advectionKernel; // the level set to be advected has to be inserted last // the other could be taken as a mask layer for advection @@ -115,13 +118,14 @@ int main() { time += advectionKernel.getAdvectedTime()) { advectionKernel.apply(); - auto mesh = lsSmartPointer>::New(); - lsToSurfaceMesh(newLayer, mesh).apply(); - lsVTKWriter(mesh, "trench-" + std::to_string(counter) + ".vtp") + auto mesh = ls::SmartPointer>::New(); + ls::ToSurfaceMesh(newLayer, mesh).apply(); + ls::VTKWriter(mesh, + "trench-" + std::to_string(counter) + ".vtp") .apply(); - lsToMesh(newLayer, mesh).apply(); - lsVTKWriter(mesh, "LS-" + std::to_string(counter) + ".vtp") + ls::ToMesh(newLayer, mesh).apply(); + ls::VTKWriter(mesh, "LS-" + std::to_string(counter) + ".vtp") .apply(); ++counter; diff --git a/examples/GeometricAdvection/GeometricAdvection.cpp b/examples/GeometricAdvection/GeometricAdvection.cpp index 37ab04ba..3502b3a3 100644 --- a/examples/GeometricAdvection/GeometricAdvection.cpp +++ b/examples/GeometricAdvection/GeometricAdvection.cpp @@ -19,6 +19,8 @@ \example GeometricAdvection.cpp */ +namespace ls = viennals; + using NumericType = float; int main() { @@ -30,61 +32,62 @@ int main() { NumericType gridDelta = 0.5; double bounds[2 * D] = {-extent, extent, -extent, extent, -extent, extent}; - lsDomain::BoundaryType boundaryCons[D]; + ls::Domain::BoundaryType boundaryCons[D]; for (unsigned i = 0; i < D - 1; ++i) boundaryCons[i] = - lsDomain::BoundaryType::REFLECTIVE_BOUNDARY; - boundaryCons[2] = lsDomain::BoundaryType::INFINITE_BOUNDARY; + ls::Domain::BoundaryType::REFLECTIVE_BOUNDARY; + boundaryCons[2] = ls::Domain::BoundaryType::INFINITE_BOUNDARY; - auto substrate = lsSmartPointer>::New( + auto substrate = ls::SmartPointer>::New( bounds, boundaryCons, gridDelta); { NumericType origin[3] = {0., 0., 0.}; NumericType planeNormal[3] = {0., 0., 1.}; auto plane = - lsSmartPointer>::New(origin, planeNormal); - lsMakeGeometry(substrate, plane).apply(); + ls::SmartPointer>::New(origin, planeNormal); + ls::MakeGeometry(substrate, plane).apply(); } { - auto trench = lsSmartPointer>::New( + auto trench = ls::SmartPointer>::New( bounds, boundaryCons, gridDelta); // make -x and +x greater than domain for numerical stability NumericType ylimit = extent / 4.; NumericType minCorner[D] = {-extent - 1, -ylimit, -15.}; NumericType maxCorner[D] = {extent + 1, ylimit, 1.}; - auto box = lsSmartPointer>::New(minCorner, maxCorner); - lsMakeGeometry(trench, box).apply(); + auto box = + ls::SmartPointer>::New(minCorner, maxCorner); + ls::MakeGeometry(trench, box).apply(); // Create trench geometry - lsBooleanOperation( - substrate, trench, lsBooleanOperationEnum::RELATIVE_COMPLEMENT) + ls::BooleanOperation( + substrate, trench, ls::BooleanOperationEnum::RELATIVE_COMPLEMENT) .apply(); } { std::cout << "Extracting..." << std::endl; - auto mesh = lsSmartPointer>::New(); - lsToSurfaceMesh(substrate, mesh).apply(); - lsVTKWriter(mesh, "trench-0.vtp").apply(); + auto mesh = ls::SmartPointer>::New(); + ls::ToSurfaceMesh(substrate, mesh).apply(); + ls::VTKWriter(mesh, "trench-0.vtp").apply(); } // Now grow new material isotropically // create new levelset for new material, which will be grown // since it has to wrap around the substrate, just copy it - auto newLayer = lsSmartPointer>::New(substrate); + auto newLayer = ls::SmartPointer>::New(substrate); std::cout << "Advecting" << std::endl; // Grow the layer uniformly by 4 as in deposition example - auto dist = lsSmartPointer>::New( + auto dist = ls::SmartPointer>::New( 4.0, gridDelta); - lsGeometricAdvect(newLayer, dist).apply(); + ls::GeometricAdvect(newLayer, dist).apply(); { - auto mesh = lsSmartPointer>::New(); - lsToSurfaceMesh(newLayer, mesh).apply(); - lsVTKWriter(mesh, "trench-final.vtp").apply(); + auto mesh = ls::SmartPointer>::New(); + ls::ToSurfaceMesh(newLayer, mesh).apply(); + ls::VTKWriter(mesh, "trench-final.vtp").apply(); } return 0; diff --git a/examples/PatternedSubstrate/PatternedSubstrate.cpp b/examples/PatternedSubstrate/PatternedSubstrate.cpp index 2ca87bae..450b0daa 100644 --- a/examples/PatternedSubstrate/PatternedSubstrate.cpp +++ b/examples/PatternedSubstrate/PatternedSubstrate.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include @@ -23,8 +22,10 @@ \example PatternedSubstrate.cpp */ +namespace ls = viennals; + // implement velocity field describing a directional etch -class directionalEtch : public lsVelocityField { +class directionalEtch : public ls::VelocityField { public: double getScalarVelocity(const std::array & /*coordinate*/, int material, @@ -48,7 +49,7 @@ class directionalEtch : public lsVelocityField { }; // implement velocity field describing an isotropic deposition -class isotropicDepo : public lsVelocityField { +class isotropicDepo : public ls::VelocityField { public: double getScalarVelocity(const std::array & /*coordinate*/, int /*material*/, @@ -69,11 +70,11 @@ class isotropicDepo : public lsVelocityField { // create a rounded cone as the primitive pattern. // Define a pointcloud and create a hull mesh using lsConvexHull. -void makeRoundCone(lsSmartPointer> mesh, +void makeRoundCone(ls::SmartPointer> mesh, hrleVectorType center, double radius, double height) { // cone is just a circle with a point above the center - auto cloud = lsSmartPointer>::New(); + auto cloud = ls::SmartPointer>::New(); // frist inside top point { hrleVectorType topPoint = center; @@ -98,7 +99,7 @@ void makeRoundCone(lsSmartPointer> mesh, } } - lsConvexHull(mesh, cloud).apply(); + ls::ConvexHull(mesh, cloud).apply(); } int main() { @@ -116,24 +117,25 @@ int main() { double bounds[2 * D] = {-xExtent / 2., xExtent / 2., -yExtent / 2., yExtent / 2., -5, 5}; - lsDomain::BoundaryType boundaryCons[D]; - boundaryCons[0] = lsDomain::BoundaryType::PERIODIC_BOUNDARY; - boundaryCons[1] = lsDomain::BoundaryType::PERIODIC_BOUNDARY; - boundaryCons[2] = lsDomain::BoundaryType::INFINITE_BOUNDARY; + ls::Domain::BoundaryType boundaryCons[D]; + boundaryCons[0] = ls::Domain::BoundaryType::PERIODIC_BOUNDARY; + boundaryCons[1] = ls::Domain::BoundaryType::PERIODIC_BOUNDARY; + boundaryCons[2] = ls::Domain::BoundaryType::INFINITE_BOUNDARY; - auto substrate = - lsSmartPointer>::New(bounds, boundaryCons, gridDelta); + auto substrate = ls::SmartPointer>::New( + bounds, boundaryCons, gridDelta); { double origin[3] = {0., 0., 0.001}; double planeNormal[3] = {0., 0., 1.}; - auto plane = lsSmartPointer>::New(origin, planeNormal); - lsMakeGeometry(substrate, plane).apply(); + auto plane = + ls::SmartPointer>::New(origin, planeNormal); + ls::MakeGeometry(substrate, plane).apply(); } // copy the structure to add the pattern on top - auto pattern = - lsSmartPointer>::New(bounds, boundaryCons, gridDelta); + auto pattern = ls::SmartPointer>::New( + bounds, boundaryCons, gridDelta); pattern->setLevelSetWidth(2); // Create varying cones and put them in hexagonal pattern --------- @@ -162,16 +164,16 @@ int main() { // for each cone in a row for (unsigned i = 0; i < 6; ++i) { // make ls from cone mesh and add to substrate - auto cone = lsSmartPointer>::New( + auto cone = ls::SmartPointer>::New( bounds, boundaryCons, gridDelta); // create cone - auto coneMesh = lsSmartPointer>::New(); + auto coneMesh = ls::SmartPointer>::New(); makeRoundCone(coneMesh, coneCenter, coneRadius * dis(gen), coneHeight * dis(gen)); - lsFromSurfaceMesh(cone, coneMesh, false).apply(); - lsBooleanOperation boolOp(pattern, cone, - lsBooleanOperationEnum::UNION); + ls::FromSurfaceMesh(cone, coneMesh, false).apply(); + ls::BooleanOperation boolOp(pattern, cone, + ls::BooleanOperationEnum::UNION); boolOp.apply(); // now shift mesh for next bool @@ -182,19 +184,19 @@ int main() { } } - lsBooleanOperation(substrate, pattern, - lsBooleanOperationEnum::UNION) + ls::BooleanOperation(substrate, pattern, + ls::BooleanOperationEnum::UNION) .apply(); // Etch the substrate under the pattern --------------------------- unsigned numberOfEtchSteps = 30; std::cout << "Advecting" << std::endl; - lsAdvect advectionKernel; + ls::Advect advectionKernel; advectionKernel.insertNextLevelSet(pattern); advectionKernel.insertNextLevelSet(substrate); { - auto velocities = lsSmartPointer::New(); + auto velocities = ls::SmartPointer::New(); advectionKernel.setVelocityField(velocities); // Now advect the level set, outputting every @@ -204,9 +206,9 @@ int main() { for (unsigned i = 0; i < numberOfEtchSteps; ++i) { std::cout << "\rEtch step " + std::to_string(i) + " / " << numberOfEtchSteps << std::flush; - auto mesh = lsSmartPointer>::New(); - lsToSurfaceMesh(substrate, mesh).apply(); - lsVTKWriter(mesh, "substrate-" + std::to_string(i) + ".vtp") + auto mesh = ls::SmartPointer>::New(); + ls::ToSurfaceMesh(substrate, mesh).apply(); + ls::VTKWriter(mesh, "substrate-" + std::to_string(i) + ".vtp") .apply(); advectionKernel.apply(); @@ -215,10 +217,10 @@ int main() { std::cout << std::endl; { - auto mesh = lsSmartPointer>::New(); - lsToSurfaceMesh(substrate, mesh).apply(); - lsVTKWriter(mesh, "substrate-" + - std::to_string(numberOfEtchSteps) + ".vtp") + auto mesh = ls::SmartPointer>::New(); + ls::ToSurfaceMesh(substrate, mesh).apply(); + ls::VTKWriter( + mesh, "substrate-" + std::to_string(numberOfEtchSteps) + ".vtp") .apply(); } @@ -228,16 +230,17 @@ int main() { // make disk mesh and output { - auto mesh = lsSmartPointer>::New(); - lsToDiskMesh(substrate, mesh).apply(); - lsVTKWriter(mesh, lsFileFormatEnum::VTP, "diskMesh.vtp").apply(); + auto mesh = ls::SmartPointer>::New(); + ls::ToDiskMesh(substrate, mesh).apply(); + ls::VTKWriter(mesh, ls::FileFormatEnum::VTP, "diskMesh.vtp") + .apply(); } // Deposit new layer ---------------------------------------------- // new level set for new layer - auto fillLayer = lsSmartPointer>::New(substrate); + auto fillLayer = ls::SmartPointer>::New(substrate); { - auto velocities = lsSmartPointer::New(); + auto velocities = ls::SmartPointer::New(); advectionKernel.setVelocityField(velocities); advectionKernel.insertNextLevelSet(fillLayer); @@ -250,11 +253,11 @@ int main() { for (unsigned i = 0; i < numberOfDepoSteps; ++i) { std::cout << "\rDepo step " + std::to_string(i) + " / " << numberOfDepoSteps << std::flush; - auto mesh = lsSmartPointer>::New(); - lsToSurfaceMesh(fillLayer, mesh).apply(); - lsVTKWriter(mesh, "fillLayer-" + - std::to_string(numberOfEtchSteps + 1 + i) + - ".vtp") + auto mesh = ls::SmartPointer>::New(); + ls::ToSurfaceMesh(fillLayer, mesh).apply(); + ls::VTKWriter( + mesh, + "fillLayer-" + std::to_string(numberOfEtchSteps + 1 + i) + ".vtp") .apply(); advectionKernel.apply(); @@ -263,9 +266,9 @@ int main() { std::cout << std::endl; { - auto mesh = lsSmartPointer>::New(); - lsToSurfaceMesh(fillLayer, mesh).apply(); - lsVTKWriter( + auto mesh = ls::SmartPointer>::New(); + ls::ToSurfaceMesh(fillLayer, mesh).apply(); + ls::VTKWriter( mesh, "fillLayer-" + std::to_string(numberOfEtchSteps + numberOfDepoSteps) + ".vtp") @@ -278,12 +281,12 @@ int main() { // now output the final level sets { - auto mesh = lsSmartPointer>::New(); - lsToSurfaceMesh(substrate, mesh).apply(); - lsVTKWriter(mesh, "final-substrate.vtp").apply(); + auto mesh = ls::SmartPointer>::New(); + ls::ToSurfaceMesh(substrate, mesh).apply(); + ls::VTKWriter(mesh, "final-substrate.vtp").apply(); - lsToSurfaceMesh(fillLayer, mesh).apply(); - lsVTKWriter(mesh, "final-fillLayer.vtp").apply(); + ls::ToSurfaceMesh(fillLayer, mesh).apply(); + ls::VTKWriter(mesh, "final-fillLayer.vtp").apply(); } return 0; diff --git a/examples/PeriodicBoundary/PeriodicBoundary.cpp b/examples/PeriodicBoundary/PeriodicBoundary.cpp index 9b5657df..6d47107d 100644 --- a/examples/PeriodicBoundary/PeriodicBoundary.cpp +++ b/examples/PeriodicBoundary/PeriodicBoundary.cpp @@ -17,8 +17,10 @@ \example PeriodicBoundary.cpp */ +namespace ls = viennals; + // implement own velocity field -class velocityField : public lsVelocityField { +class velocityField : public ls::VelocityField { public: double getScalarVelocity(const std::array & /*coordinate*/, int /*material*/, @@ -46,48 +48,50 @@ int main() { double gridDelta = 0.5; double bounds[2 * D] = {-extent, extent, -extent, extent, -extent, extent}; - lsDomain::BoundaryType boundaryCons[D]; - boundaryCons[0] = lsDomain::BoundaryType::PERIODIC_BOUNDARY; - boundaryCons[1] = lsDomain::BoundaryType::PERIODIC_BOUNDARY; - boundaryCons[2] = lsDomain::BoundaryType::INFINITE_BOUNDARY; + ls::Domain::BoundaryType boundaryCons[D]; + boundaryCons[0] = ls::Domain::BoundaryType::PERIODIC_BOUNDARY; + boundaryCons[1] = ls::Domain::BoundaryType::PERIODIC_BOUNDARY; + boundaryCons[2] = ls::Domain::BoundaryType::INFINITE_BOUNDARY; - auto substrate = - lsSmartPointer>::New(bounds, boundaryCons, gridDelta); + auto substrate = ls::SmartPointer>::New( + bounds, boundaryCons, gridDelta); { double origin[3] = {0., 0., 0.}; double planeNormal[3] = {0., 0., 1.}; - auto plane = lsSmartPointer>::New(origin, planeNormal); - lsMakeGeometry(substrate, plane).apply(); + auto plane = + ls::SmartPointer>::New(origin, planeNormal); + ls::MakeGeometry(substrate, plane).apply(); } { // create spheres used for booling std::cout << "Creating pillar..." << std::endl; - auto pillar = lsSmartPointer>::New(bounds, boundaryCons, - gridDelta); + auto pillar = ls::SmartPointer>::New( + bounds, boundaryCons, gridDelta); double lowerCorner[D] = {15, 15, -1}; double upperCorner[D] = {25, 25, 10}; - auto box = lsSmartPointer>::New(lowerCorner, upperCorner); - lsMakeGeometry(pillar, box).apply(); - auto mesh = lsSmartPointer>::New(); - lsToSurfaceMesh(pillar, mesh).apply(); - lsVTKWriter(mesh, "pillar.vtp").apply(); - lsBooleanOperation boolOp(substrate, pillar, - lsBooleanOperationEnum::UNION); + auto box = + ls::SmartPointer>::New(lowerCorner, upperCorner); + ls::MakeGeometry(pillar, box).apply(); + auto mesh = ls::SmartPointer>::New(); + ls::ToSurfaceMesh(pillar, mesh).apply(); + ls::VTKWriter(mesh, "pillar.vtp").apply(); + ls::BooleanOperation boolOp(substrate, pillar, + ls::BooleanOperationEnum::UNION); boolOp.apply(); } // Now etch the substrate isotropically - auto velocities = lsSmartPointer::New(); + auto velocities = ls::SmartPointer::New(); std::cout << "Advecting" << std::endl; - lsAdvect advectionKernel; + ls::Advect advectionKernel; advectionKernel.insertNextLevelSet(substrate); advectionKernel.setVelocityField(velocities); advectionKernel.setIntegrationScheme( - lsIntegrationSchemeEnum::ENGQUIST_OSHER_2ND_ORDER); + ls::IntegrationSchemeEnum::ENGQUIST_OSHER_2ND_ORDER); // Now advect the level set 50 times, outputting every // advection step. Save the physical time that @@ -97,9 +101,9 @@ int main() { for (unsigned i = 0; i < numberOfSteps; ++i) { std::cout << "\rAdvection step " + std::to_string(i) + " / " << numberOfSteps << std::flush; - auto mesh = lsSmartPointer>::New(); - lsToSurfaceMesh(substrate, mesh).apply(); - lsVTKWriter(mesh, "pillar-" + std::to_string(i) + ".vtp").apply(); + auto mesh = ls::SmartPointer>::New(); + ls::ToSurfaceMesh(substrate, mesh).apply(); + ls::VTKWriter(mesh, "pillar-" + std::to_string(i) + ".vtp").apply(); advectionKernel.apply(); passedTime += advectionKernel.getAdvectedTime(); diff --git a/examples/SharedLib/SharedLib.cpp b/examples/SharedLib/SharedLib.cpp index 53ee288c..31d0aff9 100644 --- a/examples/SharedLib/SharedLib.cpp +++ b/examples/SharedLib/SharedLib.cpp @@ -19,6 +19,8 @@ "lsPreCompileMacros.hpp" \example SharedLib.cpp */ +namespace ls = viennals; + int main() { // do not need to define dimension @@ -28,50 +30,50 @@ int main() { double gridDelta = 0.25; - // Usually we would use lsDomain. + // Usually we would use ls::Domain. // Since we want to make sure we get an error // if we do not use a pre-built type, we use // the specialization typedef - auto sphere1 = lsSmartPointer::New(gridDelta); - auto sphere2 = lsSmartPointer::New(gridDelta); + auto sphere1 = ls::SmartPointer::New(gridDelta); + auto sphere2 = ls::SmartPointer::New(gridDelta); float origin[3] = {5., 0., 0.}; float radius = 7.3; { // these typedefs are available for all templated classes - auto sphere = lsSmartPointer::New(origin, radius); - lsMakeGeometry_float_3(sphere1, sphere).apply(); + auto sphere = ls::SmartPointer::New(origin, radius); + ls::MakeGeometry_float_3(sphere1, sphere).apply(); origin[0] = -5.0; radius = 9.5; - sphere = lsSmartPointer::New(origin, radius); - lsMakeGeometry_float_3(sphere2, sphere).apply(); + sphere = ls::SmartPointer::New(origin, radius); + ls::MakeGeometry_float_3(sphere2, sphere).apply(); } { - auto mesh1 = lsSmartPointer>::New(); - auto mesh2 = lsSmartPointer>::New(); + auto mesh1 = ls::SmartPointer>::New(); + auto mesh2 = ls::SmartPointer>::New(); std::cout << "Extracting..." << std::endl; - lsToSurfaceMesh_float_3(sphere1, mesh1).apply(); - lsToSurfaceMesh_float_3(sphere2, mesh2).apply(); + ls::ToSurfaceMesh_float_3(sphere1, mesh1).apply(); + ls::ToSurfaceMesh_float_3(sphere2, mesh2).apply(); - lsVTKWriter(mesh1, "sphere1.vtp").apply(); - lsVTKWriter(mesh2, "sphere2.vtp").apply(); + ls::VTKWriter(mesh1, "sphere1.vtp").apply(); + ls::VTKWriter(mesh2, "sphere2.vtp").apply(); } // Perform a boolean operation - lsBooleanOperation_float_3(sphere1, sphere2, - lsBooleanOperationEnum::RELATIVE_COMPLEMENT) + ls::BooleanOperation_float_3(sphere1, sphere2, + ls::BooleanOperationEnum::RELATIVE_COMPLEMENT) .apply(); std::cout << "Extracting..." << std::endl; - auto mesh = lsSmartPointer>::New(); - lsToSurfaceMesh_float_3(sphere1, mesh).apply(); + auto mesh = ls::SmartPointer>::New(); + ls::ToSurfaceMesh_float_3(sphere1, mesh).apply(); mesh->print(); - lsVTKWriter(mesh, "after.vtp").apply(); + ls::VTKWriter(mesh, "after.vtp").apply(); return 0; } diff --git a/examples/SquareEtch/SquareEtch.cpp b/examples/SquareEtch/SquareEtch.cpp index bdc97fc2..fa2d044b 100644 --- a/examples/SquareEtch/SquareEtch.cpp +++ b/examples/SquareEtch/SquareEtch.cpp @@ -17,10 +17,12 @@ \example SquareEtch.cpp */ +namespace ls = viennals; + // Numerical velocity field. // Advection scheme will take care of numerical // artefacts itself. -class velocityField : public lsVelocityField { +class velocityField : public ls::VelocityField { public: double getScalarVelocity(const std::array & /*coordinate*/, int material, @@ -39,7 +41,7 @@ class velocityField : public lsVelocityField { // this will produce better results than numerical // approximations. lsLocalLaxFriedrichsAnalytical has // to be used for advection. -class analyticalField : public lsVelocityField { +class analyticalField : public ls::VelocityField { const double velocity = -1; public: @@ -88,50 +90,51 @@ int main() { double bounds[2 * D] = {-extent, extent, -extent, extent}; //, -extent, extent}; - lsDomain::BoundaryType boundaryCons[D]; + ls::Domain::BoundaryType boundaryCons[D]; for (unsigned i = 0; i < D - 1; ++i) - boundaryCons[i] = lsDomain::BoundaryType::REFLECTIVE_BOUNDARY; - boundaryCons[D - 1] = lsDomain::BoundaryType::INFINITE_BOUNDARY; + boundaryCons[i] = ls::Domain::BoundaryType::REFLECTIVE_BOUNDARY; + boundaryCons[D - 1] = ls::Domain::BoundaryType::INFINITE_BOUNDARY; - auto substrate = - lsSmartPointer>::New(bounds, boundaryCons, gridDelta); + auto substrate = ls::SmartPointer>::New( + bounds, boundaryCons, gridDelta); double origin[3] = {0., 0., 0.}; double planeNormal[3] = {0., D == 2, D == 3}; { - auto plane = lsSmartPointer>::New(origin, planeNormal); - lsMakeGeometry(substrate, plane).apply(); + auto plane = + ls::SmartPointer>::New(origin, planeNormal); + ls::MakeGeometry(substrate, plane).apply(); } double trenchBottom = -2.; { - auto trench = lsSmartPointer>::New(bounds, boundaryCons, - gridDelta); + auto trench = ls::SmartPointer>::New( + bounds, boundaryCons, gridDelta); // trench bottom is the initial bottom of the trench double minCorner[D] = {-extent / 1.5, trenchBottom}; double maxCorner[D] = {extent / 1.5, 1.}; - auto box = lsSmartPointer>::New(minCorner, maxCorner); - lsMakeGeometry(trench, box).apply(); + auto box = ls::SmartPointer>::New(minCorner, maxCorner); + ls::MakeGeometry(trench, box).apply(); // Create trench geometry - lsBooleanOperation(substrate, trench, - lsBooleanOperationEnum::RELATIVE_COMPLEMENT) + ls::BooleanOperation( + substrate, trench, ls::BooleanOperationEnum::RELATIVE_COMPLEMENT) .apply(); } // in order only to etch the bottom of the trench, we need a mask layer - auto mask = - lsSmartPointer>::New(bounds, boundaryCons, gridDelta); + auto mask = ls::SmartPointer>::New(bounds, boundaryCons, + gridDelta); // make downward facing plane to remove bottom of trench for the mask // layer // add small offset so bottom of trench is definetly gone origin[D - 1] = trenchBottom + 1e-9; planeNormal[D - 1] = -1.; - lsMakeGeometry( - mask, lsSmartPointer>::New(origin, planeNormal)) + ls::MakeGeometry( + mask, ls::SmartPointer>::New(origin, planeNormal)) .apply(); - lsBooleanOperation(mask, substrate, - lsBooleanOperationEnum::INTERSECT) + ls::BooleanOperation(mask, substrate, + ls::BooleanOperationEnum::INTERSECT) .apply(); std::string fileName; @@ -143,21 +146,21 @@ int main() { std::cout << "Extracting..." << std::endl; // output substrate layer (which wraps around mask layer) // wrapping is necessary for stable advection - auto mesh = lsSmartPointer>::New(); - lsToSurfaceMesh(substrate, mesh).apply(); - lsVTKWriter(mesh, fileName + "0.vtp").apply(); + auto mesh = ls::SmartPointer>::New(); + ls::ToSurfaceMesh(substrate, mesh).apply(); + ls::VTKWriter(mesh, fileName + "0.vtp").apply(); // output mask layer - lsToSurfaceMesh(mask, mesh).apply(); - lsVTKWriter(mesh, "mask.vtp").apply(); + ls::ToSurfaceMesh(mask, mesh).apply(); + ls::VTKWriter(mesh, "mask.vtp").apply(); } // START ADVECTION - auto velocities = lsSmartPointer::New(); - auto analyticalVelocities = lsSmartPointer::New(); + auto velocities = ls::SmartPointer::New(); + auto analyticalVelocities = ls::SmartPointer::New(); std::cout << "Advecting" << std::endl; - lsAdvect advectionKernel; + ls::Advect advectionKernel; // the level set to be advected has to be inserted last // the other is used as the mask layer for etching @@ -170,7 +173,7 @@ int main() { // Analytical velocity fields and dissipation coefficients // can only be used with this integration scheme advectionKernel.setIntegrationScheme( - lsIntegrationSchemeEnum::LOCAL_LAX_FRIEDRICHS_ANALYTICAL_1ST_ORDER); + ls::IntegrationSchemeEnum::LOCAL_LAX_FRIEDRICHS_ANALYTICAL_1ST_ORDER); } else { // for numerical velocities, just use the default // integration scheme, which is not accurate for certain @@ -181,7 +184,7 @@ int main() { // this numerical scheme is superior though. // However, it is slower. // advectionKernel.setIntegrationScheme( - // lsIntegrationSchemeEnum::STENCIL_LOCAL_LAX_FRIEDRICHS_1ST_ORDER); + // ls::IntegrationSchemeEnum::STENCIL_LOCAL_LAX_FRIEDRICHS_1ST_ORDER); } // advect the level set until 50s have passed @@ -193,18 +196,18 @@ int main() { std::cout << "Advection step: " << counter << ", time: " << advectionKernel.getAdvectedTime() << std::endl; - auto mesh = lsSmartPointer>::New(); - lsToSurfaceMesh(substrate, mesh).apply(); - lsVTKWriter(mesh, fileName + std::to_string(counter) + ".vtp") + auto mesh = ls::SmartPointer>::New(); + ls::ToSurfaceMesh(substrate, mesh).apply(); + ls::VTKWriter(mesh, fileName + std::to_string(counter) + ".vtp") .apply(); ++counter; } std::cout << std::endl; std::cout << "Number of Advection steps taken: " << counter << std::endl; - auto mesh = lsSmartPointer>::New(); - lsToSurfaceMesh(substrate, mesh).apply(); - lsVTKWriter(mesh, "final.vtp").apply(); + auto mesh = ls::SmartPointer>::New(); + ls::ToSurfaceMesh(substrate, mesh).apply(); + ls::VTKWriter(mesh, "final.vtp").apply(); return 0; } diff --git a/examples/VoidEtching/VoidEtching.cpp b/examples/VoidEtching/VoidEtching.cpp index f198833d..c1c28e0f 100644 --- a/examples/VoidEtching/VoidEtching.cpp +++ b/examples/VoidEtching/VoidEtching.cpp @@ -17,8 +17,10 @@ \example VoidEtching.cpp */ +namespace ls = viennals; + // implement own velocity field -class velocityField : public lsVelocityField { +class velocityField : public ls::VelocityField { public: double getScalarVelocity(const std::array & /*coordinate*/, int /*material*/, @@ -46,43 +48,44 @@ int main() { double gridDelta = 1; double bounds[2 * D] = {-extent, extent, -extent, extent, -extent, extent}; - lsDomain::BoundaryType boundaryCons[D]; - boundaryCons[0] = lsDomain::BoundaryType::REFLECTIVE_BOUNDARY; - boundaryCons[1] = lsDomain::BoundaryType::REFLECTIVE_BOUNDARY; - boundaryCons[2] = lsDomain::BoundaryType::INFINITE_BOUNDARY; + ls::Domain::BoundaryType boundaryCons[D]; + boundaryCons[0] = ls::Domain::BoundaryType::REFLECTIVE_BOUNDARY; + boundaryCons[1] = ls::Domain::BoundaryType::REFLECTIVE_BOUNDARY; + boundaryCons[2] = ls::Domain::BoundaryType::INFINITE_BOUNDARY; - auto substrate = - lsSmartPointer>::New(bounds, boundaryCons, gridDelta); + auto substrate = ls::SmartPointer>::New( + bounds, boundaryCons, gridDelta); double origin[3] = {0., 0., 0.}; { double planeNormal[3] = {0., 0., 1.}; - auto plane = lsSmartPointer>::New(origin, planeNormal); - lsMakeGeometry(substrate, plane).apply(); + auto plane = + ls::SmartPointer>::New(origin, planeNormal); + ls::MakeGeometry(substrate, plane).apply(); } { // create spheres used for booling std::cout << "Creating spheres..." << std::endl; - auto sphere = lsSmartPointer>::New(bounds, boundaryCons, - gridDelta); + auto sphere = ls::SmartPointer>::New( + bounds, boundaryCons, gridDelta); origin[0] = -12; origin[1] = -5; origin[2] = -15; double radius = 10; - lsMakeGeometry( - sphere, lsSmartPointer>::New(origin, radius)) + ls::MakeGeometry( + sphere, ls::SmartPointer>::New(origin, radius)) .apply(); - lsBooleanOperation boolOp( - substrate, sphere, lsBooleanOperationEnum::RELATIVE_COMPLEMENT); + ls::BooleanOperation boolOp( + substrate, sphere, ls::BooleanOperationEnum::RELATIVE_COMPLEMENT); boolOp.apply(); origin[0] = -7; origin[1] = -30; origin[2] = -20; radius = 8; - lsMakeGeometry( - sphere, lsSmartPointer>::New(origin, radius)) + ls::MakeGeometry( + sphere, ls::SmartPointer>::New(origin, radius)) .apply(); // reference to substrate and sphere are kept in boolOp boolOp.apply(); @@ -91,8 +94,8 @@ int main() { origin[1] = 15; origin[2] = -2; radius = 8; - lsMakeGeometry( - sphere, lsSmartPointer>::New(origin, radius)) + ls::MakeGeometry( + sphere, ls::SmartPointer>::New(origin, radius)) .apply(); boolOp.apply(); @@ -100,18 +103,18 @@ int main() { origin[1] = 8; origin[2] = -27; radius = 8; - lsMakeGeometry( - sphere, lsSmartPointer>::New(origin, radius)) + ls::MakeGeometry( + sphere, ls::SmartPointer>::New(origin, radius)) .apply(); boolOp.apply(); } // Now etch the substrate isotropically - auto velocities = lsSmartPointer::New(); + auto velocities = ls::SmartPointer::New(); std::cout << "Advecting" << std::endl; - lsAdvect advectionKernel; + ls::Advect advectionKernel; advectionKernel.insertNextLevelSet(substrate); advectionKernel.setVelocityField(velocities); advectionKernel.setIgnoreVoids(true); @@ -124,9 +127,9 @@ int main() { for (unsigned i = 0; i < numberOfSteps; ++i) { std::cout << "\rAdvection step " + std::to_string(i) + " / " << numberOfSteps << std::flush; - auto mesh = lsSmartPointer>::New(); - lsToSurfaceMesh(substrate, mesh).apply(); - lsVTKWriter(mesh, "void-" + std::to_string(i) + ".vtp").apply(); + auto mesh = ls::SmartPointer>::New(); + ls::ToSurfaceMesh(substrate, mesh).apply(); + ls::VTKWriter(mesh, "void-" + std::to_string(i) + ".vtp").apply(); advectionKernel.apply(); passedTime += advectionKernel.getAdvectedTime(); diff --git a/examples/VolumeToLevelSets/VolumeToLevelSets.cpp b/examples/VolumeToLevelSets/VolumeToLevelSets.cpp index 4df316f2..30607ce6 100644 --- a/examples/VolumeToLevelSets/VolumeToLevelSets.cpp +++ b/examples/VolumeToLevelSets/VolumeToLevelSets.cpp @@ -2,11 +2,12 @@ #include #include -#include #include #include #include +namespace ls = viennals; + int main(int argc, char *argv[]) { using NumericType = double; @@ -20,12 +21,12 @@ int main(int argc, char *argv[]) { fileName = "volumeInitial.vtu"; } - auto mesh = lsSmartPointer>::New(); - lsVTKReader(mesh, lsFileFormatEnum::VTU, fileName).apply(); + auto mesh = ls::SmartPointer>::New(); + ls::VTKReader(mesh, ls::FileFormatEnum::VTU, fileName).apply(); // reorder numbering { - typename lsPointData::ScalarDataType *materialData = + typename ls::PointData::ScalarDataType *materialData = mesh->getCellData().getScalarData("Material"); std::vector translator = {3, 2, 4, 7, 7, 6, 5, 7, 1, 0}; @@ -40,27 +41,27 @@ int main(int argc, char *argv[]) { mesh->print(); - lsVTKWriter(mesh, lsFileFormatEnum::VTU, "ReadVolumeMesh.vtu").apply(); + ls::VTKWriter(mesh, ls::FileFormatEnum::VTU, "ReadVolumeMesh.vtu").apply(); double bounds[2 * D] = {-6, 6, 1e-10, 0.078, -0.034, 0.034}; - lsBoundaryConditionEnum boundaryCons[D]; + ls::BoundaryConditionEnum boundaryCons[D]; for (unsigned i = 0; i < D; ++i) { - boundaryCons[i] = lsBoundaryConditionEnum::REFLECTIVE_BOUNDARY; + boundaryCons[i] = ls::BoundaryConditionEnum::REFLECTIVE_BOUNDARY; } - boundaryCons[0] = lsBoundaryConditionEnum::INFINITE_BOUNDARY; + boundaryCons[0] = ls::BoundaryConditionEnum::INFINITE_BOUNDARY; - auto domain = lsSmartPointer>::New( + auto domain = ls::SmartPointer>::New( bounds, boundaryCons, gridDelta); // read in as LS - lsFromVolumeMesh reader(domain->getGrid(), mesh); + ls::FromVolumeMesh reader(domain->getGrid(), mesh); reader.apply(); auto levelSets = reader.getLevelSets(); for (unsigned i = 0; i < levelSets.size(); ++i) { - auto mesh = lsSmartPointer>::New(); - lsToSurfaceMesh(levelSets[i], mesh).apply(); - lsVTKWriter(mesh, "LSsurface-" + std::to_string(i) + ".vtp") + auto mesh = ls::SmartPointer>::New(); + ls::ToSurfaceMesh(levelSets[i], mesh).apply(); + ls::VTKWriter(mesh, "LSsurface-" + std::to_string(i) + ".vtp") .apply(); } diff --git a/include/viennals/lsAdvect.hpp b/include/viennals/lsAdvect.hpp index 52ebffd2..51bb630e 100644 --- a/include/viennals/lsAdvect.hpp +++ b/include/viennals/lsAdvect.hpp @@ -1,5 +1,4 @@ -#ifndef LS_ADVECT_HPP -#define LS_ADVECT_HPP +#pragma once #include @@ -9,12 +8,13 @@ #include #include +#include +#include + #include #include #include -#include #include -#include // Integration schemes #include @@ -37,15 +37,19 @@ namespace lsInternal::advect { template > = lsConcepts::assignable> void reduceTimeStepHamiltonJacobi(IntegrationSchemeType &, double &, hrleCoordType) {} } // namespace lsInternal::advect +namespace viennals { + +using namespace viennacore; + /// Enumeration for the different Integration schemes /// used by the advection kernel -enum struct lsIntegrationSchemeEnum : unsigned { +enum struct IntegrationSchemeEnum : unsigned { ENGQUIST_OSHER_1ST_ORDER = 0, ENGQUIST_OSHER_2ND_ORDER = 1, LAX_FRIEDRICHS_1ST_ORDER = 2, @@ -67,11 +71,11 @@ enum struct lsIntegrationSchemeEnum : unsigned { /// sets. The velocities used to advect the level set are given in a concrete /// implementation of the lsVelocityField (check Advection examples for /// guidance) -template class lsAdvect { - std::vector>> levelSets; - lsSmartPointer> velocities = nullptr; - lsIntegrationSchemeEnum integrationScheme = - lsIntegrationSchemeEnum::ENGQUIST_OSHER_1ST_ORDER; +template class Advect { + std::vector>> levelSets; + SmartPointer> velocities = nullptr; + IntegrationSchemeEnum integrationScheme = + IntegrationSchemeEnum::ENGQUIST_OSHER_1ST_ORDER; double timeStepRatio = 0.4999; double dissipationAlpha = 1.0; bool calculateNormalVectors = true; @@ -90,9 +94,9 @@ template class lsAdvect { // renormalisation is needed, so it might be good to implement // Euler distance renormalisation as an option auto &grid = levelSets.back()->getGrid(); - auto newlsDomain = lsSmartPointer>::New(grid); - typename lsDomain::DomainType &newDomain = newlsDomain->getDomain(); - typename lsDomain::DomainType &domain = levelSets.back()->getDomain(); + auto newlsDomain = SmartPointer>::New(grid); + typename Domain::DomainType &newDomain = newlsDomain->getDomain(); + typename Domain::DomainType &domain = levelSets.back()->getDomain(); newDomain.initialize(domain.getNewSegmentation(), domain.getAllocation() * @@ -107,9 +111,9 @@ template class lsAdvect { #ifdef DEBUG_LS_ADVECT_HPP { - auto mesh = lsSmartPointer>::New(); - lsToMesh(levelSets.back(), mesh).apply(); - lsVTKWriter(mesh, "lsAdvect_beforeRebuild.vtk").apply(); + auto mesh = SmartPointer>::New(); + ToMesh(levelSets.back(), mesh).apply(); + VTKWriter(mesh, "Advect_beforeRebuild.vtk").apply(); } #endif @@ -136,7 +140,7 @@ template class lsAdvect { if (updateData) newDataSourceIds[p].reserve(2.5 * domainSegment.getNumberOfPoints()); - for (hrleSparseStarIterator::DomainType, 1> it( + for (hrleSparseStarIterator::DomainType, 1> it( domain, startVector); it.getIndices() < endVector; ++it) { @@ -198,14 +202,14 @@ template class lsAdvect { } else { domainSegment.insertNextUndefinedPoint( it.getIndices(), (it.getCenter().getDefinedValue() < 0) - ? lsDomain::NEG_VALUE - : lsDomain::POS_VALUE); + ? Domain::NEG_VALUE + : Domain::POS_VALUE); } } else { // if the center is not an active grid point if (it.getCenter().getValue() >= 0) { int usedNeighbor = -1; - T distance = lsDomain::POS_VALUE; + T distance = Domain::POS_VALUE; for (int i = 0; i < 2 * D; i++) { T value = it.getNeighbor(i).getValue(); if (std::abs(value) <= 1.0 && (value < 0.)) { @@ -223,12 +227,12 @@ template class lsAdvect { it.getNeighbor(usedNeighbor).getPointId()); } else { domainSegment.insertNextUndefinedPoint(it.getIndices(), - lsDomain::POS_VALUE); + Domain::POS_VALUE); } } else { int usedNeighbor = -1; - T distance = lsDomain::NEG_VALUE; + T distance = Domain::NEG_VALUE; for (int i = 0; i < 2 * D; i++) { T value = it.getNeighbor(i).getValue(); if (std::abs(value) <= 1.0 && (value > 0)) { @@ -247,7 +251,7 @@ template class lsAdvect { it.getNeighbor(usedNeighbor).getPointId()); } else { domainSegment.insertNextUndefinedPoint(it.getIndices(), - lsDomain::NEG_VALUE); + Domain::NEG_VALUE); } } } @@ -272,14 +276,14 @@ template class lsAdvect { double advect(double maxTimeStep = std::numeric_limits::max()) { // check whether a level set and velocites have been given if (levelSets.size() < 1) { - lsMessage::getInstance() - .addWarning("No level sets passed to lsAdvect. Not advecting.") + Logger::getInstance() + .addWarning("No level sets passed to Advect. Not advecting.") .print(); return std::numeric_limits::max(); } if (velocities == nullptr) { - lsMessage::getInstance() - .addWarning("No velocity field passed to lsAdvect. Not advecting.") + Logger::getInstance() + .addWarning("No velocity field passed to Advect. Not advecting.") .print(); return std::numeric_limits::max(); } @@ -287,63 +291,61 @@ template class lsAdvect { prepareLS(); double currentTime = 0.; - if (integrationScheme == - lsIntegrationSchemeEnum::ENGQUIST_OSHER_1ST_ORDER) { - auto is = lsInternal::lsEnquistOsher( - levelSets.back(), velocities, calculateNormalVectors); + if (integrationScheme == IntegrationSchemeEnum::ENGQUIST_OSHER_1ST_ORDER) { + auto is = lsInternal::EnquistOsher(levelSets.back(), velocities, + calculateNormalVectors); currentTime = integrateTime(is, maxTimeStep); } else if (integrationScheme == - lsIntegrationSchemeEnum::ENGQUIST_OSHER_2ND_ORDER) { - auto is = lsInternal::lsEnquistOsher( - levelSets.back(), velocities, calculateNormalVectors); + IntegrationSchemeEnum::ENGQUIST_OSHER_2ND_ORDER) { + auto is = lsInternal::EnquistOsher(levelSets.back(), velocities, + calculateNormalVectors); currentTime = integrateTime(is, maxTimeStep); } else if (integrationScheme == - lsIntegrationSchemeEnum::LAX_FRIEDRICHS_1ST_ORDER) { - auto is = lsInternal::lsLaxFriedrichs( - levelSets.back(), velocities, dissipationAlpha, - calculateNormalVectors); + IntegrationSchemeEnum::LAX_FRIEDRICHS_1ST_ORDER) { + auto is = lsInternal::LaxFriedrichs(levelSets.back(), velocities, + dissipationAlpha, + calculateNormalVectors); currentTime = integrateTime(is, maxTimeStep); } else if (integrationScheme == - lsIntegrationSchemeEnum::LAX_FRIEDRICHS_2ND_ORDER) { - auto is = lsInternal::lsLaxFriedrichs( - levelSets.back(), velocities, dissipationAlpha, - calculateNormalVectors); + IntegrationSchemeEnum::LAX_FRIEDRICHS_2ND_ORDER) { + auto is = lsInternal::LaxFriedrichs(levelSets.back(), velocities, + dissipationAlpha, + calculateNormalVectors); currentTime = integrateTime(is, maxTimeStep); } else if (integrationScheme == - lsIntegrationSchemeEnum:: + IntegrationSchemeEnum:: LOCAL_LAX_FRIEDRICHS_ANALYTICAL_1ST_ORDER) { - auto is = lsInternal::lsLocalLaxFriedrichsAnalytical( + auto is = lsInternal::LocalLaxFriedrichsAnalytical( levelSets.back(), velocities); currentTime = integrateTime(is, maxTimeStep); } else if (integrationScheme == - lsIntegrationSchemeEnum::LOCAL_LOCAL_LAX_FRIEDRICHS_1ST_ORDER) { - auto is = lsInternal::lsLocalLocalLaxFriedrichs( + IntegrationSchemeEnum::LOCAL_LOCAL_LAX_FRIEDRICHS_1ST_ORDER) { + auto is = lsInternal::LocalLocalLaxFriedrichs( levelSets.back(), velocities, dissipationAlpha); currentTime = integrateTime(is, maxTimeStep); } else if (integrationScheme == - lsIntegrationSchemeEnum::LOCAL_LOCAL_LAX_FRIEDRICHS_2ND_ORDER) { - auto is = lsInternal::lsLocalLocalLaxFriedrichs( + IntegrationSchemeEnum::LOCAL_LOCAL_LAX_FRIEDRICHS_2ND_ORDER) { + auto is = lsInternal::LocalLocalLaxFriedrichs( levelSets.back(), velocities, dissipationAlpha); currentTime = integrateTime(is, maxTimeStep); } else if (integrationScheme == - lsIntegrationSchemeEnum::LOCAL_LAX_FRIEDRICHS_1ST_ORDER) { - auto is = lsInternal::lsLocalLaxFriedrichs( + IntegrationSchemeEnum::LOCAL_LAX_FRIEDRICHS_1ST_ORDER) { + auto is = lsInternal::LocalLaxFriedrichs( levelSets.back(), velocities, dissipationAlpha); currentTime = integrateTime(is, maxTimeStep); } else if (integrationScheme == - lsIntegrationSchemeEnum::LOCAL_LAX_FRIEDRICHS_2ND_ORDER) { - auto is = lsInternal::lsLocalLaxFriedrichs( + IntegrationSchemeEnum::LOCAL_LAX_FRIEDRICHS_2ND_ORDER) { + auto is = lsInternal::LocalLaxFriedrichs( levelSets.back(), velocities, dissipationAlpha); currentTime = integrateTime(is, maxTimeStep); } else if (integrationScheme == - lsIntegrationSchemeEnum:: - STENCIL_LOCAL_LAX_FRIEDRICHS_1ST_ORDER) { - auto is = lsInternal::lsStencilLocalLaxFriedrichsScalar( + IntegrationSchemeEnum::STENCIL_LOCAL_LAX_FRIEDRICHS_1ST_ORDER) { + auto is = lsInternal::StencilLocalLaxFriedrichsScalar( levelSets.back(), velocities, dissipationAlpha); currentTime = integrateTime(is, maxTimeStep); } else { - lsMessage::getInstance() - .addWarning("lsAdvect: Integration scheme not found. Not advecting.") + Logger::getInstance() + .addWarning("Advect: Integration scheme not found. Not advecting.") .print(); // if no correct scheme was found return infinity @@ -354,15 +356,15 @@ template class lsAdvect { rebuildLS(); // Adjust all level sets below the advected one - // This means, that when the top levelset and one below - // are etched, the lower one is moved with the top levelset + // This means, that when the top level-set and one below + // are etched, the lower one is moved with the top level-set // TODO: Adjust lower layers also when they have grown, // to allow for two different growth rates of materials if (integrationScheme != - lsIntegrationSchemeEnum::STENCIL_LOCAL_LAX_FRIEDRICHS_1ST_ORDER) { + IntegrationSchemeEnum::STENCIL_LOCAL_LAX_FRIEDRICHS_1ST_ORDER) { for (unsigned i = 0; i < levelSets.size() - 1; ++i) { - lsBooleanOperation(levelSets[i], levelSets.back(), - lsBooleanOperationEnum::INTERSECT) + BooleanOperation(levelSets[i], levelSets.back(), + BooleanOperationEnum::INTERSECT) .apply(); } } @@ -379,7 +381,7 @@ template class lsAdvect { integrateTime(IntegrationSchemeType IntegrationScheme, double maxTimeStep = std::numeric_limits::max()) { if (timeStepRatio >= 0.5) { - lsMessage::getInstance() + Logger::getInstance() .addWarning("Integration time step ratio should be smaller than 0.5. " "Advection might fail!") .print(); @@ -391,15 +393,15 @@ template class lsAdvect { std::vector>> totalTempRates; totalTempRates.resize((levelSets.back())->getNumberOfSegments()); - typename lsPointData::ScalarDataType *voidMarkerPointer; + typename PointData::ScalarDataType *voidMarkerPointer; if (ignoreVoids) { - lsMarkVoidPoints(levelSets.back()).apply(); + MarkVoidPoints(levelSets.back()).apply(); auto &pointData = levelSets.back()->getPointData(); voidMarkerPointer = - pointData.getScalarData(lsMarkVoidPoints::voidPointLabel); + pointData.getScalarData(MarkVoidPoints::voidPointLabel); if (voidMarkerPointer == nullptr) { - lsMessage::getInstance() - .addWarning("lsAdvect: Cannot find void point markers. Not " + Logger::getInstance() + .addWarning("Advect: Cannot find void point markers. Not " "ignoring void points.") .print(); ignoreVoids = false; @@ -431,17 +433,17 @@ template class lsAdvect { 10); // an iterator for each level set - std::vector::DomainType>> + std::vector::DomainType>> iterators; for (auto it = levelSets.begin(); it != levelSets.end(); ++it) { iterators.push_back( - hrleSparseIterator::DomainType>( + hrleSparseIterator::DomainType>( (*it)->getDomain())); } IntegrationSchemeType scheme(IntegrationScheme); - for (hrleSparseIterator::DomainType> it( + for (hrleSparseIterator::DomainType> it( topDomain, startVector); it.getStartIndices() < endVector; ++it) { @@ -543,7 +545,7 @@ template class lsAdvect { // reduce to one layer thickness and apply new values directly to the // domain segments --> DO NOT CHANGE SEGMENTATION HERE (true parameter) - lsReduce(levelSets.back(), 1, true).apply(); + Reduce(levelSets.back(), 1, true).apply(); const bool saveVelocities = saveAdvectionVelocities; std::vector> velocityVectors( @@ -604,7 +606,7 @@ template class lsAdvect { pointData.eraseScalarData(i); } - typename lsPointData::ScalarDataType vels; + typename PointData::ScalarDataType vels; for (unsigned i = 0; i < velocityVectors.size(); ++i) { vels.insert(vels.end(), @@ -620,52 +622,34 @@ template class lsAdvect { public: static constexpr char velocityLabel[] = "AdvectionVelocities"; - lsAdvect() {} + Advect() {} - lsAdvect(lsSmartPointer> passedlsDomain) { + Advect(SmartPointer> passedlsDomain) { levelSets.push_back(passedlsDomain); } - template - lsAdvect(lsSmartPointer> passedlsDomain, - lsSmartPointer passedVelocities) { + Advect(SmartPointer> passedlsDomain, + SmartPointer> passedVelocities) { levelSets.push_back(passedlsDomain); - velocities = - std::dynamic_pointer_cast>(passedVelocities); - } - - template , VelocityField> = - lsConcepts::assignable> - lsAdvect(lsSmartPointer passedVelocities) { - velocities = - std::dynamic_pointer_cast>(passedVelocities); + velocities = passedVelocities; } - template , VelocityField> = - lsConcepts::assignable> - lsAdvect(std::vector>> passedlsDomains, - lsSmartPointer passedVelocities) + Advect(std::vector>> passedlsDomains, + SmartPointer> passedVelocities) : levelSets(passedlsDomains) { - velocities = - std::dynamic_pointer_cast>(passedVelocities); + velocities = passedVelocities; } /// Pushes the passed level set to the back of the list of level sets /// used for advection. - void insertNextLevelSet(lsSmartPointer> passedlsDomain) { + void insertNextLevelSet(SmartPointer> passedlsDomain) { levelSets.push_back(passedlsDomain); } /// Set the velocity field used for advection. This should be a concrete /// implementation of lsVelocityField - template , VelocityField> = - lsConcepts::assignable> - void setVelocityField(lsSmartPointer passedVelocities) { - velocities = - std::dynamic_pointer_cast>(passedVelocities); + void setVelocityField(SmartPointer> passedVelocities) { + velocities = passedVelocities; } /// Set the time until when the level set should be advected. @@ -719,8 +703,8 @@ template class lsAdvect { bool getCalculateNormalVectors() { return calculateNormalVectors; } /// Set which integration scheme should be used out of the ones specified - /// in lsIntegrationSchemeEnum. - void setIntegrationScheme(lsIntegrationSchemeEnum scheme) { + /// in IntegrationSchemeEnum. + void setIntegrationScheme(IntegrationSchemeEnum scheme) { integrationScheme = scheme; } @@ -737,53 +721,49 @@ template class lsAdvect { // Prepare the levelset for advection, based on the provided integration // scheme. void prepareLS() { - // check whether a level set and velocites have been given + // check whether a level set and velocities have been given if (levelSets.size() < 1) { - lsMessage::getInstance() - .addWarning("No level sets passed to lsAdvect.") + Logger::getInstance() + .addWarning("No level sets passed to Advect.") .print(); return; } - if (integrationScheme == - lsIntegrationSchemeEnum::ENGQUIST_OSHER_1ST_ORDER) { - lsInternal::lsEnquistOsher::prepareLS(levelSets.back()); + if (integrationScheme == IntegrationSchemeEnum::ENGQUIST_OSHER_1ST_ORDER) { + lsInternal::EnquistOsher::prepareLS(levelSets.back()); } else if (integrationScheme == - lsIntegrationSchemeEnum::ENGQUIST_OSHER_2ND_ORDER) { - lsInternal::lsEnquistOsher::prepareLS(levelSets.back()); + IntegrationSchemeEnum::ENGQUIST_OSHER_2ND_ORDER) { + lsInternal::EnquistOsher::prepareLS(levelSets.back()); } else if (integrationScheme == - lsIntegrationSchemeEnum::LAX_FRIEDRICHS_1ST_ORDER) { - lsInternal::lsLaxFriedrichs::prepareLS(levelSets.back()); + IntegrationSchemeEnum::LAX_FRIEDRICHS_1ST_ORDER) { + lsInternal::LaxFriedrichs::prepareLS(levelSets.back()); } else if (integrationScheme == - lsIntegrationSchemeEnum::LAX_FRIEDRICHS_2ND_ORDER) { - lsInternal::lsLaxFriedrichs::prepareLS(levelSets.back()); + IntegrationSchemeEnum::LAX_FRIEDRICHS_2ND_ORDER) { + lsInternal::LaxFriedrichs::prepareLS(levelSets.back()); } else if (integrationScheme == - lsIntegrationSchemeEnum:: + IntegrationSchemeEnum:: LOCAL_LAX_FRIEDRICHS_ANALYTICAL_1ST_ORDER) { - lsInternal::lsLocalLaxFriedrichsAnalytical::prepareLS( + lsInternal::LocalLaxFriedrichsAnalytical::prepareLS( levelSets.back()); } else if (integrationScheme == - lsIntegrationSchemeEnum::LOCAL_LOCAL_LAX_FRIEDRICHS_1ST_ORDER) { - lsInternal::lsLocalLocalLaxFriedrichs::prepareLS( - levelSets.back()); + IntegrationSchemeEnum::LOCAL_LOCAL_LAX_FRIEDRICHS_1ST_ORDER) { + lsInternal::LocalLocalLaxFriedrichs::prepareLS(levelSets.back()); } else if (integrationScheme == - lsIntegrationSchemeEnum::LOCAL_LOCAL_LAX_FRIEDRICHS_2ND_ORDER) { - lsInternal::lsLocalLocalLaxFriedrichs::prepareLS( - levelSets.back()); + IntegrationSchemeEnum::LOCAL_LOCAL_LAX_FRIEDRICHS_2ND_ORDER) { + lsInternal::LocalLocalLaxFriedrichs::prepareLS(levelSets.back()); } else if (integrationScheme == - lsIntegrationSchemeEnum::LOCAL_LAX_FRIEDRICHS_1ST_ORDER) { - lsInternal::lsLocalLaxFriedrichs::prepareLS(levelSets.back()); + IntegrationSchemeEnum::LOCAL_LAX_FRIEDRICHS_1ST_ORDER) { + lsInternal::LocalLaxFriedrichs::prepareLS(levelSets.back()); } else if (integrationScheme == - lsIntegrationSchemeEnum::LOCAL_LAX_FRIEDRICHS_2ND_ORDER) { - lsInternal::lsLocalLaxFriedrichs::prepareLS(levelSets.back()); + IntegrationSchemeEnum::LOCAL_LAX_FRIEDRICHS_2ND_ORDER) { + lsInternal::LocalLaxFriedrichs::prepareLS(levelSets.back()); } else if (integrationScheme == - lsIntegrationSchemeEnum:: - STENCIL_LOCAL_LAX_FRIEDRICHS_1ST_ORDER) { - lsInternal::lsStencilLocalLaxFriedrichsScalar::prepareLS( + IntegrationSchemeEnum::STENCIL_LOCAL_LAX_FRIEDRICHS_1ST_ORDER) { + lsInternal::StencilLocalLaxFriedrichsScalar::prepareLS( levelSets.back()); } else { - lsMessage::getInstance() - .addWarning("lsAdvect: Integration scheme not found. Not advecting.") + Logger::getInstance() + .addWarning("Advect: Integration scheme not found. Not advecting.") .print(); } } @@ -807,7 +787,7 @@ template class lsAdvect { } }; -// add all template specialisations for this class -PRECOMPILE_PRECISION_DIMENSION(lsAdvect) +// add all template specializations for this class +PRECOMPILE_PRECISION_DIMENSION(Advect) -#endif // LS_ADVECT_HPP \ No newline at end of file +} // namespace viennals diff --git a/include/viennals/lsBooleanOperation.hpp b/include/viennals/lsBooleanOperation.hpp index 6c1348c3..da44d251 100644 --- a/include/viennals/lsBooleanOperation.hpp +++ b/include/viennals/lsBooleanOperation.hpp @@ -1,5 +1,4 @@ -#ifndef LS_BOOLEAN_OPERATION_HPP -#define LS_BOOLEAN_OPERATION_HPP +#pragma once #include @@ -7,9 +6,15 @@ #include #include -#include #include +#include +#include + +namespace viennals { + +using namespace viennacore; + /// Enumeration for the different types /// of boolean operations which are /// supported. @@ -17,7 +22,7 @@ /// When CUSTOM, the user has to supply a valid /// function pointer of the form const T (*comp)(const T &, const T &). /// For CUSTOM only the first level set pointer is checked for validity. -enum struct lsBooleanOperationEnum : unsigned { +enum struct BooleanOperationEnum : unsigned { INTERSECT = 0, UNION = 1, RELATIVE_COMPLEMENT = 2, @@ -35,24 +40,24 @@ enum struct lsBooleanOperationEnum : unsigned { /// always return the smaller of the two values. /// The function signature for the comparator is defined in the public /// ComparatorType. -template class lsBooleanOperation { +template class BooleanOperation { public: using ComparatorType = std::pair (*)(const T &, const T &); private: - typedef typename lsDomain::DomainType hrleDomainType; - lsSmartPointer> levelSetA = nullptr; - lsSmartPointer> levelSetB = nullptr; - lsBooleanOperationEnum operation = lsBooleanOperationEnum::INTERSECT; + typedef typename Domain::DomainType hrleDomainType; + SmartPointer> levelSetA = nullptr; + SmartPointer> levelSetB = nullptr; + BooleanOperationEnum operation = BooleanOperationEnum::INTERSECT; ComparatorType operationComp = nullptr; bool updatePointData = true; bool pruneResult = true; void booleanOpInternal(ComparatorType comp) { auto &grid = levelSetA->getGrid(); - auto newlsDomain = lsSmartPointer>::New(grid); - typename lsDomain::DomainType &newDomain = newlsDomain->getDomain(); - typename lsDomain::DomainType &domain = levelSetA->getDomain(); + auto newlsDomain = SmartPointer>::New(grid); + typename Domain::DomainType &newDomain = newlsDomain->getDomain(); + typename Domain::DomainType &domain = levelSetA->getDomain(); newDomain.initialize(domain.getNewSegmentation(), domain.getAllocation()); @@ -93,8 +98,8 @@ template class lsBooleanOperation { const auto &comparison = comp(itA.getValue(), itB.getValue()); const auto ¤tValue = comparison.first; - if (currentValue != lsDomain::NEG_VALUE && - currentValue != lsDomain::POS_VALUE) { + if (currentValue != Domain::NEG_VALUE && + currentValue != Domain::POS_VALUE) { domainSegment.insertNextDefinedPoint(currentVector, currentValue); if (updateData) { // if taken from A, set to true @@ -106,8 +111,8 @@ template class lsBooleanOperation { } } else { domainSegment.insertNextUndefinedPoint( - currentVector, (currentValue < 0) ? lsDomain::NEG_VALUE - : lsDomain::POS_VALUE); + currentVector, (currentValue < 0) ? Domain::NEG_VALUE + : Domain::POS_VALUE); } switch (compare(itA.getEndIndices(), itB.getEndIndices())) { @@ -149,7 +154,7 @@ template class lsBooleanOperation { if (BPointer != nullptr) { auto APointer = AData.getScalarData(i); // copy all data into the new scalarData - typename lsDomain::PointDataType::ScalarDataType scalars; + typename Domain::PointDataType::ScalarDataType scalars; scalars.resize(newlsDomain->getNumberOfPoints()); for (unsigned j = 0; j < newlsDomain->getNumberOfPoints(); ++j) { scalars[j] = (newDataLS[0][j]) @@ -167,7 +172,7 @@ template class lsBooleanOperation { if (BPointer != nullptr) { auto APointer = AData.getVectorData(i); // copy all data into the new vectorData - typename lsDomain::PointDataType::VectorDataType vectors; + typename Domain::PointDataType::VectorDataType vectors; vectors.resize(newlsDomain->getNumberOfPoints()); for (unsigned j = 0; j < newlsDomain->getNumberOfPoints(); ++j) { vectors[j] = (newDataLS[0][j]) @@ -184,12 +189,12 @@ template class lsBooleanOperation { newlsDomain->setLevelSetWidth(levelSetA->getLevelSetWidth()); if (pruneResult) { - auto pruner = lsPrune(newlsDomain); + auto pruner = Prune(newlsDomain); pruner.setRemoveStrayZeros(true); pruner.apply(); // now we need to prune, to remove stray defined points - lsPrune(newlsDomain).apply(); + Prune(newlsDomain).apply(); } levelSetA->deepCopy(newlsDomain); @@ -212,13 +217,13 @@ template class lsBooleanOperation { // add undefined values if missing if (domainSegment.undefinedValues.size() < 1) { - domainSegment.undefinedValues.push_back(T(lsDomain::NEG_VALUE)); + domainSegment.undefinedValues.push_back(T(Domain::NEG_VALUE)); } if (domainSegment.undefinedValues.size() < 2) { - if (domainSegment.undefinedValues[0] == lsDomain::NEG_VALUE) { - domainSegment.undefinedValues.push_back(T(lsDomain::POS_VALUE)); + if (domainSegment.undefinedValues[0] == Domain::NEG_VALUE) { + domainSegment.undefinedValues.push_back(T(Domain::POS_VALUE)); } else { - domainSegment.undefinedValues.push_back(T(lsDomain::NEG_VALUE)); + domainSegment.undefinedValues.push_back(T(Domain::NEG_VALUE)); } } @@ -260,33 +265,33 @@ template class lsBooleanOperation { } public: - lsBooleanOperation() {} + BooleanOperation() {} - lsBooleanOperation( - lsSmartPointer> passedlsDomain, - lsBooleanOperationEnum passedOperation = lsBooleanOperationEnum::INVERT) + BooleanOperation( + SmartPointer> passedlsDomain, + BooleanOperationEnum passedOperation = BooleanOperationEnum::INVERT) : levelSetA(passedlsDomain), operation(passedOperation) {} - lsBooleanOperation(lsSmartPointer> passedlsDomainA, - lsSmartPointer> passedlsDomainB, - lsBooleanOperationEnum passedOperation = - lsBooleanOperationEnum::INTERSECT) + BooleanOperation( + SmartPointer> passedlsDomainA, + SmartPointer> passedlsDomainB, + BooleanOperationEnum passedOperation = BooleanOperationEnum::INTERSECT) : levelSetA(passedlsDomainA), levelSetB(passedlsDomainB), - operation(passedOperation) {}; + operation(passedOperation){}; /// Set which level set to perform the boolean operation on. - void setLevelSet(lsSmartPointer> passedlsDomain) { + void setLevelSet(SmartPointer> passedlsDomain) { levelSetA = passedlsDomain; } /// Set the level set which will be used to modify the /// first level set. - void setSecondLevelSet(lsSmartPointer> passedlsDomain) { + void setSecondLevelSet(SmartPointer> passedlsDomain) { levelSetB = passedlsDomain; } - /// Set which of the operations of lsBooleanOperationEnum to perform. - void setBooleanOperation(lsBooleanOperationEnum passedOperation) { + /// Set which of the operations of BooleanOperationEnum to perform. + void setBooleanOperation(BooleanOperationEnum passedOperation) { operation = passedOperation; } @@ -306,8 +311,8 @@ template class lsBooleanOperation { /// Perform operation. void apply() { if (levelSetA == nullptr) { - lsMessage::getInstance() - .addWarning("No level set was passed to lsBooleanOperation. Not " + Logger::getInstance() + .addWarning("No level set was passed to BooleanOperation. Not " "performing operation.") .print(); return; @@ -315,8 +320,8 @@ template class lsBooleanOperation { if (static_cast(operation) < 3) { if (levelSetB == nullptr) { - lsMessage::getInstance() - .addWarning("Only one level set was passed to lsBooleanOperation, " + Logger::getInstance() + .addWarning("Only one level set was passed to BooleanOperation, " "although two were required. Not performing operation.") .print(); return; @@ -324,22 +329,22 @@ template class lsBooleanOperation { } switch (operation) { - case lsBooleanOperationEnum::INTERSECT: - booleanOpInternal(&lsBooleanOperation::maxComp); + case BooleanOperationEnum::INTERSECT: + booleanOpInternal(&BooleanOperation::maxComp); break; - case lsBooleanOperationEnum::UNION: - booleanOpInternal(&lsBooleanOperation::minComp); + case BooleanOperationEnum::UNION: + booleanOpInternal(&BooleanOperation::minComp); break; - case lsBooleanOperationEnum::RELATIVE_COMPLEMENT: - booleanOpInternal(&lsBooleanOperation::relativeComplementComp); + case BooleanOperationEnum::RELATIVE_COMPLEMENT: + booleanOpInternal(&BooleanOperation::relativeComplementComp); break; - case lsBooleanOperationEnum::INVERT: + case BooleanOperationEnum::INVERT: invert(); break; - case lsBooleanOperationEnum::CUSTOM: + case BooleanOperationEnum::CUSTOM: if (operationComp == nullptr) { - lsMessage::getInstance() - .addWarning("No comparator supplied to custom lsBooleanOperation. " + Logger::getInstance() + .addWarning("No comparator supplied to custom BooleanOperation. " "Not performing operation.") .print(); return; @@ -350,6 +355,6 @@ template class lsBooleanOperation { }; // add all template specialisations for this class -PRECOMPILE_PRECISION_DIMENSION(lsBooleanOperation) +PRECOMPILE_PRECISION_DIMENSION(BooleanOperation) -#endif // LS_BOOLEAN_OPERATION_HPP +} // namespace viennals diff --git a/include/viennals/lsCalculateCurvatures.hpp b/include/viennals/lsCalculateCurvatures.hpp index a17c788e..e3716095 100644 --- a/include/viennals/lsCalculateCurvatures.hpp +++ b/include/viennals/lsCalculateCurvatures.hpp @@ -1,11 +1,17 @@ -#ifndef LS_CALCULATE_CURVATURES_HPP -#define LS_CALCULATE_CURVATURES_HPP +#pragma once #include #include #include -enum struct lsCurvatureEnum : unsigned { +#include +#include + +namespace viennals { + +using namespace viennacore; + +enum struct CurvatureEnum : unsigned { MEAN_CURVATURE = 0, GAUSSIAN_CURVATURE = 1, MEAN_AND_GAUSSIAN_CURVATURE = 2 @@ -14,36 +20,36 @@ enum struct lsCurvatureEnum : unsigned { // Calculates the Mean Curvature and/or Gaussian Curvature (3D) // for the passed lsDomain for all points with level set values <= 0.5. The // result is saved in the lsDomain. -template class lsCalculateCurvatures { - lsSmartPointer> levelSet = nullptr; +template class CalculateCurvatures { + SmartPointer> levelSet = nullptr; T maxValue = 0.5; - lsCurvatureEnum type = lsCurvatureEnum::MEAN_CURVATURE; + CurvatureEnum type = CurvatureEnum::MEAN_CURVATURE; public: static constexpr char meanCurvatureLabel[] = "MeanCurvatures"; static constexpr char gaussianCurvatureLabel[] = "GaussianCurvatures"; - lsCalculateCurvatures() {} + CalculateCurvatures() {} - lsCalculateCurvatures(lsSmartPointer> passedLevelSet) + CalculateCurvatures(SmartPointer> passedLevelSet) : levelSet(passedLevelSet) {} - lsCalculateCurvatures(lsSmartPointer> passedLevelSet, - lsCurvatureEnum method) + CalculateCurvatures(SmartPointer> passedLevelSet, + CurvatureEnum method) : levelSet(passedLevelSet), type(method) {} - void setLevelSet(lsSmartPointer> passedLevelSet) { + void setLevelSet(SmartPointer> passedLevelSet) { levelSet = passedLevelSet; } - void setCurvatureType(lsCurvatureEnum passedType) { + void setCurvatureType(CurvatureEnum passedType) { // in 2D there is only one option so ignore if constexpr (D == 3) { type = passedType; } else { if (passedType != type) { - lsMessage::getInstance().addWarning( - "lsCalculateCurvatures: Could not set curvature type because 2D " + Logger::getInstance().addWarning( + "CalculateCurvatures: Could not set curvature type because 2D " "only supports mean curvature."); } } @@ -53,16 +59,16 @@ template class lsCalculateCurvatures { void apply() { if (levelSet == nullptr) { - lsMessage::getInstance() - .addWarning("No level set was passed to lsCalculateCurvatures.") + Logger::getInstance() + .addWarning("No level set was passed to CalculateCurvatures.") .print(); } // need second neighbours if (unsigned minWidth = std::ceil((maxValue * 8) + 1); levelSet->getLevelSetWidth() < minWidth) { - lsMessage::getInstance() - .addWarning("lsCalculateCurvatures: Level set width must be " + Logger::getInstance() + .addWarning("CalculateCurvatures: Level set width must be " "at least " + std::to_string(minWidth) + " !") .print(); @@ -75,11 +81,11 @@ template class lsCalculateCurvatures { auto grid = levelSet->getGrid(); const bool calculateMean = - (type == lsCurvatureEnum::MEAN_CURVATURE) || - (type == lsCurvatureEnum::MEAN_AND_GAUSSIAN_CURVATURE); + (type == CurvatureEnum::MEAN_CURVATURE) || + (type == CurvatureEnum::MEAN_AND_GAUSSIAN_CURVATURE); const bool calculateGauss = - (type == lsCurvatureEnum::GAUSSIAN_CURVATURE) || - (type == lsCurvatureEnum::MEAN_AND_GAUSSIAN_CURVATURE); + (type == CurvatureEnum::GAUSSIAN_CURVATURE) || + (type == CurvatureEnum::MEAN_AND_GAUSSIAN_CURVATURE); //! Calculate Curvatures #pragma omp parallel num_threads(levelSet->getNumberOfSegments()) @@ -110,7 +116,7 @@ template class lsCalculateCurvatures { ? levelSet->getDomain().getSegmentation()[p] : grid.incrementIndices(grid.getMaxGridPoint()); - for (hrleCartesianPlaneIterator::DomainType> + for (hrleCartesianPlaneIterator::DomainType> neighborIt(levelSet->getDomain(), startVector); neighborIt.getIndices() < endVector; neighborIt.next()) { @@ -193,4 +199,4 @@ template class lsCalculateCurvatures { } }; -#endif // LS_CALCULATE_CURVATURES_HPP \ No newline at end of file +} // namespace viennals diff --git a/include/viennals/lsCalculateNormalVectors.hpp b/include/viennals/lsCalculateNormalVectors.hpp index 90994dd8..99ab16a3 100644 --- a/include/viennals/lsCalculateNormalVectors.hpp +++ b/include/viennals/lsCalculateNormalVectors.hpp @@ -1,5 +1,4 @@ -#ifndef LS_CALCULATE_NORMAL_VECTORS_HPP -#define LS_CALCULATE_NORMAL_VECTORS_HPP +#pragma once #include @@ -9,28 +8,35 @@ #include #include -#include + +#include +#include +#include + +namespace viennals { + +using namespace viennacore; /// This algorithm is used to compute the normal vectors for all points /// with level set values <= 0.5. The result is saved in the lsPointData of the /// lsDomain and can be retrieved with /// lsDomain.getPointData().getVectorData("Normals"). Since neighbors in each -/// cartesian direction are necessary for the calculation, the levelset width +/// cartesian direction are necessary for the calculation, the level set width /// must be >=3. -template class lsCalculateNormalVectors { - lsSmartPointer> levelSet = nullptr; +template class CalculateNormalVectors { + SmartPointer> levelSet = nullptr; T maxValue = 0.5; public: static constexpr char normalVectorsLabel[] = "Normals"; - lsCalculateNormalVectors() {} + CalculateNormalVectors() {} - lsCalculateNormalVectors(lsSmartPointer> passedLevelSet, - T passedMaxValue = 0.5) + CalculateNormalVectors(SmartPointer> passedLevelSet, + T passedMaxValue = 0.5) : levelSet(passedLevelSet), maxValue(passedMaxValue) {} - void setLevelSet(lsSmartPointer> passedLevelSet) { + void setLevelSet(SmartPointer> passedLevelSet) { levelSet = passedLevelSet; } @@ -38,20 +44,20 @@ template class lsCalculateNormalVectors { void apply() { if (levelSet == nullptr) { - lsMessage::getInstance() - .addWarning("No level set was passed to lsCalculateNormalVectors.") + Logger::getInstance() + .addWarning("No level set was passed to CalculateNormalVectors.") .print(); } if (levelSet->getLevelSetWidth() < (maxValue * 4) + 1) { - lsMessage::getInstance() - .addWarning("lsCalculateNormalVectors: Level set width must be " + Logger::getInstance() + .addWarning("CalculateNormalVectors: Level set width must be " "greater than " + std::to_string((maxValue * 4) + 1) + "!") .print(); } - std::vector>> normalVectorsVector( + std::vector>> normalVectorsVector( levelSet->getNumberOfSegments()); double pointsPerSegment = double(2 * levelSet->getDomain().getNumberOfPoints()) / @@ -79,7 +85,7 @@ template class lsCalculateNormalVectors { ? levelSet->getDomain().getSegmentation()[p] : grid.incrementIndices(grid.getMaxGridPoint()); - for (hrleConstSparseStarIterator::DomainType, 1> + for (hrleConstSparseStarIterator::DomainType, 1> neighborIt(levelSet->getDomain(), startVector); neighborIt.getIndices() < endVector; neighborIt.next()) { @@ -88,12 +94,12 @@ template class lsCalculateNormalVectors { continue; } else if (std::abs(center.getValue()) > maxValue) { // push an empty vector to keep ordering correct - std::array tmp = {}; + Triple tmp = {}; normalVectors.push_back(tmp); continue; } - std::array n; + Triple n; T denominator = 0; for (int i = 0; i < D; i++) { @@ -106,9 +112,9 @@ template class lsCalculateNormalVectors { denominator = std::sqrt(denominator); if (std::abs(denominator) < 1e-12) { std::ostringstream oss; - oss << "lsCalculateNormalVectors: Vector of length 0 at " + oss << "CalculateNormalVectors: Vector of length 0 at " << neighborIt.getIndices(); - lsMessage::getInstance().addWarning(oss.str()).print(); + Logger::getInstance().addWarning(oss.str()).print(); for (unsigned i = 0; i < D; ++i) n[i] = 0.; } else { @@ -149,6 +155,6 @@ template class lsCalculateNormalVectors { }; // add all template specialisations for this class -PRECOMPILE_PRECISION_DIMENSION(lsCalculateNormalVectors) +PRECOMPILE_PRECISION_DIMENSION(CalculateNormalVectors) -#endif // LS_CALCULATE_NORMAL_VECTORS_HPP +} // namespace viennals diff --git a/include/viennals/lsCheck.hpp b/include/viennals/lsCheck.hpp index 4c400c29..42aa17d1 100644 --- a/include/viennals/lsCheck.hpp +++ b/include/viennals/lsCheck.hpp @@ -1,5 +1,4 @@ -#ifndef LS_CHECK_HPP -#define LS_CHECK_HPP +#pragma once #include #include @@ -8,7 +7,11 @@ #include -enum struct lsCheckStatusEnum : unsigned { +namespace viennals { + +using namespace viennacore; + +enum struct CheckStatusEnum : unsigned { SUCCESS = 0, FAILED = 1, UNCHECKED = 2 @@ -16,9 +19,9 @@ enum struct lsCheckStatusEnum : unsigned { /// This class is used to find errors in the underlying level set /// structure, like invalid neighbours of different signs. -template class lsCheck { - lsSmartPointer> levelSet = nullptr; - lsCheckStatusEnum status = lsCheckStatusEnum::UNCHECKED; +template class Check { + SmartPointer> levelSet = nullptr; + CheckStatusEnum status = CheckStatusEnum::UNCHECKED; std::string errors = "Level Set has not been checked yet!"; bool printMessage = false; @@ -37,8 +40,8 @@ template class lsCheck { } else if (i == 2) { result += "z"; } else { - lsMessage::getInstance().addError("lsCheck: " + std::to_string(i) + - " is not a valid direction index!"); + Logger::getInstance().addError("Check: " + std::to_string(i) + + " is not a valid direction index!"); } return result; } @@ -55,27 +58,27 @@ template class lsCheck { } public: - lsCheck() {} + Check() {} - lsCheck(lsSmartPointer> passedLevelSet, bool print = false) + Check(SmartPointer> passedLevelSet, bool print = false) : levelSet(passedLevelSet), printMessage(print) {} - void setLevelSet(lsSmartPointer> passedLevelSet) { + void setLevelSet(SmartPointer> passedLevelSet) { levelSet = passedLevelSet; } void setPrintMessage(bool print) { printMessage = print; } - lsCheckStatusEnum getStatus() const { return status; } + CheckStatusEnum getStatus() const { return status; } - bool isValid() const { return status == lsCheckStatusEnum::SUCCESS; } + bool isValid() const { return status == CheckStatusEnum::SUCCESS; } std::string what() const { return errors; } void apply() { if (levelSet == nullptr) { - lsMessage::getInstance() - .addWarning("No level set was passed to lsCheck.") + Logger::getInstance() + .addWarning("No level set was passed to Check.") .print(); return; } @@ -137,17 +140,17 @@ template class lsCheck { // output any faults as error if (std::string s = oss.str(); !s.empty()) { - status = lsCheckStatusEnum::FAILED; + status = CheckStatusEnum::FAILED; errors = s; if (printMessage) { - std::string message = "Report from lsCheck:\n" + s; - lsMessage::getInstance().addError(s); + std::string message = "Report from Check:\n" + s; + Logger::getInstance().addError(s); } } else { - status = lsCheckStatusEnum::SUCCESS; + status = CheckStatusEnum::SUCCESS; errors = ""; } } }; -#endif // LS_CHECK_HPP +} // namespace viennals diff --git a/include/viennals/lsConcepts.hpp b/include/viennals/lsConcepts.hpp index f3fc6d15..aa331cf2 100644 --- a/include/viennals/lsConcepts.hpp +++ b/include/viennals/lsConcepts.hpp @@ -1,5 +1,4 @@ -#ifndef LS_CONCEPTS_HPP -#define LS_CONCEPTS_HPP +#pragma once #include #include @@ -25,5 +24,3 @@ using IsFloatingPoint = std::enable_if_t::value, AssignType>; } // namespace lsConcepts - -#endif // LS_CONCEPTS_HPP \ No newline at end of file diff --git a/include/viennals/lsConvexHull.hpp b/include/viennals/lsConvexHull.hpp index 3771c4c0..c8a2d80e 100644 --- a/include/viennals/lsConvexHull.hpp +++ b/include/viennals/lsConvexHull.hpp @@ -1,5 +1,4 @@ -#ifndef LS_CONVEX_HULL_HPP -#define LS_CONVEX_HULL_HPP +#pragma once #include @@ -11,17 +10,23 @@ #include #include -#include -#include + +#include +#include +#include + +namespace viennals { + +using namespace viennacore; /// This algorithm creates a convex hull mesh from a /// point cloud. This is done using the gift wrapping approach. /// The points in the point cloud MUST be unique, otherwise this will fail. -template class lsConvexHull { +template class ConvexHull { typedef hrleVectorType EdgeType; - lsSmartPointer> mesh = nullptr; - lsSmartPointer> pointCloud = nullptr; + SmartPointer> mesh = nullptr; + SmartPointer> pointCloud = nullptr; std::vector visitedEdges; std::vector> hullElements; std::list remainingEdges; @@ -265,28 +270,28 @@ template class lsConvexHull { } public: - lsConvexHull() {} + ConvexHull() {} - lsConvexHull(lsSmartPointer> passedMesh, - lsSmartPointer> passedPointCloud) + ConvexHull(SmartPointer> passedMesh, + SmartPointer> passedPointCloud) : mesh(passedMesh), pointCloud(passedPointCloud) {} - void setMesh(lsSmartPointer> passedMesh) { mesh = passedMesh; } + void setMesh(SmartPointer> passedMesh) { mesh = passedMesh; } - void setPointCloud(lsSmartPointer> passedPointCloud) { + void setPointCloud(SmartPointer> passedPointCloud) { pointCloud = passedPointCloud; } void apply() { if (mesh == nullptr) { - lsMessage::getInstance() - .addWarning("No mesh was passed to lsConvexHull.") + Logger::getInstance() + .addWarning("No mesh was passed to ConvexHull.") .print(); return; } if (pointCloud == nullptr) { - lsMessage::getInstance() - .addWarning("No point cloud was passed to lsConvexHull.") + Logger::getInstance() + .addWarning("No point cloud was passed to ConvexHull.") .print(); return; } @@ -402,9 +407,9 @@ template class lsConvexHull { // if insertion took place, add the point to the nodes if (insertion.second) { - std::array node{ - points[hullElements[i][j]][0], points[hullElements[i][j]][1], - (D == 2) ? T(0.) : points[hullElements[i][j]][2]}; + Triple node{points[hullElements[i][j]][0], + points[hullElements[i][j]][1], + (D == 2) ? T(0.) : points[hullElements[i][j]][2]}; mesh->nodes.push_back(node); } @@ -417,6 +422,6 @@ template class lsConvexHull { }; // add all template specialisations for this class -PRECOMPILE_PRECISION_DIMENSION(lsConvexHull) +PRECOMPILE_PRECISION_DIMENSION(ConvexHull) -#endif // LS_CONVEX_HULL_HPP +} // namespace viennals diff --git a/include/viennals/lsCurvatureFormulas.hpp b/include/viennals/lsCurvatureFormulas.hpp index 93569df7..f1bc6bc1 100644 --- a/include/viennals/lsCurvatureFormulas.hpp +++ b/include/viennals/lsCurvatureFormulas.hpp @@ -1,12 +1,15 @@ -#ifndef LS_CURVATURE_FORMULAS_HPP -#define LS_CURVATURE_FORMULAS_HPP +#pragma once #include #include +#include + namespace lsInternal { +using namespace viennacore; + // Formulas for space curves and higher dimension can be found here: // https://doi.org/10.1016/j.cagd.2005.06.005 @@ -184,7 +187,7 @@ T gaussianCurvature(It &it, bool bigStencil = false) { else d = smallStencilFromIterator(it, gridDelta); if constexpr (D == 2) { - lsMessage::getInstance() + Logger::getInstance() .addWarning( "2D structures do not have a Gaussian Curvature, use " "\"meanCurvature(IteratorType & neighborIterator)\" instead!") @@ -196,5 +199,3 @@ T gaussianCurvature(It &it, bool bigStencil = false) { } } // namespace lsInternal - -#endif // LS_CURVATURE_FORMULAS_HPP diff --git a/include/viennals/lsDetectFeatures.hpp b/include/viennals/lsDetectFeatures.hpp index bba2413f..b12ec74d 100644 --- a/include/viennals/lsDetectFeatures.hpp +++ b/include/viennals/lsDetectFeatures.hpp @@ -1,5 +1,4 @@ -#ifndef LS_FEATURE_DETECTION_HPP -#define LS_FEATURE_DETECTION_HPP +#pragma once #include #include @@ -8,7 +7,14 @@ #include #include -enum struct lsFeatureDetectionEnum : unsigned { +#include +#include + +namespace viennals { + +using namespace viennacore; + +enum struct FeatureDetectionEnum : unsigned { CURVATURE = 0, NORMALS_ANGLE = 1, }; @@ -18,10 +24,10 @@ enum struct lsFeatureDetectionEnum : unsigned { /// and based on the angle between surface normals. The curvature-based /// algorithm is the default as it leads to more accurate results and should be /// preferred in general. -template class lsDetectFeatures { - typedef typename lsDomain::DomainType hrleDomainType; - lsSmartPointer> levelSet = nullptr; - lsFeatureDetectionEnum method = lsFeatureDetectionEnum::CURVATURE; +template class DetectFeatures { + typedef typename Domain::DomainType hrleDomainType; + SmartPointer> levelSet = nullptr; + FeatureDetectionEnum method = FeatureDetectionEnum::CURVATURE; T flatLimit = 1.; T flatLimit2 = 1.; std::vector flaggedCells; @@ -29,17 +35,17 @@ template class lsDetectFeatures { public: static constexpr char featureMarkersLabel[] = "FeatureMarkers"; - lsDetectFeatures() {} + DetectFeatures() {} - lsDetectFeatures(lsSmartPointer> passedLevelSet) + DetectFeatures(SmartPointer> passedLevelSet) : levelSet(passedLevelSet) {} - lsDetectFeatures(lsSmartPointer> passedLevelSet, T passedLimit) + DetectFeatures(SmartPointer> passedLevelSet, T passedLimit) : levelSet(passedLevelSet), flatLimit(passedLimit), flatLimit2(flatLimit * flatLimit) {} - lsDetectFeatures(lsSmartPointer> passedLevelSet, T passedLimit, - lsFeatureDetectionEnum passedMethod) + DetectFeatures(SmartPointer> passedLevelSet, T passedLimit, + FeatureDetectionEnum passedMethod) : levelSet(passedLevelSet), flatLimit(passedLimit), flatLimit2(flatLimit * flatLimit), method(passedMethod) {} @@ -51,13 +57,13 @@ template class lsDetectFeatures { /// Set which algorithm to use to detect features. The curvature-based /// algorithm should always be preferred, while the normals-based algorithm is /// just provided for experimental use. - void setDetectionMethod(lsFeatureDetectionEnum passedMethod) { + void setDetectionMethod(FeatureDetectionEnum passedMethod) { method = passedMethod; } /// Execute the algorithm. void apply() { - if (method == lsFeatureDetectionEnum::CURVATURE) { + if (method == FeatureDetectionEnum::CURVATURE) { FeatureDetectionCurvature(); } else { FeatureDetectionNormals(); @@ -86,7 +92,7 @@ template class lsDetectFeatures { flaggedCells.clear(); auto grid = levelSet->getGrid(); - typename lsDomain::DomainType &domain = levelSet->getDomain(); + typename Domain::DomainType &domain = levelSet->getDomain(); std::vector> flagsReserve(levelSet->getNumberOfSegments()); #pragma omp parallel num_threads((levelSet)->getNumberOfSegments()) @@ -108,7 +114,7 @@ template class lsDetectFeatures { ? domain.getSegmentation()[p] : grid.incrementIndices(grid.getMaxGridPoint()); - for (hrleCartesianPlaneIterator::DomainType> + for (hrleCartesianPlaneIterator::DomainType> neighborIt(levelSet->getDomain(), startVector, 1); neighborIt.getIndices() < endVector; neighborIt.next()) { @@ -155,10 +161,10 @@ template class lsDetectFeatures { T cosAngleTreshold = std::cos(flatLimit); // CALCULATE NORMALS - lsExpand(levelSet, 3).apply(); - lsCalculateNormalVectors(levelSet).apply(); + Expand(levelSet, 3).apply(); + CalculateNormalVectors(levelSet).apply(); const auto &normals = *(levelSet->getPointData().getVectorData( - lsCalculateNormalVectors::normalVectorsLabel)); + CalculateNormalVectors::normalVectorsLabel)); std::vector> flagsReserve(levelSet->getNumberOfSegments()); @@ -170,7 +176,7 @@ template class lsDetectFeatures { p = omp_get_thread_num(); #endif - std::array zeroVector{}; + Triple zeroVector{}; std::vector &flagsSegment = flagsReserve[p]; flagsSegment.reserve( @@ -184,8 +190,8 @@ template class lsDetectFeatures { ? domain.getSegmentation()[p] : grid.incrementIndices(grid.getMaxGridPoint()); - for (hrleSparseBoxIterator::DomainType> - neighborIt(levelSet->getDomain(), startVector, 1); + for (hrleSparseBoxIterator::DomainType> neighborIt( + levelSet->getDomain(), startVector, 1); neighborIt.getIndices() < endVector; neighborIt.next()) { if (!neighborIt.getCenter().isDefined()) { continue; @@ -194,13 +200,12 @@ template class lsDetectFeatures { continue; } - std::array centerNormal = - normals[neighborIt.getCenter().getPointId()]; + Triple centerNormal = normals[neighborIt.getCenter().getPointId()]; bool flag = false; for (unsigned dir = 0; dir < (D * D * D); dir++) { - std::array currentNormal = + Triple currentNormal = normals[neighborIt.getNeighbor(dir).getPointId()]; if (currentNormal != zeroVector) { @@ -231,4 +236,4 @@ template class lsDetectFeatures { } }; -#endif // LS_FEATURE_DETECTION_HPP \ No newline at end of file +} // namespace viennals diff --git a/include/viennals/lsDomain.hpp b/include/viennals/lsDomain.hpp index 402e35fe..3fc37104 100644 --- a/include/viennals/lsDomain.hpp +++ b/include/viennals/lsDomain.hpp @@ -1,5 +1,4 @@ -#ifndef LS_DOMAIN_HPP -#define LS_DOMAIN_HPP +#pragma once #include @@ -10,27 +9,33 @@ #include #include -#include + +#include +#include #define LS_DOMAIN_SERIALIZATION_VERSION 0 +namespace viennals { + +using namespace viennacore; + // Boundary condition alias for easier access template -using lsBoundaryConditionEnum = typename hrleGrid::boundaryType; +using BoundaryConditionEnum = typename hrleGrid::boundaryType; /// Class containing all information about the level set, including /// the dimensions of the domain, boundary conditions and all data. -template class lsDomain { +template class Domain { public: // TYPEDEFS typedef T ValueType; typedef hrleGrid GridType; typedef hrleDomain DomainType; - typedef lsBoundaryConditionEnum BoundaryType; + typedef BoundaryConditionEnum BoundaryType; typedef typename std::vector, T>> PointValueVectorType; typedef typename std::vector> NormalVectorType; - typedef lsPointData PointDataType; + typedef PointData PointDataType; typedef typename std::vector VoidPointMarkersType; private: @@ -49,8 +54,8 @@ template class lsDomain { static constexpr T POS_VALUE = std::numeric_limits::max(); static constexpr T NEG_VALUE = std::numeric_limits::lowest(); - /// initalise an empty infinite lsDomain - lsDomain(hrleCoordType gridDelta = 1.0) { + /// initalise an empty infinite Domain + Domain(hrleCoordType gridDelta = 1.0) { hrleIndexType gridMin[D], gridMax[D]; BoundaryType boundaryCons[D]; for (unsigned i = 0; i < D; ++i) { @@ -63,8 +68,8 @@ template class lsDomain { domain.deepCopy(grid, DomainType(grid, T(POS_VALUE))); } - lsDomain(hrleCoordType *bounds, BoundaryType *boundaryConditions, - hrleCoordType gridDelta = 1.0) { + Domain(hrleCoordType *bounds, BoundaryType *boundaryConditions, + hrleCoordType gridDelta = 1.0) { hrleIndexType gridMin[D], gridMax[D]; for (unsigned i = 0; i < D; ++i) { gridMin[i] = std::floor(bounds[2 * i] / gridDelta); @@ -75,34 +80,34 @@ template class lsDomain { domain.deepCopy(grid, DomainType(grid, T(POS_VALUE))); } - lsDomain(std::vector bounds, - std::vector boundaryConditions, - hrleCoordType gridDelta = 1.0) { + Domain(std::vector bounds, + std::vector boundaryConditions, + hrleCoordType gridDelta = 1.0) { BoundaryType boundaryCons[D]; for (unsigned i = 0; i < D; ++i) { boundaryCons[i] = static_cast(boundaryConditions[i]); } - auto newDomain = lsSmartPointer>::New( - bounds.data(), boundaryCons, gridDelta); + auto newDomain = + SmartPointer>::New(bounds.data(), boundaryCons, gridDelta); this->deepCopy(newDomain); } - /// initialise lsDomain with domain size "bounds", filled with point/value + /// initialise Domain with domain size "bounds", filled with point/value /// pairs in pointData - lsDomain(PointValueVectorType pointData, hrleCoordType *bounds, - BoundaryType *boundaryConditions, hrleCoordType gridDelta = 1.0) { - auto newDomain = lsSmartPointer>::New( - bounds, boundaryConditions, gridDelta); + Domain(PointValueVectorType pointData, hrleCoordType *bounds, + BoundaryType *boundaryConditions, hrleCoordType gridDelta = 1.0) { + auto newDomain = + SmartPointer>::New(bounds, boundaryConditions, gridDelta); this->deepCopy(newDomain); hrleFillDomainWithSignedDistance(domain, pointData, T(NEG_VALUE), T(POS_VALUE)); } - lsDomain(GridType passedGrid) : grid(passedGrid) { + Domain(GridType passedGrid) : grid(passedGrid) { domain.deepCopy(grid, DomainType(grid, T(POS_VALUE))); } - lsDomain(lsSmartPointer passedDomain) { deepCopy(passedDomain); } + Domain(SmartPointer passedDomain) { deepCopy(passedDomain); } /// this function sets a new levelset width and finalizes the levelset, so it /// is ready for use by other algorithms @@ -112,15 +117,15 @@ template class lsDomain { /// algorithms void finalize() {} - /// copy all values of "passedlsDomain" to this lsDomain - void deepCopy(const lsSmartPointer> passedlsDomain) { - grid = passedlsDomain->grid; - domain.deepCopy(grid, passedlsDomain->domain); - levelSetWidth = passedlsDomain->levelSetWidth; - pointData = passedlsDomain->pointData; + /// copy all values of "passedDomain" to this Domain + void deepCopy(const SmartPointer> passedDomain) { + grid = passedDomain->grid; + domain.deepCopy(grid, passedDomain->domain); + levelSetWidth = passedDomain->levelSetWidth; + pointData = passedDomain->pointData; } - /// re-initalise lsDomain with the point/value pairs in pointData + /// re-initalise Domain with the point/value pairs in pointData /// This is similar to lsFromMesh with the difference that pointData /// contains (INDEX, Value) pairs, while lsFromMesh expects coordinates /// rather than indices @@ -169,7 +174,7 @@ template class lsDomain { /// prints basic information and all memebers of the levelset structure void print(std::ostream &out = std::cout) { out << "Grid pointer: " << &grid << std::endl; - out << "Domain: " << &domain << std::endl; + out << "lsDomain: " << &domain << std::endl; out << "DomainSegments: " << std::endl; for (unsigned i = 0; i < getNumberOfSegments(); ++i) { out << &(domain.getDomainSegment(i)) << std::endl; @@ -177,9 +182,9 @@ template class lsDomain { domain.print(out); } - /// Serializes the lsDomain into a binary stream + /// Serializes the Domain into a binary stream std::ostream &serialize(std::ostream &stream) { - // Save header to identify lsDomain + // Save header to identify Domain stream << "lsDomain"; // now write format version number @@ -192,13 +197,13 @@ template class lsDomain { // serialize hrleDomain which saves LS values domain.serialize(stream); - // serialize lsDomain members + // serialize Domain members // level set width as 32bit uint const uint32_t width = levelSetWidth; stream.write(reinterpret_cast(&width), sizeof(uint32_t)); // serialize pointData if there is any point data associated with this - // lsDomain mark whether there is point data or not (1/0) + // Domain mark whether there is point data or not (1/0) char hasPointData = (pointData.empty()) ? 0 : 1; stream.write(&hasPointData, 1); if (hasPointData == 1) { @@ -208,15 +213,15 @@ template class lsDomain { return stream; } - /// Deserialize lsDomain from binary stream + /// Deserialize Domain from binary stream std::istream &deserialize(std::istream &stream) { // Check identifier char identifier[8]; stream.read(identifier, 8); if (std::string(identifier).compare(0, 8, "lsDomain")) { - lsMessage::getInstance() + Logger::getInstance() .addWarning( - "Reading lsDomain from stream failed. Header could not be found.") + "Reading Domain from stream failed. Header could not be found.") .print(); return stream; } @@ -225,9 +230,9 @@ template class lsDomain { char formatVersion; stream.read(&formatVersion, 1); if (formatVersion > LS_DOMAIN_SERIALIZATION_VERSION) { - lsMessage::getInstance() + Logger::getInstance() .addWarning( - "Reading lsDomain of version " + std::to_string(formatVersion) + + "Reading Domain of version " + std::to_string(formatVersion) + " with reader of version " + std::to_string(LS_DOMAIN_SERIALIZATION_VERSION) + " failed.") .print(); @@ -261,6 +266,6 @@ template class lsDomain { }; // add all template specialisations for this class -PRECOMPILE_PRECISION_DIMENSION(lsDomain) +PRECOMPILE_PRECISION_DIMENSION(Domain) -#endif // LS_DOMAIN_HPP +} // namespace viennals diff --git a/include/viennals/lsEnquistOsher.hpp b/include/viennals/lsEnquistOsher.hpp index 5be3450b..1e80d7ee 100644 --- a/include/viennals/lsEnquistOsher.hpp +++ b/include/viennals/lsEnquistOsher.hpp @@ -1,5 +1,4 @@ -#ifndef LS_ENQUIST_OSHER_SV_HPP -#define LS_ENQUIST_OSHER_SV_HPP +#pragma once #include #include @@ -8,27 +7,31 @@ #include #include +#include + namespace lsInternal { +using namespace viennals; + /// Engquist osher integration scheme based on the /// upwind integration scheme. Offers high performance /// but lower accuracy for complex velocity fields. -template class lsEnquistOsher { - lsSmartPointer> levelSet; - lsSmartPointer> velocities; +template class EnquistOsher { + SmartPointer> levelSet; + SmartPointer> velocities; hrleSparseStarIterator, order> neighborIterator; bool calculateNormalVectors = true; static T pow2(const T &value) { return value * value; } public: - static void prepareLS(lsSmartPointer> passedlsDomain) { + static void prepareLS(SmartPointer> passedlsDomain) { assert(order == 1 || order == 2); - lsExpand(passedlsDomain, 2 * order + 1).apply(); + Expand(passedlsDomain, 2 * order + 1).apply(); } - lsEnquistOsher(lsSmartPointer> passedlsDomain, - lsSmartPointer> vel, bool calcNormal = true) + EnquistOsher(SmartPointer> passedlsDomain, + SmartPointer> vel, bool calcNormal = true) : levelSet(passedlsDomain), velocities(vel), neighborIterator(hrleSparseStarIterator, order>( levelSet->getDomain())), @@ -115,7 +118,7 @@ template class lsEnquistOsher { // Calculate normal vector for velocity calculation // use std::array since it will be exposed to interface - std::array normalVector = {}; + Triple normalVector = {}; if (calculateNormalVectors) { T denominator = 0; for (int i = 0; i < D; i++) { @@ -133,12 +136,12 @@ template class lsEnquistOsher { } // convert coordinate to std array for interface - std::array coordArray = {coordinate[0], coordinate[1], coordinate[2]}; + Triple coordArray = {coordinate[0], coordinate[1], coordinate[2]}; double scalarVelocity = velocities->getScalarVelocity( coordArray, material, normalVector, neighborIterator.getCenter().getPointId()); - std::array vectorVelocity = velocities->getVectorVelocity( + Triple vectorVelocity = velocities->getVectorVelocity( coordArray, material, normalVector, neighborIterator.getCenter().getPointId()); @@ -161,5 +164,3 @@ template class lsEnquistOsher { }; } // namespace lsInternal - -#endif // LS_ENQUIST_OSHER_SV_HPP diff --git a/include/viennals/lsExpand.hpp b/include/viennals/lsExpand.hpp index 3c03f666..2dfe1841 100644 --- a/include/viennals/lsExpand.hpp +++ b/include/viennals/lsExpand.hpp @@ -1,32 +1,34 @@ -#ifndef LS_EXPAND_HPP -#define LS_EXPAND_HPP +#pragma once #include #include #include #include -#include + +namespace viennals { + +using namespace viennacore; /// Expands the leveleSet to the specified number of layers. /// The largest value in the levelset is thus width*0.5 /// Returns the number of added points -template class lsExpand { - typedef typename lsDomain::GridType GridType; - lsSmartPointer> levelSet = nullptr; +template class Expand { + typedef typename Domain::GridType GridType; + SmartPointer> levelSet = nullptr; int width = 0; bool updatePointData = true; public: - lsExpand() {} + Expand() {} - lsExpand(lsSmartPointer> passedlsDomain) + Expand(SmartPointer> passedlsDomain) : levelSet(passedlsDomain) {} - lsExpand(lsSmartPointer> passedlsDomain, int passedWidth) + Expand(SmartPointer> passedlsDomain, int passedWidth) : levelSet(passedlsDomain), width(passedWidth) {} - void setLevelSet(lsSmartPointer> passedlsDomain) { + void setLevelSet(SmartPointer> passedlsDomain) { levelSet = passedlsDomain; } @@ -41,8 +43,8 @@ template class lsExpand { /// Apply the expansion to the specified width void apply() { if (levelSet == nullptr) { - lsMessage::getInstance() - .addWarning("No level set passed to lsExpand. Not expanding.") + Logger::getInstance() + .addWarning("No level set passed to Expand. Not expanding.") .print(); return; } @@ -65,9 +67,9 @@ template class lsExpand { const T limit = (startWidth + currentCycle + 1) * T(0.5); auto &grid = levelSet->getGrid(); - auto newlsDomain = lsSmartPointer>::New(grid); - typename lsDomain::DomainType &newDomain = newlsDomain->getDomain(); - typename lsDomain::DomainType &domain = levelSet->getDomain(); + auto newlsDomain = SmartPointer>::New(grid); + typename Domain::DomainType &newDomain = newlsDomain->getDomain(); + typename Domain::DomainType &domain = levelSet->getDomain(); newDomain.initialize(domain.getNewSegmentation(), domain.getAllocation() * allocationFactor); @@ -97,7 +99,7 @@ template class lsExpand { ? newDomain.getSegmentation()[p] : grid.incrementIndices(grid.getMaxGridPoint()); - for (hrleSparseStarIterator::DomainType, 1> + for (hrleSparseStarIterator::DomainType, 1> neighborIt(domain, startVector); neighborIt.getIndices() < endVector; neighborIt.next()) { @@ -109,7 +111,7 @@ template class lsExpand { newDataSourceIds[p].push_back(centerIt.getPointId()); } else { if (centerIt.getValue() > -std::numeric_limits::epsilon()) { - T distance = lsDomain::POS_VALUE; + T distance = Domain::POS_VALUE; int neighbor = -1; for (int i = 0; i < 2 * D; i++) { T newValue = neighborIt.getNeighbor(i).getValue() + T(1); @@ -126,11 +128,11 @@ template class lsExpand { neighborIt.getNeighbor(neighbor).getPointId()); } else { // TODO: use insertNextUndefinedRunType - domainSegment.insertNextUndefinedPoint( - neighborIt.getIndices(), lsDomain::POS_VALUE); + domainSegment.insertNextUndefinedPoint(neighborIt.getIndices(), + Domain::POS_VALUE); } } else { - T distance = lsDomain::NEG_VALUE; + T distance = Domain::NEG_VALUE; int neighbor = -1; for (int i = 0; i < 2 * D; i++) { T newValue = neighborIt.getNeighbor(i).getValue() - T(1); @@ -147,8 +149,8 @@ template class lsExpand { neighborIt.getNeighbor(neighbor).getPointId()); } else { // TODO: use insertNextUndefinedRunType - domainSegment.insertNextUndefinedPoint( - neighborIt.getIndices(), lsDomain::NEG_VALUE); + domainSegment.insertNextUndefinedPoint(neighborIt.getIndices(), + Domain::NEG_VALUE); } } } @@ -170,6 +172,6 @@ template class lsExpand { }; // add all template specialisations for this class -PRECOMPILE_PRECISION_DIMENSION(lsExpand) +PRECOMPILE_PRECISION_DIMENSION(Expand) -#endif // LS_EXPAND_HPP +} // namespace viennals diff --git a/include/viennals/lsExtrude.hpp b/include/viennals/lsExtrude.hpp index 9c83977e..499d8428 100644 --- a/include/viennals/lsExtrude.hpp +++ b/include/viennals/lsExtrude.hpp @@ -1,69 +1,70 @@ -#ifndef LS_EXTRUDE_HPP -#define LS_EXTRUDE_HPP +#pragma once #include #include #include +namespace viennals { + +using namespace viennacore; + /// Extrudes a 2D Level Set into a 3D domain. The axis in which should be /// extruded can be set and boundary conditions in the 3D domain must be /// specified. -template class lsExtrude { - lsSmartPointer> inputLevelSet = nullptr; - lsSmartPointer> outputLevelSet = nullptr; - std::array extent = {0., 0.}; +template class Extrude { + SmartPointer> inputLevelSet = nullptr; + SmartPointer> outputLevelSet = nullptr; + Pair extent = {0., 0.}; int extrudeDim = 0; - std::array, 3> boundaryConds; + Triple> boundaryConds; public: - lsExtrude() {} - lsExtrude(lsSmartPointer> passedInputLS, - lsSmartPointer> passedOutputLS, - std::array passedExtent, const int passedExtrudeDim, - std::array, 3> passedBoundaryConds) + Extrude() {} + Extrude(SmartPointer> passedInputLS, + SmartPointer> passedOutputLS, Pair passedExtent, + const int passedExtrudeDim, + Triple> passedBoundaryConds) : inputLevelSet(passedInputLS), outputLevelSet(passedOutputLS), extent(passedExtent), extrudeDim(passedExtrudeDim), boundaryConds(passedBoundaryConds) {} - void setInputLevelSet(lsSmartPointer> passedInputLS) { + void setInputLevelSet(SmartPointer> passedInputLS) { inputLevelSet = passedInputLS; } // The 3D output LS will be overwritten by the extruded LS - void setOutputLevelSet(lsSmartPointer> &passedOutputLS) { + void setOutputLevelSet(SmartPointer> &passedOutputLS) { outputLevelSet = passedOutputLS; } // Set the min and max extent in the extruded dimension - void setExtent(std::array passedExtent) { extent = passedExtent; } + void setExtent(Pair passedExtent) { extent = passedExtent; } // Set which index of the added dimension (x: 0, y: 1, z: 2) void setExtrudeDimension(const int passedExtrudeDim) { extrudeDim = passedExtrudeDim; } - void setBoundaryConditions( - std::array, 3> passedBoundaryConds) { + void + setBoundaryConditions(Triple> passedBoundaryConds) { boundaryConds = passedBoundaryConds; } - void - setBoundaryConditions(lsBoundaryConditionEnum<3> passedBoundaryConds[3]) { + void setBoundaryConditions(BoundaryConditionEnum<3> passedBoundaryConds[3]) { for (int i = 0; i < 3; i++) boundaryConds[i] = passedBoundaryConds[i]; } void apply() { if (inputLevelSet == nullptr) { - lsMessage::getInstance() - .addWarning( - "No input Level Set supplied to lsExtrude! Not converting.") + Logger::getInstance() + .addWarning("No input Level Set supplied to Extrude! Not converting.") .print(); } if (outputLevelSet == nullptr) { - lsMessage::getInstance() + Logger::getInstance() .addWarning( - "No output Level Set supplied to lsExtrude! Not converting.") + "No output Level Set supplied to Extrude! Not converting.") .print(); return; } @@ -85,13 +86,13 @@ template class lsExtrude { domainBounds[2 * extrudeDims[1]] = gridDelta * minBounds[1]; domainBounds[2 * extrudeDims[1] + 1] = gridDelta * maxBounds[1]; - auto tmpLevelSet = lsSmartPointer>::New( + auto tmpLevelSet = SmartPointer>::New( domainBounds, boundaryConds.data(), gridDelta); outputLevelSet->deepCopy(tmpLevelSet); } - auto surface = lsSmartPointer>::New(); - lsToSurfaceMesh(inputLevelSet, surface).apply(); + auto surface = SmartPointer>::New(); + ToSurfaceMesh(inputLevelSet, surface).apply(); auto &lines = surface->template getElements<2>(); auto &nodes = surface->getNodes(); @@ -126,7 +127,7 @@ template class lsExtrude { } surface->template getElements<2>().clear(); // remove lines - lsFromSurfaceMesh(outputLevelSet, surface).apply(); + FromSurfaceMesh(outputLevelSet, surface).apply(); } private: @@ -142,4 +143,4 @@ template class lsExtrude { } }; -#endif // LS_EXTRUDE_HPP \ No newline at end of file +} // namespace viennals diff --git a/include/viennals/lsFileFormats.hpp b/include/viennals/lsFileFormats.hpp index bdf4033c..03baa04b 100644 --- a/include/viennals/lsFileFormats.hpp +++ b/include/viennals/lsFileFormats.hpp @@ -1,11 +1,10 @@ -#ifndef LS_FILE_FORMATS_HPP -#define LS_FILE_FORMATS_HPP +#pragma once -enum struct lsFileFormatEnum : unsigned { +namespace viennals { +enum struct FileFormatEnum : unsigned { VTK_LEGACY = 0, VTP = 1, VTU = 2, VTK_AUTO = 3 }; - -#endif +} diff --git a/include/viennals/lsFiniteDifferences.hpp b/include/viennals/lsFiniteDifferences.hpp index 8314a454..1e64c0ae 100644 --- a/include/viennals/lsFiniteDifferences.hpp +++ b/include/viennals/lsFiniteDifferences.hpp @@ -1,12 +1,13 @@ -#ifndef LS_FINITE_DIFFERENCES_HPP -#define LS_FINITE_DIFFERENCES_HPP +#pragma once #include -#include +#include namespace lsInternal { +using namespace viennacore; + // Numerical scheme definitions, central is default enum class DifferentiationSchemeEnum : unsigned { FIRST_ORDER = 0, @@ -17,11 +18,11 @@ enum class DifferentiationSchemeEnum : unsigned { template -class lsFiniteDifferences { +class FiniteDifferences { template static V square(V x) { return x * x; } public: - lsFiniteDifferences() {}; + FiniteDifferences(){}; static unsigned getNumberOfValues(DifferentiationSchemeEnum s) { switch (s) { @@ -33,7 +34,7 @@ class lsFiniteDifferences { case DifferentiationSchemeEnum::WENO5: return 7; default: - lsMessage::getInstance().addError("Invalid finite differences scheme!"); + Logger::getInstance().addError("Invalid finite differences scheme!"); return 0; } } @@ -49,14 +50,14 @@ class lsFiniteDifferences { T result = 0; if (plus) { - T rp = (eps + lsFiniteDifferences::square(dx[3] - dx[2])) / - (eps + lsFiniteDifferences::square(dx[2] - dx[1])); - T wp = 1.0 / (1 + 2.0 * lsFiniteDifferences::square(rp)); + T rp = (eps + FiniteDifferences::square(dx[3] - dx[2])) / + (eps + FiniteDifferences::square(dx[2] - dx[1])); + T wp = 1.0 / (1 + 2.0 * FiniteDifferences::square(rp)); result = dx[1] + dx[2] - wp * (dx[3] - 2.0 * dx[2] + dx[1]); } else { - T rp = (eps + lsFiniteDifferences::square(dx[1] - dx[0])) / - (eps + lsFiniteDifferences::square(dx[2] - dx[1])); - T wp = 1.0 / (1 + 2.0 * lsFiniteDifferences::square(rp)); + T rp = (eps + FiniteDifferences::square(dx[1] - dx[0])) / + (eps + FiniteDifferences::square(dx[2] - dx[1])); + T wp = 1.0 / (1 + 2.0 * FiniteDifferences::square(rp)); result = dx[1] + dx[2] - wp * (dx[0] - 2.0 * dx[1] + dx[2]); } @@ -79,12 +80,12 @@ class lsFiniteDifferences { T p2 = -v2 / 6.0 + 5 * v3 / 6.0 + v4 / 3.0; T p3 = v3 / 3.0 + 5 * v4 / 6.0 - v5 / 6.0; - T s1 = 13 / 12.0 * lsFiniteDifferences::square(v1 - 2 * v2 + v3) + - 1 / 4.0 * lsFiniteDifferences::square(v1 - 4 * v2 + 3 * v3); - T s2 = 13 / 12.0 * lsFiniteDifferences::square(v2 - 2 * v3 + v4) + - 1 / 4.0 * lsFiniteDifferences::square(v2 - v4); - T s3 = 13 / 12.0 * lsFiniteDifferences::square(v3 - 2 * v4 + v5) + - 1 / 4.0 * lsFiniteDifferences::square(3 * v3 - 4 * v4 + v5); + T s1 = 13 / 12.0 * FiniteDifferences::square(v1 - 2 * v2 + v3) + + 1 / 4.0 * FiniteDifferences::square(v1 - 4 * v2 + 3 * v3); + T s2 = 13 / 12.0 * FiniteDifferences::square(v2 - 2 * v3 + v4) + + 1 / 4.0 * FiniteDifferences::square(v2 - v4); + T s3 = 13 / 12.0 * FiniteDifferences::square(v3 - 2 * v4 + v5) + + 1 / 4.0 * FiniteDifferences::square(3 * v3 - 4 * v4 + v5); T al1 = 0.1 / (eps + s1); T al2 = 0.6 / (eps + s2); @@ -108,12 +109,12 @@ class lsFiniteDifferences { T p2 = -v2 / 6.0 + 5 * v3 / 6.0 + v4 / 3.0; T p3 = v3 / 3.0 + 5 * v4 / 6.0 - v5 / 6.0; - T s1 = 13 / 12.0 * lsFiniteDifferences::square(v1 - 2 * v2 + v3) + - 1 / 4.0 * lsFiniteDifferences::square(v1 - 4 * v2 + 3 * v3); - T s2 = 13 / 12.0 * lsFiniteDifferences::square(v2 - 2 * v3 + v4) + - 1 / 4.0 * lsFiniteDifferences::square(v2 - v4); - T s3 = 13 / 12.0 * lsFiniteDifferences::square(v3 - 2 * v4 + v5) + - 1 / 4.0 * lsFiniteDifferences::square(3 * v3 - 4 * v4 + v5); + T s1 = 13 / 12.0 * FiniteDifferences::square(v1 - 2 * v2 + v3) + + 1 / 4.0 * FiniteDifferences::square(v1 - 4 * v2 + 3 * v3); + T s2 = 13 / 12.0 * FiniteDifferences::square(v2 - 2 * v3 + v4) + + 1 / 4.0 * FiniteDifferences::square(v2 - v4); + T s3 = 13 / 12.0 * FiniteDifferences::square(v3 - 2 * v4 + v5) + + 1 / 4.0 * FiniteDifferences::square(3 * v3 - 4 * v4 + v5); T al1 = 0.1 / (eps + s1); T al2 = 0.6 / (eps + s2); @@ -146,7 +147,7 @@ class lsFiniteDifferences { } else if (scheme == DifferentiationSchemeEnum::WENO5) { return weno5(values, delta, false); } else { - lsMessage::getInstance().addError("Invalid finite differences scheme!"); + Logger::getInstance().addError("Invalid finite differences scheme!"); } } @@ -166,7 +167,7 @@ class lsFiniteDifferences { } else if (scheme == DifferentiationSchemeEnum::WENO5) { return weno5(values, delta, true); } else { - lsMessage::getInstance().addError("Invalid finite differences scheme!"); + Logger::getInstance().addError("Invalid finite differences scheme!"); } } @@ -189,5 +190,3 @@ class lsFiniteDifferences { }; } // namespace lsInternal - -#endif // LS_FINITE_DIFFERENCES_HPP diff --git a/include/viennals/lsFromMesh.hpp b/include/viennals/lsFromMesh.hpp index 245e998d..930d95d5 100644 --- a/include/viennals/lsFromMesh.hpp +++ b/include/viennals/lsFromMesh.hpp @@ -1,36 +1,37 @@ -#ifndef LS_FROM_MESH_HPP -#define LS_FROM_MESH_HPP +#pragma once #include #include #include +namespace viennals { + +using namespace viennacore; + /// Import the regular grid, on which the level set values are -/// defined, from an explicit lsMesh<>. The Vertices must be defined, +/// defined, from an explicit Mesh<>. The Vertices must be defined, /// as well as a scalar data field "LSValues". If used for custom /// read-in, make sure all vertices are lexicographically sorted. -template class lsFromMesh { - typedef typename lsDomain::DomainType hrleDomainType; +template class FromMesh { + typedef typename Domain::DomainType hrleDomainType; - lsSmartPointer> levelSet = nullptr; - lsSmartPointer> mesh = nullptr; + SmartPointer> levelSet = nullptr; + SmartPointer> mesh = nullptr; bool sortPointList = true; public: - lsFromMesh() {}; + FromMesh(){}; - lsFromMesh(lsSmartPointer> passedLevelSet, - const lsSmartPointer> passedMesh) + FromMesh(SmartPointer> passedLevelSet, + const SmartPointer> passedMesh) : levelSet(passedLevelSet), mesh(passedMesh) {} - void setLevelSet(lsSmartPointer> passedlsDomain) { + void setLevelSet(SmartPointer> passedlsDomain) { levelSet = passedlsDomain; } - void setMesh(const lsSmartPointer> passedMesh) { - mesh = passedMesh; - } + void setMesh(const SmartPointer> passedMesh) { mesh = passedMesh; } void setSortPointList(bool passedSortPointList) { sortPointList = passedSortPointList; @@ -38,14 +39,14 @@ template class lsFromMesh { void apply() { if (levelSet == nullptr) { - lsMessage::getInstance() - .addWarning("No level set was passed to lsFromMesh.") + Logger::getInstance() + .addWarning("No level set was passed to FromMesh.") .print(); return; } if (mesh == nullptr) { - lsMessage::getInstance() - .addWarning("No lsMesh<> was supplied to lsFromMesh.") + Logger::getInstance() + .addWarning("No Mesh<> was supplied to FromMesh.") .print(); return; } @@ -55,7 +56,7 @@ template class lsFromMesh { auto values = mesh->cellData.getScalarData("LSValues"); if (values == nullptr) { - lsMessage::getInstance() + Logger::getInstance() .addWarning("Mesh does not contain level set values (\"LSValues\").") .print(); return; @@ -74,8 +75,8 @@ template class lsFromMesh { if (hrleVectorType(nodes.front()) != grid.getMinGridPoint()) { domain.insertNextUndefinedPoint(0, grid.getMinGridPoint(), (values->front() < 0) - ? lsDomain::NEG_VALUE - : lsDomain::POS_VALUE); + ? Domain::NEG_VALUE + : Domain::POS_VALUE); } hrleVectorType lastIndex(nodes.front()); @@ -166,8 +167,8 @@ template class lsFromMesh { break; domain.insertNextUndefinedPoint(0, tmp, - signs[q] ? lsDomain::NEG_VALUE - : lsDomain::POS_VALUE); + signs[q] ? Domain::NEG_VALUE + : Domain::POS_VALUE); } } @@ -176,6 +177,6 @@ template class lsFromMesh { }; // add all template specialisations for this class -PRECOMPILE_PRECISION_DIMENSION(lsFromMesh) +PRECOMPILE_PRECISION_DIMENSION(FromMesh) -#endif // LS_FROM_MESH_HPP \ No newline at end of file +} // namespace viennals diff --git a/include/viennals/lsFromSurfaceMesh.hpp b/include/viennals/lsFromSurfaceMesh.hpp index ed8d4043..e6ea2dbb 100644 --- a/include/viennals/lsFromSurfaceMesh.hpp +++ b/include/viennals/lsFromSurfaceMesh.hpp @@ -1,5 +1,4 @@ -#ifndef LS_FROM_SURFACE_MESH_HPP -#define LS_FROM_SURFACE_MESH_HPP +#pragma once #include @@ -7,10 +6,13 @@ #include #include -#include + +namespace viennals { + +using namespace viennacore; /// Construct a level set from an explicit mesh. -template class lsFromSurfaceMesh { +template class FromSurfaceMesh { /// Class defining a box used in ray tracing optimisation class box { @@ -93,9 +95,8 @@ template class lsFromSurfaceMesh { }; }; - lsSmartPointer> levelSet = - lsSmartPointer>::New(); - lsSmartPointer> mesh = lsSmartPointer>::New(); + SmartPointer> levelSet = SmartPointer>::New(); + SmartPointer> mesh = SmartPointer>::New(); // bool removeBoundaryTriangles = true; std::array removeBoundaryTriangles{true, true, true}; T boundaryEps = 1e-5; @@ -211,21 +212,21 @@ template class lsFromSurfaceMesh { } public: - lsFromSurfaceMesh() {} + FromSurfaceMesh() {} - lsFromSurfaceMesh(lsSmartPointer> passedLevelSet, - lsSmartPointer> passedMesh, - bool passedRemoveBoundaryTriangles = true) + FromSurfaceMesh(SmartPointer> passedLevelSet, + SmartPointer> passedMesh, + bool passedRemoveBoundaryTriangles = true) : levelSet(passedLevelSet), mesh(passedMesh), removeBoundaryTriangles{passedRemoveBoundaryTriangles, passedRemoveBoundaryTriangles, passedRemoveBoundaryTriangles} {} - void setLevelSet(lsSmartPointer> passedLevelSet) { + void setLevelSet(SmartPointer> passedLevelSet) { levelSet = passedLevelSet; } - void setMesh(lsSmartPointer> passedMesh) { mesh = passedMesh; } + void setMesh(SmartPointer> passedMesh) { mesh = passedMesh; } /// Set whether all triangles outside of the domain should be ignored (=true) /// or whether boundary conditions should be applied correctly to such @@ -248,14 +249,14 @@ template class lsFromSurfaceMesh { void apply() { if (levelSet == nullptr) { - lsMessage::getInstance() - .addWarning("No level set was passed to lsFromSurfaceMesh.") + Logger::getInstance() + .addWarning("No level set was passed to FromSurfaceMesh.") .print(); return; } if (mesh == nullptr) { - lsMessage::getInstance() - .addWarning("No mesh was passed to lsFromSurfaceMesh.") + Logger::getInstance() + .addWarning("No mesh was passed to FromSurfaceMesh.") .print(); return; } @@ -487,6 +488,6 @@ template class lsFromSurfaceMesh { }; // add all template specialisations for this class -PRECOMPILE_PRECISION_DIMENSION(lsFromSurfaceMesh) +PRECOMPILE_PRECISION_DIMENSION(FromSurfaceMesh) -#endif // LS_FROM_SURFACE_MESH_HPP \ No newline at end of file +} // namespace viennals diff --git a/include/viennals/lsFromVolumeMesh.hpp b/include/viennals/lsFromVolumeMesh.hpp index f71e1b51..f6f3478a 100644 --- a/include/viennals/lsFromVolumeMesh.hpp +++ b/include/viennals/lsFromVolumeMesh.hpp @@ -1,5 +1,4 @@ -#ifndef LS_FROM_VOLUME_MESH_HPP -#define LS_FROM_VOLUME_MESH_HPP +#pragma once #include @@ -8,31 +7,36 @@ #include #include #include -#include + +#include +#include + +namespace viennals { + +using namespace viennacore; /// This class creates a level set from a tetrahedral mesh. /// If the mesh contains a scalar data array called "Material", /// one level set for each material will be created and stored -/// in the supplied std::vector> object. -template class lsFromVolumeMesh { +/// in the supplied std::vector> object. +template class FromVolumeMesh { public: - using LevelSetType = lsSmartPointer>; + using LevelSetType = SmartPointer>; using LevelSetsType = std::vector; - using GridType = typename lsDomain::GridType; + using GridType = typename Domain::GridType; private: LevelSetsType levelSets; - lsSmartPointer> mesh = nullptr; + SmartPointer> mesh = nullptr; GridType grid; bool removeBoundaryTriangles = true; bool gridSet = false; public: - lsFromVolumeMesh() {} + FromVolumeMesh() {} - lsFromVolumeMesh(const GridType &passedGrid, - lsSmartPointer> passedMesh, - bool passedRemoveBoundaryTriangles = true) + FromVolumeMesh(const GridType &passedGrid, SmartPointer> passedMesh, + bool passedRemoveBoundaryTriangles = true) : grid(passedGrid), mesh(passedMesh), removeBoundaryTriangles(passedRemoveBoundaryTriangles), gridSet(true) {} @@ -41,7 +45,7 @@ template class lsFromVolumeMesh { gridSet = true; } - void setMesh(lsSmartPointer> passedMesh) { mesh = passedMesh; } + void setMesh(SmartPointer> passedMesh) { mesh = passedMesh; } void setRemoveBoundaryTriangles(bool passedRemoveBoundaryTriangles) { removeBoundaryTriangles = passedRemoveBoundaryTriangles; @@ -51,21 +55,21 @@ template class lsFromVolumeMesh { void apply() { if (!gridSet) { - lsMessage::getInstance() - .addWarning("No grid has been set in lsFromVolumeMesh.") + Logger::getInstance() + .addWarning("No grid has been set in FromVolumeMesh.") .print(); return; } if (mesh == nullptr) { - lsMessage::getInstance() - .addWarning("No mesh was passed to lsFromVolumeMesh.") + Logger::getInstance() + .addWarning("No mesh was passed to FromVolumeMesh.") .print(); return; } // get the unique material numbers for explicit booling std::vector materialInts; - typename lsPointData::ScalarDataType *materialData = + typename PointData::ScalarDataType *materialData = mesh->cellData.getScalarData("Material"); if (materialData != nullptr) { // make unique list of materialIds @@ -137,7 +141,7 @@ template class lsFromVolumeMesh { (it->first == currentSurfaceElement)) { if (Orientation(currentElementPoints)) { if (it->second.second != materialInts.back() + 1) { - lsMessage::getInstance() + Logger::getInstance() .addWarning( "Coinciding surface elements with same orientation in " "Element: " + @@ -148,7 +152,7 @@ template class lsFromVolumeMesh { (materialData == nullptr) ? 0 : (*materialData)[i]; } else { if (it->second.first != materialInts.back() + 1) { - lsMessage::getInstance() + Logger::getInstance() .addWarning( "Coinciding surface elements with same orientation in " "Element: " + @@ -195,7 +199,7 @@ template class lsFromVolumeMesh { auto levelSetIterator = levelSets.begin(); for (auto matIt = materialInts.begin(); matIt != materialInts.end(); ++matIt) { - auto currentSurface = lsSmartPointer>::New(); + auto currentSurface = SmartPointer>::New(); auto &meshElements = currentSurface->template getElements(); for (auto it = surfaceElements.begin(); it != surfaceElements.end(); ++it) { @@ -233,8 +237,8 @@ template class lsFromVolumeMesh { } // create level set from surface - lsFromSurfaceMesh(*levelSetIterator, currentSurface, - removeBoundaryTriangles) + FromSurfaceMesh(*levelSetIterator, currentSurface, + removeBoundaryTriangles) .apply(); ++levelSetIterator; @@ -243,6 +247,6 @@ template class lsFromVolumeMesh { }; // add all template specialisations for this class -PRECOMPILE_PRECISION_DIMENSION(lsFromVolumeMesh) +PRECOMPILE_PRECISION_DIMENSION(FromVolumeMesh) -#endif // LS_FROM_VOLUME_MESH_HPP +} // namespace viennals diff --git a/include/viennals/lsGeometricAdvect.hpp b/include/viennals/lsGeometricAdvect.hpp index 18e2aaa6..59685425 100644 --- a/include/viennals/lsGeometricAdvect.hpp +++ b/include/viennals/lsGeometricAdvect.hpp @@ -1,5 +1,4 @@ -#ifndef LS_FAST_ADVECT_HPP -#define LS_FAST_ADVECT_HPP +#pragma once #include @@ -8,23 +7,28 @@ #include #include -#include -#include - #include #include #include #include #include #include +#include #include +#include +#include + #ifndef NDEBUG // if in debug build #include #include #include #endif +namespace viennals { + +using namespace viennacore; + /// This class advects the level set according to a given distribution. /// This distribution is overlayed at every grid point of the old surface. All /// cells within this distribution are then filled, with cells at the edge @@ -32,10 +36,10 @@ /// shifted long distances in one step. This algorithm is therefore preferable /// to normal advection if there is growth/reduction by a purely geometric /// directional distribution. -template class lsGeometricAdvect { - lsSmartPointer> levelSet = nullptr; - lsSmartPointer> maskLevelSet = nullptr; - lsSmartPointer> dist = +template class GeometricAdvect { + SmartPointer> levelSet = nullptr; + SmartPointer> maskLevelSet = nullptr; + SmartPointer> dist = nullptr; static constexpr T cutoffValue = T(1.) + std::numeric_limits::epsilon() * T(100); @@ -62,67 +66,66 @@ template class lsGeometricAdvect { } public: - lsGeometricAdvect() {} - - template , - DistType> = lsConcepts::assignable> - lsGeometricAdvect(lsSmartPointer> passedLevelSet, - lsSmartPointer passedDist, - lsSmartPointer> passedMaskLevelSet = nullptr) + GeometricAdvect() {} + + template , + DistType> = lsConcepts::assignable> + GeometricAdvect(SmartPointer> passedLevelSet, + SmartPointer passedDist, + SmartPointer> passedMaskLevelSet = nullptr) : levelSet(passedLevelSet), maskLevelSet(passedMaskLevelSet) { dist = std::dynamic_pointer_cast< - lsGeometricAdvectDistribution>(passedDist); + GeometricAdvectDistribution>(passedDist); } /// Set the levelset which should be advected. - void setLevelSet(lsSmartPointer> passedLevelSet) { + void setLevelSet(SmartPointer> passedLevelSet) { levelSet = passedLevelSet; } /// Set which advection distribution to use. Must be derived from - /// lsGeometricAdvectDistribution. - template , - DistType> = lsConcepts::assignable> - void setAdvectionDistribution(lsSmartPointer passedDist) { + /// GeometricAdvectDistribution. + template , + DistType> = lsConcepts::assignable> + void setAdvectionDistribution(SmartPointer passedDist) { dist = std::dynamic_pointer_cast< - lsGeometricAdvectDistribution>(passedDist); + GeometricAdvectDistribution>(passedDist); } /// Set the levelset, which should be used as a mask. This level set /// has to be wrapped by the levelset set by setLevelSet, so the mask /// is entirely inside the advected level set. - void setMaskLevelSet(lsSmartPointer> passedMaskLevelSet) { + void setMaskLevelSet(SmartPointer> passedMaskLevelSet) { maskLevelSet = passedMaskLevelSet; } /// Perform geometrical advection. void apply() { if (levelSet == nullptr) { - lsMessage::getInstance() - .addWarning( - "No level set passed to lsGeometricAdvect. Not Advecting.") + Logger::getInstance() + .addWarning("No level set passed to GeometricAdvect. Not Advecting.") .print(); return; } if (dist == nullptr) { - lsMessage::getInstance() - .addWarning("No lsGeometricAdvectDistribution passed to " - "lsGeometricAdvect. Not " + Logger::getInstance() + .addWarning("No GeometricAdvectDistribution passed to " + "GeometricAdvect. Not " "Advecting.") .print(); return; } // levelSet must have at least a width of 3 - lsExpand(levelSet, 3).apply(); + Expand(levelSet, 3).apply(); if (maskLevelSet != nullptr) { - lsExpand(maskLevelSet, 3).apply(); + Expand(maskLevelSet, 3).apply(); } - typedef typename lsDomain::DomainType DomainType; + typedef typename Domain::DomainType DomainType; auto &domain = levelSet->getDomain(); @@ -131,10 +134,10 @@ template class lsGeometricAdvect { // Extract the original surface as a point cloud of grid // points shifted to the surface (disk mesh) - auto surfaceMesh = lsSmartPointer>::New(); + auto surfaceMesh = SmartPointer>::New(); auto pointIdTranslator = - lsSmartPointer::TranslatorType>::New(); - lsToDiskMesh(levelSet, surfaceMesh, pointIdTranslator) + SmartPointer::TranslatorType>::New(); + ToDiskMesh(levelSet, surfaceMesh, pointIdTranslator) .apply(); *pointIdTranslator = inverseTranslator(*pointIdTranslator); @@ -208,8 +211,8 @@ template class lsGeometricAdvect { auto values = surfaceMesh->cellData.getScalarData("LSValues"); auto valueIt = values->begin(); - auto newSurfaceMesh = lsSmartPointer>::New(); - typename lsPointData::ScalarDataType newValues; + auto newSurfaceMesh = SmartPointer>::New(); + typename PointData::ScalarDataType newValues; hrleConstSparseIterator maskIt(maskDomain); for (auto &node : surfaceMesh->getNodes()) { hrleVectorType index; @@ -239,22 +242,22 @@ template class lsGeometricAdvect { #ifndef NDEBUG // if in debug build { - lsMessage::getInstance() + Logger::getInstance() .addDebug("GeomAdvect: Writing debug meshes") .print(); - lsVTKWriter(surfaceMesh, lsFileFormatEnum::VTP, - "DEBUG_lsGeomAdvectMesh_contributewoMask.vtp") + VTKWriter(surfaceMesh, FileFormatEnum::VTP, + "DEBUG_lsGeomAdvectMesh_contributewoMask.vtp") .apply(); - auto mesh = lsSmartPointer>::New(); + auto mesh = SmartPointer>::New(); if (maskLevelSet != nullptr) { - lsToMesh(maskLevelSet, mesh).apply(); - lsVTKWriter(mesh, lsFileFormatEnum::VTP, - "DEBUG_lsGeomAdvectMesh_mask.vtp") + ToMesh(maskLevelSet, mesh).apply(); + VTKWriter(mesh, FileFormatEnum::VTP, + "DEBUG_lsGeomAdvectMesh_mask.vtp") .apply(); } - lsToMesh(levelSet, mesh).apply(); - lsVTKWriter(mesh, lsFileFormatEnum::VTP, - "DEBUG_lsGeomAdvectMesh_initial.vtp") + ToMesh(levelSet, mesh).apply(); + VTKWriter(mesh, FileFormatEnum::VTP, + "DEBUG_lsGeomAdvectMesh_initial.vtp") .apply(); } @@ -300,7 +303,7 @@ template class lsGeometricAdvect { { std::ostringstream oss; oss << "GeomAdvect: Min: " << min << ", Max: " << max << std::endl; - lsMessage::getInstance().addDebug(oss.str()).print(); + Logger::getInstance().addDebug(oss.str()).print(); } #endif // set up multithreading @@ -328,9 +331,9 @@ template class lsGeometricAdvect { startVector); // Mask iterator for checking whether inside mask or not - lsSmartPointer> maskIt = nullptr; + SmartPointer> maskIt = nullptr; if (maskLevelSet != nullptr) { - maskIt = lsSmartPointer>::New( + maskIt = SmartPointer>::New( maskLevelSet->getDomain(), startVector); } @@ -481,7 +484,7 @@ template class lsGeometricAdvect { } } - auto mesh = lsSmartPointer>::New(); + auto mesh = SmartPointer>::New(); // output all points directly to mesh { std::vector scalarData; @@ -501,36 +504,30 @@ template class lsGeometricAdvect { } #ifndef NDEBUG // if in debug build - lsMessage::getInstance() - .addDebug("GeomAdvect: Writing final mesh...") - .print(); - lsVTKWriter(mesh, lsFileFormatEnum::VTP, - "DEBUG_lsGeomAdvectMesh_final.vtp") + Logger::getInstance().addDebug("GeomAdvect: Writing final mesh...").print(); + VTKWriter(mesh, FileFormatEnum::VTP, "DEBUG_lsGeomAdvectMesh_final.vtp") .apply(); #endif - lsFromMesh(levelSet, mesh).apply(); + FromMesh(levelSet, mesh).apply(); #ifndef NDEBUG // if in debug build - lsMessage::getInstance() - .addDebug("GeomAdvect: Writing final LS...") - .print(); - lsToMesh(levelSet, mesh).apply(); - lsVTKWriter(mesh, lsFileFormatEnum::VTP, - "DEBUG_lsGeomAdvectLS_final.vtp") + Logger::getInstance().addDebug("GeomAdvect: Writing final LS...").print(); + ToMesh(levelSet, mesh).apply(); + VTKWriter(mesh, FileFormatEnum::VTP, "DEBUG_lsGeomAdvectLS_final.vtp") .apply(); #endif - lsPrune(levelSet).apply(); + Prune(levelSet).apply(); levelSet->getDomain().segment(); levelSet->finalize(1); - lsExpand(levelSet, 2).apply(); + Expand(levelSet, 2).apply(); } }; // add all template specialisations for this class -PRECOMPILE_PRECISION_DIMENSION(lsGeometricAdvect) +PRECOMPILE_PRECISION_DIMENSION(GeometricAdvect) -#endif // LS_FAST_ADVECT_HPP +} // namespace viennals diff --git a/include/viennals/lsGeometricAdvectDistributions.hpp b/include/viennals/lsGeometricAdvectDistributions.hpp index 0cf19ba6..d4c06b85 100644 --- a/include/viennals/lsGeometricAdvectDistributions.hpp +++ b/include/viennals/lsGeometricAdvectDistributions.hpp @@ -1,22 +1,27 @@ -#ifndef LS_FAST_ADVECT_DISTRIBUTIONS_HPP -#define LS_FAST_ADVECT_DISTRIBUTIONS_HPP +#pragma once #include -#include + +#include +#include + +namespace viennals { + +using namespace viennacore; /// Base class for distributions used by lsGeometricAdvect. /// All functions are pure virtual and must be implemented /// by any advection distribution. -template class lsGeometricAdvectDistribution { +template class GeometricAdvectDistribution { public: - lsGeometricAdvectDistribution() {} + GeometricAdvectDistribution() {} /// Quick check whether a point relative to the distributions /// center is inside the distribution. If there is no quick /// check due to the complexity of the distribution, always /// return true or do not overload this function. - virtual bool isInside(const std::array &initial, - const std::array &candidate, + virtual bool isInside(const Triple &initial, + const Triple &candidate, double eps = 0.) const { return true; } @@ -24,30 +29,30 @@ template class lsGeometricAdvectDistribution { /// Returns the signed distance of a point relative to the distributions /// center. This is the signed manhatten distance to the nearest surface /// point. - virtual T getSignedDistance(const std::array &initial, - const std::array &candidate, + virtual T getSignedDistance(const Triple &initial, + const Triple &candidate, unsigned long initialPointId) const = 0; /// Sets bounds to the bounding box of the distribution. virtual std::array getBounds() const = 0; - virtual ~lsGeometricAdvectDistribution() {} + virtual ~GeometricAdvectDistribution() {} }; -/// Concrete implementation of lsGeometricAdvectDistribution for a spherical +/// Concrete implementation of GeometricAdvectDistribution for a spherical /// advection distribution. template -class lsSphereDistribution : public lsGeometricAdvectDistribution { +class SphereDistribution : public GeometricAdvectDistribution { public: const T radius = 0.; const T radius2; const T gridDelta; - lsSphereDistribution(const T passedRadius, const T delta) + SphereDistribution(const T passedRadius, const T delta) : radius(passedRadius), radius2(radius * radius), gridDelta(delta) {} - bool isInside(const std::array &initial, - const std::array &candidate, + bool isInside(const Triple &initial, + const Triple &candidate, double eps = 0.) const override { hrleCoordType dot = 0.; for (unsigned i = 0; i < D; ++i) { @@ -61,11 +66,11 @@ class lsSphereDistribution : public lsGeometricAdvectDistribution { return false; } - T getSignedDistance(const std::array &initial, - const std::array &candidate, + T getSignedDistance(const Triple &initial, + const Triple &candidate, unsigned long /*initialPointId*/) const override { T distance = std::numeric_limits::max(); - std::array v{}; + Triple v{}; for (unsigned i = 0; i < D; ++i) { v[i] = candidate[i] - initial[i]; } @@ -106,20 +111,20 @@ class lsSphereDistribution : public lsGeometricAdvectDistribution { } }; -/// Concrete implementation of lsGeometricAdvectDistribution +/// Concrete implementation of GeometricAdvectDistribution /// for a rectangular box distribution. template -class lsBoxDistribution : public lsGeometricAdvectDistribution { +class BoxDistribution : public GeometricAdvectDistribution { public: const hrleVectorType posExtent; const T gridDelta; - lsBoxDistribution(const std::array &halfAxes, const T delta) + BoxDistribution(const std::array &halfAxes, const T delta) : posExtent(halfAxes), gridDelta(delta) { for (unsigned i = 0; i < D; ++i) { if (std::abs(posExtent[i]) < gridDelta) { - lsMessage::getInstance() - .addWarning("One half-axis of lsBoxDistribution is smaller than " + Logger::getInstance() + .addWarning("One half-axis of BoxDistribution is smaller than " "the grid Delta! This can lead to numerical errors " "breaking the distribution!") .print(); @@ -127,8 +132,8 @@ class lsBoxDistribution : public lsGeometricAdvectDistribution { } } - bool isInside(const std::array &initial, - const std::array &candidate, + bool isInside(const Triple &initial, + const Triple &candidate, double eps = 0.) const override { for (unsigned i = 0; i < D; ++i) { if (std::abs(candidate[i] - initial[i]) > @@ -139,8 +144,8 @@ class lsBoxDistribution : public lsGeometricAdvectDistribution { return true; } - T getSignedDistance(const std::array &initial, - const std::array &candidate, + T getSignedDistance(const Triple &initial, + const Triple &candidate, unsigned long /*initialPointId*/) const override { T distance = std::numeric_limits::lowest(); for (unsigned i = 0; i < D; ++i) { @@ -160,4 +165,4 @@ class lsBoxDistribution : public lsGeometricAdvectDistribution { } }; -#endif // LS_FAST_ADVECT_DISTRIBUTIONS_HPP +} // namespace viennals diff --git a/include/viennals/lsGeometries.hpp b/include/viennals/lsGeometries.hpp index 6903c4af..c06491ee 100644 --- a/include/viennals/lsGeometries.hpp +++ b/include/viennals/lsGeometries.hpp @@ -1,5 +1,4 @@ -#ifndef LS_GEOMETRIES_HPP -#define LS_GEOMETRIES_HPP +#pragma once #include #include @@ -8,76 +7,77 @@ #include +namespace viennals { + /// Class describing a sphere via origin and radius. -template class lsSphere { +template class Sphere { public: hrleVectorType origin = hrleVectorType(T(0)); T radius = 0.; - lsSphere() {} + Sphere() {} - lsSphere(hrleVectorType passedOrigin, T passedRadius) + Sphere(hrleVectorType passedOrigin, T passedRadius) : origin(passedOrigin), radius(passedRadius) {} - lsSphere(T *passedOrigin, T passedRadius) : radius(passedRadius) { + Sphere(T *passedOrigin, T passedRadius) : radius(passedRadius) { for (unsigned i = 0; i < D; ++i) { origin[i] = passedOrigin[i]; } } - lsSphere(const std::vector &passedOrigin, T passedRadius) + Sphere(const std::vector &passedOrigin, T passedRadius) : origin(passedOrigin), radius(passedRadius) {} }; /// Class describing a plane via a point in it and the plane normal. -template class lsPlane { +template class Plane { public: hrleVectorType origin = hrleVectorType(T(0)); hrleVectorType normal = hrleVectorType(T(0)); - lsPlane() {} + Plane() {} - lsPlane(hrleVectorType passedOrigin, hrleVectorType passedNormal) + Plane(hrleVectorType passedOrigin, hrleVectorType passedNormal) : origin(passedOrigin), normal(passedNormal) {} - lsPlane(const T *passedOrigin, const T *passedNormal) { + Plane(const T *passedOrigin, const T *passedNormal) { for (unsigned i = 0; i < D; ++i) { origin[i] = passedOrigin[i]; normal[i] = passedNormal[i]; } } - lsPlane(const std::vector &passedOrigin, - const std::vector &passedNormal) + Plane(const std::vector &passedOrigin, const std::vector &passedNormal) : origin(passedOrigin), normal(passedNormal) {} }; /// Class describing a square box from one coordinate to another. -template class lsBox { +template class Box { public: hrleVectorType minCorner = hrleVectorType(T(0)); hrleVectorType maxCorner = hrleVectorType(T(0)); - lsBox() {} + Box() {} - lsBox(hrleVectorType passedMinCorner, - hrleVectorType passedMaxCorner) + Box(hrleVectorType passedMinCorner, + hrleVectorType passedMaxCorner) : minCorner(passedMinCorner), maxCorner(passedMaxCorner) {} - lsBox(const T *passedMinCorner, const T *passedMaxCorner) { + Box(const T *passedMinCorner, const T *passedMaxCorner) { for (unsigned i = 0; i < D; ++i) { minCorner[i] = passedMinCorner[i]; maxCorner[i] = passedMaxCorner[i]; } } - lsBox(const std::vector &passedMinCorner, - const std::vector &passedMaxCorner) + Box(const std::vector &passedMinCorner, + const std::vector &passedMaxCorner) : minCorner(passedMinCorner), maxCorner(passedMaxCorner) {} }; /// Class describing a square box from one coordinate to another. -template class lsCylinder { +template class Cylinder { public: /// This is the location of the center of the base of the cylinder hrleVectorType origin = hrleVectorType(T(0)); @@ -90,18 +90,18 @@ template class lsCylinder { /// radius of the top of the cylinder T topRadius = 0.; - lsCylinder() {} + Cylinder() {} - lsCylinder(hrleVectorType passedOrigin, - hrleVectorType passedAxisDirection, T passedHeight, - T passedRadius, T passedTopRadius = 0) + Cylinder(hrleVectorType passedOrigin, + hrleVectorType passedAxisDirection, T passedHeight, + T passedRadius, T passedTopRadius = 0) : origin(passedOrigin), axisDirection(passedAxisDirection), height(passedHeight), radius(passedRadius), topRadius(passedTopRadius) { } - lsCylinder(const T *passedOrigin, const T *passedAxisDirection, - const T passedHeight, const T passedRadius, - const T passedTopRadius = 0) + Cylinder(const T *passedOrigin, const T *passedAxisDirection, + const T passedHeight, const T passedRadius, + const T passedTopRadius = 0) : height(passedHeight), radius(passedRadius), topRadius(passedTopRadius) { for (unsigned i = 0; i < D; ++i) { origin[i] = passedOrigin[i]; @@ -109,8 +109,8 @@ template class lsCylinder { } } - lsCylinder(std::vector passedOrigin, std::vector passedAxisDirection, - T passedHeight, T passedRadius, T passedTopRadius = 0) + Cylinder(std::vector passedOrigin, std::vector passedAxisDirection, + T passedHeight, T passedRadius, T passedTopRadius = 0) : origin(passedOrigin), axisDirection(passedAxisDirection), height(passedHeight), radius(passedRadius), topRadius(passedTopRadius) { } @@ -118,16 +118,16 @@ template class lsCylinder { /// Class describing a point cloud, which can be used to /// create geometries from its convex hull mesh. -template class lsPointCloud { +template class PointCloud { public: std::vector> points; - lsPointCloud() {} + PointCloud() {} - lsPointCloud(std::vector> passedPoints) + PointCloud(std::vector> passedPoints) : points(passedPoints) {} - lsPointCloud(const std::vector> &passedPoints) { + PointCloud(const std::vector> &passedPoints) { for (auto point : passedPoints) { hrleVectorType p(point); points.push_back(p); @@ -177,9 +177,9 @@ template class lsPointCloud { }; // add all template specialisations for this class -PRECOMPILE_PRECISION_DIMENSION(lsSphere) -PRECOMPILE_PRECISION_DIMENSION(lsPlane) -PRECOMPILE_PRECISION_DIMENSION(lsBox) -PRECOMPILE_PRECISION_DIMENSION(lsPointCloud) +PRECOMPILE_PRECISION_DIMENSION(Sphere) +PRECOMPILE_PRECISION_DIMENSION(Plane) +PRECOMPILE_PRECISION_DIMENSION(Box) +PRECOMPILE_PRECISION_DIMENSION(PointCloud) -#endif // LS_GEOMETRIES_HPP +} // namespace viennals diff --git a/include/viennals/lsGraph.hpp b/include/viennals/lsGraph.hpp index d2121089..b603ab58 100644 --- a/include/viennals/lsGraph.hpp +++ b/include/viennals/lsGraph.hpp @@ -1,15 +1,16 @@ -#ifndef LS_GRAPH_HPP -#define LS_GRAPH_HPP +#pragma once #include #include #include -#include +#include namespace lsInternal { -class lsGraph { +using namespace viennacore; + +class Graph { // type for indexing components using IndexType = std::size_t; // edges must be unique @@ -29,8 +30,8 @@ class lsGraph { // cylce through all connected vertices and set their component auto vertexListIt = adjacencyList.find(currentVertex); if (vertexListIt == adjacencyList.end()) { - lsMessage::getInstance().addError( - "lsGraph: Vertex " + std::to_string(currentVertex) + + Logger::getInstance().addError( + "Graph: Vertex " + std::to_string(currentVertex) + " could not be found although it should exist!"); } @@ -100,5 +101,3 @@ class lsGraph { } }; } // namespace lsInternal - -#endif // LS_GRAPH_HPP diff --git a/include/viennals/lsLaxFriedrichs.hpp b/include/viennals/lsLaxFriedrichs.hpp index 14dea086..d8040645 100644 --- a/include/viennals/lsLaxFriedrichs.hpp +++ b/include/viennals/lsLaxFriedrichs.hpp @@ -1,5 +1,4 @@ -#ifndef LS_LAX_FRIEDRICHS_HPP -#define LS_LAX_FRIEDRICHS_HPP +#pragma once #include #include @@ -7,15 +6,19 @@ #include #include +#include + namespace lsInternal { +using namespace viennals; + /// Lax Friedrichs integration scheme with constant alpha /// value for dissipation. This alpha value should be fitted /// based on the results of the advection and passed to the /// advection Kernel. -template class lsLaxFriedrichs { - lsSmartPointer> levelSet; - lsSmartPointer> velocities; +template class LaxFriedrichs { + SmartPointer> levelSet; + SmartPointer> velocities; hrleSparseStarIterator, order> neighborIterator; bool calculateNormalVectors = true; const double alpha = 1.0; @@ -23,14 +26,14 @@ template class lsLaxFriedrichs { static T pow2(const T &value) { return value * value; } public: - static void prepareLS(lsSmartPointer> passedlsDomain) { + static void prepareLS(SmartPointer> passedlsDomain) { assert(order == 1 || order == 2); - lsExpand(passedlsDomain, 2 * order + 1).apply(); + Expand(passedlsDomain, 2 * order + 1).apply(); } - lsLaxFriedrichs(lsSmartPointer> passedlsDomain, - lsSmartPointer> vel, - bool calcNormal = true, double a = 1.0) + LaxFriedrichs(SmartPointer> passedlsDomain, + SmartPointer> vel, bool calcNormal = true, + double a = 1.0) : levelSet(passedlsDomain), velocities(vel), neighborIterator(hrleSparseStarIterator, order>( levelSet->getDomain())), @@ -55,7 +58,7 @@ template class lsLaxFriedrichs { T grad = 0.; T dissipation = 0.; - std::array normalVector = {}; + Triple normalVector = {}; T normalModulus = 0; const bool calcNormals = calculateNormalVectors; @@ -130,12 +133,12 @@ template class lsLaxFriedrichs { } // convert coordinate to std array for interface - std::array coordArray = {coordinate[0], coordinate[1], coordinate[2]}; + Triple coordArray = {coordinate[0], coordinate[1], coordinate[2]}; double scalarVelocity = velocities->getScalarVelocity( coordArray, material, normalVector, neighborIterator.getCenter().getPointId()); - std::array vectorVelocity = velocities->getVectorVelocity( + Triple vectorVelocity = velocities->getVectorVelocity( coordArray, material, normalVector, neighborIterator.getCenter().getPointId()); @@ -156,5 +159,3 @@ template class lsLaxFriedrichs { } }; } // namespace lsInternal - -#endif // LS_LAX_FRIEDRICHS_HPP diff --git a/include/viennals/lsLocalLaxFriedrichs.hpp b/include/viennals/lsLocalLaxFriedrichs.hpp index b825b531..df59a2e9 100644 --- a/include/viennals/lsLocalLaxFriedrichs.hpp +++ b/include/viennals/lsLocalLaxFriedrichs.hpp @@ -1,5 +1,4 @@ -#ifndef LS_LOCAL_LAX_FRIEDRICHS_HPP -#define LS_LOCAL_LAX_FRIEDRICHS_HPP +#pragma once #include #include @@ -7,16 +6,20 @@ #include #include +#include + namespace lsInternal { +using namespace viennals; + /// Lax Friedrichs integration scheme, which uses a first neighbour /// stencil to calculate the alpha values for all neighbours. /// The largest alpha value is then chosen for dissipation. /// Slower than lsLocalLocalLaxFriedrichs or lsEngquistOsher /// but more reliable for complex velocity fields. -template class lsLocalLaxFriedrichs { - lsSmartPointer> levelSet; - lsSmartPointer> velocities; +template class LocalLaxFriedrichs { + SmartPointer> levelSet; + SmartPointer> velocities; hrleSparseBoxIterator> neighborIterator; const double alphaFactor; @@ -40,16 +43,16 @@ template class lsLocalLaxFriedrichs { } public: - static void prepareLS(lsSmartPointer> passedlsDomain) { + static void prepareLS(SmartPointer> passedlsDomain) { assert(order == 1 || order == 2); // at least order+1 layers since we need neighbor neighbors for // dissipation alpha calculation - lsExpand(passedlsDomain, 2 * (order + 2) + 1).apply(); + Expand(passedlsDomain, 2 * (order + 2) + 1).apply(); } // neighboriterator always needs order 2 for alpha calculation - lsLocalLaxFriedrichs(lsSmartPointer> passedlsDomain, - lsSmartPointer> vel, double a = 1.0) + LocalLaxFriedrichs(SmartPointer> passedlsDomain, + SmartPointer> vel, double a = 1.0) : levelSet(passedlsDomain), velocities(vel), neighborIterator(levelSet->getDomain(), 2), alphaFactor(a) {} @@ -67,7 +70,7 @@ template class lsLocalLaxFriedrichs { neighborIterator.goToIndicesSequential(indices); // convert coordinate to std array for interface - std::array coordArray = {coordinate[0], coordinate[1], coordinate[2]}; + Triple coordArray = {coordinate[0], coordinate[1], coordinate[2]}; T gradPos[D]; T gradNeg[D]; @@ -75,7 +78,7 @@ template class lsLocalLaxFriedrichs { T grad = 0.; T dissipation = 0.; - std::array normalVector = {}; + Triple normalVector = {}; T normalModulus = 0; for (int i = 0; i < D; i++) { // iterate over dimensions @@ -153,7 +156,7 @@ template class lsLocalLaxFriedrichs { double scalarVelocity = velocities->getScalarVelocity( coordArray, material, normalVector, neighborIterator.getCenter().getPointId()); - std::array vectorVelocity = velocities->getVectorVelocity( + Triple vectorVelocity = velocities->getVectorVelocity( coordArray, material, normalVector, neighborIterator.getCenter().getPointId()); @@ -181,11 +184,11 @@ template class lsLocalLaxFriedrichs { hrleVectorType neighborIndex(minIndex); for (unsigned i = 0; i < numNeighbors; ++i) { - std::array coords; + Triple coords; for (unsigned dir = 0; dir < D; ++dir) { coords[dir] = coordinate[dir] + neighborIndex[dir] * gridDelta; } - std::array normal = {}; + Triple normal = {}; double normalModulus = 0.; auto center = neighborIterator.getNeighbor(neighborIndex).getValue(); for (unsigned dir = 0; dir < D; ++dir) { @@ -231,5 +234,3 @@ template class lsLocalLaxFriedrichs { } }; } // namespace lsInternal - -#endif // LS_LOCAL_LAX_FRIEDRICHS_HPP diff --git a/include/viennals/lsLocalLaxFriedrichsAnalytical.hpp b/include/viennals/lsLocalLaxFriedrichsAnalytical.hpp index aa90e76b..0c4eae98 100644 --- a/include/viennals/lsLocalLaxFriedrichsAnalytical.hpp +++ b/include/viennals/lsLocalLaxFriedrichsAnalytical.hpp @@ -1,5 +1,4 @@ -#ifndef LS_LOCAL_LAX_FRIEDRICHS_ANALYTICAL_HPP -#define LS_LOCAL_LAX_FRIEDRICHS_ANALYTICAL_HPP +#pragma once #include #include @@ -7,16 +6,20 @@ #include #include +#include + namespace lsInternal { +using namespace viennals; + /// Lax Friedrichs integration scheme, which uses alpha values /// provided by the user in getDissipationAlphas in lsVelocityField. /// If it is possible to derive analytical solutions for the velocityField /// and the alpha values, this integration scheme should be used and never /// otherwise. -template class lsLocalLaxFriedrichsAnalytical { - lsSmartPointer> levelSet; - lsSmartPointer> velocities; +template class LocalLaxFriedrichsAnalytical { + SmartPointer> levelSet; + SmartPointer> velocities; hrleSparseBoxIterator> neighborIterator; static T pow2(const T &value) { return value * value; } @@ -39,16 +42,16 @@ template class lsLocalLaxFriedrichsAnalytical { } public: - static void prepareLS(lsSmartPointer> passedlsDomain) { + static void prepareLS(SmartPointer> passedlsDomain) { assert(order == 1 || order == 2); // at least order+1 layers since we need neighbor neighbors for // dissipation alpha calculation - lsExpand(passedlsDomain, 2 * (order + 2) + 1).apply(); + Expand(passedlsDomain, 2 * (order + 2) + 1).apply(); } // neighboriterator always needs order 2 for alpha calculation - lsLocalLaxFriedrichsAnalytical(lsSmartPointer> passedlsDomain, - lsSmartPointer> vel) + LocalLaxFriedrichsAnalytical(SmartPointer> passedlsDomain, + SmartPointer> vel) : levelSet(passedlsDomain), velocities(vel), neighborIterator(levelSet->getDomain(), 2) {} @@ -66,7 +69,7 @@ template class lsLocalLaxFriedrichsAnalytical { neighborIterator.goToIndicesSequential(indices); // convert coordinate to std array for interface - std::array coordArray = {coordinate[0], coordinate[1], coordinate[2]}; + Triple coordArray = {coordinate[0], coordinate[1], coordinate[2]}; T gradPos[D]; T gradNeg[D]; @@ -74,7 +77,7 @@ template class lsLocalLaxFriedrichsAnalytical { T grad = 0.; T dissipation = 0.; - std::array normalVector = {}; + Triple normalVector = {}; T normalModulus = 0; for (int i = 0; i < D; i++) { // iterate over dimensions @@ -152,7 +155,7 @@ template class lsLocalLaxFriedrichsAnalytical { double scalarVelocity = velocities->getScalarVelocity( coordArray, material, normalVector, neighborIterator.getCenter().getPointId()); - std::array vectorVelocity = velocities->getVectorVelocity( + Triple vectorVelocity = velocities->getVectorVelocity( coordArray, material, normalVector, neighborIterator.getCenter().getPointId()); @@ -181,7 +184,7 @@ template class lsLocalLaxFriedrichsAnalytical { hrleVectorType neighborIndex(minIndex); for (unsigned i = 0; i < numNeighbors; ++i) { - std::array normal = {}; + Triple normal = {}; auto center = neighborIterator.getNeighbor(neighborIndex).getValue(); for (unsigned dir = 0; dir < D; ++dir) { hrleVectorType unity(0); @@ -215,5 +218,3 @@ template class lsLocalLaxFriedrichsAnalytical { } }; } // namespace lsInternal - -#endif // LS_LOCAL_LAX_FRIEDRICHS_ANALYTICAL_HPP diff --git a/include/viennals/lsLocalLocalLaxFriedrichs.hpp b/include/viennals/lsLocalLocalLaxFriedrichs.hpp index f68ac4e6..2b2ff73c 100644 --- a/include/viennals/lsLocalLocalLaxFriedrichs.hpp +++ b/include/viennals/lsLocalLocalLaxFriedrichs.hpp @@ -1,5 +1,4 @@ -#ifndef LS_LOCAL_LOCAL_LAX_FRIEDRICHS_HPP -#define LS_LOCAL_LOCAL_LAX_FRIEDRICHS_HPP +#pragma once #include #include @@ -7,28 +6,31 @@ #include #include +#include + namespace lsInternal { +using namespace viennals; + /// Lax Friedrichs integration scheme, which considers only the current /// point for alpha calculation. Faster than lsLocalLaxFriedrichs but /// not as accurate. -template class lsLocalLocalLaxFriedrichs { - lsSmartPointer> levelSet; - lsSmartPointer> velocities; +template class LocalLocalLaxFriedrichs { + SmartPointer> levelSet; + SmartPointer> velocities; hrleSparseStarIterator, order> neighborIterator; const double alphaFactor; static T pow2(const T &value) { return value * value; } public: - static void prepareLS(lsSmartPointer> passedlsDomain) { + static void prepareLS(SmartPointer> passedlsDomain) { assert(order == 1 || order == 2); - lsExpand(passedlsDomain, 2 * order + 1).apply(); + Expand(passedlsDomain, 2 * order + 1).apply(); } - lsLocalLocalLaxFriedrichs(lsSmartPointer> passedlsDomain, - lsSmartPointer> vel, - double a = 1.0) + LocalLocalLaxFriedrichs(SmartPointer> passedlsDomain, + SmartPointer> vel, double a = 1.0) : levelSet(passedlsDomain), velocities(vel), neighborIterator(hrleSparseStarIterator, order>( levelSet->getDomain())), @@ -48,7 +50,7 @@ template class lsLocalLocalLaxFriedrichs { neighborIterator.goToIndicesSequential(indices); // convert coordinate to std array for interface - std::array coordArray = {coordinate[0], coordinate[1], coordinate[2]}; + Triple coordArray = {coordinate[0], coordinate[1], coordinate[2]}; T gradPos[D]; T gradNeg[D]; @@ -56,7 +58,7 @@ template class lsLocalLocalLaxFriedrichs { T grad = 0.; T dissipation = 0.; - std::array normalVector = {}; + Triple normalVector = {}; T normalModulus = 0; for (int i = 0; i < D; i++) { // iterate over dimensions @@ -129,7 +131,7 @@ template class lsLocalLocalLaxFriedrichs { double scalarVelocity = velocities->getScalarVelocity( coordArray, material, normalVector, neighborIterator.getCenter().getPointId()); - std::array vectorVelocity = velocities->getVectorVelocity( + Triple vectorVelocity = velocities->getVectorVelocity( coordArray, material, normalVector, neighborIterator.getCenter().getPointId()); @@ -159,5 +161,3 @@ template class lsLocalLocalLaxFriedrichs { } }; } // namespace lsInternal - -#endif // LS_LOCAL_LOCAL_LAX_FRIEDRICHS_HPP diff --git a/include/viennals/lsMakeGeometry.hpp b/include/viennals/lsMakeGeometry.hpp index fdb784e2..33c2ab7d 100644 --- a/include/viennals/lsMakeGeometry.hpp +++ b/include/viennals/lsMakeGeometry.hpp @@ -1,5 +1,4 @@ -#ifndef LS_MAKE_GEOMETRY_HPP -#define LS_MAKE_GEOMETRY_HPP +#pragma once #include @@ -13,20 +12,23 @@ #include #include #include -#include #include #ifndef NDEBUG #include #endif +namespace viennals { + +using namespace viennacore; + /// Create level sets describing basic geometric forms. -template class lsMakeGeometry { - typedef typename lsDomain::PointValueVectorType pointDataType; +template class MakeGeometry { + typedef typename Domain::PointValueVectorType pointDataType; /// Enumeration for the different types of - /// geometries supported by lsMakeGeometry - enum struct lsGeometryEnum : unsigned { + /// geometries supported by MakeGeometry + enum struct GeometryEnum : unsigned { SPHERE = 0, PLANE = 1, BOX = 2, @@ -34,86 +36,86 @@ template class lsMakeGeometry { CYLINDER = 4 }; - lsSmartPointer> levelSet; - lsGeometryEnum geometry = lsGeometryEnum::SPHERE; - lsSmartPointer> sphere; - lsSmartPointer> plane; - lsSmartPointer> box; - lsSmartPointer> cylinder; - lsSmartPointer> pointCloud; + SmartPointer> levelSet; + GeometryEnum geometry = GeometryEnum::SPHERE; + SmartPointer> sphere; + SmartPointer> plane; + SmartPointer> box; + SmartPointer> cylinder; + SmartPointer> pointCloud; const double numericEps = 1e-9; // bool ignoreBoundaryConditions = false; std::array ignoreBoundaryConditions{false, false, false}; public: - lsMakeGeometry() {} + MakeGeometry() {} - lsMakeGeometry(lsSmartPointer> passedLevelSet) + MakeGeometry(SmartPointer> passedLevelSet) : levelSet(passedLevelSet) {} - lsMakeGeometry(lsSmartPointer> passedLevelSet, - lsSmartPointer> passedSphere) + MakeGeometry(SmartPointer> passedLevelSet, + SmartPointer> passedSphere) : levelSet(passedLevelSet), sphere(passedSphere) { - geometry = lsGeometryEnum::SPHERE; + geometry = GeometryEnum::SPHERE; } - lsMakeGeometry(lsSmartPointer> passedLevelSet, - lsSmartPointer> passedPlane) + MakeGeometry(SmartPointer> passedLevelSet, + SmartPointer> passedPlane) : levelSet(passedLevelSet), plane(passedPlane) { - geometry = lsGeometryEnum::PLANE; + geometry = GeometryEnum::PLANE; } - lsMakeGeometry(lsSmartPointer> passedLevelSet, - lsSmartPointer> passedBox) + MakeGeometry(SmartPointer> passedLevelSet, + SmartPointer> passedBox) : levelSet(passedLevelSet), box(passedBox) { - geometry = lsGeometryEnum::BOX; + geometry = GeometryEnum::BOX; } - lsMakeGeometry(lsSmartPointer> passedLevelSet, - lsSmartPointer> passedCylinder) + MakeGeometry(SmartPointer> passedLevelSet, + SmartPointer> passedCylinder) : levelSet(passedLevelSet), cylinder(passedCylinder) { - geometry = lsGeometryEnum::CYLINDER; + geometry = GeometryEnum::CYLINDER; } - lsMakeGeometry(lsSmartPointer> passedLevelSet, - lsSmartPointer> passedPointCloud) + MakeGeometry(SmartPointer> passedLevelSet, + SmartPointer> passedPointCloud) : levelSet(passedLevelSet), pointCloud(passedPointCloud) { - geometry = lsGeometryEnum::CUSTOM; + geometry = GeometryEnum::CUSTOM; } - void setLevelSet(lsSmartPointer> passedlsDomain) { + void setLevelSet(SmartPointer> passedlsDomain) { levelSet = passedlsDomain; } /// Set sphere as geometry to be created in the level set. - void setGeometry(lsSmartPointer> passedSphere) { + void setGeometry(SmartPointer> passedSphere) { sphere = passedSphere; - geometry = lsGeometryEnum::SPHERE; + geometry = GeometryEnum::SPHERE; } /// Set a plane to be created in the level set. - void setGeometry(lsSmartPointer> passedPlane) { + void setGeometry(SmartPointer> passedPlane) { plane = passedPlane; - geometry = lsGeometryEnum::PLANE; + geometry = GeometryEnum::PLANE; } /// Set a box to be created in the level set. - void setGeometry(lsSmartPointer> passedBox) { + void setGeometry(SmartPointer> passedBox) { box = passedBox; - geometry = lsGeometryEnum::BOX; + geometry = GeometryEnum::BOX; } /// Set a cylinder to be created in the level set. - void setGeometry(lsSmartPointer> passedCylinder) { + void setGeometry(SmartPointer> passedCylinder) { cylinder = passedCylinder; - geometry = lsGeometryEnum::CYLINDER; + geometry = GeometryEnum::CYLINDER; } /// Set a point cloud, which is used to create /// a geometry from its convex hull. - void setGeometry(lsSmartPointer> passedPointCloud) { + void setGeometry(SmartPointer> passedPointCloud) { pointCloud = passedPointCloud; - geometry = lsGeometryEnum::CUSTOM; + geometry = GeometryEnum::CUSTOM; } /// Ignore boundary conditions, meaning the parts of the generated @@ -137,31 +139,31 @@ template class lsMakeGeometry { void apply() { if (levelSet == nullptr) { - lsMessage::getInstance() - .addWarning("No level set was passed to lsMakeGeometry.") + Logger::getInstance() + .addWarning("No level set was passed to MakeGeometry.") .print(); return; } switch (geometry) { - case lsGeometryEnum::SPHERE: + case GeometryEnum::SPHERE: makeSphere(sphere->origin, sphere->radius); break; - case lsGeometryEnum::PLANE: + case GeometryEnum::PLANE: makePlane(plane->origin, plane->normal); break; - case lsGeometryEnum::BOX: + case GeometryEnum::BOX: makeBox(box->minCorner, box->maxCorner); break; - case lsGeometryEnum::CYLINDER: + case GeometryEnum::CYLINDER: makeCylinder(cylinder); break; - case lsGeometryEnum::CUSTOM: + case GeometryEnum::CUSTOM: makeCustom(pointCloud); break; default: - lsMessage::getInstance() - .addWarning("Invalid geometry type was specified for lsMakeGeometry. " + Logger::getInstance() + .addWarning("Invalid geometry type was specified for MakeGeometry. " "Not creating geometry.") .print(); } @@ -170,8 +172,8 @@ template class lsMakeGeometry { private: void makeSphere(hrleVectorType origin, T radius) { if (levelSet == nullptr) { - lsMessage::getInstance() - .addWarning("No level set was passed to lsMakeGeometry.") + Logger::getInstance() + .addWarning("No level set was passed to MakeGeometry.") .print(); return; } @@ -246,8 +248,8 @@ template class lsMakeGeometry { void makePlane(hrleVectorType origin, hrleVectorType passedNormal) { if (levelSet == nullptr) { - lsMessage::getInstance() - .addWarning("No level set was passed to lsMakeGeometry.") + Logger::getInstance() + .addWarning("No level set was passed to MakeGeometry.") .print(); return; } @@ -276,20 +278,20 @@ template class lsMakeGeometry { i = n; infDimSet = true; } else { - lsMessage::getInstance().addError( + Logger::getInstance().addError( "Planes can only be created with one Infinite Boundary " "Condition. More than one found!"); } } } if (!infDimSet) { - lsMessage::getInstance().addError("Planes require exactly one Infinite " - "Boundary Condition. None found!"); + Logger::getInstance().addError("Planes require exactly one Infinite " + "Boundary Condition. None found!"); } if (passedNormal[i] == 0.) { - lsMessage::getInstance().addError( - "lsMakeGeometry: Plane cannot be parallel to Infinite Boundary " + Logger::getInstance().addError( + "MakeGeometry: Plane cannot be parallel to Infinite Boundary " "direction!"); } @@ -329,7 +331,7 @@ template class lsMakeGeometry { } // now find i coordinate of points - auto mesh = lsSmartPointer>::New(); + auto mesh = SmartPointer>::New(); for (unsigned n = 0; n < cornerPoints.size(); ++n) { double numerator = (cornerPoints[n][j] - origin[j]) * normal[j]; @@ -359,19 +361,19 @@ template class lsMakeGeometry { #ifndef NDEBUG static unsigned planeCounter = 0; - lsVTKWriter(mesh, "plane" + std::to_string(planeCounter++) + ".vtk") + VTKWriter(mesh, "plane" + std::to_string(planeCounter++) + ".vtk") .apply(); #endif // now convert mesh to levelset - lsFromSurfaceMesh(levelSet, mesh).apply(); + FromSurfaceMesh(levelSet, mesh).apply(); } // This function creates a box starting in minCorner spanning to maxCorner void makeBox(hrleVectorType minCorner, hrleVectorType maxCorner) { if (levelSet == nullptr) { - lsMessage::getInstance() - .addWarning("No level set was passed to lsMakeGeometry.") + Logger::getInstance() + .addWarning("No level set was passed to MakeGeometry.") .print(); return; } @@ -410,7 +412,7 @@ template class lsMakeGeometry { } // now add all corners to mesh - auto mesh = lsSmartPointer>::New(); + auto mesh = SmartPointer>::New(); for (unsigned i = 0; i < corners.size(); ++i) { mesh->insertNextNode(corners[i]); } @@ -428,15 +430,15 @@ template class lsMakeGeometry { } // now convert mesh to levelset - lsFromSurfaceMesh mesher(levelSet, mesh); + FromSurfaceMesh mesher(levelSet, mesh); mesher.setRemoveBoundaryTriangles(ignoreBoundaryConditions); mesher.apply(); } - void makeCylinder(lsSmartPointer> cylinder) { + void makeCylinder(SmartPointer> cylinder) { if (D != 3) { - lsMessage::getInstance() - .addWarning("lsMakeGeometry: Cylinder can only be created in 3D!") + Logger::getInstance() + .addWarning("MakeGeometry: Cylinder can only be created in 3D!") .print(); return; } @@ -445,11 +447,11 @@ template class lsMakeGeometry { // cylinder axis will be (0,0,1) auto gridDelta = levelSet->getGrid().getGridDelta(); - auto points = lsSmartPointer>::New(); + auto points = SmartPointer>::New(); unsigned numPoints = std::ceil(2 * M_PI * cylinder->radius / gridDelta); double smallAngle = 2.0 * M_PI / double(numPoints); - auto mesh = lsSmartPointer>::New(); + auto mesh = SmartPointer>::New(); // insert midpoint at base mesh->insertNextNode(std::array{0.0, 0.0, 0.0}); { @@ -527,7 +529,7 @@ template class lsMakeGeometry { T rotationAngle = std::acos(cylinderAxis[2]); // rotate mesh - lsTransformMesh(mesh, lsTransformEnum::ROTATION, rotAxis, rotationAngle) + TransformMesh(mesh, TransformEnum::ROTATION, rotAxis, rotationAngle) .apply(); // translate mesh @@ -535,28 +537,28 @@ template class lsMakeGeometry { for (unsigned i = 0; i < 3; ++i) { translationVector[i] = cylinder->origin[i]; } - lsTransformMesh(mesh, lsTransformEnum::TRANSLATION, translationVector) + TransformMesh(mesh, TransformEnum::TRANSLATION, translationVector) .apply(); // read mesh from surface - lsFromSurfaceMesh mesher(levelSet, mesh); + FromSurfaceMesh mesher(levelSet, mesh); mesher.setRemoveBoundaryTriangles(ignoreBoundaryConditions); mesher.apply(); } - void makeCustom(lsSmartPointer> pointCloud) { + void makeCustom(SmartPointer> pointCloud) { // create mesh from point cloud - auto mesh = lsSmartPointer>::New(); - lsConvexHull(mesh, pointCloud).apply(); + auto mesh = SmartPointer>::New(); + ConvexHull(mesh, pointCloud).apply(); // read mesh from surface - lsFromSurfaceMesh mesher(levelSet, mesh); + FromSurfaceMesh mesher(levelSet, mesh); mesher.setRemoveBoundaryTriangles(ignoreBoundaryConditions); mesher.apply(); } }; // add all template specialisations for this class -PRECOMPILE_PRECISION_DIMENSION(lsMakeGeometry) +PRECOMPILE_PRECISION_DIMENSION(MakeGeometry) -#endif // LS_MAKE_GEOMETRY_HPP +} // namespace viennals diff --git a/include/viennals/lsMarchingCubes.hpp b/include/viennals/lsMarchingCubes.hpp index a9ed3af0..61efb89b 100644 --- a/include/viennals/lsMarchingCubes.hpp +++ b/include/viennals/lsMarchingCubes.hpp @@ -1,10 +1,9 @@ -#ifndef LS_MARCHING_CUBES_HPP -#define LS_MARCHING_CUBES_HPP +#pragma once namespace lsInternal { /// Helper class for lsToSurfaceMesh. Should not be used directly. -class lsMarchingCubes { +class MarchingCubes { // const unsigned int edgeTable2[16] = {0x0, 0x9, 0x3, 0xa, 0x6, 0xf, // 0x5, 0xc, 0xc, 0x5, 0xf, 0x6, @@ -334,5 +333,3 @@ class lsMarchingCubes { }; } // namespace lsInternal - -#endif // LS_MARCHING_CUBES_HPP diff --git a/include/viennals/lsMarkVoidPoints.hpp b/include/viennals/lsMarkVoidPoints.hpp index 7469ed88..cb8c6257 100644 --- a/include/viennals/lsMarkVoidPoints.hpp +++ b/include/viennals/lsMarkVoidPoints.hpp @@ -1,5 +1,4 @@ -#ifndef LS_MARK_VOID_POINTS_HPP -#define LS_MARK_VOID_POINTS_HPP +#pragma once #include @@ -8,6 +7,10 @@ #include #include +namespace viennals { + +using namespace viennacore; + /// Enumeration describing which connected component to use /// as top surface during void point detection. /// All others points will be set as void poitns. @@ -15,7 +18,7 @@ /// lexicographic first or last LS point, while LARGEST /// means that the connected component containing the /// largest number of points will be chosen. -enum struct lsVoidTopSurfaceEnum : unsigned { +enum struct VoidTopSurfaceEnum : unsigned { LEX_LOWEST = 0, LEX_HIGHEST = 1, LARGEST = 2, @@ -24,10 +27,10 @@ enum struct lsVoidTopSurfaceEnum : unsigned { /// This class is used to mark points of the level set /// which are enclosed in a void. -template class lsMarkVoidPoints { +template class MarkVoidPoints { using IndexType = std::size_t; - lsSmartPointer> domain = nullptr; + SmartPointer> domain = nullptr; bool reverseVoidDetection = false; bool saveComponents = false; bool detectLargestSurface = false; @@ -50,7 +53,7 @@ template class lsMarkVoidPoints { } } - // merge pointsPerComponent acording to the connected components + // merge pointsPerComponent according to the connected components std::vector pointsPerConnected; pointsPerConnected.resize(highestIndex + 1, 0); for (unsigned i = 0; i < components.size(); ++i) { @@ -82,14 +85,14 @@ template class lsMarkVoidPoints { public: static constexpr char voidPointLabel[] = "VoidPointMarkers"; - lsMarkVoidPoints() {} + MarkVoidPoints() {} - lsMarkVoidPoints(lsSmartPointer> passedlsDomain, - bool passedReverseVoidDetection = false) + MarkVoidPoints(SmartPointer> passedlsDomain, + bool passedReverseVoidDetection = false) : domain(passedlsDomain), reverseVoidDetection(passedReverseVoidDetection) {} - void setLevelSet(lsSmartPointer> passedlsDomain) { + void setLevelSet(SmartPointer> passedlsDomain) { domain = passedlsDomain; } @@ -113,28 +116,28 @@ template class lsMarkVoidPoints { /// Set which connected component to use as the top surface /// and mark all other components as void points. - void setVoidTopSurface(lsVoidTopSurfaceEnum topSurface) { + void setVoidTopSurface(VoidTopSurfaceEnum topSurface) { switch (topSurface) { - case lsVoidTopSurfaceEnum::LEX_LOWEST: + case VoidTopSurfaceEnum::LEX_LOWEST: reverseVoidDetection = true; detectLargestSurface = false; break; - case lsVoidTopSurfaceEnum::LEX_HIGHEST: + case VoidTopSurfaceEnum::LEX_HIGHEST: reverseVoidDetection = false; detectLargestSurface = false; break; - case lsVoidTopSurfaceEnum::LARGEST: + case VoidTopSurfaceEnum::LARGEST: reverseVoidDetection = false; detectLargestSurface = true; break; - case lsVoidTopSurfaceEnum::SMALLEST: + case VoidTopSurfaceEnum::SMALLEST: reverseVoidDetection = true; detectLargestSurface = true; break; default: - lsMessage::getInstance() - .addWarning("lsMarkVoidPoints: Invalid lsVoidTopSurfaceEnum set. " + Logger::getInstance() + .addWarning("MarkVoidPoints: Invalid VoidTopSurfaceEnum set. " "Using default values.") .print(); reverseVoidDetection = false; @@ -149,7 +152,7 @@ template class lsMarkVoidPoints { void setSaveComponentIds(bool scid) { saveComponents = scid; } void apply() { - lsInternal::lsGraph graph; + lsInternal::Graph graph; std::vector>> componentList( domain->getNumberOfSegments()); @@ -166,7 +169,7 @@ template class lsMarkVoidPoints { std::vector pointsPerComponent; // cycle through and set up the graph to get connectivity information - for (hrleConstSparseStarIterator::DomainType, 1> + for (hrleConstSparseStarIterator::DomainType, 1> neighborIt(domain->getDomain()); !neighborIt.isFinished(); neighborIt.next()) { auto ¢er = neighborIt.getCenter(); @@ -258,7 +261,7 @@ template class lsMarkVoidPoints { componentMarkers.resize(domain->getNumberOfPoints()); // cycle through again to set correct voidPointMarkers - for (hrleConstSparseStarIterator::DomainType, 1> + for (hrleConstSparseStarIterator::DomainType, 1> neighborIt(domain->getDomain()); !neighborIt.isFinished(); neighborIt.next()) { auto center = neighborIt.getCenter(); @@ -322,4 +325,4 @@ template class lsMarkVoidPoints { } }; -#endif // LS_MARK_VOID_POINTS_HPP +} // namespace viennals diff --git a/include/viennals/lsMaterialMap.hpp b/include/viennals/lsMaterialMap.hpp index 493d5979..7ddbad2d 100644 --- a/include/viennals/lsMaterialMap.hpp +++ b/include/viennals/lsMaterialMap.hpp @@ -3,14 +3,16 @@ #include #include -class lsMaterialMap { +namespace viennals { + +class MaterialMap { std::vector materialMap; std::set materials; public: - lsMaterialMap() = default; - lsMaterialMap(lsMaterialMap &) = default; - lsMaterialMap(lsMaterialMap &&) = default; + MaterialMap() = default; + MaterialMap(MaterialMap &) = default; + MaterialMap(MaterialMap &&) = default; void insertNextMaterial(const int passedMaterialId) { materialMap.push_back(passedMaterialId); @@ -34,4 +36,6 @@ class lsMaterialMap { return -1; return materialMap[index]; } -}; \ No newline at end of file +}; + +} // namespace viennals diff --git a/include/viennals/lsMesh.hpp b/include/viennals/lsMesh.hpp index 449fe693..82a011bb 100644 --- a/include/viennals/lsMesh.hpp +++ b/include/viennals/lsMesh.hpp @@ -1,5 +1,4 @@ -#ifndef LS_MESH_HPP -#define LS_MESH_HPP +#pragma once #include @@ -9,28 +8,34 @@ #include +#include + +namespace viennals { + +using namespace viennacore; + /// This class holds an explicit mesh, which is always given in 3 dimensions. /// If it describes a 2D mesh, the third dimension is set to 0. /// Vertices, Lines, Triangles, Tetras & Hexas are supported as geometric /// elements. -template class lsMesh { +template class Mesh { public: - std::vector> nodes; + std::vector> nodes; std::vector> vertices; std::vector> lines; std::vector> triangles; std::vector> tetras; std::vector> hexas; - lsPointData pointData; - lsPointData cellData; - std::array minimumExtent; - std::array maximumExtent; + PointData pointData; + PointData cellData; + Triple minimumExtent; + Triple maximumExtent; private: // iterator typedef - using VectorIt = typename lsPointData::VectorDataType::iterator; + using VectorIt = typename PointData::VectorDataType::iterator; // find function to avoid including the whole algorithm header - VectorIt find(VectorIt first, VectorIt last, const std::array &value) { + VectorIt find(VectorIt first, VectorIt last, const Triple &value) { for (; first != last; ++first) { if (*first == value) { return first; @@ -52,9 +57,9 @@ template class lsMesh { }; public: - const std::vector> &getNodes() const { return nodes; } + const std::vector> &getNodes() const { return nodes; } - std::vector> &getNodes() { return nodes; } + std::vector> &getNodes() { return nodes; } template ::type = 0> std::vector> &getElements() { @@ -81,15 +86,15 @@ template class lsMesh { return hexas; } - lsPointData &getPointData() { return pointData; } + PointData &getPointData() { return pointData; } - const lsPointData &getPointData() const { return pointData; } + const PointData &getPointData() const { return pointData; } - lsPointData &getCellData() { return cellData; } + PointData &getCellData() { return cellData; } - const lsPointData &getCellData() const { return cellData; } + const PointData &getCellData() const { return cellData; } - unsigned insertNextNode(const std::array &node) { + unsigned insertNextNode(const Triple &node) { nodes.push_back(node); return nodes.size() - 1; } @@ -145,7 +150,7 @@ template class lsMesh { } void removeDuplicateNodes() { - std::vector> newNodes; + std::vector> newNodes; // can just push first point since it cannot be duplicate newNodes.push_back(nodes[0]); // now check for duplicates @@ -178,7 +183,7 @@ template class lsMesh { } } - void append(const lsMesh &passedMesh) { + void append(const Mesh &passedMesh) { const unsigned numberOfOldNodes = nodes.size(); // append new nodes @@ -265,7 +270,7 @@ template class lsMesh { } void print() { - std::cout << "lsMesh:" << std::endl; + std::cout << "Mesh:" << std::endl; std::cout << "Number of Nodes: " << nodes.size() << std::endl; if (vertices.size() > 0) std::cout << "Number of Vertices: " << vertices.size() << std::endl; @@ -311,7 +316,7 @@ template class lsMesh { } }; -#endif // LS_MESH_HPP - // add all template specialisations for this class -PRECOMPILE_PRECISION(lsMesh); \ No newline at end of file +PRECOMPILE_PRECISION(Mesh); + +} // namespace viennals \ No newline at end of file diff --git a/include/viennals/lsMessage.hpp b/include/viennals/lsMessage.hpp deleted file mode 100644 index acf77fa6..00000000 --- a/include/viennals/lsMessage.hpp +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef LS_MESSAGE_HPP -#define LS_MESSAGE_HPP - -#include - -/// Singleton class for thread-safe logging. -class lsMessage { - std::string message; - - bool error = false; - const unsigned tabWidth = 4; - - lsMessage() {} - -public: - // delete constructors to result in better error messages by compilers - lsMessage(const lsMessage &) = delete; - void operator=(const lsMessage &) = delete; - - static lsMessage &getInstance() { - static lsMessage instance; - return instance; - } - - lsMessage &add(std::string s) { -#pragma omp critical - { message += "\n" + std::string(tabWidth, ' ') + "WARNING: " + s + "\n"; } - return *this; - } - - lsMessage &addWarning(std::string s) { -#pragma omp critical - { message += "\n" + std::string(tabWidth, ' ') + "WARNING: " + s + "\n"; } - return *this; - } - - lsMessage &addError(std::string s, bool shouldAbort = true) { -#pragma omp critical - { - message += "\n" + std::string(tabWidth, ' ') + "ERROR: " + s + "\n"; - // always abort once error message should be printed - error = true; - } - // abort now if asked - if (shouldAbort) - print(); - return *this; - } - - lsMessage &addDebug(std::string s) { -#pragma omp critical - { message += std::string(tabWidth, ' ') + "DEBUG: " + s + "\n"; } - return *this; - } - - void print(std::ostream &out = std::cout) { -#pragma omp critical - { - out << message; - message.clear(); - if (error) - abort(); - } - } -}; - -#endif // LS_MESSAGE_HPP diff --git a/include/viennals/lsPointData.hpp b/include/viennals/lsPointData.hpp index 7454e2aa..a20b2f1d 100644 --- a/include/viennals/lsPointData.hpp +++ b/include/viennals/lsPointData.hpp @@ -1,5 +1,4 @@ -#ifndef LS_POINT_DATA_HPP -#define LS_POINT_DATA_HPP +#pragma once #include @@ -8,12 +7,17 @@ #include #include -#include + +#include + +namespace viennals { + +using namespace viennacore; /// This class holds data associated with points in space. template = lsConcepts::assignable> -class lsPointData { +class PointData { public: typedef std::vector ScalarDataType; typedef std::vector> VectorDataType; @@ -32,8 +36,8 @@ class lsPointData { if (index >= 0 && index < v.size()) return &(v[index]); else - lsMessage::getInstance() - .addWarning("lsPointData: Tried to access out of bounds index! " + Logger::getInstance() + .addWarning("PointData: Tried to access out of bounds index! " "Returned nullptr instead.") .print(); return nullptr; @@ -177,8 +181,8 @@ class lsPointData { vectorDataLabels.erase(vectorDataLabels.begin() + index); } - /// Append the passed lsPointData to this one. - void append(const lsPointData &passedData) { + /// Append the passed PointData to this one. + void append(const PointData &passedData) { scalarData.insert(scalarData.end(), passedData.scalarData.begin(), passedData.scalarData.end()); scalarDataLabels.insert(scalarDataLabels.end(), @@ -195,7 +199,7 @@ class lsPointData { /// indices passed. The index of the indices vector corresponds to the index /// of this data, while the values of indices correspond to the index in /// source. - void translateFromData(const lsPointData &source, + void translateFromData(const PointData &source, const std::vector &indices) { // scalars for (unsigned j = 0; j < source.getScalarDataSize(); ++j) { @@ -215,7 +219,7 @@ class lsPointData { /// Same as translateFromData, but the indices are given as a vector, as /// is the case when collecting indices during parallel algorithms. void translateFromMultiData( - const lsPointData &source, + const PointData &source, const std::vector> &indicesVector) { // scalars for (unsigned j = 0; j < source.getScalarDataSize(); ++j) { @@ -247,13 +251,13 @@ class lsPointData { /// Return whether this object is empty. bool empty() { return scalarData.empty() && vectorData.empty(); } - /// Serialize lsPointData into a binary stream. + /// Serialize PointData into a binary stream. std::ostream &serialize(std::ostream &stream) { // HEADER - // identifier: "lsPointData" + // identifier: "PointData" // 4 byte: number of scalar data sets // 4 byte: number of vector data sets - stream << "lsPointData"; + stream << "PointData"; uint32_t numberOfScalarData = scalarData.size(); uint32_t numberOfVectorData = vectorData.size(); stream.write(reinterpret_cast(&numberOfScalarData), @@ -310,13 +314,13 @@ class lsPointData { return stream; } - /// Deserialize lsPointData from a binary stream. + /// Deserialize PointData from a binary stream. std::istream &deserialize(std::istream &stream) { char identifier[11]; stream.read(identifier, 11); - if (std::string(identifier).compare(0, 11, "lsPointData")) { - lsMessage::getInstance() - .addWarning("Reading lsPointData from stream failed. Header could " + if (std::string(identifier).compare(0, 11, "PointData")) { + Logger::getInstance() + .addWarning("Reading PointData from stream failed. Header could " "not be found.") .print(); return stream; @@ -345,7 +349,7 @@ class lsPointData { stream.read(reinterpret_cast(&value), sizeof(typename ScalarDataType::value_type)); } - // now add this scalar data to current lsPointData + // now add this scalar data to current PointData insertNextScalarData(scalarData, std::string(dataLabel.begin(), dataLabel.end())); } @@ -367,7 +371,7 @@ class lsPointData { sizeof(typename VectorDataType::value_type::value_type)); } } - // now add this scalar data to current lsPointData + // now add this scalar data to current PointData insertNextVectorData(vectorData, std::string(dataLabel.begin(), dataLabel.end())); } @@ -377,6 +381,6 @@ class lsPointData { }; // add all template specialisations for this class -PRECOMPILE_PRECISION(lsPointData); +PRECOMPILE_PRECISION(PointData); -#endif // LS_POINT_DATA_HPP +} // namespace viennals diff --git a/include/viennals/lsPreCompileMacros.hpp b/include/viennals/lsPreCompileMacros.hpp index b46ec354..f249a0fe 100644 --- a/include/viennals/lsPreCompileMacros.hpp +++ b/include/viennals/lsPreCompileMacros.hpp @@ -1,5 +1,4 @@ -#ifndef LS_PRE_COMPILE_MACROS_HPP -#define LS_PRE_COMPILE_MACROS_HPP +#pragma once #ifdef VIENNALS_USE_PRECOMPILED @@ -43,5 +42,3 @@ #define PRECOMPILE_SPECIALIZE_PRECISION(className) \ template class className; \ template class className; - -#endif // LS_PRE_COMPILE_MACROS_HPP diff --git a/include/viennals/lsPrune.hpp b/include/viennals/lsPrune.hpp index a03df2d8..ec34f193 100644 --- a/include/viennals/lsPrune.hpp +++ b/include/viennals/lsPrune.hpp @@ -1,5 +1,4 @@ -#ifndef LS_PRUNE_HPP -#define LS_PRUNE_HPP +#pragma once #include @@ -8,13 +7,17 @@ #include +namespace viennals { + +using namespace viennacore; + /// Removes all level set points, which do not have /// at least one oppositely signed neighbour (Meaning /// they do not lie directly at the interface). /// Afterwards the level set will occupy the least memory /// possible. -template class lsPrune { - lsSmartPointer> levelSet = nullptr; +template class Prune { + SmartPointer> levelSet = nullptr; bool updatePointData = true; bool removeStrayZeros = false; @@ -51,12 +54,11 @@ template class lsPrune { } public: - lsPrune() {} + Prune() {} - lsPrune(lsSmartPointer> passedlsDomain) - : levelSet(passedlsDomain) {}; + Prune(SmartPointer> passedlsDomain) : levelSet(passedlsDomain){}; - void setLevelSet(lsSmartPointer> passedlsDomain) { + void setLevelSet(SmartPointer> passedlsDomain) { levelSet = passedlsDomain; } @@ -73,8 +75,8 @@ template class lsPrune { /// returns the number of removed points void apply() { if (levelSet == nullptr) { - lsMessage::getInstance() - .addWarning("No level set was passed to lsPrune.") + Logger::getInstance() + .addWarning("No level set was passed to Prune.") .print(); return; } @@ -83,9 +85,9 @@ template class lsPrune { } auto &grid = levelSet->getGrid(); - auto newlsDomain = lsSmartPointer>::New(grid); - typename lsDomain::DomainType &newDomain = newlsDomain->getDomain(); - typename lsDomain::DomainType &domain = levelSet->getDomain(); + auto newlsDomain = SmartPointer>::New(grid); + typename Domain::DomainType &newDomain = newlsDomain->getDomain(); + typename Domain::DomainType &domain = levelSet->getDomain(); newDomain.initialize(domain.getNewSegmentation(), domain.getAllocation()); @@ -115,7 +117,7 @@ template class lsPrune { ? newDomain.getSegmentation()[p] : grid.incrementIndices(grid.getMaxGridPoint()); - for (hrleSparseStarIterator::DomainType, 1> + for (hrleSparseStarIterator::DomainType, 1> neighborIt(domain, startVector); neighborIt.getIndices() < endVector; neighborIt.next()) { auto ¢erIt = neighborIt.getCenter(); @@ -169,14 +171,13 @@ template class lsPrune { // TODO: it is more efficient to insertNextUndefinedRunType, since // we know it already exists domainSegment.insertNextUndefinedPoint( - neighborIt.getIndices(), centerSign - ? lsDomain::NEG_VALUE - : lsDomain::POS_VALUE); + neighborIt.getIndices(), + centerSign ? Domain::NEG_VALUE : Domain::POS_VALUE); } } else { domainSegment.insertNextUndefinedPoint( - neighborIt.getIndices(), centerSign ? lsDomain::NEG_VALUE - : lsDomain::POS_VALUE); + neighborIt.getIndices(), + centerSign ? Domain::NEG_VALUE : Domain::POS_VALUE); } } } @@ -196,6 +197,6 @@ template class lsPrune { }; // add all template specialisations for this class -PRECOMPILE_PRECISION_DIMENSION(lsPrune) +PRECOMPILE_PRECISION_DIMENSION(Prune) -#endif // LS_PRUNE_HPP +} // namespace viennals diff --git a/include/viennals/lsReader.hpp b/include/viennals/lsReader.hpp index 2eaba6c6..b41ccc25 100644 --- a/include/viennals/lsReader.hpp +++ b/include/viennals/lsReader.hpp @@ -1,26 +1,28 @@ -#ifndef LS_READER_HPP -#define LS_READER_HPP +#pragma once #include #include #include -template class lsReader { - lsSmartPointer> levelSet = nullptr; +namespace viennals { + +using namespace viennacore; + +template class Reader { + SmartPointer> levelSet = nullptr; std::string fileName; public: - lsReader() {} + Reader() {} - lsReader(lsSmartPointer> passedLevelSet) + Reader(SmartPointer> passedLevelSet) : levelSet(passedLevelSet) {} - lsReader(lsSmartPointer> passedLevelSet, - std::string passedFileName) + Reader(SmartPointer> passedLevelSet, std::string passedFileName) : levelSet(passedLevelSet), fileName(passedFileName) {} - void setLevelSet(lsSmartPointer> passedLevelSet) { + void setLevelSet(SmartPointer> passedLevelSet) { levelSet = passedLevelSet; } @@ -30,20 +32,20 @@ template class lsReader { void apply() { // check mesh if (levelSet == nullptr) { - lsMessage::getInstance() - .addWarning("No mesh was passed to lsReader. Not writing.") + Logger::getInstance() + .addWarning("No mesh was passed to Reader. Not writing.") .print(); return; } // check filename if (fileName.empty()) { - lsMessage::getInstance() - .addWarning("No file name specified for lsReader. Not writing.") + Logger::getInstance() + .addWarning("No file name specified for Reader. Not writing.") .print(); return; } if (fileName.find(".lvst") != fileName.length() - 5) { - lsMessage::getInstance() + Logger::getInstance() .addWarning("File name does not end in '.lvst', appending it.") .print(); fileName.append(".lvst"); @@ -59,6 +61,6 @@ template class lsReader { }; // add all template specialisations for this class -PRECOMPILE_PRECISION_DIMENSION(lsReader) +PRECOMPILE_PRECISION_DIMENSION(Reader) -#endif // LS_READER_HPP +} // namespace viennals diff --git a/include/viennals/lsReduce.hpp b/include/viennals/lsReduce.hpp index ac993a97..073420ba 100644 --- a/include/viennals/lsReduce.hpp +++ b/include/viennals/lsReduce.hpp @@ -1,5 +1,4 @@ -#ifndef LS_REDUCE_HPP -#define LS_REDUCE_HPP +#pragma once #include @@ -7,28 +6,32 @@ #include #include +namespace viennals { + +using namespace viennacore; + /// Reduce the level set size to the specified width. /// This means all level set points with value <= 0.5*width /// are removed, reducing the memory footprint of the lsDomain. -template class lsReduce { - typedef typename lsDomain::GridType GridType; - lsSmartPointer> levelSet = nullptr; +template class Reduce { + typedef typename Domain::GridType GridType; + SmartPointer> levelSet = nullptr; int width = 0; bool noNewSegment = false; bool updatePointData = true; public: - lsReduce() {} + Reduce() {} - lsReduce(lsSmartPointer> passedlsDomain) - : levelSet(passedlsDomain) {}; + Reduce(SmartPointer> passedlsDomain) + : levelSet(passedlsDomain){}; - lsReduce(lsSmartPointer> passedlsDomain, int passedWidth, - bool passedNoNewSegment = false) + Reduce(SmartPointer> passedlsDomain, int passedWidth, + bool passedNoNewSegment = false) : levelSet(passedlsDomain), width(passedWidth), - noNewSegment(passedNoNewSegment) {}; + noNewSegment(passedNoNewSegment){}; - void setLevelSet(lsSmartPointer> passedlsDomain) { + void setLevelSet(SmartPointer> passedlsDomain) { levelSet = passedlsDomain; } @@ -53,8 +56,8 @@ template class lsReduce { /// Returns the number of added points void apply() { if (levelSet == nullptr) { - lsMessage::getInstance() - .addWarning("No level set was passed to lsReduce.") + Logger::getInstance() + .addWarning("No level set was passed to Reduce.") .print(); return; } @@ -65,9 +68,9 @@ template class lsReduce { const T valueLimit = width * 0.5; auto &grid = levelSet->getGrid(); - auto newlsDomain = lsSmartPointer>::New(levelSet->getGrid()); - typename lsDomain::DomainType &newDomain = newlsDomain->getDomain(); - typename lsDomain::DomainType &domain = levelSet->getDomain(); + auto newlsDomain = SmartPointer>::New(levelSet->getGrid()); + typename Domain::DomainType &newDomain = newlsDomain->getDomain(); + typename Domain::DomainType &domain = levelSet->getDomain(); if (noNewSegment) newDomain.initialize(domain.getSegmentation(), domain.getAllocation()); @@ -99,7 +102,7 @@ template class lsReduce { ? newDomain.getSegmentation()[p] : grid.incrementIndices(grid.getMaxGridPoint()); - for (hrleSparseIterator::DomainType> it( + for (hrleSparseIterator::DomainType> it( domain, startVector); it.getStartIndices() < endVector; ++it) { T currentValue = it.getValue(); @@ -110,10 +113,10 @@ template class lsReduce { newDataSourceIds[p].push_back(it.getPointId()); } else { // TODO: use insertNextUndefinedRunType - domainSegment.insertNextUndefinedPoint( - it.getStartIndices(), (currentValue < 0) - ? lsDomain::NEG_VALUE - : lsDomain::POS_VALUE); + domainSegment.insertNextUndefinedPoint(it.getStartIndices(), + (currentValue < 0) + ? Domain::NEG_VALUE + : Domain::POS_VALUE); } } } @@ -134,6 +137,6 @@ template class lsReduce { }; // add all template specialisations for this class -PRECOMPILE_PRECISION_DIMENSION(lsReduce) +PRECOMPILE_PRECISION_DIMENSION(Reduce) -#endif // LS_REDUCE_HPP +} // namespace viennals diff --git a/include/viennals/lsRemoveStrayPoints.hpp b/include/viennals/lsRemoveStrayPoints.hpp index 345a6b34..b80cb2ef 100644 --- a/include/viennals/lsRemoveStrayPoints.hpp +++ b/include/viennals/lsRemoveStrayPoints.hpp @@ -2,38 +2,41 @@ #include #include -#include + +namespace viennals { + +using namespace viennacore; /// This algorithm can be used to remove all LS values /// which are not part of a so-called top surface. -/// This surface is detected using the lsMarkVoidPoints +/// This surface is detected using the MarkVoidPoints /// algorithm, according to the method chosen by the user. /// This method is set using setVoidTopSurface, which /// is equivalent to the corresponding member function /// of lsMarkVoidPoints. -template class lsRemoveStrayPoints { - lsSmartPointer> levelSet = nullptr; - lsVoidTopSurfaceEnum voidTopSurface = lsVoidTopSurfaceEnum::LARGEST; +template class RemoveStrayPoints { + SmartPointer> levelSet = nullptr; + VoidTopSurfaceEnum voidTopSurface = VoidTopSurfaceEnum::LARGEST; public: - lsRemoveStrayPoints() {} + RemoveStrayPoints() {} - lsRemoveStrayPoints(lsSmartPointer> passedLevelSet) + RemoveStrayPoints(SmartPointer> passedLevelSet) : levelSet(passedLevelSet) {} - void setLevelSet(lsSmartPointer> passedLevelSet) { + void setLevelSet(SmartPointer> passedLevelSet) { levelSet = passedLevelSet; } /// Set how the algorithm should pick the surface which will not /// be removed. Defaults to the surface with the most LS points. - void setVoidTopSurface(lsVoidTopSurfaceEnum topSurface) { + void setVoidTopSurface(VoidTopSurfaceEnum topSurface) { voidTopSurface = topSurface; } void apply() { if (levelSet == nullptr) { - lsMessage::getInstance() + Logger::getInstance() .addWarning("No level set was passed to lsPrune.") .print(); return; @@ -44,7 +47,7 @@ template class lsRemoveStrayPoints { // Mark which points are voids { - lsMarkVoidPoints marker; + MarkVoidPoints marker; marker.setLevelSet(levelSet); marker.setVoidTopSurface(voidTopSurface); marker.apply(); @@ -53,21 +56,21 @@ template class lsRemoveStrayPoints { auto voidMarkers = levelSet->getPointData().getScalarData("VoidPointMarkers"); if (voidMarkers == nullptr) { - lsMessage::getInstance() - .addWarning("lsRemoveStrayPoints: No scalar data for void point " + Logger::getInstance() + .addWarning("RemoveStrayPoints: No scalar data for void point " "markers found. Cannot remove stray points.") .print(); } // now iterate through the domain and remove points which are void points auto &grid = levelSet->getGrid(); - auto newlsDomain = lsSmartPointer>::New(grid); - typename lsDomain::DomainType &newDomain = newlsDomain->getDomain(); - typename lsDomain::DomainType &domain = levelSet->getDomain(); + auto newlsDomain = SmartPointer>::New(grid); + typename Domain::DomainType &newDomain = newlsDomain->getDomain(); + typename Domain::DomainType &domain = levelSet->getDomain(); newDomain.initialize(domain.getNewSegmentation(), domain.getAllocation()); - std::vector::PointValueVectorType> newPoints; + std::vector::PointValueVectorType> newPoints; newPoints.resize(newDomain.getNumberOfSegments()); #pragma omp parallel num_threads(newDomain.getNumberOfSegments()) @@ -88,7 +91,7 @@ template class lsRemoveStrayPoints { ? newDomain.getSegmentation()[p] : grid.incrementIndices(grid.getMaxGridPoint()); - for (hrleConstSparseIterator::DomainType> it( + for (hrleConstSparseIterator::DomainType> it( domain, startVector); it.getStartIndices() < endVector; it.next()) { if (it.isDefined() && !voidMarkers->at(it.getPointId())) { @@ -112,4 +115,6 @@ template class lsRemoveStrayPoints { levelSet->deepCopy(newlsDomain); levelSet->finalize(2); } -}; \ No newline at end of file +}; + +} // namespace viennals diff --git a/include/viennals/lsSmartPointer.hpp b/include/viennals/lsSmartPointer.hpp deleted file mode 100644 index 89bf0af0..00000000 --- a/include/viennals/lsSmartPointer.hpp +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef LS_SMART_POINTER_HPP -#define LS_SMART_POINTER_HPP - -#include - -/// std::shared_ptr wrapper for use with ViennaLS. -/// lsSmartPointers should be created using the function ::New(...). -/// All other interface functions are identical to std::shared_ptr -template class lsSmartPointer : public std::shared_ptr { -public: - // lsSmartPointer(T& passedObject) : - // std::shared_ptr(std::make_shared(passedObject)) {} - - // Make visible all constructors of std::shared_ptr - // including copy constructors - template - lsSmartPointer(Args &&...args) - : std::shared_ptr(std::forward(args)...) {} - - /// Use this function to create new objects when using ViennaLS - template static lsSmartPointer New(TArgs &&...targs) { - return lsSmartPointer(std::make_shared(std::forward(targs)...)); - } -}; - -#endif // LS_SMART_POINTER_HPP \ No newline at end of file diff --git a/include/viennals/lsStencilLocalLaxFriedrichsScalar.hpp b/include/viennals/lsStencilLocalLaxFriedrichsScalar.hpp index bd8c897b..e83e3b22 100644 --- a/include/viennals/lsStencilLocalLaxFriedrichsScalar.hpp +++ b/include/viennals/lsStencilLocalLaxFriedrichsScalar.hpp @@ -1,5 +1,4 @@ -#ifndef LS_STENCIL_LOCAL_LACHS_FRIEDRICHS_SCALAR_HPP -#define LS_STENCIL_LOCAL_LACHS_FRIEDRICHS_SCALAR_HPP +#pragma once #include #include @@ -10,18 +9,20 @@ namespace lsInternal { +using namespace viennals; + /// Stencil Local Lax Friedrichs Integration Scheme. /// It uses a stencil of order around active points, in order to /// evaluate dissipation values for each point, taking into account /// the mathematical nature of the speed function. /// see Toifl et al., 2019. ISBN: 978-1-7281-0938-1; /// DOI: 10.1109/SISPAD.2019.8870443 -template class lsStencilLocalLaxFriedrichsScalar { - using LevelSetType = lsSmartPointer>; +template class StencilLocalLaxFriedrichsScalar { + using LevelSetType = SmartPointer>; using LevelSetsType = std::vector; LevelSetType levelSet; - lsSmartPointer> velocities; + SmartPointer> velocities; const DifferentiationSchemeEnum finiteDifferenceScheme = DifferentiationSchemeEnum::FIRST_ORDER; hrleSparseBoxIterator> neighborIterator; @@ -49,7 +50,7 @@ template class lsStencilLocalLaxFriedrichsScalar { index[i] = startIndex + j; values.push_back(neighborIterator.getNeighbor(index).getValue()); } - normal[i] = lsFiniteDifferences::calculateGradient( + normal[i] = FiniteDifferences::calculateGradient( &(values[0]), levelSet->getGrid().getGridDelta()); modulus += normal[i] * normal[i]; } @@ -65,7 +66,7 @@ template class lsStencilLocalLaxFriedrichsScalar { hrleVectorType gradient; const unsigned numValues = - lsFiniteDifferences::getNumberOfValues(finiteDifferenceScheme); + FiniteDifferences::getNumberOfValues(finiteDifferenceScheme); const int startIndex = -std::floor(numValues / 2); for (unsigned i = 0; i < D; ++i) { @@ -78,14 +79,14 @@ template class lsStencilLocalLaxFriedrichsScalar { if (finiteDifferenceScheme == DifferentiationSchemeEnum::FIRST_ORDER) { gradient[i] = - lsFiniteDifferences:: + FiniteDifferences:: calculateGradient(&(values[0]), levelSet->getGrid().getGridDelta()); } else if (finiteDifferenceScheme == DifferentiationSchemeEnum::WENO3) { - gradient[i] = lsFiniteDifferences:: + gradient[i] = FiniteDifferences:: calculateGradient(&(values[0]), levelSet->getGrid().getGridDelta()); } else if (finiteDifferenceScheme == DifferentiationSchemeEnum::WENO5) - gradient[i] = lsFiniteDifferences:: + gradient[i] = FiniteDifferences:: calculateGradient(&(values[0]), levelSet->getGrid().getGridDelta()); } @@ -96,7 +97,7 @@ template class lsStencilLocalLaxFriedrichsScalar { hrleVectorType gradient; const unsigned numValues = - lsFiniteDifferences::getNumberOfValues(finiteDifferenceScheme); + FiniteDifferences::getNumberOfValues(finiteDifferenceScheme); const int startIndex = -std::floor(numValues / 2); for (unsigned i = 0; i < D; ++i) { @@ -109,15 +110,15 @@ template class lsStencilLocalLaxFriedrichsScalar { if (finiteDifferenceScheme == DifferentiationSchemeEnum::FIRST_ORDER) { gradient[i] = - lsFiniteDifferences:: + FiniteDifferences:: calculateGradientDiff(&(values[0]), levelSet->getGrid().getGridDelta()); } else if (finiteDifferenceScheme == DifferentiationSchemeEnum::WENO3) { - gradient[i] = lsFiniteDifferences:: + gradient[i] = FiniteDifferences:: calculateGradientDiff(&(values[0]), levelSet->getGrid().getGridDelta()); } else if (finiteDifferenceScheme == DifferentiationSchemeEnum::WENO5) - gradient[i] = lsFiniteDifferences:: + gradient[i] = FiniteDifferences:: calculateGradientDiff(&(values[0]), levelSet->getGrid().getGridDelta()); } @@ -131,11 +132,11 @@ template class lsStencilLocalLaxFriedrichsScalar { static void prepareLS(LevelSetType passedlsDomain) { // Expansion of sparse field must depend on spatial derivative order // AND slf stencil order! --> currently assume scheme = 3rd order always - lsExpand(passedlsDomain, 2 * (order + 1) + 4).apply(); + Expand(passedlsDomain, 2 * (order + 1) + 4).apply(); } - lsStencilLocalLaxFriedrichsScalar( - LevelSetType passedlsDomain, lsSmartPointer> vel, + StencilLocalLaxFriedrichsScalar( + LevelSetType passedlsDomain, SmartPointer> vel, double a = 1.0, DifferentiationSchemeEnum scheme = DifferentiationSchemeEnum::FIRST_ORDER) : levelSet(passedlsDomain), velocities(vel), @@ -331,7 +332,7 @@ namespace advect { template < class IntegrationSchemeType, class T, int D, lsConcepts::IsSame> = + lsInternal::StencilLocalLaxFriedrichsScalar> = lsConcepts::assignable> void reduceTimeStepHamiltonJacobi(IntegrationSchemeType &scheme, double &MaxTimeStep, @@ -351,6 +352,10 @@ void reduceTimeStepHamiltonJacobi(IntegrationSchemeType &scheme, } // namespace advect } // namespace lsInternal +namespace viennals { + +using namespace viennacore; + /// This function creates the specialized layer wrapping which /// produces better results for the SSLF integration scheme. /// isDepo must contain whether the corresponding level sets @@ -363,13 +368,13 @@ void reduceTimeStepHamiltonJacobi(IntegrationSchemeType &scheme, /// after advection instead of trying to deal with numerous /// separate masking layers. template -void lsPrepareStencilLocalLaxFriedrichs( - std::vector>> &levelSets, +void PrepareStencilLocalLaxFriedrichs( + std::vector>> &levelSets, std::vector isDepo) { if (isDepo.size() < levelSets.size()) { - lsMessage::getInstance() + Logger::getInstance() .addWarning( - "lsPrepareStencilLocalLaxFriedrichs: isDepo does not have enough " + "PrepareStencilLocalLaxFriedrichs: isDepo does not have enough " "elements. Assuming all higher layers are not depo layers.") .print(); } @@ -380,7 +385,7 @@ void lsPrepareStencilLocalLaxFriedrichs( auto layerIt = levelSets.rbegin(); // make empty LS which will contain the final top layer - auto finalTop = lsSmartPointer>::New(levelSets[0]->getGrid()); + auto finalTop = SmartPointer>::New(levelSets[0]->getGrid()); bool layerAboveIsDepo = false; auto depoIt = isDepo.rbegin(); @@ -397,15 +402,15 @@ void lsPrepareStencilLocalLaxFriedrichs( } else { // no depo on this layer if (layerAboveIsDepo) { - auto layerAbove = lsSmartPointer>::New(*layerIt); - lsBooleanOperation(layerAbove, *maskIt, - lsBooleanOperationEnum::RELATIVE_COMPLEMENT) + auto layerAbove = SmartPointer>::New(*layerIt); + BooleanOperation(layerAbove, *maskIt, + BooleanOperationEnum::RELATIVE_COMPLEMENT) .apply(); - lsBooleanOperation(finalTop, layerAbove, - lsBooleanOperationEnum::UNION) + BooleanOperation(finalTop, layerAbove, + BooleanOperationEnum::UNION) .apply(); - lsPrune(finalTop).apply(); + Prune(finalTop).apply(); } layerAboveIsDepo = false; } @@ -414,25 +419,25 @@ void lsPrepareStencilLocalLaxFriedrichs( // If the lowest layer is a depo substrate, add it to the final top layer if (layerAboveIsDepo) { - lsBooleanOperation(finalTop, *layerIt, lsBooleanOperationEnum::UNION) + BooleanOperation(finalTop, *layerIt, BooleanOperationEnum::UNION) .apply(); } - lsBooleanOperation(finalTop, lsBooleanOperationEnum::INVERT).apply(); + BooleanOperation(finalTop, BooleanOperationEnum::INVERT).apply(); levelSets.back()->deepCopy(finalTop); } /// After advection using the SLLF layer wrapping approach is done, /// restore the original layer wrapping used everywhere else. template -void lsFinalizeStencilLocalLaxFriedrichs( - std::vector>> &levelSets) { +void FinalizeStencilLocalLaxFriedrichs( + std::vector>> &levelSets) { auto layerIt = levelSets.rbegin(); auto lastIt = ++levelSets.rbegin(); - lsBooleanOperation(*layerIt, lsBooleanOperationEnum::INVERT).apply(); - lsBooleanOperation(*layerIt, *lastIt, lsBooleanOperationEnum::UNION) + BooleanOperation(*layerIt, BooleanOperationEnum::INVERT).apply(); + BooleanOperation(*layerIt, *lastIt, BooleanOperationEnum::UNION) .apply(); } -#endif // LS_STENCIL_LOCAL_LACHS_FRIEDRICHS_SCALAR_HPP +} // namespace viennals diff --git a/include/viennals/lsTestAsserts.hpp b/include/viennals/lsTestAsserts.hpp index fd666515..376cac14 100644 --- a/include/viennals/lsTestAsserts.hpp +++ b/include/viennals/lsTestAsserts.hpp @@ -19,7 +19,7 @@ #define LSTEST_ASSERT_VALID_LS(levelSet, NumericType, D) \ { \ - auto check = lsCheck(levelSet); \ + auto check = viennals::Check(levelSet); \ check.apply(); \ if (check.isValid()) { \ std::cout << "SUCCESS" << std::endl; \ diff --git a/include/viennals/lsToDiskMesh.hpp b/include/viennals/lsToDiskMesh.hpp index a68751fb..11209e92 100644 --- a/include/viennals/lsToDiskMesh.hpp +++ b/include/viennals/lsToDiskMesh.hpp @@ -1,5 +1,4 @@ -#ifndef LS_TO_DISK_MESH_HPP -#define LS_TO_DISK_MESH_HPP +#pragma once #include @@ -12,66 +11,70 @@ #include #include +namespace viennals { + +using namespace viennacore; + /// This class creates a mesh from the level set /// with all grid points with a level set value <= 0.5. /// These grid points are shifted in space towards the /// direction of their normal vector by grid delta * LS value. /// Grid delta and the origin grid point are saved for each point. /// This allows for a simple setup of disks for ray tracing. -template class lsToDiskMesh { - typedef typename lsDomain::DomainType hrleDomainType; +template class ToDiskMesh { + typedef typename Domain::DomainType hrleDomainType; public: using TranslatorType = std::unordered_map; private: - std::vector>> levelSets; - lsSmartPointer> mesh = nullptr; - lsSmartPointer translator = nullptr; - lsSmartPointer materialMap = nullptr; + std::vector>> levelSets; + SmartPointer> mesh = nullptr; + SmartPointer translator = nullptr; + SmartPointer materialMap = nullptr; T maxValue = 0.5; bool buildTranslator = false; static constexpr double wrappingLayerEpsilon = 1e-4; public: - lsToDiskMesh() {} + ToDiskMesh() {} - lsToDiskMesh(lsSmartPointer> passedMesh, T passedMaxValue = 0.5) + ToDiskMesh(SmartPointer> passedMesh, T passedMaxValue = 0.5) : mesh(passedMesh), maxValue(passedMaxValue) {} - lsToDiskMesh(lsSmartPointer> passedLevelSet, - lsSmartPointer> passedMesh, T passedMaxValue = 0.5) + ToDiskMesh(SmartPointer> passedLevelSet, + SmartPointer> passedMesh, T passedMaxValue = 0.5) : mesh(passedMesh), maxValue(passedMaxValue) { levelSets.push_back(passedLevelSet); } - lsToDiskMesh(lsSmartPointer> passedLevelSet, - lsSmartPointer> passedMesh, - lsSmartPointer passedTranslator, - T passedMaxValue = 0.5) + ToDiskMesh(SmartPointer> passedLevelSet, + SmartPointer> passedMesh, + SmartPointer passedTranslator, + T passedMaxValue = 0.5) : mesh(passedMesh), translator(passedTranslator), maxValue(passedMaxValue) { levelSets.push_back(passedLevelSet); buildTranslator = true; } - void setLevelSet(lsSmartPointer> passedLevelSet) { + void setLevelSet(SmartPointer> passedLevelSet) { levelSets.push_back(passedLevelSet); } /// Pushes the passed level set to the back of the list of level sets - void insertNextLevelSet(lsSmartPointer> passedLevelSet) { + void insertNextLevelSet(SmartPointer> passedLevelSet) { levelSets.push_back(passedLevelSet); } - void setMesh(lsSmartPointer> passedMesh) { mesh = passedMesh; } + void setMesh(SmartPointer> passedMesh) { mesh = passedMesh; } - void setTranslator(lsSmartPointer passedTranslator) { + void setTranslator(SmartPointer passedTranslator) { translator = passedTranslator; buildTranslator = true; } - void setMaterialMap(lsSmartPointer passedMaterialMap) { + void setMaterialMap(SmartPointer passedMaterialMap) { materialMap = passedMaterialMap; } @@ -79,33 +82,33 @@ template class lsToDiskMesh { void apply() { if (levelSets.size() < 1) { - lsMessage::getInstance() - .addWarning("No level sets passed to lsToDiskMesh.") + Logger::getInstance() + .addWarning("No level sets passed to ToDiskMesh.") .print(); return; } if (mesh == nullptr) { - lsMessage::getInstance() - .addWarning("No mesh was passed to lsToDiskMesh.") + Logger::getInstance() + .addWarning("No mesh was passed to ToDiskMesh.") .print(); return; } if (buildTranslator && translator == nullptr) { - lsMessage::getInstance() - .addWarning("No translator was passed to lsToDiskMesh.") + Logger::getInstance() + .addWarning("No translator was passed to ToDiskMesh.") .print(); } mesh->clear(); // expand top levelset - lsExpand(levelSets.back(), (maxValue * 4) + 1).apply(); - lsCalculateNormalVectors(levelSets.back(), maxValue).apply(); + Expand(levelSets.back(), (maxValue * 4) + 1).apply(); + CalculateNormalVectors(levelSets.back(), maxValue).apply(); const T gridDelta = levelSets.back()->getGrid().getGridDelta(); const auto &normalVectors = *(levelSets.back()->getPointData().getVectorData( - lsCalculateNormalVectors::normalVectorsLabel)); + CalculateNormalVectors::normalVectorsLabel)); // set up data arrays std::vector values; @@ -223,10 +226,10 @@ template class lsToDiskMesh { { auto &pointData = levelSets.back()->getPointData(); auto index = pointData.getVectorDataIndex( - lsCalculateNormalVectors::normalVectorsLabel); + CalculateNormalVectors::normalVectorsLabel); if (index < 0) { - lsMessage::getInstance() - .addWarning("lsToDiskMesh: Internal error: Could not find normal " + Logger::getInstance() + .addWarning("ToDiskMesh: Internal error: Could not find normal " "vector data.") .print(); } else { @@ -242,4 +245,4 @@ template class lsToDiskMesh { } }; -#endif // LS_TO_DISK_MESH_HPP +} // namespace viennals diff --git a/include/viennals/lsToMesh.hpp b/include/viennals/lsToMesh.hpp index 80879258..a9df1e3f 100644 --- a/include/viennals/lsToMesh.hpp +++ b/include/viennals/lsToMesh.hpp @@ -1,5 +1,4 @@ -#ifndef LS_TO_MESH_HPP -#define LS_TO_MESH_HPP +#pragma once #include @@ -9,33 +8,37 @@ #include #include +namespace viennals { + +using namespace viennacore; + /// Extract the regular grid, on which the level set values are -/// defined, to an explicit lsMesh<>. The Vertices will contain +/// defined, to an explicit Mesh<>. The Vertices will contain /// the level set value stored at its location. (This is very useful /// for debugging) -template class lsToMesh { - typedef typename lsDomain::DomainType hrleDomainType; +template class ToMesh { + typedef typename Domain::DomainType hrleDomainType; - lsSmartPointer> levelSet = nullptr; - lsSmartPointer> mesh = nullptr; + SmartPointer> levelSet = nullptr; + SmartPointer> mesh = nullptr; bool onlyDefined = true; bool onlyActive = false; static constexpr long long maxDomainExtent = 1e6; public: - lsToMesh() {}; + ToMesh(){}; - lsToMesh(const lsSmartPointer> passedLevelSet, - lsSmartPointer> passedMesh, bool passedOnlyDefined = true, - bool passedOnlyActive = false) + ToMesh(const SmartPointer> passedLevelSet, + SmartPointer> passedMesh, bool passedOnlyDefined = true, + bool passedOnlyActive = false) : levelSet(passedLevelSet), mesh(passedMesh), onlyDefined(passedOnlyDefined), onlyActive(passedOnlyActive) {} - void setLevelSet(lsSmartPointer> passedlsDomain) { + void setLevelSet(SmartPointer> passedlsDomain) { levelSet = passedlsDomain; } - void setMesh(lsSmartPointer> passedMesh) { mesh = passedMesh; } + void setMesh(SmartPointer> passedMesh) { mesh = passedMesh; } void setOnlyDefined(bool passedOnlyDefined) { onlyDefined = passedOnlyDefined; @@ -45,15 +48,13 @@ template class lsToMesh { void apply() { if (levelSet == nullptr) { - lsMessage::getInstance() - .addWarning("No level set was passed to lsToMesh.") + Logger::getInstance() + .addWarning("No level set was passed to ToMesh.") .print(); return; } if (mesh == nullptr) { - lsMessage::getInstance() - .addWarning("No mesh was passed to lsToMesh.") - .print(); + Logger::getInstance().addWarning("No mesh was passed to ToMesh.").print(); return; } @@ -69,7 +70,7 @@ template class lsToMesh { std::vector subLS; // point data const auto &pointData = levelSet->getPointData(); - using DomainType = lsDomain; + using DomainType = Domain; using ScalarDataType = typename DomainType::PointDataType::ScalarDataType; using VectorDataType = typename DomainType::PointDataType::VectorDataType; @@ -128,8 +129,8 @@ template class lsToMesh { const auto ¤tData = *dataPointer; scalarData[i].push_back(currentData[it.getPointId()]); } else { - lsMessage::getInstance() - .addWarning("lsToMesh: Tried to access out of bounds scalarData! " + Logger::getInstance() + .addWarning("ToMesh: Tried to access out of bounds scalarData! " "Ignoring.") .print(); break; @@ -142,8 +143,8 @@ template class lsToMesh { const auto ¤tData = *dataPointer; vectorData[i].push_back(currentData[it.getPointId()]); } else { - lsMessage::getInstance() - .addWarning("lsToMesh: Tried to access out of bounds vectorData! " + Logger::getInstance() + .addWarning("ToMesh: Tried to access out of bounds vectorData! " "Ignoring.") .print(); break; @@ -169,6 +170,6 @@ template class lsToMesh { }; // add all template specialisations for this class -PRECOMPILE_PRECISION_DIMENSION(lsToMesh) +PRECOMPILE_PRECISION_DIMENSION(ToMesh) -#endif // LS_TO_MESH_HPP +} // namespace viennals diff --git a/include/viennals/lsToSurfaceMesh.hpp b/include/viennals/lsToSurfaceMesh.hpp index 51fc45ac..f3b6bf4e 100644 --- a/include/viennals/lsToSurfaceMesh.hpp +++ b/include/viennals/lsToSurfaceMesh.hpp @@ -1,5 +1,4 @@ -#ifndef LS_TO_SURFACE_MESH_HPP -#define LS_TO_SURFACE_MESH_HPP +#pragma once #include @@ -10,45 +9,48 @@ #include #include #include -#include -/// Extract an explicit lsMesh<> instance from an lsDomain. +namespace viennals { + +using namespace viennacore; + +/// Extract an explicit Mesh<> instance from an lsDomain. /// The interface is then described by explciit surface elements: /// Lines in 2D, Triangles in 3D. -template class lsToSurfaceMesh { - typedef typename lsDomain::DomainType hrleDomainType; +template class ToSurfaceMesh { + typedef typename Domain::DomainType hrleDomainType; - lsSmartPointer> levelSet = nullptr; - lsSmartPointer> mesh = nullptr; + SmartPointer> levelSet = nullptr; + SmartPointer> mesh = nullptr; // std::vector meshNodeToPointIdMapping; const T epsilon; bool updatePointData = true; public: - lsToSurfaceMesh(double eps = 1e-12) : epsilon(eps) {} + ToSurfaceMesh(double eps = 1e-12) : epsilon(eps) {} - lsToSurfaceMesh(const lsSmartPointer> passedLevelSet, - lsSmartPointer> passedMesh, double eps = 1e-12) + ToSurfaceMesh(const SmartPointer> passedLevelSet, + SmartPointer> passedMesh, double eps = 1e-12) : levelSet(passedLevelSet), mesh(passedMesh), epsilon(eps) {} - void setLevelSet(lsSmartPointer> passedlsDomain) { + void setLevelSet(SmartPointer> passedlsDomain) { levelSet = passedlsDomain; } - void setMesh(lsSmartPointer> passedMesh) { mesh = passedMesh; } + void setMesh(SmartPointer> passedMesh) { mesh = passedMesh; } void setUpdatePointData(bool update) { updatePointData = update; } void apply() { if (levelSet == nullptr) { - lsMessage::getInstance() - .addWarning("No level set was passed to lsToSurfaceMesh.") + Logger::getInstance() + .addWarning("No level set was passed to ToSurfaceMesh.") .print(); return; } if (mesh == nullptr) { - lsMessage::getInstance() - .addWarning("No mesh was passed to lsToSurfaceMesh.") + Logger::getInstance() + .addWarning("No mesh was passed to ToSurfaceMesh.") .print(); return; } @@ -65,7 +67,7 @@ template class lsToSurfaceMesh { // test if level set function consists of at least 2 layers of // defined grid points if (levelSet->getLevelSetWidth() < 2) { - lsMessage::getInstance() + Logger::getInstance() .addWarning("Levelset is less than 2 layers wide. Export might fail!") .print(); } @@ -77,9 +79,9 @@ template class lsToSurfaceMesh { typename nodeContainerType::iterator nodeIt; - lsInternal::lsMarchingCubes marchingCubes; + lsInternal::MarchingCubes marchingCubes; - using DomainType = lsDomain; + using DomainType = Domain; using ScalarDataType = typename DomainType::PointDataType::ScalarDataType; using VectorDataType = typename DomainType::PointDataType::VectorDataType; @@ -201,6 +203,6 @@ template class lsToSurfaceMesh { }; // add all template specialisations for this class -PRECOMPILE_PRECISION_DIMENSION(lsToSurfaceMesh) +PRECOMPILE_PRECISION_DIMENSION(ToSurfaceMesh) -#endif // LS_TO_SURFACE_MESH_HPP +} // namespace viennals diff --git a/include/viennals/lsToVoxelMesh.hpp b/include/viennals/lsToVoxelMesh.hpp index a3f3656e..425481fb 100644 --- a/include/viennals/lsToVoxelMesh.hpp +++ b/include/viennals/lsToVoxelMesh.hpp @@ -1,5 +1,4 @@ -#ifndef LS_TO_VOXEL_MESH_HPP -#define LS_TO_VOXEL_MESH_HPP +#pragma once #include @@ -10,16 +9,20 @@ #include #include +namespace viennals { + +using namespace viennacore; + /// Creates a mesh, which consists only of quads/hexas for completely /// filled grid cells in the level set. Interfaces will not be smooth /// but stepped. (This can be used to create meshes for finite difference /// algorithms) -template class lsToVoxelMesh { - typedef typename lsDomain::DomainType hrleDomainType; +template class ToVoxelMesh { + typedef typename Domain::DomainType hrleDomainType; - std::vector>> levelSets; - lsSmartPointer> mesh = nullptr; - lsSmartPointer materialMap = nullptr; + std::vector>> levelSets; + SmartPointer> mesh = nullptr; + SmartPointer materialMap = nullptr; hrleVectorType minIndex, maxIndex; void calculateBounds() { @@ -44,19 +47,18 @@ template class lsToVoxelMesh { } public: - lsToVoxelMesh() {} + ToVoxelMesh() {} - lsToVoxelMesh(lsSmartPointer> passedMesh) : mesh(passedMesh) {} + ToVoxelMesh(SmartPointer> passedMesh) : mesh(passedMesh) {} - lsToVoxelMesh(lsSmartPointer> passedLevelSet, - lsSmartPointer> passedMesh) + ToVoxelMesh(SmartPointer> passedLevelSet, + SmartPointer> passedMesh) : mesh(passedMesh) { levelSets.push_back(passedLevelSet); } - lsToVoxelMesh( - const std::vector>> passedLevelSets, - lsSmartPointer> passedMesh) + ToVoxelMesh(const std::vector>> passedLevelSets, + SmartPointer> passedMesh) : mesh(passedMesh) { levelSets = passedLevelSets; } @@ -65,26 +67,25 @@ template class lsToVoxelMesh { /// If more than one are specified, the voxels will be marked /// using a material number for each level set and output into /// a single mesh. - void insertNextLevelSet(lsSmartPointer> passedLevelSet) { + void insertNextLevelSet(SmartPointer> passedLevelSet) { levelSets.push_back(passedLevelSet); } - void setMesh(lsSmartPointer> passedMesh) { mesh = passedMesh; } + void setMesh(SmartPointer> passedMesh) { mesh = passedMesh; } - void setMaterialMap(lsSmartPointer passedMaterialMap) { + void setMaterialMap(SmartPointer passedMaterialMap) { materialMap = passedMaterialMap; } void apply() { if (levelSets.size() < 1) { - lsMessage::getInstance() - .addWarning( - "No Level Sets supplied to lsToVoxelMesh! Not converting.") + Logger::getInstance() + .addWarning("No Level Sets supplied to ToVoxelMesh! Not converting.") .print(); } if (mesh == nullptr) { - lsMessage::getInstance() - .addWarning("No mesh was passed to lsToVoxelMesh.") + Logger::getInstance() + .addWarning("No mesh was passed to ToVoxelMesh.") .print(); return; } @@ -107,17 +108,17 @@ template class lsToVoxelMesh { size_t currentPointId = 0; // prepare mesh for material ids - mesh->cellData.insertNextScalarData( - typename lsPointData::ScalarDataType(), "Material"); + mesh->cellData.insertNextScalarData(typename PointData::ScalarDataType(), + "Material"); auto &materialIds = *(mesh->cellData.getScalarData(0)); const bool useMaterialMap = materialMap != nullptr; // set up iterators for all materials - std::vector::DomainType>> + std::vector::DomainType>> iterators; for (auto it = levelSets.begin(); it != levelSets.end(); ++it) { iterators.push_back( - hrleConstDenseCellIterator::DomainType>( + hrleConstDenseCellIterator::DomainType>( (*it)->getDomain(), minIndex)); } @@ -213,7 +214,7 @@ template class lsToVoxelMesh { } }; -// add all template specialisations for this class -PRECOMPILE_PRECISION_DIMENSION(lsToVoxelMesh) +// add all template specializations for this class +PRECOMPILE_PRECISION_DIMENSION(ToVoxelMesh) -#endif // LS_TO_VOXEL_MESH_HPP +} // namespace viennals diff --git a/include/viennals/lsTransformMesh.hpp b/include/viennals/lsTransformMesh.hpp index 21394598..8f73ad95 100644 --- a/include/viennals/lsTransformMesh.hpp +++ b/include/viennals/lsTransformMesh.hpp @@ -1,25 +1,26 @@ -#ifndef LS_TRANSFORM_MESH_HPP -#define LS_TRANSFORM_MESH_HPP +#pragma once #include #include #include -#include -#include + +namespace viennals { + +using namespace viennacore; /// Enumeration for the different types of /// transformation operations -enum struct lsTransformEnum : unsigned { +enum struct TransformEnum : unsigned { TRANSLATION = 0, ROTATION = 1, SCALE = 2 }; -template class lsTransformMesh { - lsSmartPointer> mesh = nullptr; - lsTransformEnum transform = lsTransformEnum::TRANSLATION; +template class TransformMesh { + SmartPointer> mesh = nullptr; + TransformEnum transform = TransformEnum::TRANSLATION; hrleVectorType transformVector{}; double angle = 0.0; double numericEps = 1e-6; @@ -79,8 +80,8 @@ template class lsTransformMesh { void scaleMesh() { if (!isValidVector()) { - lsMessage::getInstance() - .addWarning("lsTransformMesh: TransformVector is not valid!") + Logger::getInstance() + .addWarning("TransformMesh: TransformVector is not valid!") .print(); return; } @@ -92,46 +93,44 @@ template class lsTransformMesh { } public: - lsTransformMesh( - lsSmartPointer> passedMesh, - lsTransformEnum passedTransform = lsTransformEnum::TRANSLATION, - std::array passedTransformVector = {}, - double passedAngle = 0.0) + TransformMesh(SmartPointer> passedMesh, + TransformEnum passedTransform = TransformEnum::TRANSLATION, + std::array passedTransformVector = {}, + double passedAngle = 0.0) : mesh(passedMesh), transform(passedTransform), transformVector(passedTransformVector), angle(passedAngle) {} - lsTransformMesh( - lsSmartPointer> passedMesh, - lsTransformEnum passedTransform = lsTransformEnum::TRANSLATION, - hrleVectorType passedTransformVector = {}, - double passedAngle = 0.0) + TransformMesh(SmartPointer> passedMesh, + TransformEnum passedTransform = TransformEnum::TRANSLATION, + hrleVectorType passedTransformVector = {}, + double passedAngle = 0.0) : mesh(passedMesh), transform(passedTransform), transformVector(passedTransformVector), angle(passedAngle) {} void apply() { if (mesh == nullptr) { - lsMessage::getInstance() - .addWarning("No mesh passed to lsTransformMesh. Not transforming!") + Logger::getInstance() + .addWarning("No mesh passed to TransformMesh. Not transforming!") .print(); } switch (transform) { - case lsTransformEnum::TRANSLATION: + case TransformEnum::TRANSLATION: translateMesh(); break; - case lsTransformEnum::ROTATION: + case TransformEnum::ROTATION: rotateMesh(); break; - case lsTransformEnum::SCALE: + case TransformEnum::SCALE: scaleMesh(); break; default: - lsMessage::getInstance() + Logger::getInstance() .addWarning( - "Invalid tranform passed to lsTransformMesh. Not transforming!") + "Invalid transform passed to TransformMesh. Not transforming!") .print(); } } }; -#endif // LS_TRANSFORM_MESH_HPP \ No newline at end of file +} // namespace viennals diff --git a/include/viennals/lsVTKReader.hpp b/include/viennals/lsVTKReader.hpp index 2cdc4555..eb6bf4a7 100644 --- a/include/viennals/lsVTKReader.hpp +++ b/include/viennals/lsVTKReader.hpp @@ -1,12 +1,13 @@ -#ifndef LS_VTK_READER_HPP -#define LS_VTK_READER_HPP +#pragma once #include #include #include #include -#include + +#include +#include #ifdef VIENNALS_USE_VTK #include @@ -19,34 +20,36 @@ #include #endif // VIENNALS_USE_VTK +namespace viennals { + +using namespace viennacore; + /// Class handling the import of VTK file types. -template class lsVTKReader { - lsSmartPointer> mesh = nullptr; - lsFileFormatEnum fileFormat = lsFileFormatEnum::VTK_AUTO; +template class VTKReader { + SmartPointer> mesh = nullptr; + FileFormatEnum fileFormat = FileFormatEnum::VTK_AUTO; std::string fileName; unsigned vtk_nodes_for_cell_type[15] = {0, 1, 0, 2, 0, 3, 0, 0, 4, 4, 4, 8, 8, 6, 5}; public: - lsVTKReader() {} + VTKReader() {} - lsVTKReader(lsSmartPointer> passedMesh) : mesh(passedMesh) {} + VTKReader(SmartPointer> passedMesh) : mesh(passedMesh) {} - lsVTKReader(lsSmartPointer> passedMesh, std::string passedFileName) + VTKReader(SmartPointer> passedMesh, std::string passedFileName) : mesh(passedMesh), fileName(passedFileName) {} - lsVTKReader(lsSmartPointer> passedMesh, - lsFileFormatEnum passedFormat, std::string passedFileName) + VTKReader(SmartPointer> passedMesh, FileFormatEnum passedFormat, + std::string passedFileName) : mesh(passedMesh), fileFormat(passedFormat), fileName(passedFileName) {} /// set the mesh the file should be read into - void setMesh(lsSmartPointer> passedMesh) { mesh = passedMesh; } + void setMesh(SmartPointer> passedMesh) { mesh = passedMesh; } /// set file format for file to read. Defaults to VTK_LEGACY. - void setFileFormat(lsFileFormatEnum passedFormat) { - fileFormat = passedFormat; - } + void setFileFormat(FileFormatEnum passedFormat) { fileFormat = passedFormat; } /// set file name for file to read void setFileName(std::string passedFileName) { fileName = passedFileName; } @@ -54,39 +57,39 @@ template class lsVTKReader { void apply() { // check mesh if (mesh == nullptr) { - lsMessage::getInstance() - .addWarning("No mesh was passed to lsVTKReader. Not reading.") + Logger::getInstance() + .addWarning("No mesh was passed to VTKReader. Not reading.") .print(); return; } // check filename if (fileName.empty()) { - lsMessage::getInstance() - .addWarning("No file name specified for lsVTKReader. Not reading.") + Logger::getInstance() + .addWarning("No file name specified for VTKReader. Not reading.") .print(); return; } - if (fileFormat == lsFileFormatEnum::VTK_AUTO) { + if (fileFormat == FileFormatEnum::VTK_AUTO) { auto dotPos = fileName.rfind('.'); if (dotPos == std::string::npos) { - lsMessage::getInstance() + Logger::getInstance() .addWarning("No valid file format found based on the file ending " - "passed to lsVTKReader. Not reading.") + "passed to VTKReader. Not reading.") .print(); return; } auto ending = fileName.substr(dotPos); if (ending == ".vtk") { - fileFormat = lsFileFormatEnum::VTK_LEGACY; + fileFormat = FileFormatEnum::VTK_LEGACY; } else if (ending == ".vtp") { - fileFormat = lsFileFormatEnum::VTP; + fileFormat = FileFormatEnum::VTP; } else if (ending == ".vtu") { - fileFormat = lsFileFormatEnum::VTU; + fileFormat = FileFormatEnum::VTU; } else { - lsMessage::getInstance() + Logger::getInstance() .addWarning("No valid file format found based on the file ending " - "passed to lsVTKReader. Not reading.") + "passed to VTKReader. Not reading.") .print(); return; } @@ -94,28 +97,28 @@ template class lsVTKReader { // check file format switch (fileFormat) { - case lsFileFormatEnum::VTK_LEGACY: + case FileFormatEnum::VTK_LEGACY: readVTKLegacy(fileName); break; #ifdef VIENNALS_USE_VTK - case lsFileFormatEnum::VTP: + case FileFormatEnum::VTP: readVTP(fileName); break; - case lsFileFormatEnum::VTU: + case FileFormatEnum::VTU: readVTU(fileName); break; #else - case lsFileFormatEnum::VTP: - case lsFileFormatEnum::VTU: - lsMessage::getInstance() + case FileFormatEnum::VTP: + case FileFormatEnum::VTU: + Logger::getInstance() .addWarning( - "lsVTKReader was built without VTK support. Only VTK_LEGACY " + "VTKReader was built without VTK support. Only VTK_LEGACY " "can be used. File not read.") .print(); #endif default: - lsMessage::getInstance() - .addWarning("No valid file format set for lsVTKReader. Not reading.") + Logger::getInstance() + .addWarning("No valid file format set for VTKReader. Not reading.") .print(); } } @@ -124,8 +127,8 @@ template class lsVTKReader { #ifdef VIENNALS_USE_VTK void readVTP(std::string filename) { if (mesh == nullptr) { - lsMessage::getInstance() - .addWarning("No mesh was passed to lsVTKReader.") + Logger::getInstance() + .addWarning("No mesh was passed to VTKReader.") .print(); return; } @@ -202,7 +205,7 @@ template class lsVTKReader { dataArray = pointData->GetArray(i); if (dataArray->GetNumberOfComponents() == 1) { mesh->pointData.insertNextScalarData( - typename lsPointData::ScalarDataType(), + typename PointData::ScalarDataType(), std::string(pointData->GetArrayName(i))); auto &scalars = *(mesh->pointData.getScalarData(i)); scalars.resize(pointData->GetNumberOfTuples()); @@ -211,7 +214,7 @@ template class lsVTKReader { } } else if (dataArray->GetNumberOfComponents() == 3) { mesh->pointData.insertNextVectorData( - typename lsPointData::VectorDataType(), + typename PointData::VectorDataType(), std::string(pointData->GetArrayName(i))); auto &vectors = *(mesh->pointData.getVectorData(i)); vectors.resize(pointData->GetNumberOfTuples()); @@ -233,7 +236,7 @@ template class lsVTKReader { dataArray = cellData->GetArray(i); if (cellData->GetNumberOfComponents() == 1) { mesh->cellData.insertNextScalarData( - typename lsPointData::ScalarDataType(), + typename PointData::ScalarDataType(), std::string(cellData->GetArrayName(i))); auto &scalars = *(mesh->cellData.getScalarData(i)); scalars.resize(cellData->GetNumberOfTuples()); @@ -242,7 +245,7 @@ template class lsVTKReader { } } else if (cellData->GetNumberOfComponents() == 3) { mesh->cellData.insertNextVectorData( - typename lsPointData::VectorDataType(), + typename PointData::VectorDataType(), std::string(cellData->GetArrayName(i))); auto &vectors = *(mesh->cellData.getVectorData(i)); vectors.resize(cellData->GetNumberOfTuples()); @@ -257,8 +260,8 @@ template class lsVTKReader { void readVTU(std::string filename) { if (mesh == nullptr) { - lsMessage::getInstance() - .addWarning("No mesh was passed to lsVTKReader.") + Logger::getInstance() + .addWarning("No mesh was passed to VTKReader.") .print(); return; } @@ -340,7 +343,7 @@ template class lsVTKReader { dataArray = pointData->GetArray(i); if (dataArray->GetNumberOfComponents() == 1) { mesh->pointData.insertNextScalarData( - typename lsPointData::ScalarDataType(), + typename PointData::ScalarDataType(), std::string(pointData->GetArrayName(i))); auto &scalars = *(mesh->pointData.getScalarData(i)); scalars.resize(pointData->GetNumberOfTuples()); @@ -349,7 +352,7 @@ template class lsVTKReader { } } else if (dataArray->GetNumberOfComponents() == 3) { mesh->pointData.insertNextVectorData( - typename lsPointData::VectorDataType(), + typename PointData::VectorDataType(), std::string(pointData->GetArrayName(i))); auto &vectors = *(mesh->pointData.getVectorData(i)); vectors.resize(pointData->GetNumberOfTuples()); @@ -371,7 +374,7 @@ template class lsVTKReader { dataArray = cellData->GetArray(i); if (cellData->GetNumberOfComponents() == 1) { mesh->cellData.insertNextScalarData( - typename lsPointData::ScalarDataType(), + typename PointData::ScalarDataType(), std::string(cellData->GetArrayName(i))); auto &scalars = *(mesh->cellData.getScalarData(i)); scalars.resize(cellData->GetNumberOfTuples()); @@ -380,7 +383,7 @@ template class lsVTKReader { } } else if (cellData->GetNumberOfComponents() == 3) { mesh->cellData.insertNextVectorData( - typename lsPointData::VectorDataType(), + typename PointData::VectorDataType(), std::string(cellData->GetArrayName(i))); auto &vectors = *(mesh->cellData.getVectorData(i)); vectors.resize(cellData->GetNumberOfTuples()); @@ -397,8 +400,8 @@ template class lsVTKReader { void readVTKLegacy(std::string filename) { if (mesh == nullptr) { - lsMessage::getInstance() - .addWarning("No mesh was passed to lsVTKReader.") + Logger::getInstance() + .addWarning("No mesh was passed to VTKReader.") .print(); return; } @@ -407,7 +410,7 @@ template class lsVTKReader { // open geometry file std::ifstream f(filename.c_str()); if (!f) - lsMessage::getInstance().addError("Could not open geometry file!"); + Logger::getInstance().addError("Could not open geometry file!"); std::string temp; // Check if geometry is an unstructured grid as required @@ -416,7 +419,7 @@ template class lsVTKReader { break; } if (temp.find("UNSTRUCTURED_GRID") == std::string::npos) { - lsMessage::getInstance().addError("DATASET is not an UNSTRUCTURED_GRID!"); + Logger::getInstance().addError("DATASET is not an UNSTRUCTURED_GRID!"); } // Find POINTS in file to know number of nodes to read in @@ -465,7 +468,7 @@ template class lsVTKReader { int num_cell_types = atoi(&temp[temp.find(" ") + 1]); // need a cell_type for each cell if (num_elems != num_cell_types) { - lsMessage::getInstance().addError( + Logger::getInstance().addError( "Corrupt input geometry! Number of CELLS and CELL_TYPES " "is different!"); } @@ -567,14 +570,14 @@ template class lsVTKReader { std::ostringstream oss; oss << "VTK Cell type " << cell_type << " is not supported. Cell ignored..." << std::endl; - lsMessage::getInstance().addWarning(oss.str()).print(); + Logger::getInstance().addWarning(oss.str()).print(); } } else { std::ostringstream oss; oss << "INVALID CELL TYPE! Expected number of nodes: " << number_nodes << ", Found number of nodes: " << elems_fake << "; Ignoring element..."; - lsMessage::getInstance().addError(oss.str()); + Logger::getInstance().addError(oss.str()); // ignore rest of lines f.ignore(std::numeric_limits::max(), '\n'); } @@ -613,7 +616,7 @@ template class lsVTKReader { // consume one line, which defines the lookup table std::getline(f, temp); if (temp.compare("LOOKUP_TABLE default") != 0) { - lsMessage::getInstance() + Logger::getInstance() .addWarning("Wrong lookup table for VTKLegacy: " + temp) .print(); } @@ -634,4 +637,4 @@ template class lsVTKReader { } }; -#endif // LS_VTK_READER_HPP +} // namespace viennals diff --git a/include/viennals/lsVTKWriter.hpp b/include/viennals/lsVTKWriter.hpp index ccf13773..3b197f45 100644 --- a/include/viennals/lsVTKWriter.hpp +++ b/include/viennals/lsVTKWriter.hpp @@ -1,13 +1,13 @@ -#ifndef LS_VTK_WRITER_HPP -#define LS_VTK_WRITER_HPP +#pragma once #include #include #include #include -#include -#include + +#include +#include #ifdef VIENNALS_USE_VTK #include @@ -23,10 +23,14 @@ #include #endif // VIENNALS_USE_VTK -/// Class handling the output of an lsMesh<> to VTK file types. -template class lsVTKWriter { - lsSmartPointer> mesh = nullptr; - lsFileFormatEnum fileFormat = lsFileFormatEnum::VTK_AUTO; +namespace viennals { + +using namespace viennacore; + +/// Class handling the output of an Mesh<> to VTK file types. +template class VTKWriter { + SmartPointer> mesh = nullptr; + FileFormatEnum fileFormat = FileFormatEnum::VTK_AUTO; std::string fileName; #ifdef VIENNALS_USE_VTK @@ -62,23 +66,21 @@ template class lsVTKWriter { #endif // VIENNALS_USE_VTK public: - lsVTKWriter() {} + VTKWriter() {} - lsVTKWriter(lsSmartPointer> passedMesh) : mesh(passedMesh) {} + VTKWriter(SmartPointer> passedMesh) : mesh(passedMesh) {} - lsVTKWriter(lsSmartPointer> passedMesh, std::string passedFileName) + VTKWriter(SmartPointer> passedMesh, std::string passedFileName) : mesh(passedMesh), fileName(passedFileName) {} - lsVTKWriter(lsSmartPointer> passedMesh, - lsFileFormatEnum passedFormat, std::string passedFileName) + VTKWriter(SmartPointer> passedMesh, FileFormatEnum passedFormat, + std::string passedFileName) : mesh(passedMesh), fileFormat(passedFormat), fileName(passedFileName) {} - void setMesh(lsSmartPointer> passedMesh) { mesh = passedMesh; } + void setMesh(SmartPointer> passedMesh) { mesh = passedMesh; } /// set file format for file to write. Defaults to VTK_LEGACY. - void setFileFormat(lsFileFormatEnum passedFormat) { - fileFormat = passedFormat; - } + void setFileFormat(FileFormatEnum passedFormat) { fileFormat = passedFormat; } /// set file name for file to write void setFileName(std::string passedFileName) { fileName = passedFileName; } @@ -86,35 +88,35 @@ template class lsVTKWriter { void apply() { // check mesh if (mesh == nullptr) { - lsMessage::getInstance() - .addWarning("No mesh was passed to lsVTKWriter. Not writing.") + Logger::getInstance() + .addWarning("No mesh was passed to VTKWriter. Not writing.") .print(); return; } // check filename if (fileName.empty()) { - lsMessage::getInstance() - .addWarning("No file name specified for lsVTKWriter. Not writing.") + Logger::getInstance() + .addWarning("No file name specified for VTKWriter. Not writing.") .print(); return; } - if (fileFormat == lsFileFormatEnum::VTK_AUTO) { + if (fileFormat == FileFormatEnum::VTK_AUTO) { auto dotPos = fileName.rfind('.'); if (dotPos == std::string::npos) { - fileFormat = lsFileFormatEnum::VTP; + fileFormat = FileFormatEnum::VTP; } else { auto ending = fileName.substr(dotPos); if (ending == ".vtk") { - fileFormat = lsFileFormatEnum::VTK_LEGACY; + fileFormat = FileFormatEnum::VTK_LEGACY; } else if (ending == ".vtp") { - fileFormat = lsFileFormatEnum::VTP; + fileFormat = FileFormatEnum::VTP; } else if (ending == ".vtu") { - fileFormat = lsFileFormatEnum::VTU; + fileFormat = FileFormatEnum::VTU; } else { - lsMessage::getInstance() + Logger::getInstance() .addWarning("No valid file format found based on the file ending " - "passed to lsVTKWriter. Not writing.") + "passed to VTKWriter. Not writing.") .print(); return; } @@ -123,29 +125,29 @@ template class lsVTKWriter { // check file format switch (fileFormat) { - case lsFileFormatEnum::VTK_LEGACY: + case FileFormatEnum::VTK_LEGACY: writeVTKLegacy(fileName); break; #ifdef VIENNALS_USE_VTK - case lsFileFormatEnum::VTP: + case FileFormatEnum::VTP: writeVTP(fileName); break; - case lsFileFormatEnum::VTU: + case FileFormatEnum::VTU: writeVTU(fileName); break; #else - case lsFileFormatEnum::VTP: - case lsFileFormatEnum::VTU: - lsMessage::getInstance() - .addWarning("lsVTKWriter was built without VTK support. Falling back " + case FileFormatEnum::VTP: + case FileFormatEnum::VTU: + Logger::getInstance() + .addWarning("VTKWriter was built without VTK support. Falling back " "to VTK_LEGACY.") .print(); writeVTKLegacy(fileName); break; #endif default: - lsMessage::getInstance() - .addWarning("No valid file format set for lsVTKWriter. Not writing.") + Logger::getInstance() + .addWarning("No valid file format set for VTKWriter. Not writing.") .print(); } } @@ -154,8 +156,8 @@ template class lsVTKWriter { #ifdef VIENNALS_USE_VTK void writeVTP(std::string filename) const { if (mesh == nullptr) { - lsMessage::getInstance() - .addWarning("No mesh was passed to lsVTKWriter.") + Logger::getInstance() + .addWarning("No mesh was passed to VTKWriter.") .print(); return; } @@ -222,8 +224,8 @@ template class lsVTKWriter { void writeVTU(std::string filename) const { if (mesh == nullptr) { - lsMessage::getInstance() - .addWarning("No mesh was passed to lsVTKWriter.") + Logger::getInstance() + .addWarning("No mesh was passed to VTKWriter.") .print(); return; } @@ -347,8 +349,8 @@ template class lsVTKWriter { void writeVTKLegacy(std::string filename) { if (mesh == nullptr) { - lsMessage::getInstance() - .addWarning("No mesh was passed to lsVTKWriter.") + Logger::getInstance() + .addWarning("No mesh was passed to VTKWriter.") .print(); return; } @@ -429,7 +431,7 @@ template class lsVTKWriter { // WRITE POINT DATA if (mesh->pointData.getScalarDataSize() || mesh->pointData.getVectorDataSize()) { - lsMessage::getInstance() + Logger::getInstance() .addWarning("Point data output not supported for legacy VTK output. " "Point data is ignored.") .print(); @@ -471,4 +473,4 @@ template class lsVTKWriter { } }; -#endif // LS_VTK_WRITER_HPP +} // namespace viennals diff --git a/include/viennals/lsVelocityField.hpp b/include/viennals/lsVelocityField.hpp index 5b372990..0e37f4ef 100644 --- a/include/viennals/lsVelocityField.hpp +++ b/include/viennals/lsVelocityField.hpp @@ -1,42 +1,46 @@ -#ifndef LS_VELOCITY_FIELD_HPP -#define LS_VELOCITY_FIELD_HPP +#pragma once #include +#include + +namespace viennals { + +using namespace viennacore; + /// Abstract class defining the interface for /// the velocity field used during advection using lsAdvect. -template class lsVelocityField { +template class VelocityField { public: - lsVelocityField() {} + VelocityField() {} /// Should return a scalar value for the velocity at coordinate /// for a point of material with the given normalVector. - virtual T getScalarVelocity(const std::array & /*coordinate*/, + virtual T getScalarVelocity(const Triple & /*coordinate*/, int /*material*/, - const std::array & /*normalVector*/, + const Triple & /*normalVector*/, unsigned long /*pointId*/) { return 0; } /// Like getScalarVelocity, but returns a velocity value for each /// cartesian direction. - virtual std::array - getVectorVelocity(const std::array & /*coordinate*/, int /*material*/, - const std::array & /*normalVector*/, - unsigned long /*pointId*/) { + virtual Triple getVectorVelocity(const Triple & /*coordinate*/, + int /*material*/, + const Triple & /*normalVector*/, + unsigned long /*pointId*/) { return {0, 0, 0}; } /// If lsLocalLaxFriedrichsAnalytical is used as the advection scheme, /// this is called to provide the analytical solution for the alpha /// values, needed for stable integration. - virtual T - getDissipationAlpha(int /*direction*/, int /*material*/, - const std::array & /*centralDifferences*/) { + virtual T getDissipationAlpha(int /*direction*/, int /*material*/, + const Triple & /*centralDifferences*/) { return 0; } - virtual ~lsVelocityField() {} + virtual ~VelocityField() {} }; -#endif // LS_VELOCITY_FIELD_HPP +} // namespace viennals diff --git a/include/viennals/lsWriteVisualizationMesh.hpp b/include/viennals/lsWriteVisualizationMesh.hpp index 8990009a..3b06bfaf 100644 --- a/include/viennals/lsWriteVisualizationMesh.hpp +++ b/include/viennals/lsWriteVisualizationMesh.hpp @@ -1,7 +1,6 @@ -#ifdef VIENNALS_USE_VTK // this class needs vtk support +#pragma once -#ifndef LS_TO_VISUALIZATION_MESH_HPP -#define LS_TO_VISUALIZATION_MESH_HPP +#ifdef VIENNALS_USE_VTK // this class needs vtk support #include #include @@ -25,7 +24,6 @@ #include #include -#include #include // #define LS_TO_VISUALIZATION_DEBUG @@ -33,17 +31,21 @@ #include #endif +namespace viennals { + +using namespace viennacore; + /// This algorithm is used to extract tetrahedral volume meshes and triangle /// hull meshes with material numbers sorted by order of input of level sets. It /// should ONLY BE USED FOR VISUALIZATION because the algorithm does not /// guarantee manifold meshes, which should not be a problem for visualization. /// In order to obtain a hull triangle mesh from the outline of each material, /// use setExtractHull(true). -template class lsWriteVisualizationMesh { - typedef typename lsDomain::DomainType hrleDomainType; - using LevelSetsType = std::vector>>; +template class WriteVisualizationMesh { + typedef typename Domain::DomainType hrleDomainType; + using LevelSetsType = std::vector>>; LevelSetsType levelSets; - lsSmartPointer materialMap = nullptr; + SmartPointer materialMap = nullptr; std::string fileName; bool extractVolumeMesh = true; bool extractHullMesh = false; @@ -224,7 +226,7 @@ template class lsWriteVisualizationMesh { // boundary conditions template vtkSmartPointer - LS2RectiLinearGrid(lsSmartPointer> levelSet, + LS2RectiLinearGrid(SmartPointer> levelSet, const double LSOffset = 0., int infiniteMinimum = std::numeric_limits::max(), int infiniteMaximum = -std::numeric_limits::max()) { @@ -244,7 +246,7 @@ template class lsWriteVisualizationMesh { coords[i] = vtkSmartPointer::New(); if (grid.getBoundaryConditions(i) == - lsDomain::BoundaryType::INFINITE_BOUNDARY) { + Domain::BoundaryType::INFINITE_BOUNDARY) { // add one to gridMin and gridMax for numerical stability gridMin = std::min(domain.getMinRunBreak(i), infiniteMinimum) - 1; // choose the smaller number so that for first levelset the @@ -286,7 +288,7 @@ template class lsWriteVisualizationMesh { // typename levelSetType::const_iterator_runs it_l(levelSet); // use dense iterator to got to every index location - hrleConstDenseIterator::DomainType> it( + hrleConstDenseIterator::DomainType> it( levelSet->getDomain()); // need to save the current position one dimension above open boundary @@ -320,9 +322,9 @@ template class lsWriteVisualizationMesh { signedDistances->GetDataTypeValueMax()); } else { // if inside domain just write the correct value - if (it.getValue() == lsDomain::POS_VALUE || it.isFinished()) { + if (it.getValue() == Domain::POS_VALUE || it.isFinished()) { value = numLayers; - } else if (it.getValue() == lsDomain::NEG_VALUE) { + } else if (it.getValue() == Domain::NEG_VALUE) { value = -numLayers; } else { value = it.getValue() + LSOffset; @@ -412,14 +414,14 @@ template class lsWriteVisualizationMesh { } public: - lsWriteVisualizationMesh() {} + WriteVisualizationMesh() {} - lsWriteVisualizationMesh(lsSmartPointer> levelSet) { + WriteVisualizationMesh(SmartPointer> levelSet) { levelSets.push_back(levelSet); } /// Level sets wrapping other level sets have to be inserted last. - void insertNextLevelSet(lsSmartPointer> levelSet) { + void insertNextLevelSet(SmartPointer> levelSet) { levelSets.push_back(levelSet); } @@ -437,7 +439,7 @@ template class lsWriteVisualizationMesh { extractVolumeMesh = passedExtractVolumeMesh; } - void setMaterialMap(lsSmartPointer passedMaterialMap) { + void setMaterialMap(SmartPointer passedMaterialMap) { materialMap = passedMaterialMap; } @@ -445,9 +447,9 @@ template class lsWriteVisualizationMesh { // check if level sets have enough layers for (unsigned i = 0; i < levelSets.size(); ++i) { if (levelSets[i]->getLevelSetWidth() < 2) { - lsMessage::getInstance() + Logger::getInstance() .addWarning( - "lsWriteVisualizationMesh: Level Set " + std::to_string(i) + + "WriteVisualizationMesh: Level Set " + std::to_string(i) + " should have a width greater than 1! Conversion might fail!") .print(); } @@ -469,7 +471,7 @@ template class lsWriteVisualizationMesh { auto &domain = it->getDomain(); for (unsigned i = 0; i < D; ++i) { if (grid.getBoundaryConditions(i) == - lsDomain::BoundaryType::INFINITE_BOUNDARY) { + Domain::BoundaryType::INFINITE_BOUNDARY) { totalMinimum = std::min(totalMinimum, domain.getMinRunBreak(i)); totalMaximum = std::max(totalMaximum, domain.getMaxRunBreak(i)); } @@ -720,7 +722,8 @@ template class lsWriteVisualizationMesh { }; // add all template specialisations for this class -PRECOMPILE_PRECISION_DIMENSION(lsWriteVisualizationMesh) +PRECOMPILE_PRECISION_DIMENSION(WriteVisualizationMesh) + +} // namespace viennals -#endif // LS_TO_VISUALIZATION_MESH_HPP #endif // VIENNALS_USE_VTK \ No newline at end of file diff --git a/include/viennals/lsWriter.hpp b/include/viennals/lsWriter.hpp index 052df8c6..db7ba0b9 100644 --- a/include/viennals/lsWriter.hpp +++ b/include/viennals/lsWriter.hpp @@ -1,26 +1,28 @@ -#ifndef LS_WRITER_HPP -#define LS_WRITER_HPP +#pragma once #include #include #include -template class lsWriter { - lsSmartPointer> levelSet = nullptr; +namespace viennals { + +using namespace viennacore; + +template class Writer { + SmartPointer> levelSet = nullptr; std::string fileName; public: - lsWriter() {} + Writer() {} - lsWriter(lsSmartPointer> passedLevelSet) + Writer(SmartPointer> passedLevelSet) : levelSet(passedLevelSet) {} - lsWriter(lsSmartPointer> passedLevelSet, - std::string passedFileName) + Writer(SmartPointer> passedLevelSet, std::string passedFileName) : levelSet(passedLevelSet), fileName(passedFileName) {} - void setLevelSet(lsSmartPointer> passedLevelSet) { + void setLevelSet(SmartPointer> passedLevelSet) { levelSet = passedLevelSet; } @@ -30,21 +32,21 @@ template class lsWriter { void apply() { // check mesh if (levelSet == nullptr) { - lsMessage::getInstance() - .addWarning("No mesh was passed to lsWriter. Not writing.") + Logger::getInstance() + .addWarning("No mesh was passed to Writer. Not writing.") .print(); return; } // check filename if (fileName.empty()) { - lsMessage::getInstance() - .addWarning("No file name specified for lsWriter. Not writing.") + Logger::getInstance() + .addWarning("No file name specified for Writer. Not writing.") .print(); return; } if (fileName.find(".lvst") != fileName.length() - 5) { - lsMessage::getInstance() + Logger::getInstance() .addWarning("File name does not end in '.lvst', appending it.") .print(); fileName.append(".lvst"); @@ -60,6 +62,6 @@ template class lsWriter { }; // add all template specialisations for this class -PRECOMPILE_PRECISION_DIMENSION(lsWriter) +PRECOMPILE_PRECISION_DIMENSION(Writer) -#endif // LS_WRITER_HPP +} // namespace viennals diff --git a/python/pyWrap.cpp b/python/pyWrap.cpp index 6f9adaac..7253dffa 100644 --- a/python/pyWrap.cpp +++ b/python/pyWrap.cpp @@ -43,22 +43,26 @@ #include #include #include -#include #include #include #include #include #include #include +#include #include #include +#include + +using namespace viennals; + // always use double for python export typedef double T; // get dimension from cmake define constexpr int D = VIENNALS_PYTHON_DIMENSION; -PYBIND11_DECLARE_HOLDER_TYPE(TemplateType, lsSmartPointer); +PYBIND11_DECLARE_HOLDER_TYPE(TemplateType, SmartPointer); // define trampoline classes for interface functions // ALSO NEED TO ADD TRAMPOLINE CLASSES FOR CLASSES @@ -66,33 +70,33 @@ PYBIND11_DECLARE_HOLDER_TYPE(TemplateType, lsSmartPointer); // BASE CLASS WRAPPERS // lsVelocityField only defines interface and has no functionality -class PylsVelocityField : public lsVelocityField { +class PylsVelocityField : public VelocityField { typedef std::array vectorType; - using lsVelocityField::lsVelocityField; + using VelocityField::VelocityField; public: T getScalarVelocity(const vectorType &coordinate, int material, const vectorType &normalVector, unsigned long pointId) override { - PYBIND11_OVERLOAD(T, lsVelocityField, getScalarVelocity, coordinate, + PYBIND11_OVERLOAD(T, VelocityField, getScalarVelocity, coordinate, material, normalVector, pointId); } vectorType getVectorVelocity(const vectorType &coordinate, int material, const vectorType &normalVector, unsigned long pointId) override { - PYBIND11_OVERLOAD(vectorType, lsVelocityField, getVectorVelocity, + PYBIND11_OVERLOAD(vectorType, VelocityField, getVectorVelocity, coordinate, material, normalVector, pointId); } }; -// lsGeometricAdvectDistribution +// GeometricAdvectDistribution class PylsGeometricAdvectDistribution - : public lsGeometricAdvectDistribution { + : public GeometricAdvectDistribution { typedef std::array vectorType; typedef std::array boundsType; - typedef lsGeometricAdvectDistribution ClassType; - using lsGeometricAdvectDistribution::lsGeometricAdvectDistribution; + typedef GeometricAdvectDistribution ClassType; + using GeometricAdvectDistribution::GeometricAdvectDistribution; public: bool isInside(const vectorType &initial, const vectorType &candidate, @@ -116,15 +120,15 @@ class PylsGeometricAdvectDistribution // maybe needed wrapper code once we move to smart pointers // https://github.com/pybind/pybind11/issues/1389 // // lsAdvect wrapping since it holds lsVelocityField references -// class PylsAdvect : public lsAdvect { +// class PylsAdvect : public Advect { // pybind11::object pyObj; // public: -// PylsAdvect(lsDomain &passedDomain, lsVelocityField -// &passedVelocities) : lsAdvect(passedDomain, passedVelocities), +// PylsAdvect(Domain &passedDomain, VelocityField +// &passedVelocities) : Advect(passedDomain, passedVelocities), // pyObj(pybind11::cast(passedVelocities)) {} // -// PylsAdvect(lsVelocityField &passedVelocities) : -// lsAdvect(passedVelocities), pyObj(pybind11::cast(passedVelocities)) {} +// PylsAdvect(VelocityField &passedVelocities) : +// Advect(passedVelocities), pyObj(pybind11::cast(passedVelocities)) {} // }; // module specification @@ -133,7 +137,7 @@ PYBIND11_MODULE(VIENNALS_MODULE_NAME, module) { "ViennaLS is a header-only C++ level set library developed for high " "performance topography simulations. The main design goals are " "simplicity and efficiency, tailored towards scientific simulations. " - "ViennaLS can also be used for visualisation applications, although this " + "ViennaLS can also be used for visualization applications, although this " "is not the main design target."; // set version string of python module @@ -142,263 +146,254 @@ PYBIND11_MODULE(VIENNALS_MODULE_NAME, module) { // wrap omp_set_num_threads to control number of threads module.def("setNumThreads", &omp_set_num_threads); - // lsAdvect - pybind11::class_, lsSmartPointer>>(module, - "lsAdvect") + // Advect + pybind11::class_, SmartPointer>>(module, "Advect") // constructors - .def(pybind11::init(&lsSmartPointer>::New<>)) - .def(pybind11::init(&lsSmartPointer>::New< - lsSmartPointer> &>)) - .def(pybind11::init(&lsSmartPointer>::New< - lsSmartPointer> &>)) - .def(pybind11::init(&lsSmartPointer>::New< - lsSmartPointer> &, - lsSmartPointer> &>)) + .def(pybind11::init(&SmartPointer>::New<>)) + .def(pybind11::init( + &SmartPointer>::New> &>)) + .def(pybind11::init( + &SmartPointer>::New> &, + SmartPointer> &>)) // getters and setters - .def("insertNextLevelSet", &lsAdvect::insertNextLevelSet, + .def("insertNextLevelSet", &Advect::insertNextLevelSet, "Insert next level set to use for advection.") - .def("setVelocityField", - &lsAdvect::setVelocityField, + .def("setVelocityField", &Advect::setVelocityField, "Set the velocity to use for advection.") - .def("setAdvectionTime", &lsAdvect::setAdvectionTime, + .def("setAdvectionTime", &Advect::setAdvectionTime, "Set the time until when the level set should be advected.") - .def("setTimeStepRatio", &lsAdvect::setTimeStepRatio, + .def("setTimeStepRatio", &Advect::setTimeStepRatio, "Set the maximum time step size relative to grid size. Advection is " "only stable for <0.5.") .def("setCalculateNormalVectors", - &lsAdvect::setCalculateNormalVectors, + &Advect::setCalculateNormalVectors, "Set whether normal vectors are needed for the supplied velocity " "field.") - .def("setIgnoreVoids", &lsAdvect::setIgnoreVoids, + .def("setIgnoreVoids", &Advect::setIgnoreVoids, "Set whether voids in the geometry should be ignored during " "advection or not.") - .def("getAdvectedTime", &lsAdvect::getAdvectedTime, + .def("getAdvectedTime", &Advect::getAdvectedTime, "Get the time passed during advection.") - .def("getNumberOfTimeSteps", &lsAdvect::getNumberOfTimeSteps, + .def("getNumberOfTimeSteps", &Advect::getNumberOfTimeSteps, "Get how many advection steps were performed after the last apply() " "call.") - .def("getTimeStepRatio", &lsAdvect::getTimeStepRatio, + .def("getTimeStepRatio", &Advect::getTimeStepRatio, "Get the time step ratio used for advection.") .def("getCalculateNormalVectors", - &lsAdvect::getCalculateNormalVectors, + &Advect::getCalculateNormalVectors, "Get whether normal vectors are computed during advection.") - .def("setIntegrationScheme", &lsAdvect::setIntegrationScheme, + .def("setIntegrationScheme", &Advect::setIntegrationScheme, "Set the integration scheme to use during advection.") - .def("setDissipationAlpha", &lsAdvect::setDissipationAlpha, + .def("setDissipationAlpha", &Advect::setDissipationAlpha, "Set the dissipation value to use for Lax Friedrichs integration.") // need scoped release since we are calling a python method from // parallelised C++ code here - .def("apply", &lsAdvect::apply, + .def("apply", &Advect::apply, pybind11::call_guard(), "Perform advection."); // enums - pybind11::enum_(module, "lsIntegrationSchemeEnum") + pybind11::enum_(module, "IntegrationSchemeEnum") .value("ENGQUIST_OSHER_1ST_ORDER", - lsIntegrationSchemeEnum::ENGQUIST_OSHER_1ST_ORDER) + IntegrationSchemeEnum::ENGQUIST_OSHER_1ST_ORDER) .value("ENGQUIST_OSHER_2ND_ORDER", - lsIntegrationSchemeEnum::ENGQUIST_OSHER_2ND_ORDER) + IntegrationSchemeEnum::ENGQUIST_OSHER_2ND_ORDER) .value("LAX_FRIEDRICHS_1ST_ORDER", - lsIntegrationSchemeEnum::LAX_FRIEDRICHS_1ST_ORDER) + IntegrationSchemeEnum::LAX_FRIEDRICHS_1ST_ORDER) .value("LAX_FRIEDRICHS_2ND_ORDER", - lsIntegrationSchemeEnum::LAX_FRIEDRICHS_2ND_ORDER) + IntegrationSchemeEnum::LAX_FRIEDRICHS_2ND_ORDER) .value("LOCAL_LAX_FRIEDRICHS_ANALYTICAL_1ST_ORDER", - lsIntegrationSchemeEnum::LOCAL_LAX_FRIEDRICHS_ANALYTICAL_1ST_ORDER) + IntegrationSchemeEnum::LOCAL_LAX_FRIEDRICHS_ANALYTICAL_1ST_ORDER) .value("LOCAL_LOCAL_LAX_FRIEDRICHS_1ST_ORDER", - lsIntegrationSchemeEnum::LOCAL_LOCAL_LAX_FRIEDRICHS_1ST_ORDER) + IntegrationSchemeEnum::LOCAL_LOCAL_LAX_FRIEDRICHS_1ST_ORDER) .value("LOCAL_LOCAL_LAX_FRIEDRICHS_2ND_ORDER", - lsIntegrationSchemeEnum::LOCAL_LOCAL_LAX_FRIEDRICHS_2ND_ORDER) + IntegrationSchemeEnum::LOCAL_LOCAL_LAX_FRIEDRICHS_2ND_ORDER) .value("LOCAL_LAX_FRIEDRICHS_1ST_ORDER", - lsIntegrationSchemeEnum::LOCAL_LAX_FRIEDRICHS_1ST_ORDER) + IntegrationSchemeEnum::LOCAL_LAX_FRIEDRICHS_1ST_ORDER) .value("LOCAL_LAX_FRIEDRICHS_2ND_ORDER", - lsIntegrationSchemeEnum::LOCAL_LAX_FRIEDRICHS_2ND_ORDER) + IntegrationSchemeEnum::LOCAL_LAX_FRIEDRICHS_2ND_ORDER) .value("STENCIL_LOCAL_LAX_FRIEDRICHS_1ST_ORDER", - lsIntegrationSchemeEnum::STENCIL_LOCAL_LAX_FRIEDRICHS_1ST_ORDER); + IntegrationSchemeEnum::STENCIL_LOCAL_LAX_FRIEDRICHS_1ST_ORDER); - // lsBooleanOperation - pybind11::class_, - lsSmartPointer>>( - module, "lsBooleanOperation") + // BooleanOperation + pybind11::class_, + SmartPointer>>(module, + "BooleanOperation") // constructors - .def(pybind11::init(&lsSmartPointer>::New<>)) - .def(pybind11::init(&lsSmartPointer>::New< - lsSmartPointer> &>)) - .def(pybind11::init(&lsSmartPointer>::New< - lsSmartPointer> &, - lsSmartPointer> &>)) + .def(pybind11::init(&SmartPointer>::New<>)) + .def(pybind11::init(&SmartPointer>::New< + SmartPointer> &>)) + .def(pybind11::init( + &SmartPointer>::New< + SmartPointer> &, SmartPointer> &>)) // some constructors need lambda to work: seems to be an issue with // implicit move constructor - .def(pybind11::init([](lsSmartPointer> &domain, - lsBooleanOperationEnum op) { - return lsSmartPointer>::New(domain, op); - })) - .def(pybind11::init([](lsSmartPointer> &domainA, - lsSmartPointer> &domainB, - lsBooleanOperationEnum op) { - return lsSmartPointer>::New(domainA, domainB, - op); + .def(pybind11::init( + [](SmartPointer> &domain, BooleanOperationEnum op) { + return SmartPointer>::New(domain, op); + })) + .def(pybind11::init([](SmartPointer> &domainA, + SmartPointer> &domainB, + BooleanOperationEnum op) { + return SmartPointer>::New(domainA, domainB, op); })) // methods - .def("setLevelset", &lsBooleanOperation::setLevelSet, + .def("setLevelset", &BooleanOperation::setLevelSet, "Set levelset on which the boolean operation should be performed.") - .def("setSecondLevelSet", &lsBooleanOperation::setSecondLevelSet, + .def("setSecondLevelSet", &BooleanOperation::setSecondLevelSet, "Set second levelset for boolean operation.") - .def("setBooleanOperation", - &lsBooleanOperation::setBooleanOperation, + .def("setBooleanOperation", &BooleanOperation::setBooleanOperation, "Set which type of boolean operation should be performed.") - .def("apply", &lsBooleanOperation::apply, + .def("apply", &BooleanOperation::apply, "Perform the boolean operation."); // enums - pybind11::enum_(module, "lsBooleanOperationEnum") - .value("INTERSECT", lsBooleanOperationEnum::INTERSECT) - .value("UNION", lsBooleanOperationEnum::UNION) - .value("RELATIVE_COMPLEMENT", lsBooleanOperationEnum::RELATIVE_COMPLEMENT) - .value("INVERT", lsBooleanOperationEnum::INVERT); + pybind11::enum_(module, "BooleanOperationEnum") + .value("INTERSECT", BooleanOperationEnum::INTERSECT) + .value("UNION", BooleanOperationEnum::UNION) + .value("RELATIVE_COMPLEMENT", BooleanOperationEnum::RELATIVE_COMPLEMENT) + .value("INVERT", BooleanOperationEnum::INVERT); - pybind11::class_, - lsSmartPointer>>( - module, "lsCalculateCurvatures") + pybind11::class_, + SmartPointer>>( + module, "CalculateCurvatures") // constructors - .def(pybind11::init(&lsSmartPointer>::New<>)) - .def(pybind11::init(&lsSmartPointer>::New< - lsSmartPointer> &>)) + .def(pybind11::init(&SmartPointer>::New<>)) + .def(pybind11::init(&SmartPointer>::New< + SmartPointer> &>)) // some constructors need lambda to work: seems to be an issue with // implicit move constructor - .def(pybind11::init([](lsSmartPointer> &domain, - lsCurvatureEnum type) { - return lsSmartPointer>::New(domain, type); - })) + .def(pybind11::init( + [](SmartPointer> &domain, CurvatureEnum type) { + return SmartPointer>::New(domain, type); + })) // methods - .def("setLevelSet", &lsCalculateCurvatures::setLevelSet, + .def("setLevelSet", &CalculateCurvatures::setLevelSet, "Set levelset for which to calculate the curvatures.") - .def("setCurvatureType", &lsCalculateCurvatures::setCurvatureType, + .def("setCurvatureType", &CalculateCurvatures::setCurvatureType, "Set which method to use for calculation: Defaults to mean " "curvature.") - .def("setMaxValue", &lsCalculateCurvatures::setMaxValue, + .def("setMaxValue", &CalculateCurvatures::setMaxValue, "Curvatures will be calculated for all LS values < maxValue.") - .def("apply", &lsCalculateCurvatures::apply, + .def("apply", &CalculateCurvatures::apply, "Perform normal vector calculation."); // enums - pybind11::enum_(module, "lsCurvatureEnum") - .value("MEAN_CURVATURE", lsCurvatureEnum::MEAN_CURVATURE) - .value("GAUSSIAN_CURVATURE", lsCurvatureEnum::GAUSSIAN_CURVATURE) + pybind11::enum_(module, "CurvatureEnum") + .value("MEAN_CURVATURE", CurvatureEnum::MEAN_CURVATURE) + .value("GAUSSIAN_CURVATURE", CurvatureEnum::GAUSSIAN_CURVATURE) .value("MEAN_AND_GAUSSIAN_CURVATURE", - lsCurvatureEnum::MEAN_AND_GAUSSIAN_CURVATURE); + CurvatureEnum::MEAN_AND_GAUSSIAN_CURVATURE); - // lsCalculateNormalVectors - pybind11::class_, - lsSmartPointer>>( - module, "lsCalculateNormalVectors") + // CalculateNormalVectors + pybind11::class_, + SmartPointer>>( + module, "CalculateNormalVectors") // constructors - .def(pybind11::init( - &lsSmartPointer>::New<>)) - .def(pybind11::init(&lsSmartPointer>::New< - lsSmartPointer> &>)) + .def(pybind11::init(&SmartPointer>::New<>)) + .def(pybind11::init(&SmartPointer>::New< + SmartPointer> &>)) // methods - .def("setLevelSet", &lsCalculateNormalVectors::setLevelSet, + .def("setLevelSet", &CalculateNormalVectors::setLevelSet, "Set levelset for which to calculate normal vectors.") - .def("apply", &lsCalculateNormalVectors::apply, + .def("apply", &CalculateNormalVectors::apply, "Perform normal vector calculation."); - // lsCheck - pybind11::class_, lsSmartPointer>>(module, - "lsCheck") + // Check + pybind11::class_, SmartPointer>>(module, "Check") // constructors - .def(pybind11::init(&lsSmartPointer>::New<>)) - .def(pybind11::init(&lsSmartPointer>::New< - lsSmartPointer> &>)) + .def(pybind11::init(&SmartPointer>::New<>)) + .def(pybind11::init( + &SmartPointer>::New> &>)) // methods - .def("setLevelSet", &lsCheck::setLevelSet, + .def("setLevelSet", &Check::setLevelSet, "Set levelset for which to calculate normal vectors.") - .def("apply", &lsCheck::apply, "Perform check."); + .def("apply", &Check::apply, "Perform check."); - // lsConvexHull - pybind11::class_, lsSmartPointer>>( - module, "lsConvexHull") + // ConvexHull + pybind11::class_, SmartPointer>>( + module, "ConvexHull") // constructors - .def(pybind11::init(&lsSmartPointer>::New<>)) - .def(pybind11::init(&lsSmartPointer>::New< - lsSmartPointer> &, - lsSmartPointer> &>)) + .def(pybind11::init(&SmartPointer>::New<>)) + .def(pybind11::init( + &SmartPointer>::New< + SmartPointer> &, SmartPointer> &>)) // methods - .def("setMesh", &lsConvexHull::setMesh, + .def("setMesh", &ConvexHull::setMesh, "Set mesh object where the generated mesh should be stored.") - .def("setPointCloud", &lsConvexHull::setPointCloud, + .def("setPointCloud", &ConvexHull::setPointCloud, "Set point cloud used to generate mesh.") - .def("apply", &lsConvexHull::apply, "Generate Hull."); + .def("apply", &ConvexHull::apply, "Generate Hull."); - // lsDetectFeatures - pybind11::class_, - lsSmartPointer>>(module, - "lsDetectFeatures") + // DetectFeatures + pybind11::class_, SmartPointer>>( + module, "DetectFeatures") // constructors - .def(pybind11::init(&lsSmartPointer>::New<>)) - .def(pybind11::init(&lsSmartPointer>::New< - lsSmartPointer> &>)) - .def(pybind11::init(&lsSmartPointer>::New< - lsSmartPointer> &, T>)) + .def(pybind11::init(&SmartPointer>::New<>)) + .def(pybind11::init(&SmartPointer>::New< + SmartPointer> &>)) + .def(pybind11::init( + &SmartPointer>::New> &, + T>)) // some constructors need lambda to work: seems to be an issue with // implicit move constructor - .def(pybind11::init([](lsSmartPointer> &domain, T maxValue, - lsFeatureDetectionEnum type) { - return lsSmartPointer>::New(domain, maxValue, - type); + .def(pybind11::init([](SmartPointer> &domain, T maxValue, + FeatureDetectionEnum type) { + return SmartPointer>::New(domain, maxValue, type); })) .def("setDetectionThreshold", - &lsDetectFeatures::setDetectionThreshold, + &DetectFeatures::setDetectionThreshold, "Set the curvature value above which a point is considered a " "feature.") - .def("setDetectionMethod", &lsDetectFeatures::setDetectionMethod, + .def("setDetectionMethod", &DetectFeatures::setDetectionMethod, "Set which method to use to detect features. Defaults to Curvature.") - .def("apply", &lsDetectFeatures::apply, "Detect features."); + .def("apply", &DetectFeatures::apply, "Detect features."); // enums - pybind11::enum_(module, "lsFeatureDetectionEnum") - .value("CURVATURE", lsFeatureDetectionEnum::CURVATURE) - .value("NORMALS_ANGLE", lsFeatureDetectionEnum::NORMALS_ANGLE); + pybind11::enum_(module, "FeatureDetectionEnum") + .value("CURVATURE", FeatureDetectionEnum::CURVATURE) + .value("NORMALS_ANGLE", FeatureDetectionEnum::NORMALS_ANGLE); // lsDomain - pybind11::class_, lsSmartPointer>>(module, - "lsDomain") + pybind11::class_, SmartPointer< Domain>>(module, + "Domain") // constructors - .def(pybind11::init(&lsSmartPointer>::New<>)) - .def(pybind11::init(&lsSmartPointer>::New)) + .def(pybind11::init(& SmartPointer< Domain>::New<>)) + .def(pybind11::init(& SmartPointer< Domain>::New)) .def(pybind11::init( - &lsSmartPointer>::New::BoundaryType *>)) + & SmartPointer< Domain>::New::BoundaryType *>)) .def(pybind11::init( - &lsSmartPointer>::New< - hrleCoordType *, lsDomain::BoundaryType *, hrleCoordType>)) + & SmartPointer< Domain>::New< + hrleCoordType *, Domain::BoundaryType *, hrleCoordType>)) .def(pybind11::init( - &lsSmartPointer>::New, + & SmartPointer< Domain>::New, std::vector, hrleCoordType>)) - .def(pybind11::init(&lsSmartPointer>::New< - lsDomain::PointValueVectorType, hrleCoordType *, - lsDomain::BoundaryType *>)) - .def(pybind11::init(&lsSmartPointer>::New< - lsDomain::PointValueVectorType, hrleCoordType *, - lsDomain::BoundaryType *, hrleCoordType>)) - .def(pybind11::init(&lsSmartPointer>::New< - lsSmartPointer> &>)) + .def(pybind11::init(& SmartPointer< Domain>::New< + Domain::PointValueVectorType, hrleCoordType *, + Domain::BoundaryType *>)) + .def(pybind11::init(& SmartPointer< Domain>::New< + Domain::PointValueVectorType, hrleCoordType *, + Domain::BoundaryType *, hrleCoordType>)) + .def(pybind11::init(& SmartPointer< Domain>::New< + SmartPointer< Domain> &>)) // methods - .def("deepCopy", &lsDomain::deepCopy, + .def("deepCopy", &Domain::deepCopy, "Copy lsDomain in this lsDomain.") - .def("getNumberOfSegments", &lsDomain::getNumberOfSegments, + .def("getNumberOfSegments", &Domain::getNumberOfSegments, "Get the number of segments, the level set structure is divided " "into.") - .def("getNumberOfPoints", &lsDomain::getNumberOfPoints, + .def("getNumberOfPoints", &Domain::getNumberOfPoints, "Get the number of defined level set values.") - .def("getLevelSetWidth", &lsDomain::getLevelSetWidth, + .def("getLevelSetWidth", &Domain::getLevelSetWidth, "Get the number of layers of level set points around the explicit " "surface.") - .def("setLevelSetWidth", &lsDomain::setLevelSetWidth, + .def("setLevelSetWidth", &Domain::setLevelSetWidth, "Set the number of layers of level set points which should be " "stored around the explicit surface.") - .def("clearMetaData", &lsDomain::clearMetaData, + .def("clearMetaData", &Domain::clearMetaData, "Clear all metadata stored in the level set.") // allow filehandle to be passed and default to python standard output - .def("print", [](lsDomain& d, pybind11::object fileHandle) { + .def("print", [](Domain& d, pybind11::object fileHandle) { if (!(pybind11::hasattr(fileHandle,"write") && pybind11::hasattr(fileHandle,"flush") )){ throw pybind11::type_error("MyClass::read_from_file_like_object(file): incompatible function argument: `file` must be a file-like object, but `" @@ -411,118 +406,109 @@ PYBIND11_MODULE(VIENNALS_MODULE_NAME, module) { }, pybind11::arg("stream") = pybind11::module::import("sys").attr("stdout")); // enums - pybind11::enum_>(module, "lsBoundaryConditionEnum") + pybind11::enum_>(module, "BoundaryConditionEnum") .value("REFLECTIVE_BOUNDARY", - lsBoundaryConditionEnum::REFLECTIVE_BOUNDARY) - .value("INFINITE_BOUNDARY", lsBoundaryConditionEnum::INFINITE_BOUNDARY) - .value("PERIODIC_BOUNDARY", lsBoundaryConditionEnum::PERIODIC_BOUNDARY) + BoundaryConditionEnum::REFLECTIVE_BOUNDARY) + .value("INFINITE_BOUNDARY", BoundaryConditionEnum::INFINITE_BOUNDARY) + .value("PERIODIC_BOUNDARY", BoundaryConditionEnum::PERIODIC_BOUNDARY) .value("POS_INFINITE_BOUNDARY", - lsBoundaryConditionEnum::POS_INFINITE_BOUNDARY) + BoundaryConditionEnum::POS_INFINITE_BOUNDARY) .value("NEG_INFINITE_BOUNDARY", - lsBoundaryConditionEnum::NEG_INFINITE_BOUNDARY); + BoundaryConditionEnum::NEG_INFINITE_BOUNDARY); - // lsGeometricAdvect - pybind11::class_, - lsSmartPointer>>(module, - "lsGeometricAdvect") + // GeometricAdvect + pybind11::class_, SmartPointer>>( + module, "GeometricAdvect") // constructors - .def(pybind11::init(&lsSmartPointer>::New<>)) + .def(pybind11::init(&SmartPointer>::New<>)) .def(pybind11::init( - &lsSmartPointer>::New< - lsSmartPointer> &, - lsSmartPointer> - &>)) + &SmartPointer>::New< + SmartPointer> &, + SmartPointer> &>)) // methods - .def("setLevelSet", &lsGeometricAdvect::setLevelSet, + .def("setLevelSet", &GeometricAdvect::setLevelSet, "Set levelset to advect.") .def( "setAdvectionDistribution", - &lsGeometricAdvect::setAdvectionDistribution< + &GeometricAdvect::setAdvectionDistribution< PylsGeometricAdvectDistribution>, "Set advection distribution to use as kernel for the fast advection.") - .def("apply", &lsGeometricAdvect::apply, + .def("apply", &GeometricAdvect::apply, pybind11::call_guard(), "Perform advection."); - // lsGeometricAdvectDistributions - pybind11::class_, - lsSmartPointer>, + // GeometricAdvectDistributions + pybind11::class_, + SmartPointer>, PylsGeometricAdvectDistribution>( - module, "lsGeometricAdvectDistribution") + module, "GeometricAdvectDistribution") // constructors .def(pybind11::init<>()) // methods - .def("isInside", &lsGeometricAdvectDistribution::isInside, + .def("isInside", &GeometricAdvectDistribution::isInside, "Check whether passed point is inside the distribution.") .def("getSignedDistance", - &lsGeometricAdvectDistribution::getSignedDistance, + &GeometricAdvectDistribution::getSignedDistance, "Get the signed distance of the passed point to the surface of the " "distribution.") - .def("getBounds", &lsGeometricAdvectDistribution::getBounds, + .def("getBounds", &GeometricAdvectDistribution::getBounds, "Get the cartesian bounds of the distribution."); - pybind11::class_, - lsSmartPointer>, - lsGeometricAdvectDistribution>(module, - "lsSphereDistribution") + pybind11::class_, + SmartPointer>, + GeometricAdvectDistribution>(module, + "SphereDistribution") // constructors - .def(pybind11::init( - &lsSmartPointer>::New)) + .def(pybind11::init(&SmartPointer>::New)) // methods - .def("isInside", &lsSphereDistribution::isInside, + .def("isInside", &SphereDistribution::isInside, "Check whether passed point is inside the distribution.") - .def("getSignedDistance", &lsSphereDistribution::getSignedDistance, + .def("getSignedDistance", &SphereDistribution::getSignedDistance, "Get the signed distance of the passed point to the surface of the " "distribution.") - .def("getBounds", &lsSphereDistribution::getBounds, + .def("getBounds", &SphereDistribution::getBounds, "Get the cartesian bounds of the distribution."); - pybind11::class_, - lsSmartPointer>, - lsGeometricAdvectDistribution>(module, - "lsBoxDistribution") + pybind11::class_, SmartPointer>, + GeometricAdvectDistribution>(module, "BoxDistribution") // constructors .def(pybind11::init( - &lsSmartPointer>::New, - T>)) + &SmartPointer>::New, T>)) // methods - .def("isInside", &lsBoxDistribution::isInside, + .def("isInside", &BoxDistribution::isInside, "Check whether passed point is inside the distribution.") - .def("getSignedDistance", &lsBoxDistribution::getSignedDistance, + .def("getSignedDistance", &BoxDistribution::getSignedDistance, "Get the signed distance of the passed point to the surface of the " "distribution.") - .def("getBounds", &lsBoxDistribution::getBounds, + .def("getBounds", &BoxDistribution::getBounds, "Get the cartesian bounds of the distribution."); // lsExpand - pybind11::class_, lsSmartPointer>>(module, - "lsExpand") + pybind11::class_, SmartPointer>>(module, "Expand") // constructors - .def(pybind11::init(&lsSmartPointer>::New<>)) - .def(pybind11::init(&lsSmartPointer>::New< - lsSmartPointer> &>)) + .def(pybind11::init(&SmartPointer>::New<>)) + .def(pybind11::init( + &SmartPointer>::New> &>)) .def(pybind11::init( - &lsSmartPointer>::New> &, - int>)) + &SmartPointer>::New> &, int>)) // methods - .def("setLevelSet", &lsExpand::setLevelSet, - "Set levelset to expand.") - .def("setWidth", &lsExpand::setWidth, "Set the width to expand to.") - .def("apply", &lsExpand::apply, "Perform expansion."); + .def("setLevelSet", &Expand::setLevelSet, "Set levelset to expand.") + .def("setWidth", &Expand::setWidth, "Set the width to expand to.") + .def("apply", &Expand::apply, "Perform expansion."); // lsExtrude // Does not work in current implementation, because one can not import both 2D // and 3D ViennaLS libraries in Python in the same file - // pybind11::class_, lsSmartPointer>>(module, + // pybind11::class_, SmartPointer>>(module, // "lsExtrude") // // constructors - // .def(pybind11::init(&lsSmartPointer>::New<>)) + // .def(pybind11::init(&SmartPointer>::New<>)) // .def( - // pybind11::init(&lsSmartPointer>::New< - // lsSmartPointer> &, - // lsSmartPointer> &, std::array, const int, - // std::array, 3>>)) + // pybind11::init(&SmartPointer>::New< + // SmartPointer< Domain> &, + // SmartPointer< Domain> &, + // std::array, const int, + // std::array, 3>>)) // // methods // .def("setInputLevelSet", &lsExtrude::setInputLevelSet, // "Set 2D input Level Set") @@ -533,541 +519,525 @@ PYBIND11_MODULE(VIENNALS_MODULE_NAME, module) { // .def("setExtrudeDimension", &lsExtrude::setExtrudeDimension, // "Set the dimension which should be extruded") // .def("setBoundaryConditions", - // pybind11::overload_cast, + // pybind11::overload_cast, // 3>>( // &lsExtrude::setBoundaryConditions), // "Set the boundary conditions in the 3D extruded domain.") // .def("setBoundaryConditions", - // pybind11::overload_cast *>( + // pybind11::overload_cast *>( // &lsExtrude::setBoundaryConditions), // "Set the boundary conditions in the 3D extruded domain.") // .def("apply", &lsExtrude::apply, "Perform extrusion."); // lsFileFormats - pybind11::enum_(module, "lsFileFormatEnum") - .value("VTK_LEGACY", lsFileFormatEnum::VTK_LEGACY) - .value("VTP", lsFileFormatEnum::VTP) - .value("VTU", lsFileFormatEnum::VTU); + pybind11::enum_(module, "FileFormatEnum") + .value("VTK_LEGACY", FileFormatEnum::VTK_LEGACY) + .value("VTP", FileFormatEnum::VTP) + .value("VTU", FileFormatEnum::VTU); // lsFromSurfaceMesh - pybind11::class_, - lsSmartPointer>>(module, - "lsFromSurfaceMesh") + pybind11::class_, SmartPointer>>( + module, "FromSurfaceMesh") // constructors - .def(pybind11::init(&lsSmartPointer>::New<>)) + .def(pybind11::init(&SmartPointer>::New<>)) .def(pybind11::init( - &lsSmartPointer>::New< - lsSmartPointer> &, lsSmartPointer> &>)) - .def(pybind11::init(&lsSmartPointer>::New< - lsSmartPointer> &, - lsSmartPointer> &, bool>)) + &SmartPointer>::New< + SmartPointer> &, SmartPointer> &>)) + .def(pybind11::init( + &SmartPointer>::New< + SmartPointer> &, SmartPointer> &, bool>)) // methods - .def("setLevelSet", &lsFromSurfaceMesh::setLevelSet, + .def("setLevelSet", &FromSurfaceMesh::setLevelSet, "Set levelset to read into.") - .def("setMesh", &lsFromSurfaceMesh::setMesh, + .def("setMesh", &FromSurfaceMesh::setMesh, "Set the mesh to read from.") .def("setRemoveBoundaryTriangles", - static_cast::*)(bool)>( - &lsFromSurfaceMesh::setRemoveBoundaryTriangles), + static_cast::*)(bool)>( + &FromSurfaceMesh::setRemoveBoundaryTriangles), "Set whether to include mesh elements outside of the simulation " "domain.") .def("setRemoveBoundaryTriangles", - static_cast::*)(std::array)>( - &lsFromSurfaceMesh::setRemoveBoundaryTriangles), + static_cast::*)(std::array)>( + &FromSurfaceMesh::setRemoveBoundaryTriangles), "Set whether to include mesh elements outside of the simulation " "domain.") - .def("apply", &lsFromSurfaceMesh::apply, + .def("apply", &FromSurfaceMesh::apply, "Construct a levelset from a surface mesh."); - // lsFromVolumeMesh - pybind11::class_, - lsSmartPointer>>(module, - "lsFromVolumeMesh") + // FromVolumeMesh + pybind11::class_, SmartPointer>>( + module, "FromVolumeMesh") // constructors - .def(pybind11::init(&lsSmartPointer>::New<>)) - .def(pybind11::init(&lsSmartPointer>::New< - typename lsFromVolumeMesh::GridType &, - lsSmartPointer> &>)) - .def(pybind11::init(&lsSmartPointer>::New< - typename lsFromVolumeMesh::GridType &, - lsSmartPointer> &, bool>)) + .def(pybind11::init(&SmartPointer>::New<>)) + .def(pybind11::init(&SmartPointer>::New< + typename FromVolumeMesh::GridType &, + SmartPointer> &>)) + .def(pybind11::init(&SmartPointer>::New< + typename FromVolumeMesh::GridType &, + SmartPointer> &, bool>)) // methods - .def("setGrid", &lsFromVolumeMesh::setGrid, + .def("setGrid", &FromVolumeMesh::setGrid, "Set the grid used to read in the level sets.") - .def("setMesh", &lsFromVolumeMesh::setMesh, + .def("setMesh", &FromVolumeMesh::setMesh, "Set the mesh to read from.") .def("setRemoveBoundaryTriangles", - &lsFromVolumeMesh::setRemoveBoundaryTriangles, + &FromVolumeMesh::setRemoveBoundaryTriangles, "Set whether to include mesh elements outside of the simulation " "domain.") - .def("apply", &lsFromVolumeMesh::apply, + .def("apply", &FromVolumeMesh::apply, "Construct a levelset from a volume mesh."); // lsGeometries - // lsSphere - pybind11::class_, lsSmartPointer>>(module, - "lsSphere") + // Sphere + pybind11::class_, SmartPointer>>(module, "Sphere") // constructors - .def(pybind11::init(&lsSmartPointer>::New< + .def(pybind11::init(&SmartPointer>::New< const std::vector & /*origin*/, T /*radius*/>), pybind11::arg("origin"), pybind11::arg("radius")); - // lsPlane - pybind11::class_, lsSmartPointer>>(module, - "lsPlane") + // Plane + pybind11::class_, SmartPointer>>(module, "Plane") // constructors - .def(pybind11::init(&lsSmartPointer>::New< + .def(pybind11::init(&SmartPointer>::New< const std::vector & /*origin*/, const std::vector & /*normal*/>), pybind11::arg("origin"), pybind11::arg("normal")); - // lsBox - pybind11::class_, lsSmartPointer>>(module, "lsBox") + // Box + pybind11::class_, SmartPointer>>(module, "Box") // constructors - .def(pybind11::init(&lsSmartPointer>::New< + .def(pybind11::init(&SmartPointer>::New< const std::vector & /*minPoint*/, const std::vector & /*maxPoint*/>), pybind11::arg("minPoint"), pybind11::arg("maxPoint")); - // lsCylinder - pybind11::class_, lsSmartPointer>>( - module, "lsCylinder") + // Cylinder + pybind11::class_, SmartPointer>>(module, + "Cylinder") // constructors .def(pybind11::init( - &lsSmartPointer>::New< + &SmartPointer>::New< const std::vector & /*origin*/, const std::vector & /*axisDirection*/, const T /*height*/, const T /*radius*/, const T /*topRadius*/>), pybind11::arg("origin"), pybind11::arg("axisDirection"), pybind11::arg("height"), pybind11::arg("radius"), pybind11::arg("topRadius") = 0.); - // lsPointCloud - pybind11::class_, lsSmartPointer>>( - module, "lsPointCloud") + // PointCloud + pybind11::class_, SmartPointer>>( + module, "PointCloud") // constructors - .def(pybind11::init(&lsSmartPointer>::New< + .def(pybind11::init(&SmartPointer>::New< const std::vector> &>)) // methods .def("insertNextPoint", - (void(lsPointCloud::*)(const std::vector &)) & - lsPointCloud::insertNextPoint); + (void(PointCloud::*)(const std::vector &)) & + PointCloud::insertNextPoint); - // lsMakeGeometry - pybind11::class_, lsSmartPointer>>( - module, "lsMakeGeometry") + // MakeGeometry + pybind11::class_, SmartPointer>>( + module, "MakeGeometry") // constructors - .def(pybind11::init(&lsSmartPointer>::New<>)) - .def(pybind11::init(&lsSmartPointer>::New< - lsSmartPointer> &>)) - .def(pybind11::init(&lsSmartPointer>::New< - lsSmartPointer> &, - lsSmartPointer> &>)) - .def(pybind11::init(&lsSmartPointer>::New< - lsSmartPointer> &, - lsSmartPointer> &>)) + .def(pybind11::init(&SmartPointer>::New<>)) + .def(pybind11::init( + &SmartPointer>::New> &>)) + .def(pybind11::init( + &SmartPointer>::New> &, + SmartPointer> &>)) + .def(pybind11::init( + &SmartPointer>::New> &, + SmartPointer> &>)) .def(pybind11::init( - &lsSmartPointer>::New< - lsSmartPointer> &, lsSmartPointer> &>)) - .def(pybind11::init(&lsSmartPointer>::New< - lsSmartPointer> &, - lsSmartPointer> &>)) - .def(pybind11::init(&lsSmartPointer>::New< - lsSmartPointer> &, - lsSmartPointer> &>)) + &SmartPointer>::New> &, + SmartPointer> &>)) + .def(pybind11::init( + &SmartPointer>::New< + SmartPointer> &, SmartPointer> &>)) + .def(pybind11::init( + &SmartPointer>::New< + SmartPointer> &, SmartPointer> &>)) // methods - .def("setLevelSet", &lsMakeGeometry::setLevelSet, + .def("setLevelSet", &MakeGeometry::setLevelSet, "Set the levelset in which to create the geometry.") .def("setGeometry", - (void(lsMakeGeometry::*)(lsSmartPointer>)) & - lsMakeGeometry::setGeometry) + (void(MakeGeometry::*)(SmartPointer>)) & + MakeGeometry::setGeometry) .def("setGeometry", - (void(lsMakeGeometry::*)(lsSmartPointer>)) & - lsMakeGeometry::setGeometry) + (void(MakeGeometry::*)(SmartPointer>)) & + MakeGeometry::setGeometry) .def("setGeometry", - (void(lsMakeGeometry::*)(lsSmartPointer>)) & - lsMakeGeometry::setGeometry) + (void(MakeGeometry::*)(SmartPointer>)) & + MakeGeometry::setGeometry) .def("setGeometry", - (void(lsMakeGeometry::*)(lsSmartPointer>)) & - lsMakeGeometry::setGeometry) + (void(MakeGeometry::*)(SmartPointer>)) & + MakeGeometry::setGeometry) .def("setGeometry", - (void(lsMakeGeometry::*)(lsSmartPointer>)) & - lsMakeGeometry::setGeometry) + (void(MakeGeometry::*)(SmartPointer>)) & + MakeGeometry::setGeometry) .def("setIgnoreBoundaryConditions", - (void(lsMakeGeometry::*)(bool)) & - lsMakeGeometry::setIgnoreBoundaryConditions) + (void(MakeGeometry::*)(bool)) & + MakeGeometry::setIgnoreBoundaryConditions) .def("setIgnoreBoundaryConditions", - (void(lsMakeGeometry::*)(std::array)) & - lsMakeGeometry::setIgnoreBoundaryConditions) - .def("apply", &lsMakeGeometry::apply, "Generate the geometry."); + (void(MakeGeometry::*)(std::array)) & + MakeGeometry::setIgnoreBoundaryConditions) + .def("apply", &MakeGeometry::apply, "Generate the geometry."); - // lsMarkVoidPoints - pybind11::class_, - lsSmartPointer>>(module, - "lsMarkVoidPoints") + // MarkVoidPoints + pybind11::class_, SmartPointer>>( + module, "MarkVoidPoints") // constructors - .def(pybind11::init(&lsSmartPointer>::New<>)) - .def(pybind11::init(&lsSmartPointer>::New< - lsSmartPointer> &>)) - .def(pybind11::init(&lsSmartPointer>::New< - lsSmartPointer> &, bool &>)) + .def(pybind11::init(&SmartPointer>::New<>)) + .def(pybind11::init(&SmartPointer>::New< + SmartPointer> &>)) + .def(pybind11::init( + &SmartPointer>::New> &, + bool &>)) // methods - .def("setLevelSet", &lsMarkVoidPoints::setLevelSet, + .def("setLevelSet", &MarkVoidPoints::setLevelSet, "Set the levelset to mark void points in.") .def("setReverseVoidDetection", - &lsMarkVoidPoints::setReverseVoidDetection, + &MarkVoidPoints::setReverseVoidDetection, "Reverse the logic of detecting the top surface.") .def("setDetectLargestSurface", - &lsMarkVoidPoints::setDetectLargestSurface, + &MarkVoidPoints::setDetectLargestSurface, "Set that the top surface should be the one with the most connected " "LS points.") - .def("setVoidTopSurface", &lsMarkVoidPoints::setVoidTopSurface, + .def("setVoidTopSurface", &MarkVoidPoints::setVoidTopSurface, "Set the logic by which to choose the surface which is non-void. " "All other connected surfaces will then be marked as void points.") - .def("setSaveComponentsId", &lsMarkVoidPoints::setSaveComponentIds, + .def("setSaveComponentsId", &MarkVoidPoints::setSaveComponentIds, "Save the connectivity information of all LS points in the " "pointData of the level set.") - .def("apply", &lsMarkVoidPoints::apply, "Mark void points."); + .def("apply", &MarkVoidPoints::apply, "Mark void points."); - // lsVoidTopSurfaceEnum - pybind11::enum_(module, "lsVoidTopSurfaceEnum") - .value("LEX_LOWEST", lsVoidTopSurfaceEnum::LEX_LOWEST) - .value("LEX_HIGHEST", lsVoidTopSurfaceEnum::LEX_HIGHEST) - .value("LARGEST", lsVoidTopSurfaceEnum::LARGEST) - .value("SMALLEST", lsVoidTopSurfaceEnum::SMALLEST); + // VoidTopSurfaceEnum + pybind11::enum_(module, "VoidTopSurfaceEnum") + .value("LEX_LOWEST", VoidTopSurfaceEnum::LEX_LOWEST) + .value("LEX_HIGHEST", VoidTopSurfaceEnum::LEX_HIGHEST) + .value("LARGEST", VoidTopSurfaceEnum::LARGEST) + .value("SMALLEST", VoidTopSurfaceEnum::SMALLEST); - // lsPointData - pybind11::class_, lsSmartPointer>>( - module, "lsPointData") + // PointData + pybind11::class_, SmartPointer>>(module, + "PointData") // constructors - .def(pybind11::init(&lsSmartPointer>::New<>)) + .def(pybind11::init(&SmartPointer>::New<>)) // methods .def("insertNextScalarData", - (void(lsPointData::*)(const lsPointData::ScalarDataType &, - std::string)) & - lsPointData::insertNextScalarData, + (void(PointData::*)(const PointData::ScalarDataType &, + std::string)) & + PointData::insertNextScalarData, pybind11::arg("scalars"), pybind11::arg("label") = "Scalars") .def("insertNextVectorData", - (void(lsPointData::*)(const lsPointData::VectorDataType &, - std::string)) & - lsPointData::insertNextVectorData, + (void(PointData::*)(const PointData::VectorDataType &, + std::string)) & + PointData::insertNextVectorData, pybind11::arg("vectors"), pybind11::arg("label") = "Vectors") - .def("getScalarDataSize", &lsPointData::getScalarDataSize) - .def("getVectorDataSize", &lsPointData::getVectorDataSize) + .def("getScalarDataSize", &PointData::getScalarDataSize) + .def("getVectorDataSize", &PointData::getVectorDataSize) .def("getScalarData", - (lsPointData::ScalarDataType * (lsPointData::*)(int)) & - lsPointData::getScalarData) + (PointData::ScalarDataType * (PointData::*)(int)) & + PointData::getScalarData) .def("getScalarData", - (lsPointData::ScalarDataType * (lsPointData::*)(std::string)) & - lsPointData::getScalarData) - .def("getScalarDataLabel", &lsPointData::getScalarDataLabel) + (PointData::ScalarDataType * (PointData::*)(std::string)) & + PointData::getScalarData) + .def("getScalarDataLabel", &PointData::getScalarDataLabel) .def("getVectorData", - (lsPointData::VectorDataType * (lsPointData::*)(int)) & - lsPointData::getVectorData) + (PointData::VectorDataType * (PointData::*)(int)) & + PointData::getVectorData) .def("getVectorData", - (lsPointData::VectorDataType * (lsPointData::*)(std::string)) & - lsPointData::getVectorData) - .def("getVectorDataLabel", &lsPointData::getVectorDataLabel); + (PointData::VectorDataType * (PointData::*)(std::string)) & + PointData::getVectorData) + .def("getVectorDataLabel", &PointData::getVectorDataLabel); - // lsMesh - pybind11::class_, lsSmartPointer>>(module, "lsMesh") + // Mesh + pybind11::class_, SmartPointer>>(module, "Mesh") // constructors - .def(pybind11::init(&lsSmartPointer>::New<>)) + .def(pybind11::init(&SmartPointer>::New<>)) // methods .def("getNodes", - (std::vector> & (lsMesh::*)()) & - lsMesh::getNodes, + (std::vector> & (Mesh::*)()) & + Mesh::getNodes, "Get all nodes of the mesh as a list.") .def("getNodes", - (std::vector> & (lsMesh::*)()) & - lsMesh::getNodes, + (std::vector> & (Mesh::*)()) & + Mesh::getNodes, "Get all nodes of the mesh as a list.") .def("getVerticies", - (std::vector> & (lsMesh::*)()) & - lsMesh::getElements<1>, + (std::vector> & (Mesh::*)()) & + Mesh::getElements<1>, "Get a list of verticies of the mesh.") .def("getLines", - (std::vector> & (lsMesh::*)()) & - lsMesh::getElements<2>, + (std::vector> & (Mesh::*)()) & + Mesh::getElements<2>, "Get a list of lines of the mesh.") .def("getTriangles", - (std::vector> & (lsMesh::*)()) & - lsMesh::getElements<3>, + (std::vector> & (Mesh::*)()) & + Mesh::getElements<3>, "Get a list of triangles of the mesh.") .def("getTetras", - (std::vector> & (lsMesh::*)()) & - lsMesh::getElements<4>, + (std::vector> & (Mesh::*)()) & + Mesh::getElements<4>, "Get a list of tetrahedrons of the mesh.") .def("getHexas", - (std::vector> & (lsMesh::*)()) & - lsMesh::getElements<8>, + (std::vector> & (Mesh::*)()) & + Mesh::getElements<8>, "Get a list of hexahedrons of the mesh.") .def("getPointData", - (lsPointData & (lsMesh::*)()) & lsMesh::getPointData, + (PointData & (Mesh::*)()) & Mesh::getPointData, "Return a reference to the point data of the mesh.") .def("getCellData", - (lsPointData & (lsMesh::*)()) & lsMesh::getCellData, + (PointData & (Mesh::*)()) & Mesh::getCellData, "Return a reference to the cell data of the mesh.") - .def("insertNextNode", &lsMesh::insertNextNode, + .def("insertNextNode", &Mesh::insertNextNode, "Insert a node in the mesh.") - .def("insertNextVertex", &lsMesh::insertNextVertex, + .def("insertNextVertex", &Mesh::insertNextVertex, "Insert a vertex in the mesh.") - .def("insertNextLine", &lsMesh::insertNextLine, + .def("insertNextLine", &Mesh::insertNextLine, "Insert a line in the mesh.") - .def("insertNextTriangle", &lsMesh::insertNextTriangle, + .def("insertNextTriangle", &Mesh::insertNextTriangle, "Insert a triangle in the mesh.") - .def("insertNextTetra", &lsMesh::insertNextTetra, + .def("insertNextTetra", &Mesh::insertNextTetra, "Insert a tetrahedron in the mesh.") - .def("insertNextHexa", &lsMesh::insertNextHexa, + .def("insertNextHexa", &Mesh::insertNextHexa, "Insert a hexahedron in the mesh.") - .def("removeDuplicateNodes", &lsMesh::removeDuplicateNodes, + .def("removeDuplicateNodes", &Mesh::removeDuplicateNodes, "Remove nodes which occur twice in the mesh, and replace their IDs " "in the mesh elements.") - .def("print", &lsMesh::print, - "Print basic information about the mesh."); + .def("print", &Mesh::print, "Print basic information about the mesh."); - // lsPrune - pybind11::class_, lsSmartPointer>>(module, - "lsPrune") + // Prune + pybind11::class_, SmartPointer>>(module, "Prune") // constructors - .def(pybind11::init(&lsSmartPointer>::New<>)) - .def(pybind11::init(&lsSmartPointer>::New< - lsSmartPointer> &>)) + .def(pybind11::init(&SmartPointer>::New<>)) + .def(pybind11::init( + &SmartPointer>::New> &>)) // methods - .def("setLevelSet", &lsPrune::setLevelSet, "Set levelset to prune.") - .def("apply", &lsPrune::apply, "Perform pruning operation."); + .def("setLevelSet", &Prune::setLevelSet, "Set levelset to prune.") + .def("apply", &Prune::apply, "Perform pruning operation."); - // lsReader - pybind11::class_, lsSmartPointer>>(module, - "lsReader") + // Reader + pybind11::class_, SmartPointer>>(module, "Reader") // constructors - .def(pybind11::init(&lsSmartPointer>::New<>)) - .def(pybind11::init(&lsSmartPointer>::New< - lsSmartPointer> &>)) + .def(pybind11::init(&SmartPointer>::New<>)) + .def(pybind11::init( + &SmartPointer>::New> &>)) .def(pybind11::init( - &lsSmartPointer>::New> &, - std::string>)) + &SmartPointer>::New> &, + std::string>)) // methods - .def("setLevelSet", &lsReader::setLevelSet, + .def("setLevelSet", &Reader::setLevelSet, "Set levelset to write to file.") - .def("setFileName", &lsReader::setFileName, + .def("setFileName", &Reader::setFileName, "Set the filename for the output file.") - .def("apply", &lsReader::apply, "Write to file."); + .def("apply", &Reader::apply, "Write to file."); - // lsReduce - pybind11::class_, lsSmartPointer>>(module, - "lsReduce") + // Reduce + pybind11::class_, SmartPointer>>(module, "Reduce") // constructors - .def(pybind11::init(&lsSmartPointer>::New<>)) - .def(pybind11::init(&lsSmartPointer>::New< - lsSmartPointer> &>)) + .def(pybind11::init(&SmartPointer>::New<>)) .def(pybind11::init( - &lsSmartPointer>::New> &, - int>)) + &SmartPointer>::New> &>)) .def(pybind11::init( - &lsSmartPointer>::New> &, - int, bool>)) + &SmartPointer>::New> &, int>)) + .def(pybind11::init( + &SmartPointer>::New> &, int, + bool>)) // methods - .def("setLevelSet", &lsReduce::setLevelSet, - "Set levelset to reduce.") - .def("setWidth", &lsReduce::setWidth, "Set the width to reduce to.") - .def("setNoNewSegment", &lsReduce::setNoNewSegment, + .def("setLevelSet", &Reduce::setLevelSet, "Set levelset to reduce.") + .def("setWidth", &Reduce::setWidth, "Set the width to reduce to.") + .def("setNoNewSegment", &Reduce::setNoNewSegment, "Set whether the levelset should be segmented anew (balanced across " "cores) after reduction.") - .def("apply", &lsReduce::apply, "Perform reduction."); + .def("apply", &Reduce::apply, "Perform reduction."); - // lsRemoveStrayPoints - pybind11::class_, - lsSmartPointer>>( - module, "lsRemoveStrayPoints") + // RemoveStrayPoints + pybind11::class_, + SmartPointer>>(module, + "RemoveStrayPoints") // constructors - .def(pybind11::init(&lsSmartPointer>::New<>)) - .def(pybind11::init(&lsSmartPointer>::New< - lsSmartPointer> &>)) + .def(pybind11::init(&SmartPointer>::New<>)) + .def(pybind11::init(&SmartPointer>::New< + SmartPointer> &>)) // methods - .def("setLevelSet", &lsRemoveStrayPoints::setLevelSet, + .def("setLevelSet", &RemoveStrayPoints::setLevelSet, "Set levelset for stray point removal.") - .def("setVoidTopSurface", &lsRemoveStrayPoints::setVoidTopSurface, + .def("setVoidTopSurface", &RemoveStrayPoints::setVoidTopSurface, "Set the logic by which to choose the surface which should be kept. " "All other LS values will be marked as stray points and removed.") - .def("apply", &lsRemoveStrayPoints::apply, "Remove stray points."); + .def("apply", &RemoveStrayPoints::apply, "Remove stray points."); - // lsToDiskMesh - pybind11::class_, lsSmartPointer>>( - module, "lsToDiskMesh") + // ToDiskMesh + pybind11::class_, SmartPointer>>( + module, "ToDiskMesh") // constructors - .def(pybind11::init(&lsSmartPointer>::New<>)) + .def(pybind11::init(&SmartPointer>::New<>)) .def(pybind11::init( - &lsSmartPointer>::New< - lsSmartPointer> &, lsSmartPointer> &>)) + &SmartPointer>::New> &, + SmartPointer> &>)) // methods - .def("setLevelSet", &lsToDiskMesh::setLevelSet, + .def("setLevelSet", &ToDiskMesh::setLevelSet, "Set levelset to mesh.") - .def("setMesh", &lsToDiskMesh::setMesh, "Set the mesh to generate.") - .def("apply", &lsToDiskMesh::apply, + .def("setMesh", &ToDiskMesh::setMesh, "Set the mesh to generate.") + .def("apply", &ToDiskMesh::apply, "Convert the levelset to a surface mesh."); - // lsToMesh - pybind11::class_, lsSmartPointer>>(module, - "lsToMesh") + // ToMesh + pybind11::class_, SmartPointer>>(module, "ToMesh") // constructors - .def(pybind11::init(&lsSmartPointer>::New<>)) + .def(pybind11::init(&SmartPointer>::New<>)) .def(pybind11::init( - &lsSmartPointer>::New> &, - lsSmartPointer> &>)) + &SmartPointer>::New> &, + SmartPointer> &>)) .def(pybind11::init( - &lsSmartPointer>::New> &, - lsSmartPointer> &, - bool>)) + &SmartPointer>::New> &, + SmartPointer> &, bool>)) .def(pybind11::init( - &lsSmartPointer>::New> &, - lsSmartPointer> &, - bool, bool>)) + &SmartPointer>::New> &, + SmartPointer> &, bool, + bool>)) // methods - .def("setLevelSet", &lsToMesh::setLevelSet, "Set levelset to mesh.") - .def("setMesh", &lsToMesh::setMesh, "Set the mesh to generate.") - .def("setOnlyDefined", &lsToMesh::setOnlyDefined, + .def("setLevelSet", &ToMesh::setLevelSet, "Set levelset to mesh.") + .def("setMesh", &ToMesh::setMesh, "Set the mesh to generate.") + .def("setOnlyDefined", &ToMesh::setOnlyDefined, "Set whether only defined points should be output to the mesh.") - .def("setOnlyActive", &lsToMesh::setOnlyActive, + .def("setOnlyActive", &ToMesh::setOnlyActive, "Set whether only level set points <0.5 should be output.") - .def("apply", &lsToMesh::apply, + .def("apply", &ToMesh::apply, "Convert the levelset to a surface mesh."); - // lsToSurfaceMesh - pybind11::class_, - lsSmartPointer>>(module, - "lsToSurfaceMesh") + // ToSurfaceMesh + pybind11::class_, SmartPointer>>( + module, "ToSurfaceMesh") // constructors - .def(pybind11::init(&lsSmartPointer>::New<>)) + .def(pybind11::init(&SmartPointer>::New<>)) .def(pybind11::init( - &lsSmartPointer>::New< - lsSmartPointer> &, lsSmartPointer> &>)) + &SmartPointer>::New> &, + SmartPointer> &>)) // methods - .def("setLevelSet", &lsToSurfaceMesh::setLevelSet, + .def("setLevelSet", &ToSurfaceMesh::setLevelSet, "Set levelset to mesh.") - .def("setMesh", &lsToSurfaceMesh::setMesh, + .def("setMesh", &ToSurfaceMesh::setMesh, "Set the mesh to generate.") - .def("apply", &lsToSurfaceMesh::apply, + .def("apply", &ToSurfaceMesh::apply, "Convert the levelset to a surface mesh."); - // lsToVoxelMesh - pybind11::class_, lsSmartPointer>>( - module, "lsToVoxelMesh") + // ToVoxelMesh + pybind11::class_, SmartPointer>>( + module, "ToVoxelMesh") // constructors - .def(pybind11::init(&lsSmartPointer>::New<>)) - .def(pybind11::init(&lsSmartPointer>::New< - lsSmartPointer> &>)) + .def(pybind11::init(&SmartPointer>::New<>)) + .def(pybind11::init( + &SmartPointer>::New> &>)) .def(pybind11::init( - &lsSmartPointer>::New< - lsSmartPointer> &, lsSmartPointer> &>)) - .def(pybind11::init(&lsSmartPointer>::New< - std::vector>> &, - lsSmartPointer> &>)) + &SmartPointer>::New> &, + SmartPointer> &>)) + .def(pybind11::init(&SmartPointer>::New< + std::vector>> &, + SmartPointer> &>)) // methods - .def("insertNextLevelSet", &lsToVoxelMesh::insertNextLevelSet, + .def("insertNextLevelSet", &ToVoxelMesh::insertNextLevelSet, "Insert next level set to output in the mesh.") - .def("setMesh", &lsToVoxelMesh::setMesh, - "Set the mesh to generate.") - .def("apply", &lsToVoxelMesh::apply, + .def("setMesh", &ToVoxelMesh::setMesh, "Set the mesh to generate.") + .def("apply", &ToVoxelMesh::apply, "Convert the levelset to a surface mesh."); - // lsVelocityField - pybind11::class_, lsSmartPointer>, - PylsVelocityField>(module, "lsVelocityField") + // VelocityField + pybind11::class_, SmartPointer>, + PylsVelocityField>(module, "VelocityField") // constructors .def(pybind11::init<>()) // methods - .def("getScalarVelocity", &lsVelocityField::getScalarVelocity, + .def("getScalarVelocity", &VelocityField::getScalarVelocity, "Return the scalar velocity for a point of material at coordinate " "with normal vector normal.") - .def("getVectorVelocity", &lsVelocityField::getVectorVelocity, + .def("getVectorVelocity", &VelocityField::getVectorVelocity, "Return the vector velocity for a point of material at coordinate " "with normal vector normal.") - .def("getDissipationAlpha", &lsVelocityField::getDissipationAlpha, + .def("getDissipationAlpha", &VelocityField::getDissipationAlpha, "Return the analytical dissipation alpha value if the " "lsLocalLaxFriedrichsAnalytical scheme is used for advection."); - // lsVTKReader - pybind11::class_, lsSmartPointer>>( - module, "lsVTKReader") + // VTKReader + pybind11::class_, SmartPointer>>(module, + "VTKReader") // constructors - .def(pybind11::init(&lsSmartPointer>::New<>)) + .def(pybind11::init(&SmartPointer>::New<>)) .def(pybind11::init( - &lsSmartPointer>::New> &>)) + &SmartPointer>::New> &>)) .def(pybind11::init( - &lsSmartPointer>::New> &, - std::string>)) - .def(pybind11::init([](lsSmartPointer> &mesh, - lsFileFormatEnum format, std::string s) { - return lsSmartPointer>::New(mesh, format, s); + &SmartPointer>::New> &, + std::string>)) + .def(pybind11::init([](SmartPointer> &mesh, FileFormatEnum format, + std::string s) { + return SmartPointer>::New(mesh, format, s); })) // methods - .def("setMesh", &lsVTKReader::setMesh, "Set the mesh to read into.") - .def("setFileFormat", &lsVTKReader::setFileFormat, + .def("setMesh", &VTKReader::setMesh, "Set the mesh to read into.") + .def("setFileFormat", &VTKReader::setFileFormat, "Set the file format of the file to be read.") - .def("setFileName", &lsVTKReader::setFileName, + .def("setFileName", &VTKReader::setFileName, "Set the name of the input file.") - .def("apply", &lsVTKReader::apply, "Read the mesh."); + .def("apply", &VTKReader::apply, "Read the mesh."); - // lsVTKWriter - pybind11::class_, lsSmartPointer>>( - module, "lsVTKWriter") + // VTKWriter + pybind11::class_, SmartPointer>>(module, + "VTKWriter") // constructors - .def(pybind11::init(&lsSmartPointer>::New<>)) + .def(pybind11::init(&SmartPointer>::New<>)) .def(pybind11::init( - &lsSmartPointer>::New> &>)) + &SmartPointer>::New> &>)) .def(pybind11::init( - &lsSmartPointer>::New> &, - std::string>)) - .def(pybind11::init([](lsSmartPointer> &mesh, - lsFileFormatEnum format, std::string s) { - return lsSmartPointer>::New(mesh, format, s); + &SmartPointer>::New> &, + std::string>)) + .def(pybind11::init([](SmartPointer> &mesh, FileFormatEnum format, + std::string s) { + return SmartPointer>::New(mesh, format, s); })) // methods - .def("setMesh", &lsVTKWriter::setMesh, "Set the mesh to output.") - .def("setFileFormat", &lsVTKWriter::setFileFormat, + .def("setMesh", &VTKWriter::setMesh, "Set the mesh to output.") + .def("setFileFormat", &VTKWriter::setFileFormat, "Set the file format, the mesh should be written to.") - .def("setFileName", &lsVTKWriter::setFileName, + .def("setFileName", &VTKWriter::setFileName, "Set the name of the output file.") - .def("apply", &lsVTKWriter::apply, "Write the mesh."); + .def("apply", &VTKWriter::apply, "Write the mesh."); - // lsWriter - pybind11::class_, lsSmartPointer>>(module, - "lsWriter") + // Writer + pybind11::class_, SmartPointer>>(module, "Writer") // constructors - .def(pybind11::init(&lsSmartPointer>::New<>)) - .def(pybind11::init(&lsSmartPointer>::New< - lsSmartPointer> &>)) + .def(pybind11::init(&SmartPointer>::New<>)) + .def(pybind11::init( + &SmartPointer>::New> &>)) .def(pybind11::init( - &lsSmartPointer>::New> &, - std::string>)) + &SmartPointer>::New> &, + std::string>)) // methods - .def("setLevelSet", &lsWriter::setLevelSet, + .def("setLevelSet", &Writer::setLevelSet, "Set levelset to write to file.") - .def("setFileName", &lsWriter::setFileName, + .def("setFileName", &Writer::setFileName, "Set the filename for the output file.") - .def("apply", &lsWriter::apply, "Write to file."); + .def("apply", &Writer::apply, "Write to file."); -// lsWriteVisualizationMesh +// WriteVisualizationMesh #ifdef VIENNALS_USE_VTK - pybind11::class_, - lsSmartPointer>>( - module, "lsWriteVisualizationMesh") + pybind11::class_, + SmartPointer>>( + module, "WriteVisualizationMesh") // constructors - .def(pybind11::init( - &lsSmartPointer>::New<>)) - .def(pybind11::init(&lsSmartPointer>::New< - lsSmartPointer> &>)) + .def(pybind11::init(&SmartPointer>::New<>)) + .def(pybind11::init(&SmartPointer>::New< + SmartPointer> &>)) // methods .def("insertNextLevelSet", - &lsWriteVisualizationMesh::insertNextLevelSet, + &WriteVisualizationMesh::insertNextLevelSet, "Insert next level set to convert. Bigger level sets wrapping " "smaller ones, should be inserted last.") - .def("setFileName", &lsWriteVisualizationMesh::setFileName, + .def("setFileName", &WriteVisualizationMesh::setFileName, "Set Name of File to write.") .def("setExtractHullMesh", - &lsWriteVisualizationMesh::setExtractHullMesh, + &WriteVisualizationMesh::setExtractHullMesh, "Whether to extract a hull mesh. Defaults to false.") .def("setExtractVolumeMesh", - &lsWriteVisualizationMesh::setExtractVolumeMesh, + &WriteVisualizationMesh::setExtractVolumeMesh, " Whether to extract a tetra volume mesh. Defaults to true.") - .def("apply", &lsWriteVisualizationMesh::apply, + .def("apply", &WriteVisualizationMesh::apply, "Make and write mesh."); #endif } diff --git a/tests/Advection/Advection.cpp b/tests/Advection/Advection.cpp index bee827f0..a555aaa1 100644 --- a/tests/Advection/Advection.cpp +++ b/tests/Advection/Advection.cpp @@ -11,6 +11,8 @@ #include #include +namespace ls = viennals; + /** This example shows how to use lsAdvect to create an egg shape from a spherical level set using directional growth rates. @@ -18,7 +20,7 @@ */ // implement own velocity field -class velocityField : public lsVelocityField { +class velocityField : public ls::VelocityField { public: double getScalarVelocity(const std::array & /*coordinate*/, int /*material*/, @@ -47,40 +49,40 @@ int main() { double gridDelta = 0.4999999; - auto sphere1 = lsSmartPointer>::New(gridDelta); + auto sphere1 = ls::SmartPointer>::New(gridDelta); double origin[3] = {5., 0., 0.}; double radius = 7.3; - lsMakeGeometry( - sphere1, lsSmartPointer>::New(origin, radius)) + ls::MakeGeometry( + sphere1, ls::SmartPointer>::New(origin, radius)) .apply(); // { // std::cout << "Extracting..." << std::endl; - // auto mesh = lsSmartPointer>::New(); - // lsToSurfaceMesh(sphere1, mesh).apply(); - // lsVTKWriter(mesh, "before.vtk").apply(); + // auto mesh = ls::SmartPointer>::New(); + // ls::ToSurfaceMesh(sphere1, mesh).apply(); + // ls::VTKWriter(mesh, "before.vtk").apply(); // } // instantiate velocities - auto velocities = lsSmartPointer::New(); + auto velocities = ls::SmartPointer::New(); // std::cout << "Advecting" << std::endl; // Fill point data with original point IDs to see how LS changed { - typename lsPointData::ScalarDataType pointIDs( + typename ls::PointData::ScalarDataType pointIDs( sphere1->getNumberOfPoints()); std::iota(std::begin(pointIDs), std::end(pointIDs), 0); sphere1->getPointData().insertNextScalarData(pointIDs, "originalIDs"); } - lsAdvect advectionKernel; + ls::Advect advectionKernel; advectionKernel.insertNextLevelSet(sphere1); advectionKernel.setVelocityField(velocities); advectionKernel.setIntegrationScheme( - lsIntegrationSchemeEnum::ENGQUIST_OSHER_1ST_ORDER); + ls::IntegrationSchemeEnum::ENGQUIST_OSHER_1ST_ORDER); advectionKernel.setSaveAdvectionVelocities(true); double time = 0.; @@ -89,26 +91,26 @@ int main() { time += advectionKernel.getAdvectedTime(); // std::string fileName = std::to_string(i) + ".vtp"; - // auto mesh = lsSmartPointer>::New(); - // lsToMesh(sphere1, mesh).apply(); - // lsVTKWriter(mesh, "points_" + fileName).apply(); - // lsToSurfaceMesh(sphere1, mesh).apply(); - // lsVTKWriter(mesh, "surface_" + fileName).apply(); + // auto mesh = ls::SmartPointer>::New(); + // ls::ToMesh(sphere1, mesh).apply(); + // ls::VTKWriter(mesh, "points_" + fileName).apply(); + // ls::ToSurfaceMesh(sphere1, mesh).apply(); + // ls::VTKWriter(mesh, "surface_" + fileName).apply(); } LSTEST_ASSERT_VALID_LS(sphere1, double, D) // std::cout << sphere1->getNumberOfPoints() << std::endl; - // lsPrune(sphere1).apply(); - // lsExpand(sphere1, 2).apply(); + // Prune(sphere1).apply(); + // ls::Expand(sphere1, 2).apply(); // { // std::cout << "Extracting..." << std::endl; - // auto mesh = lsSmartPointer>::New(); - // lsToSurfaceMesh(sphere1, mesh).apply(); + // auto mesh = ls::SmartPointer>::New(); + // ls::ToSurfaceMesh(sphere1, mesh).apply(); // mesh->print(); - // lsVTKWriter(mesh, "after.vtk").apply(); + // ls::VTKWriter(mesh, "after.vtk").apply(); // } return 0; diff --git a/tests/Advection2D/Advection2D.cpp b/tests/Advection2D/Advection2D.cpp index 33faeedb..51aa24dc 100644 --- a/tests/Advection2D/Advection2D.cpp +++ b/tests/Advection2D/Advection2D.cpp @@ -16,6 +16,8 @@ #include #include +namespace ls = viennals; + /** This example shows how to use lsAdvect to isotropically grow a 2D circle with reflective/symmetric boundary conditions. @@ -23,7 +25,7 @@ */ // implement own velocity field -class velocityField : public lsVelocityField { +class velocityField : public ls::VelocityField { public: double getScalarVelocity(const std::array & /*coordinate*/, int /*material*/, @@ -51,48 +53,48 @@ int main() { double gridDelta = 0.5; double bounds[2 * D] = {-extent, extent, -extent, extent}; - lsDomain::BoundaryType boundaryCons[D]; + ls::Domain::BoundaryType boundaryCons[D]; for (unsigned i = 0; i < D; ++i) { - boundaryCons[i] = lsDomain::BoundaryType::REFLECTIVE_BOUNDARY; + boundaryCons[i] = ls::Domain::BoundaryType::REFLECTIVE_BOUNDARY; } - auto sphere1 = - lsSmartPointer>::New(bounds, boundaryCons, gridDelta); + auto sphere1 = ls::SmartPointer>::New( + bounds, boundaryCons, gridDelta); double origin[D] = {5., 0.}; double radius = 7.3; - lsMakeGeometry( - sphere1, lsSmartPointer>::New(origin, radius)) + ls::MakeGeometry( + sphere1, ls::SmartPointer>::New(origin, radius)) .apply(); // { - // auto mesh = lsSmartPointer>::New(); - // lsToMesh(sphere1, mesh).apply(); - // lsVTKWriter(mesh, "sphere.vtk").apply(); + // auto mesh = ls::SmartPointer>::New(); + // ls::ToMesh(sphere1, mesh).apply(); + // ls::VTKWriter(mesh, "sphere.vtk").apply(); - // lsToSurfaceMesh(sphere1, mesh).apply(); - // lsVTKWriter(mesh, "before2D.vtk").apply(); + // ls::ToSurfaceMesh(sphere1, mesh).apply(); + // ls::VTKWriter(mesh, "before2D.vtk").apply(); // } // lsExpand(sphere1, 3).apply(); // Fill point data with original point IDs to see how LS changed { - typename lsPointData::ScalarDataType pointIDs( + typename ls::PointData::ScalarDataType pointIDs( sphere1->getNumberOfPoints()); std::iota(std::begin(pointIDs), std::end(pointIDs), 0); sphere1->getPointData().insertNextScalarData(pointIDs, "originalIDs"); } // { - // auto mesh = lsSmartPointer>::New(); + // auto mesh = ls::SmartPointer>::New(); // lsToMesh(sphere1, mesh, true, true).apply(); - // lsVTKWriter(mesh, "initial.vtp").apply(); + // ls::VTKWriter(mesh, "initial.vtp").apply(); // lsToSurfaceMesh(sphere1, mesh).apply(); - // lsVTKWriter(mesh, "surface_initial.vtp").apply(); + // ls::VTKWriter(mesh, "surface_initial.vtp").apply(); // } // Advect the sphere - auto velocities = lsSmartPointer::New(); + auto velocities = ls::SmartPointer::New(); // std::cout << "Number of points: " << // sphere1->getDomain().getNumberOfPoints() @@ -100,11 +102,11 @@ int main() { // std::cout << "Advecting" << std::endl; - lsAdvect advectionKernel; + ls::Advect advectionKernel; advectionKernel.insertNextLevelSet(sphere1); advectionKernel.setVelocityField(velocities); advectionKernel.setIntegrationScheme( - lsIntegrationSchemeEnum::LAX_FRIEDRICHS_1ST_ORDER); + ls::IntegrationSchemeEnum::LAX_FRIEDRICHS_1ST_ORDER); advectionKernel.setAdvectionTime(20.); advectionKernel.apply(); @@ -118,24 +120,24 @@ int main() { // lsExpand(sphere1, 5).apply(); // { - // auto mesh = lsSmartPointer>::New(); + // auto mesh = ls::SmartPointer>::New(); // lsToMesh(sphere1, mesh).apply(); - // lsVTKWriter(mesh, "final.vtp").apply(); + // ls::VTKWriter(mesh, "final.vtp").apply(); // lsToSurfaceMesh(sphere1, mesh).apply(); - // lsVTKWriter(mesh, "surface_final.vtp").apply(); + // ls::VTKWriter(mesh, "surface_final.vtp").apply(); // } // std::cout << "Pruning" << std::endl; - // lsPrune(sphere1).apply(); + // Prune(sphere1).apply(); // std::cout << "Expanding" << std::endl; - // lsExpand(sphere1, 2).apply(); + // ls::Expand(sphere1, 2).apply(); // { - // auto mesh = lsSmartPointer>::New(); + // auto mesh = ls::SmartPointer>::New(); // std::cout << "Extracting..." << std::endl; - // lsToSurfaceMesh(sphere1, mesh).apply(); + // ls::ToSurfaceMesh(sphere1, mesh).apply(); // mesh->print(); - // lsVTKWriter(mesh, "after2D.vtk").apply(); + // ls::VTKWriter(mesh, "after2D.vtk").apply(); // } return 0; diff --git a/tests/AdvectionBenchmark/AdvectionBenchmark.cpp b/tests/AdvectionBenchmark/AdvectionBenchmark.cpp index 2e2240eb..84054d0f 100644 --- a/tests/AdvectionBenchmark/AdvectionBenchmark.cpp +++ b/tests/AdvectionBenchmark/AdvectionBenchmark.cpp @@ -9,13 +9,15 @@ #include #include +namespace ls = viennals; + /** This example measures the time it takes for several advection steps to run. \example AdvectionBenchmark.cpp */ // implement own velocity field -class velocityField : public lsVelocityField { +class velocityField : public ls::VelocityField { std::vector &data_; public: @@ -55,25 +57,25 @@ int main() { double gridDelta = 0.25; - auto sphere1 = lsSmartPointer>::New(gridDelta); + auto sphere1 = ls::SmartPointer>::New(gridDelta); double origin[3] = {5., 0., 0.}; double radius = 7.3; - lsMakeGeometry( - sphere1, lsSmartPointer>::New(origin, radius)) + ls::MakeGeometry( + sphere1, ls::SmartPointer>::New(origin, radius)) .apply(); { std::cout << "Extracting..." << std::endl; - auto mesh = lsSmartPointer>::New(); - lsToSurfaceMesh(sphere1, mesh).apply(); - lsVTKWriter(mesh, "before.vtk").apply(); + auto mesh = ls::SmartPointer>::New(); + ls::ToSurfaceMesh(sphere1, mesh).apply(); + ls::VTKWriter(mesh, "before.vtk").apply(); } // instantiate velocities std::vector vels(sphere1->getNumberOfPoints() * 100, 0.31415); - auto velocities = lsSmartPointer::New(vels); + auto velocities = ls::SmartPointer::New(vels); std::cout << "Advecting" << std::endl; @@ -82,12 +84,12 @@ int main() { for (unsigned cores = 1; cores < 33; cores *= 2) { omp_set_num_threads(cores); - auto levelSet = lsSmartPointer>::New(gridDelta); + auto levelSet = ls::SmartPointer>::New(gridDelta); levelSet->deepCopy(sphere1); levelSet->getDomain().segment(); - lsAdvect advectionKernel; + ls::Advect advectionKernel; advectionKernel.insertNextLevelSet(levelSet); advectionKernel.setVelocityField(velocities); @@ -102,9 +104,10 @@ int main() { .count() << "\n"; - auto mesh = lsSmartPointer>::New(); - lsToSurfaceMesh(levelSet, mesh).apply(); - lsVTKWriter(mesh, "cores" + std::to_string(cores) + ".vtk").apply(); + auto mesh = ls::SmartPointer>::New(); + ls::ToSurfaceMesh(levelSet, mesh).apply(); + ls::VTKWriter(mesh, "cores" + std::to_string(cores) + ".vtk") + .apply(); } return 0; diff --git a/tests/AdvectionPlane/AdvectionPlane.cpp b/tests/AdvectionPlane/AdvectionPlane.cpp index bd480ddf..6af9f821 100644 --- a/tests/AdvectionPlane/AdvectionPlane.cpp +++ b/tests/AdvectionPlane/AdvectionPlane.cpp @@ -13,6 +13,8 @@ #include #include +namespace ls = viennals; + /** Minimal example of a plane surface being moved using lsAdvect @@ -20,7 +22,7 @@ */ // implement own velocity field -class velocityField : public lsVelocityField { +class velocityField : public ls::VelocityField { public: double getScalarVelocity(const std::array & /*coordinate*/, int /*material*/, @@ -46,55 +48,55 @@ int main() { double gridDelta = 1; double bounds[2 * D] = {-extent, extent, -extent, extent}; - lsBoundaryConditionEnum boundaryCons[D]; - boundaryCons[0] = lsBoundaryConditionEnum::REFLECTIVE_BOUNDARY; - boundaryCons[1] = lsBoundaryConditionEnum::INFINITE_BOUNDARY; + ls::BoundaryConditionEnum boundaryCons[D]; + boundaryCons[0] = ls::BoundaryConditionEnum::REFLECTIVE_BOUNDARY; + boundaryCons[1] = ls::BoundaryConditionEnum::INFINITE_BOUNDARY; - auto plane = - lsSmartPointer>::New(bounds, boundaryCons, gridDelta); + auto plane = ls::SmartPointer>::New( + bounds, boundaryCons, gridDelta); double origin[D] = {0., 0.}; double normal[D] = {2., 1.}; - lsMakeGeometry( - plane, lsSmartPointer>::New(origin, normal)) + ls::MakeGeometry( + plane, ls::SmartPointer>::New(origin, normal)) .apply(); // { - // auto mesh = lsSmartPointer>::New(); + // auto mesh = ls::ls::SmartPointer>::New(); // std::cout << "Extracting..." << std::endl; - // lsToSurfaceMesh(plane, mesh).apply(); - // lsVTKWriter(mesh, "before.vtk").apply(); + // ls::ToSurfaceMesh(plane, mesh).apply(); + // ls::VTKWriter(mesh, "before.vtk").apply(); - // lsToMesh(plane, mesh).apply(); - // lsVTKWriter(mesh, "beforeLS.vtk").apply(); + // ls::ToMesh(plane, mesh).apply(); + // ls::VTKWriter(mesh, "beforeLS.vtk").apply(); // mesh->print(); // } - auto velocities = lsSmartPointer::New(); + auto velocities = ls::SmartPointer::New(); // std::cout << "number of Points: " << plane->getNumberOfPoints() << // std::endl; // std::cout << "Advecting" << std::endl; - lsAdvect advectionKernel(plane, velocities); + ls::Advect advectionKernel(plane, velocities); advectionKernel.apply(); double advectionTime = advectionKernel.getAdvectedTime(); // std::cout << "Time difference: " << advectionTime << std::endl; LSTEST_ASSERT_VALID_LS(plane, double, D) - // lsPrune(plane).apply(); - // lsExpand(plane, 2).apply(); + // Prune(plane).apply(); + // ls::Expand(plane, 2).apply(); // std::cout << "Extracting..." << std::endl; - // auto mesh = lsSmartPointer>::New(); - // lsToSurfaceMesh(plane, mesh).apply(); + // auto mesh = ls::ls::SmartPointer>::New(); + // ls::ToSurfaceMesh(plane, mesh).apply(); // // mesh.print(); - // lsVTKWriter(mesh, "after.vtk").apply(); + // ls::VTKWriter(mesh, "after.vtk").apply(); return 0; } diff --git a/tests/BooleanOperation/BooleanOperation.cpp b/tests/BooleanOperation/BooleanOperation.cpp index 1d196640..8a369762 100644 --- a/tests/BooleanOperation/BooleanOperation.cpp +++ b/tests/BooleanOperation/BooleanOperation.cpp @@ -11,6 +11,8 @@ #include #include +namespace ls = viennals; + /** Example of boolean operations on level sets using two spheres. @@ -28,32 +30,32 @@ int main() { bounds[4] = -20; bounds[5] = 20; } - typename lsDomain::BoundaryType boundaryCons[D]; + typename ls::Domain::BoundaryType boundaryCons[D]; for (unsigned i = 0; i < D - 1; ++i) { - boundaryCons[i] = lsDomain::BoundaryType::REFLECTIVE_BOUNDARY; + boundaryCons[i] = ls::Domain::BoundaryType::REFLECTIVE_BOUNDARY; } - boundaryCons[D - 1] = lsDomain::BoundaryType::INFINITE_BOUNDARY; + boundaryCons[D - 1] = ls::Domain::BoundaryType::INFINITE_BOUNDARY; - auto sphere1 = - lsSmartPointer>::New(bounds, boundaryCons, gridDelta); - auto sphere2 = - lsSmartPointer>::New(bounds, boundaryCons, gridDelta); + auto sphere1 = ls::SmartPointer>::New( + bounds, boundaryCons, gridDelta); + auto sphere2 = ls::SmartPointer>::New( + bounds, boundaryCons, gridDelta); double origin[3] = {0., 0., 0.}; double radius = 15.7; - lsMakeGeometry( - sphere1, lsSmartPointer>::New(origin, radius)) + ls::MakeGeometry( + sphere1, ls::SmartPointer>::New(origin, radius)) .apply(); origin[0] = 15.0; radius = 9.5; - lsMakeGeometry( - sphere2, lsSmartPointer>::New(origin, radius)) + ls::MakeGeometry( + sphere2, ls::SmartPointer>::New(origin, radius)) .apply(); // put some data into either LS { - using ScalarDataType = lsDomain::PointDataType::ScalarDataType; + using ScalarDataType = ls::Domain::PointDataType::ScalarDataType; ScalarDataType scalars1(sphere1->getNumberOfPoints(), 0.); sphere1->getPointData().insertNextScalarData(std::move(scalars1), "originID"); @@ -64,33 +66,34 @@ int main() { } // { - // auto mesh1 = lsSmartPointer>::New(); - // auto mesh2 = lsSmartPointer>::New(); + // auto mesh1 = ls::ls::SmartPointer>::New(); + // auto mesh2 = ls::ls::SmartPointer>::New(); // std::cout << "Extracting..." << std::endl; - // lsToSurfaceMesh(sphere1, mesh1).apply(); - // lsToSurfaceMesh(sphere2, mesh2).apply(); + // ls::ToSurfaceMesh(sphere1, mesh1).apply(); + // ls::ToSurfaceMesh(sphere2, mesh2).apply(); - // lsVTKWriter(mesh1, "sphere1.vtk").apply(); - // lsVTKWriter(mesh2, "sphere2.vtk").apply(); + // ls::VTKWriter(mesh1, "sphere1.vtk").apply(); + // ls::VTKWriter(mesh2, "sphere2.vtk").apply(); - // lsToMesh(sphere1, mesh1).apply(); - // lsToMesh(sphere2, mesh2).apply(); + // ls::ToMesh(sphere1, mesh1).apply(); + // ls::ToMesh(sphere2, mesh2).apply(); - // lsVTKWriter(mesh1, "LS1.vtk").apply(); - // lsVTKWriter(mesh2, "LS2.vtk").apply(); + // ls::VTKWriter(mesh1, "LS1.vtk").apply(); + // ls::VTKWriter(mesh2, "LS2.vtk").apply(); // } // Perform a boolean operation - lsBooleanOperation(sphere1, sphere2, lsBooleanOperationEnum::UNION) + ls::BooleanOperation(sphere1, sphere2, + ls::BooleanOperationEnum::UNION) .apply(); LSTEST_ASSERT_VALID_LS(sphere1, double, D) // std::cout << "Extracting..." << std::endl; - // auto mesh = lsSmartPointer>::New(); - // lsToSurfaceMesh(sphere1, mesh).apply(); - // lsVTKWriter(mesh, "after.vtp").apply(); + // auto mesh = ls::ls::SmartPointer>::New(); + // ls::ToSurfaceMesh(sphere1, mesh).apply(); + // ls::VTKWriter(mesh, "after.vtp").apply(); return 0; } diff --git a/tests/BooleanOperationExactZero/BooleanOperationExactZero.cpp b/tests/BooleanOperationExactZero/BooleanOperationExactZero.cpp index 3eb97bb1..dcc960f1 100644 --- a/tests/BooleanOperationExactZero/BooleanOperationExactZero.cpp +++ b/tests/BooleanOperationExactZero/BooleanOperationExactZero.cpp @@ -18,15 +18,17 @@ \example BooleanOperationExactZero.cpp */ +namespace ls = viennals; + using NumericType = double; constexpr int D = 2; -using LSType = lsSmartPointer>; +using LSType = ls::SmartPointer>; void writeLS(LSType levelSet, std::string fileName) { - auto mesh = lsSmartPointer>::New(); - lsToMesh(levelSet, mesh, false).apply(); - lsVTKWriter(mesh, fileName).apply(); + auto mesh = ls::SmartPointer>::New(); + ls::ToMesh(levelSet, mesh, false).apply(); + ls::VTKWriter(mesh, fileName).apply(); } int main() { @@ -38,20 +40,21 @@ int main() { double extent = 10; double bounds[2 * D] = {-extent, extent, -extent, extent}; - typename lsDomain::BoundaryType boundaryCons[D]; + typename ls::Domain::BoundaryType boundaryCons[D]; boundaryCons[0] = - lsDomain::BoundaryType::REFLECTIVE_BOUNDARY; - boundaryCons[1] = lsDomain::BoundaryType::INFINITE_BOUNDARY; + ls::Domain::BoundaryType::REFLECTIVE_BOUNDARY; + boundaryCons[1] = + ls::Domain::BoundaryType::INFINITE_BOUNDARY; if constexpr (D == 3) { boundaryCons[1] = - lsDomain::BoundaryType::REFLECTIVE_BOUNDARY; + ls::Domain::BoundaryType::REFLECTIVE_BOUNDARY; boundaryCons[2] = - lsDomain::BoundaryType::INFINITE_BOUNDARY; + ls::Domain::BoundaryType::INFINITE_BOUNDARY; } - mask = lsSmartPointer>::New(bounds, boundaryCons, - gridDelta); + mask = ls::SmartPointer>::New( + bounds, boundaryCons, gridDelta); } // make mask geometry ( just a simple box ) @@ -64,7 +67,8 @@ int main() { max[1] = 5.; max[2] = 10.; } - lsMakeGeometry(mask, lsSmartPointer>::New(min, max)) + ls::MakeGeometry(mask, + ls::SmartPointer>::New(min, max)) .apply(); // writeLS(mask, "mask_initial.vtp"); } @@ -76,19 +80,21 @@ int main() { double normal[D] = {}; origin[D - 1] = 1.; normal[D - 1] = 1.; - lsMakeGeometry(substrate, - lsSmartPointer>::New(origin, normal)) + ls::MakeGeometry( + substrate, + ls::SmartPointer>::New(origin, normal)) .apply(); // writeLS(substrate, "subs_initial.vtp"); } - lsBooleanOperation(substrate, mask, lsBooleanOperationEnum::UNION).apply(); + ls::BooleanOperation(substrate, mask, ls::BooleanOperationEnum::UNION) + .apply(); // writeLS(substrate, "subs_afterBool.vtp"); // iterate through all values and check if they are correct unsigned counter = 0; - for (hrleConstSparseIterator::DomainType> it( + for (hrleConstSparseIterator::DomainType> it( substrate->getDomain()); !it.isFinished(); ++it) { auto indices = it.getStartIndices(); diff --git a/tests/BooleanOperationExactZero1/BooleanOperationExactZero1.cpp b/tests/BooleanOperationExactZero1/BooleanOperationExactZero1.cpp index 686a53ab..8c78872c 100644 --- a/tests/BooleanOperationExactZero1/BooleanOperationExactZero1.cpp +++ b/tests/BooleanOperationExactZero1/BooleanOperationExactZero1.cpp @@ -16,17 +16,19 @@ positive numbers \example BooleanOperationExactZero1.cpp */ +namespace ls = viennals; + using NumericType = double; constexpr int D = 2; -using LSType = lsSmartPointer>; +using LSType = ls::SmartPointer>; // void writeLS(LSType levelSet, std::string fileName) { -// auto mesh = lsSmartPointer>::New(); +// auto mesh = ls::SmartPointer>::New(); // lsToMesh(levelSet, mesh).apply(); -// lsVTKWriter(mesh, fileName).apply(); +// ls::VTKWriter(mesh, fileName).apply(); // lsToSurfaceMesh(levelSet, mesh).apply(); -// lsVTKWriter(mesh, "surf_" + fileName).apply(); +// ls::VTKWriter(mesh, "surf_" + fileName).apply(); // } int main() { @@ -38,20 +40,21 @@ int main() { double extent = 10; double bounds[2 * D] = {-extent, extent, -extent, extent}; - typename lsDomain::BoundaryType boundaryCons[D]; + typename ls::Domain::BoundaryType boundaryCons[D]; boundaryCons[0] = - lsDomain::BoundaryType::REFLECTIVE_BOUNDARY; - boundaryCons[1] = lsDomain::BoundaryType::INFINITE_BOUNDARY; + ls::Domain::BoundaryType::REFLECTIVE_BOUNDARY; + boundaryCons[1] = + ls::Domain::BoundaryType::INFINITE_BOUNDARY; if constexpr (D == 3) { boundaryCons[1] = - lsDomain::BoundaryType::REFLECTIVE_BOUNDARY; + ls::Domain::BoundaryType::REFLECTIVE_BOUNDARY; boundaryCons[2] = - lsDomain::BoundaryType::INFINITE_BOUNDARY; + ls::Domain::BoundaryType::INFINITE_BOUNDARY; } - mask = lsSmartPointer>::New(bounds, boundaryCons, - gridDelta); + mask = ls::SmartPointer>::New( + bounds, boundaryCons, gridDelta); } constexpr double yVal = 0.5; @@ -66,7 +69,8 @@ int main() { // max[1] = 5.; // max[2] = 10.; // } - lsMakeGeometry(mask, lsSmartPointer>::New(min, max)) + ls::MakeGeometry(mask, + ls::SmartPointer>::New(min, max)) .apply(); // writeLS(mask, "mask_initial.vtp"); } @@ -82,30 +86,30 @@ int main() { // max[1] = 5.; // max[2] = 10.; // } - lsMakeGeometry(substrate, - lsSmartPointer>::New(min, max)) + ls::MakeGeometry(substrate, + ls::SmartPointer>::New(min, max)) .apply(); // writeLS(substrate, "subs_initial.vtp"); } - lsBooleanOperation boolOp(substrate, mask, - lsBooleanOperationEnum::UNION); + ls::BooleanOperation boolOp(substrate, mask, + ls::BooleanOperationEnum::UNION); boolOp.setPruneResult(false); boolOp.apply(); // writeLS(substrate, "subs_afterBool.vtp"); - lsPrune pruner(substrate); + ls::Prune pruner(substrate); pruner.setRemoveStrayZeros(true); pruner.apply(); // writeLS(substrate, "subs_afterPrune1.vtp"); - lsPrune(substrate).apply(); + ls::Prune(substrate).apply(); // writeLS(substrate, "subs_afterPrune2.vtp"); - lsCheck checker(substrate); + ls::Check checker(substrate); checker.apply(); LSTEST_ASSERT(checker.isValid()); diff --git a/tests/BoundaryConditions/BoundaryConditions.cpp b/tests/BoundaryConditions/BoundaryConditions.cpp index e5c8bbdf..95824c17 100644 --- a/tests/BoundaryConditions/BoundaryConditions.cpp +++ b/tests/BoundaryConditions/BoundaryConditions.cpp @@ -14,6 +14,8 @@ \example BoundaryConditions.cpp */ +namespace ls = viennals; + int main() { constexpr int D = 3; @@ -23,27 +25,28 @@ int main() { double extent = 15; double bounds[2 * D] = {-extent, extent, -extent, extent, -extent, extent}; - lsDomain::BoundaryType boundaryCons[3]; + ls::Domain::BoundaryType boundaryCons[3]; for (unsigned i = 0; i < D - 1; ++i) - boundaryCons[i] = lsDomain::BoundaryType::REFLECTIVE_BOUNDARY; + boundaryCons[i] = ls::Domain::BoundaryType::REFLECTIVE_BOUNDARY; - boundaryCons[2] = lsDomain::BoundaryType::INFINITE_BOUNDARY; + boundaryCons[2] = ls::Domain::BoundaryType::INFINITE_BOUNDARY; - auto levelSet = - lsSmartPointer>::New(bounds, boundaryCons, gridDelta); + auto levelSet = ls::SmartPointer>::New( + bounds, boundaryCons, gridDelta); hrleVectorType origin(0., 0., 0.); hrleVectorType normalVector(0., 1., 1.); - lsMakeGeometry( - levelSet, lsSmartPointer>::New(origin, normalVector)) + ls::MakeGeometry( + levelSet, + ls::SmartPointer>::New(origin, normalVector)) .apply(); // { // std::cout << "Extracting..." << std::endl; - // auto mesh = lsSmartPointer>::New(); - // lsToSurfaceMesh(levelSet, mesh).apply(); - // lsVTKWriter(mesh, "plane.vtk").apply(); + // auto mesh = ls::ls::SmartPointer>::New(); + // ls::ToSurfaceMesh(levelSet, mesh).apply(); + // ls::VTKWriter(mesh, "plane.vtk").apply(); // } LSTEST_ASSERT_VALID_LS(levelSet, double, D) diff --git a/tests/CalculateCurvatures/CalculateCurvatures.cpp b/tests/CalculateCurvatures/CalculateCurvatures.cpp index 029a98f2..c5431c0a 100644 --- a/tests/CalculateCurvatures/CalculateCurvatures.cpp +++ b/tests/CalculateCurvatures/CalculateCurvatures.cpp @@ -19,6 +19,8 @@ \example calculateCurvatures.cpp */ +namespace ls = viennals; + constexpr int D = 3; typedef double NumericType; @@ -28,22 +30,22 @@ int main() { NumericType gridDelta = 0.5; - auto sphere = lsSmartPointer>::New(gridDelta); + auto sphere = ls::SmartPointer>::New(gridDelta); NumericType origin[3] = {5., 0., 0.}; NumericType radius = 10.0; - lsMakeGeometry( - sphere, lsSmartPointer>::New(origin, radius)) + ls::MakeGeometry( + sphere, ls::SmartPointer>::New(origin, radius)) .apply(); - lsExpand(sphere, 5).apply(); + ls::Expand(sphere, 5).apply(); - lsCalculateCurvatures calcCurve(sphere); + ls::CalculateCurvatures calcCurve(sphere); if (D == 2) { - calcCurve.setCurvatureType(lsCurvatureEnum::MEAN_CURVATURE); + calcCurve.setCurvatureType(ls::CurvatureEnum::MEAN_CURVATURE); } else { - calcCurve.setCurvatureType(lsCurvatureEnum::MEAN_AND_GAUSSIAN_CURVATURE); + calcCurve.setCurvatureType(ls::CurvatureEnum::MEAN_AND_GAUSSIAN_CURVATURE); } calcCurve.apply(); @@ -55,7 +57,7 @@ int main() { double analyticCurvature = 1. / radius; hrleSizeType numberOfActivePoints = 0; double sum = 0.; - for (hrleConstSparseIterator::DomainType> + for (hrleConstSparseIterator::DomainType> it(sphere->getDomain()); !it.isFinished(); ++it) { if (NumericType value = it.getValue(); @@ -74,12 +76,12 @@ int main() { // sphere->getPointData().insertNextScalarData(analytic, // "analyticCurvatures"); - // auto mesh = lsSmartPointer>::New(); + // auto mesh = ls::SmartPointer>::New(); // lsToSurfaceMesh(sphere, mesh).apply(); - // lsVTKWriter(mesh, "curvatures.vtp").apply(); + // ls::VTKWriter(mesh, "curvatures.vtp").apply(); - // lsToMesh(sphere, mesh, true, true).apply(); - // auto writer = lsVTKWriter(); + // ls::ToMesh(sphere, mesh, true, true).apply(); + // auto writer = ls::VTKWriter(); // writer.setMesh(mesh); // writer.setFileName("curvatures.vtk"); // writer.apply(); diff --git a/tests/CalculateNormalVectors/CalculateNormalVectors.cpp b/tests/CalculateNormalVectors/CalculateNormalVectors.cpp index 802f238e..fb09d5a1 100644 --- a/tests/CalculateNormalVectors/CalculateNormalVectors.cpp +++ b/tests/CalculateNormalVectors/CalculateNormalVectors.cpp @@ -17,6 +17,8 @@ \example calculateNormalVectors.cpp */ +namespace ls = viennals; + int main() { constexpr int D = 3; @@ -27,43 +29,43 @@ int main() { double gridDelta = 0.25; double bounds[2 * D] = {-extent, extent, -extent, extent, -extent, extent}; - lsDomain::BoundaryType boundaryCons[3]; + ls::Domain::BoundaryType boundaryCons[3]; for (unsigned i = 0; i < D; ++i) - boundaryCons[i] = lsDomain::BoundaryType::REFLECTIVE_BOUNDARY; + boundaryCons[i] = ls::Domain::BoundaryType::REFLECTIVE_BOUNDARY; - auto sphere1 = - lsSmartPointer>::New(bounds, boundaryCons, gridDelta); + auto sphere1 = ls::SmartPointer>::New( + bounds, boundaryCons, gridDelta); double origin[3] = {5., 0., 0.}; double radius = 7.3; - lsMakeGeometry( - sphere1, lsSmartPointer>::New(origin, radius)) + ls::MakeGeometry( + sphere1, ls::SmartPointer>::New(origin, radius)) .apply(); { - auto sphere2 = lsSmartPointer>::New( + auto sphere2 = ls::SmartPointer>::New( bounds, boundaryCons, gridDelta); origin[0] = -5.; - lsMakeGeometry( - sphere2, lsSmartPointer>::New(origin, radius)) + ls::MakeGeometry( + sphere2, ls::SmartPointer>::New(origin, radius)) .apply(); } // std::cout << "Expanding..." << std::endl; - lsExpand(sphere1, 3).apply(); + ls::Expand(sphere1, 3).apply(); // std::cout << "Number of points: " << sphere1->getNumberOfPoints() // << std::endl; // normal vectors are only valid as long as the underlying // level set does not change - lsCalculateNormalVectors(sphere1).apply(); + ls::CalculateNormalVectors(sphere1).apply(); - // auto mesh = lsSmartPointer>::New(); - // lsToMesh(sphere1, mesh, true, true).apply(); + // auto mesh = ls::SmartPointer>::New(); + // ls::ToMesh(sphere1, mesh, true, true).apply(); - // auto writer = lsVTKWriter(); + // auto writer = ls::VTKWriter(); // writer.setMesh(mesh); // writer.setFileName("explicit.vtk"); // writer.apply(); diff --git a/tests/ConvexHull/ConvexHull.cpp b/tests/ConvexHull/ConvexHull.cpp index 90f5edb8..a6b68b9d 100644 --- a/tests/ConvexHull/ConvexHull.cpp +++ b/tests/ConvexHull/ConvexHull.cpp @@ -9,6 +9,8 @@ #define PI 3.141592 +namespace ls = viennals; + int main() { constexpr int D = 2; @@ -19,16 +21,17 @@ int main() { // double gridDelta = 1; // // double bounds[2 * D] = {-extent, extent, -extent, extent}; - // lsDomain::BoundaryType boundaryCons[D]; + // ls::Domain::BoundaryType boundaryCons[D]; // for (unsigned i = 0; i < D; ++i) - // boundaryCons[i] = lsDomain::BoundaryType::REFLECTIVE_BOUNDARY; - // lsDomain sphere1(bounds, boundaryCons, gridDelta); + // boundaryCons[i] = ls::Domain::BoundaryType::REFLECTIVE_BOUNDARY; + // ls::Domain sphere1(bounds, boundaryCons, gridDelta); std::random_device rd; std::mt19937 gen(rd()); std::uniform_real_distribution<> dis(0., 1.); - auto cloud = lsSmartPointer>::New(); + auto cloud = ls::SmartPointer>::New(); // generate a circle of points int numberOfPoints = 10000; @@ -51,26 +54,27 @@ int main() { // cloud.insertNextPoint(hrleVectorType(0.1, 0.5)); // cloud.insertNextPoint(hrleVectorType(-1, 0.2)); - auto pointMesh = lsSmartPointer>::New(); + auto pointMesh = ls::SmartPointer>::New(); for (unsigned i = 0; i < cloud->points.size(); ++i) { pointMesh->nodes.push_back( std::array{cloud->points[i][0], cloud->points[i][1], 0.}); pointMesh->vertices.push_back(std::array{i}); } - lsVTKWriter(pointMesh, lsFileFormatEnum::VTP, "points.vtp").apply(); + ls::VTKWriter(pointMesh, ls::FileFormatEnum::VTP, "points.vtp") + .apply(); - lsMakeGeometry geom; - auto levelSet = lsSmartPointer>::New(); + ls::MakeGeometry geom; + auto levelSet = ls::SmartPointer>::New(); geom.setLevelSet(levelSet); geom.setGeometry(cloud); geom.apply(); { - auto mesh = lsSmartPointer>::New(); + auto mesh = ls::SmartPointer>::New(); std::cout << "Extracting..." << std::endl; - lsToSurfaceMesh(levelSet, mesh).apply(); + ls::ToSurfaceMesh(levelSet, mesh).apply(); mesh->print(); - lsVTKWriter(mesh, "LSMesh.vtk").apply(); + ls::VTKWriter(mesh, "LSMesh.vtk").apply(); } return 0; diff --git a/tests/ConvexHull3D/ConvexHull3D.cpp b/tests/ConvexHull3D/ConvexHull3D.cpp index 52aa5ab5..e7cea221 100644 --- a/tests/ConvexHull3D/ConvexHull3D.cpp +++ b/tests/ConvexHull3D/ConvexHull3D.cpp @@ -13,6 +13,8 @@ #define PI 3.141592 +namespace ls = viennals; + int main() { constexpr int D = 3; @@ -23,16 +25,17 @@ int main() { // double gridDelta = 1; // // double bounds[2 * D] = {-extent, extent, -extent, extent}; - // lsDomain::BoundaryType boundaryCons[D]; + // ls::Domain::BoundaryType boundaryCons[D]; // for (unsigned i = 0; i < D; ++i) - // boundaryCons[i] = lsDomain::BoundaryType::REFLECTIVE_BOUNDARY; - // lsDomain sphere1(bounds, boundaryCons, gridDelta); + // boundaryCons[i] = ls::Domain::BoundaryType::REFLECTIVE_BOUNDARY; + // ls::Domain sphere1(bounds, boundaryCons, gridDelta); // auto seed = 1572962798; // std::time(nullptr); // std::cout << seed << std::endl; // std::srand(seed); - auto cloud = lsSmartPointer>::New(); + auto cloud = ls::SmartPointer>::New(); // generate a circle of points ---------------------------------------------- // std::random_device rd; @@ -98,48 +101,49 @@ int main() { cloud->insertNextPoint(hrleVectorType(x, y, height)); } - auto mesh = lsSmartPointer>::New(); - lsConvexHull(mesh, cloud).apply(); + auto mesh = ls::SmartPointer>::New(); + ls::ConvexHull(mesh, cloud).apply(); - auto pointMesh = lsSmartPointer>::New(); + auto pointMesh = ls::SmartPointer>::New(); for (unsigned i = 0; i < cloud->points.size(); ++i) { pointMesh->nodes.push_back(std::array{ cloud->points[i][0], cloud->points[i][1], cloud->points[i][2]}); pointMesh->vertices.push_back(std::array{i}); } std::cout << "Output point cloud" << std::endl; - lsVTKWriter(pointMesh, lsFileFormatEnum::VTP, "points.vtp").apply(); + ls::VTKWriter(pointMesh, ls::FileFormatEnum::VTP, "points.vtp") + .apply(); // std::cout << "Output surface mesh" << std::endl; // mesh.print(); - // lsVTKWriter(mesh, lsFileFormatEnum::VTP, "hull.vtp").apply(); + // ls::VTKWriter(mesh, ls::FileFormatEnum::VTP, "hull.vtp").apply(); std::cout << "create level set" << std::endl; - auto levelSet = lsSmartPointer>::New(0.18); - lsMakeGeometry geom; + auto levelSet = ls::SmartPointer>::New(0.18); + ls::MakeGeometry geom; geom.setLevelSet(levelSet); geom.setGeometry(cloud); geom.apply(); // now make into level set - // lsDomain levelSet(0.3); - // lsFromSurfaceMesh(levelSet, mesh).apply(); + // ls::Domain levelSet(0.3); + // FromSurfaceMesh(levelSet, mesh).apply(); - auto LSMesh = lsSmartPointer>::New(); + auto LSMesh = ls::SmartPointer>::New(); std::cout << "Output level set grid" << std::endl; - lsToMesh(levelSet, LSMesh).apply(); - lsVTKWriter(LSMesh, lsFileFormatEnum::VTP, "LS.vtp").apply(); + ls::ToMesh(levelSet, LSMesh).apply(); + ls::VTKWriter(LSMesh, ls::FileFormatEnum::VTP, "LS.vtp").apply(); std::cout << "Output level set surface" << std::endl; - lsToSurfaceMesh(levelSet, LSMesh).apply(); - lsVTKWriter(LSMesh, lsFileFormatEnum::VTP, "LSmesh.vtp").apply(); + ls::ToSurfaceMesh(levelSet, LSMesh).apply(); + ls::VTKWriter(LSMesh, ls::FileFormatEnum::VTP, "LSmesh.vtp").apply(); // { - // lsMesh<> mesh; + // Mesh<> mesh; // std::cout << "Extracting..." << std::endl; - // lsToSurfaceMesh(sphere1, mesh).apply(); + // ls::ToSurfaceMesh(sphere1, mesh).apply(); // mesh.print(); - // lsVTKWriter(mesh, "after2D.vtk").apply(); + // ls::VTKWriter(mesh, "after2D.vtk").apply(); // } return 0; diff --git a/tests/DiskMesh/DiskMesh.cpp b/tests/DiskMesh/DiskMesh.cpp index b670a37d..eaa02857 100644 --- a/tests/DiskMesh/DiskMesh.cpp +++ b/tests/DiskMesh/DiskMesh.cpp @@ -16,6 +16,8 @@ \example Make3DSphere.cpp */ +namespace ls = viennals; + int main() { constexpr int D = 3; @@ -24,45 +26,46 @@ int main() { double gridDelta = 0.4; - auto sphere1 = - lsSmartPointer>::New(gridDelta); //, boundaryCons); + auto sphere1 = ls::SmartPointer>::New( + gridDelta); //, boundaryCons); - auto sphere2 = - lsSmartPointer>::New(gridDelta); //, boundaryCons); + auto sphere2 = ls::SmartPointer>::New( + gridDelta); //, boundaryCons); double origin[3] = {5., 0., 0.}; double radius = 7.3; - lsMakeGeometry( - sphere1, lsSmartPointer>::New(origin, radius)) + ls::MakeGeometry( + sphere1, ls::SmartPointer>::New(origin, radius)) .apply(); origin[0] = -5.; - lsMakeGeometry( - sphere2, lsSmartPointer>::New(origin, radius)) + ls::MakeGeometry( + sphere2, ls::SmartPointer>::New(origin, radius)) .apply(); std::cout << "Number of points: " << sphere1->getDomain().getNumberOfPoints() << std::endl; - auto mesh = lsSmartPointer>::New(); + auto mesh = ls::SmartPointer>::New(); std::cout << "Expanding..." << std::endl; - lsExpand(sphere1, 2).apply(); - lsExpand(sphere2, 2).apply(); + ls::Expand(sphere1, 2).apply(); + ls::Expand(sphere2, 2).apply(); std::cout << "Booling..." << std::endl; - lsBooleanOperation(sphere1, sphere2, lsBooleanOperationEnum::UNION) + ls::BooleanOperation(sphere1, sphere2, + ls::BooleanOperationEnum::UNION) .apply(); // std::cout << "Extracting..." << std::endl; - lsToDiskMesh(sphere1, mesh).apply(); + ls::ToDiskMesh(sphere1, mesh).apply(); // std::cout << "Disk mesh:" << std::endl; // mesh->print(); - // lsVTKWriter(mesh, "disks-" + std::to_string(radius) + + // ls::VTKWriter(mesh, "disks-" + std::to_string(radius) + // ".vtk").apply(); - // lsToSurfaceMesh(sphere1, mesh).apply(); + // ls::ToSurfaceMesh(sphere1, mesh).apply(); // std::cout << "Surface mesh:" << std::endl; // mesh->print(); - // lsVTKWriter(mesh, "surface-" + std::to_string(radius) + ".vtk") + // ls::VTKWriter(mesh, "surface-" + std::to_string(radius) + ".vtk") // .apply(); return 0; diff --git a/tests/Expand/Expand.cpp b/tests/Expand/Expand.cpp index 6c91b380..e0a679e6 100644 --- a/tests/Expand/Expand.cpp +++ b/tests/Expand/Expand.cpp @@ -15,6 +15,8 @@ \example Expand.cpp */ +namespace ls = viennals; + int main() { constexpr int D = 2; @@ -24,35 +26,35 @@ int main() { double gridDelta = 0.5; double bounds[2 * D] = {-extent, extent, -extent, extent}; - lsDomain::BoundaryType boundaryCons[D]; + ls::Domain::BoundaryType boundaryCons[D]; for (unsigned i = 0; i < D; ++i) - boundaryCons[i] = lsDomain::BoundaryType::REFLECTIVE_BOUNDARY; + boundaryCons[i] = ls::Domain::BoundaryType::REFLECTIVE_BOUNDARY; - auto sphere1 = - lsSmartPointer>::New(bounds, boundaryCons, gridDelta); + auto sphere1 = ls::SmartPointer>::New( + bounds, boundaryCons, gridDelta); double origin[D] = {5., 0.}; double radius = 7.3; - lsMakeGeometry( - sphere1, lsSmartPointer>::New(origin, radius)) + ls::MakeGeometry( + sphere1, ls::SmartPointer>::New(origin, radius)) .apply(); { - auto mesh = lsSmartPointer>::New(); - lsToMesh(sphere1, mesh).apply(); - lsVTKWriter(mesh, "sphere.vtk").apply(); + auto mesh = ls::SmartPointer>::New(); + ls::ToMesh(sphere1, mesh).apply(); + ls::VTKWriter(mesh, "sphere.vtk").apply(); } { - auto mesh = lsSmartPointer>::New(); - lsExpand(sphere1, 5).apply(); - lsToMesh(sphere1, mesh).apply(); - lsVTKWriter(mesh, "sphereExpanded.vtk").apply(); - - lsReduce(sphere1, 1).apply(); - lsToMesh(sphere1, mesh).apply(); - lsVTKWriter(mesh, "sphereReduced.vtk").apply(); + auto mesh = ls::SmartPointer>::New(); + ls::Expand(sphere1, 5).apply(); + ls::ToMesh(sphere1, mesh).apply(); + ls::VTKWriter(mesh, "sphereExpanded.vtk").apply(); + + ls::Reduce(sphere1, 1).apply(); + ls::ToMesh(sphere1, mesh).apply(); + ls::VTKWriter(mesh, "sphereReduced.vtk").apply(); } return 0; diff --git a/tests/Extrude/Extrude.cpp b/tests/Extrude/Extrude.cpp index e4dfdd05..35339b90 100644 --- a/tests/Extrude/Extrude.cpp +++ b/tests/Extrude/Extrude.cpp @@ -14,6 +14,8 @@ \example Extrude.cpp */ +namespace ls = viennals; + int main() { omp_set_num_threads(4); @@ -23,54 +25,55 @@ int main() { // 2D domain boundaries double bounds[2 * 2] = {-extent, extent, -extent, extent}; - lsDomain::BoundaryType boundaryCons[2]; - boundaryCons[0] = lsDomain::BoundaryType::REFLECTIVE_BOUNDARY; - boundaryCons[1] = lsDomain::BoundaryType::INFINITE_BOUNDARY; + ls::Domain::BoundaryType boundaryCons[2]; + boundaryCons[0] = ls::Domain::BoundaryType::REFLECTIVE_BOUNDARY; + boundaryCons[1] = ls::Domain::BoundaryType::INFINITE_BOUNDARY; - auto trench = - lsSmartPointer>::New(bounds, boundaryCons, gridDelta); + auto trench = ls::SmartPointer>::New( + bounds, boundaryCons, gridDelta); { double origin[2] = {0., 0.}; double normal[2] = {0., 1.}; - lsMakeGeometry( - trench, lsSmartPointer>::New(origin, normal)) + ls::MakeGeometry( + trench, ls::SmartPointer>::New(origin, normal)) .apply(); - auto cutOut = lsSmartPointer>::New(bounds, boundaryCons, - gridDelta); + auto cutOut = ls::SmartPointer>::New( + bounds, boundaryCons, gridDelta); double minPoint[2] = {-5., -5.}; double maxPoint[2] = {5., gridDelta}; - lsMakeGeometry( - cutOut, lsSmartPointer>::New(minPoint, maxPoint)) + ls::MakeGeometry( + cutOut, ls::SmartPointer>::New(minPoint, maxPoint)) .apply(); - lsBooleanOperation(trench, cutOut, - lsBooleanOperationEnum::RELATIVE_COMPLEMENT) + ls::BooleanOperation( + trench, cutOut, ls::BooleanOperationEnum::RELATIVE_COMPLEMENT) .apply(); } { - auto mesh = lsSmartPointer>::New(); - lsToMesh(trench, mesh).apply(); - lsVTKWriter(mesh, "trench_initial.vtp").apply(); + auto mesh = ls::SmartPointer>::New(); + ls::ToMesh(trench, mesh).apply(); + ls::VTKWriter(mesh, "trench_initial.vtp").apply(); } std::array extrudeExtent = {-5., 5.}; - std::array, 3> boundaryConds{ - lsBoundaryConditionEnum<3>::REFLECTIVE_BOUNDARY, - lsBoundaryConditionEnum<3>::INFINITE_BOUNDARY, - lsBoundaryConditionEnum<3>::REFLECTIVE_BOUNDARY}; - auto trench_3D = lsSmartPointer>::New(); - lsExtrude(trench, trench_3D, extrudeExtent, 2, boundaryConds).apply(); + std::array, 3> boundaryConds{ + ls::BoundaryConditionEnum<3>::REFLECTIVE_BOUNDARY, + ls::BoundaryConditionEnum<3>::INFINITE_BOUNDARY, + ls::BoundaryConditionEnum<3>::REFLECTIVE_BOUNDARY}; + auto trench_3D = ls::SmartPointer>::New(); + ls::Extrude(trench, trench_3D, extrudeExtent, 2, boundaryConds) + .apply(); { - auto mesh = lsSmartPointer>::New(); - lsToMesh(trench_3D, mesh).apply(); - lsVTKWriter(mesh, "trench_extrude.vtp").apply(); + auto mesh = ls::SmartPointer>::New(); + ls::ToMesh(trench_3D, mesh).apply(); + ls::VTKWriter(mesh, "trench_extrude.vtp").apply(); } return 0; diff --git a/tests/FeatureDetection/FeatureDetection.cpp b/tests/FeatureDetection/FeatureDetection.cpp index c03073b3..2b81687c 100644 --- a/tests/FeatureDetection/FeatureDetection.cpp +++ b/tests/FeatureDetection/FeatureDetection.cpp @@ -19,6 +19,8 @@ \example calculateCurvatures.cpp */ +namespace ls = viennals; + constexpr int D = 3; typedef double NumericType; @@ -40,28 +42,28 @@ int main() { bounds[5] = extent; } - typename lsDomain::BoundaryType boundaryCons[D]; + typename ls::Domain::BoundaryType boundaryCons[D]; for (unsigned i = 0; i < D - 1; ++i) { boundaryCons[i] = - lsDomain::BoundaryType::REFLECTIVE_BOUNDARY; + ls::Domain::BoundaryType::REFLECTIVE_BOUNDARY; } boundaryCons[D - 1] = - lsDomain::BoundaryType::INFINITE_BOUNDARY; + ls::Domain::BoundaryType::INFINITE_BOUNDARY; - auto levelSet = lsSmartPointer>::New( + auto levelSet = ls::SmartPointer>::New( bounds, boundaryCons, gridDelta); { auto plane = - lsSmartPointer>::New(origin, planeNormal); - lsMakeGeometry(levelSet, plane).apply(); + ls::SmartPointer>::New(origin, planeNormal); + ls::MakeGeometry(levelSet, plane).apply(); } { // create layer used for booling std::cout << "Creating box..." << std::endl; - auto trench = lsSmartPointer>::New( + auto trench = ls::SmartPointer>::New( bounds, boundaryCons, gridDelta); if constexpr (D == 3) { @@ -70,20 +72,20 @@ int main() { NumericType maxCorner[3] = {(NumericType)(extent / 4.), (NumericType)extent + 1, 5.0}; auto box = - lsSmartPointer>::New(minCorner, maxCorner); - lsMakeGeometry(trench, box).apply(); + ls::SmartPointer>::New(minCorner, maxCorner); + ls::MakeGeometry(trench, box).apply(); } else { NumericType minCorner[2] = {(NumericType)(-extent / 4.), -49.8}; NumericType maxCorner[2] = {(NumericType)(extent / 4.), 5.0}; auto box = - lsSmartPointer>::New(minCorner, maxCorner); - lsMakeGeometry(trench, box).apply(); + ls::SmartPointer>::New(minCorner, maxCorner); + ls::MakeGeometry(trench, box).apply(); } // Create trench geometry std::cout << "Booling trench..." << std::endl; - lsBooleanOperation( - levelSet, trench, lsBooleanOperationEnum::RELATIVE_COMPLEMENT) + ls::BooleanOperation( + levelSet, trench, ls::BooleanOperationEnum::RELATIVE_COMPLEMENT) .apply(); } @@ -91,14 +93,14 @@ int main() { std::cout << "Expanding..." << std::endl; - lsExpand expander(levelSet, 5); + ls::Expand expander(levelSet, 5); expander.apply(); std::cout << "Flagging Curvatures..." << std::endl; - lsDetectFeatures CurvatureFlagger( - levelSet, 1e-3, lsFeatureDetectionEnum::CURVATURE); + ls::DetectFeatures CurvatureFlagger( + levelSet, 1e-3, ls::FeatureDetectionEnum::CURVATURE); CurvatureFlagger.apply(); @@ -112,17 +114,17 @@ int main() { std::cout << "Flagging Normals..." << std::endl; - lsDetectFeatures NormalsFlagger( - levelSet, 1e-3, lsFeatureDetectionEnum::NORMALS_ANGLE); + ls::DetectFeatures NormalsFlagger( + levelSet, 1e-3, ls::FeatureDetectionEnum::NORMALS_ANGLE); NormalsFlagger.apply(); std::cout << "Writing Output..." << std::endl; - auto mesh = lsSmartPointer>::New(); - lsToMesh(levelSet, mesh, true, true).apply(); + auto mesh = ls::SmartPointer>::New(); + ls::ToMesh(levelSet, mesh, true, true).apply(); - auto writer = lsVTKWriter(); + auto writer = ls::VTKWriter(); writer.setMesh(mesh); writer.setFileName("Features.vtk"); writer.apply(); diff --git a/tests/FileWriter/FileWriter.cpp b/tests/FileWriter/FileWriter.cpp index 1deaf792..768c7c26 100644 --- a/tests/FileWriter/FileWriter.cpp +++ b/tests/FileWriter/FileWriter.cpp @@ -12,6 +12,8 @@ \example Serialize.cpp */ +namespace ls = viennals; + int main() { constexpr int D = 2; @@ -20,33 +22,34 @@ int main() { double extent = 10; double gridDelta = 1; double bounds[2 * D] = {-extent, extent, -extent, extent}; - lsDomain::BoundaryType boundaryCons[D]; + ls::Domain::BoundaryType boundaryCons[D]; for (unsigned i = 0; i < D; ++i) { - boundaryCons[i] = lsDomain::BoundaryType::REFLECTIVE_BOUNDARY; + boundaryCons[i] = ls::Domain::BoundaryType::REFLECTIVE_BOUNDARY; } - boundaryCons[D - 1] = lsBoundaryConditionEnum::INFINITE_BOUNDARY; + boundaryCons[D - 1] = ls::BoundaryConditionEnum::INFINITE_BOUNDARY; - auto levelSet = - lsSmartPointer>::New(bounds, boundaryCons, gridDelta); + auto levelSet = ls::SmartPointer>::New( + bounds, boundaryCons, gridDelta); const double radius = 7.3; const hrleVectorType centre(5., 0.); // const double centre[D] = {0,0.1}; // const double normal[D] = {0, 1}; - // lsMakeGeometry(levelSet, lsSmartPointer(levelSet, ls::SmartPointer>::New(centre, normal)).apply(); - lsMakeGeometry( - levelSet, lsSmartPointer>::New(centre, radius)) + ls::MakeGeometry( + levelSet, ls::SmartPointer>::New(centre, radius)) .apply(); - lsPointData &data = levelSet->getPointData(); - typename lsPointData::ScalarDataType scalars; - typename lsPointData::VectorDataType vectors; + ls::PointData &data = levelSet->getPointData(); + typename ls::PointData::ScalarDataType scalars; + typename ls::PointData::VectorDataType vectors; for (unsigned i = 0; i < levelSet->getNumberOfPoints(); ++i) { scalars.push_back(i); vectors.push_back( - typename lsPointData::VectorDataType::value_type({double(i)})); + typename ls::PointData::VectorDataType::value_type( + {double(i)})); } data.insertNextScalarData(scalars, "myScalars"); @@ -61,11 +64,11 @@ int main() { domainString = oss.str(); } - lsWriter(levelSet, "test.lvst").apply(); + ls::Writer(levelSet, "test.lvst").apply(); // read it in again - auto newLevelSet = lsSmartPointer>::New(); - lsReader(newLevelSet, "test.lvst").apply(); + auto newLevelSet = ls::SmartPointer>::New(); + ls::Reader(newLevelSet, "test.lvst").apply(); { std::ostringstream oss; diff --git a/tests/FromMesh/FromMesh.cpp b/tests/FromMesh/FromMesh.cpp index 8b23301d..be3a5f0e 100644 --- a/tests/FromMesh/FromMesh.cpp +++ b/tests/FromMesh/FromMesh.cpp @@ -6,6 +6,8 @@ #include #include +namespace ls = viennals; + int main() { constexpr int D = 2; @@ -15,39 +17,39 @@ int main() { double gridDelta = 0.5; double bounds[2 * D] = {-extent, extent, -extent, extent}; - lsDomain::BoundaryType boundaryCons[D]; + ls::Domain::BoundaryType boundaryCons[D]; for (unsigned i = 0; i < D; ++i) - boundaryCons[i] = lsDomain::BoundaryType::REFLECTIVE_BOUNDARY; + boundaryCons[i] = ls::Domain::BoundaryType::REFLECTIVE_BOUNDARY; - auto sphere1 = - lsSmartPointer>::New(bounds, boundaryCons, gridDelta); + auto sphere1 = ls::SmartPointer>::New( + bounds, boundaryCons, gridDelta); double origin[D] = {5., 0.}; double radius = 7.3; - lsMakeGeometry( - sphere1, lsSmartPointer>::New(origin, radius)) + ls::MakeGeometry( + sphere1, ls::SmartPointer>::New(origin, radius)) .apply(); std::cout << "Writing" << std::endl; { - auto mesh = lsSmartPointer>::New(); - lsToMesh(sphere1, mesh).apply(); - lsVTKWriter(mesh, "sphere.vtk").apply(); + auto mesh = ls::SmartPointer>::New(); + ls::ToMesh(sphere1, mesh).apply(); + ls::VTKWriter(mesh, "sphere.vtk").apply(); } std::cout << "Reading" << std::endl; { - auto mesh = lsSmartPointer>::New(); - lsVTKReader(mesh, "sphere.vtk").apply(); - auto newLS = lsSmartPointer>::New(bounds, boundaryCons, - gridDelta); - lsFromMesh(newLS, mesh).apply(); + auto mesh = ls::SmartPointer>::New(); + ls::VTKReader(mesh, "sphere.vtk").apply(); + auto newLS = ls::SmartPointer>::New( + bounds, boundaryCons, gridDelta); + ls::FromMesh(newLS, mesh).apply(); std::cout << "Writing new" << std::endl; - auto newMesh = lsSmartPointer>::New(); - lsToMesh(newLS, newMesh).apply(); - lsVTKWriter(mesh, "newMesh.vtk").apply(); + auto newMesh = ls::SmartPointer>::New(); + ls::ToMesh(newLS, newMesh).apply(); + ls::VTKWriter(mesh, "newMesh.vtk").apply(); } return 0; diff --git a/tests/GenerateHoleGeometry/GenerateHoleGeometry.cpp b/tests/GenerateHoleGeometry/GenerateHoleGeometry.cpp index af7b8ada..7041f46a 100644 --- a/tests/GenerateHoleGeometry/GenerateHoleGeometry.cpp +++ b/tests/GenerateHoleGeometry/GenerateHoleGeometry.cpp @@ -11,6 +11,8 @@ #include #include +namespace ls = viennals; + int main(int argc, char *argv[]) { constexpr int D = 3; typedef double NumericType; @@ -28,15 +30,15 @@ int main(int argc, char *argv[]) { bounds[5] = extent; } - typename lsDomain::BoundaryType boundaryCons[D]; + typename ls::Domain::BoundaryType boundaryCons[D]; for (unsigned i = 0; i < D - 1; ++i) { boundaryCons[i] = - lsDomain::BoundaryType::REFLECTIVE_BOUNDARY; + ls::Domain::BoundaryType::REFLECTIVE_BOUNDARY; } boundaryCons[D - 1] = - lsDomain::BoundaryType::INFINITE_BOUNDARY; + ls::Domain::BoundaryType::INFINITE_BOUNDARY; - auto substrate = lsSmartPointer>::New( + auto substrate = ls::SmartPointer>::New( bounds, boundaryCons, gridDelta); { @@ -45,42 +47,42 @@ int main(int argc, char *argv[]) { planeNormal[D - 1] = 1.; auto plane = - lsSmartPointer>::New(origin, planeNormal); - lsMakeGeometry(substrate, plane).apply(); + ls::SmartPointer>::New(origin, planeNormal); + ls::MakeGeometry(substrate, plane).apply(); } { std::cout << "Writing substrate" << std::endl; - auto mesh = lsSmartPointer>::New(); - lsToSurfaceMesh(substrate, mesh).apply(); - lsVTKWriter(mesh, lsFileFormatEnum::VTP, "substrate.vtp").apply(); + auto mesh = ls::SmartPointer>::New(); + ls::ToSurfaceMesh(substrate, mesh).apply(); + ls::VTKWriter(mesh, ls::FileFormatEnum::VTP, "substrate.vtp").apply(); } { // make LS from trench mesh and remove from substrate - auto hole = lsSmartPointer>::New( + auto hole = ls::SmartPointer>::New( bounds, boundaryCons, gridDelta); NumericType origin[D] = {0., 0., -depth}; NumericType axisDirection[D] = {0., 0., 1.}; - auto cylinder = lsSmartPointer>::New( + auto cylinder = ls::SmartPointer>::New( origin, axisDirection, depth, baseRadius, topRadius); - lsMakeGeometry(hole, cylinder).apply(); + ls::MakeGeometry(hole, cylinder).apply(); { std::cout << "Writing hole" << std::endl; - auto mesh = lsSmartPointer>::New(); - lsToSurfaceMesh(hole, mesh).apply(); - lsVTKWriter(mesh, lsFileFormatEnum::VTP, "hole.vtp").apply(); + auto mesh = ls::SmartPointer>::New(); + ls::ToSurfaceMesh(hole, mesh).apply(); + ls::VTKWriter(mesh, ls::FileFormatEnum::VTP, "hole.vtp").apply(); } - lsBooleanOperation( - substrate, hole, lsBooleanOperationEnum::RELATIVE_COMPLEMENT) + ls::BooleanOperation( + substrate, hole, ls::BooleanOperationEnum::RELATIVE_COMPLEMENT) .apply(); } { std::cout << "Writing output" << std::endl; - auto mesh = lsSmartPointer>::New(); - lsToSurfaceMesh(substrate, mesh).apply(); - lsVTKWriter(mesh, lsFileFormatEnum::VTP, "surface_i.vtp").apply(); + auto mesh = ls::SmartPointer>::New(); + ls::ToSurfaceMesh(substrate, mesh).apply(); + ls::VTKWriter(mesh, ls::FileFormatEnum::VTP, "surface_i.vtp").apply(); } return 0; diff --git a/tests/GeometricAdvect/GeometricAdvect.cpp b/tests/GeometricAdvect/GeometricAdvect.cpp index 9a7e9432..fda20259 100644 --- a/tests/GeometricAdvect/GeometricAdvect.cpp +++ b/tests/GeometricAdvect/GeometricAdvect.cpp @@ -9,6 +9,8 @@ #include #include +namespace ls = viennals; + int main() { omp_set_num_threads(8); @@ -23,63 +25,64 @@ int main() { bounds[5] = extent; } - typename lsDomain::BoundaryType boundaryCons[D]; + typename ls::Domain::BoundaryType boundaryCons[D]; for (unsigned i = 0; i < D - 1; ++i) { boundaryCons[i] = - lsDomain::BoundaryType::REFLECTIVE_BOUNDARY; + ls::Domain::BoundaryType::REFLECTIVE_BOUNDARY; } boundaryCons[D - 1] = - lsDomain::BoundaryType::INFINITE_BOUNDARY; + ls::Domain::BoundaryType::INFINITE_BOUNDARY; - auto levelSet = - lsSmartPointer>::New(bounds, boundaryCons, gridDelta); + auto levelSet = ls::SmartPointer>::New( + bounds, boundaryCons, gridDelta); // create a sphere in the level set NumericType origin[D] = {0., 0.}; if constexpr (D == 3) origin[2] = 0; NumericType radius = 8.0; - lsMakeGeometry( - levelSet, lsSmartPointer>::New(origin, radius)) + ls::MakeGeometry( + levelSet, + ls::SmartPointer>::New(origin, radius)) .apply(); - auto sphere = - lsSmartPointer>::New(bounds, boundaryCons, gridDelta); + auto sphere = ls::SmartPointer>::New( + bounds, boundaryCons, gridDelta); origin[1] = 10.0; - lsMakeGeometry( - sphere, lsSmartPointer>::New(origin, radius)) + ls::MakeGeometry( + sphere, ls::SmartPointer>::New(origin, radius)) .apply(); - lsBooleanOperation(levelSet, sphere, - lsBooleanOperationEnum::UNION) + ls::BooleanOperation(levelSet, sphere, + ls::BooleanOperationEnum::UNION) .apply(); - auto mesh = lsSmartPointer>::New(); + auto mesh = ls::SmartPointer>::New(); - lsToMesh(levelSet, mesh).apply(); - lsVTKWriter(mesh, "points.vtk").apply(); - lsToSurfaceMesh(levelSet, mesh).apply(); - lsVTKWriter(mesh, "surface.vtk").apply(); + ls::ToMesh(levelSet, mesh).apply(); + ls::VTKWriter(mesh, "points.vtk").apply(); + ls::ToSurfaceMesh(levelSet, mesh).apply(); + ls::VTKWriter(mesh, "surface.vtk").apply(); // set up spherical advection dist auto dist = - lsSmartPointer>::New(20.0, gridDelta); - lsGeometricAdvect(levelSet, dist).apply(); + ls::SmartPointer>::New(20.0, gridDelta); + ls::GeometricAdvect(levelSet, dist).apply(); - lsToMesh(levelSet, mesh).apply(); - lsVTKWriter(mesh, "afterDepoLS.vtk").apply(); - lsToSurfaceMesh(levelSet, mesh).apply(); - lsVTKWriter(mesh, "afterDepo.vtk").apply(); + ls::ToMesh(levelSet, mesh).apply(); + ls::VTKWriter(mesh, "afterDepoLS.vtk").apply(); + ls::ToSurfaceMesh(levelSet, mesh).apply(); + ls::VTKWriter(mesh, "afterDepo.vtk").apply(); // now remove the same again using spherical distribution - auto etch = lsSmartPointer>::New( + auto etch = ls::SmartPointer>::New( -20.0, gridDelta); - lsGeometricAdvect(levelSet, etch).apply(); + ls::GeometricAdvect(levelSet, etch).apply(); - lsToMesh(levelSet, mesh).apply(); - lsVTKWriter(mesh, "afterEtchLS.vtk").apply(); - lsToSurfaceMesh(levelSet, mesh).apply(); - lsVTKWriter(mesh, "afterEtch.vtk").apply(); + ls::ToMesh(levelSet, mesh).apply(); + ls::VTKWriter(mesh, "afterEtchLS.vtk").apply(); + ls::ToSurfaceMesh(levelSet, mesh).apply(); + ls::VTKWriter(mesh, "afterEtch.vtk").apply(); return 0; } diff --git a/tests/GeometricAdvectMask/GeometricAdvectMask.cpp b/tests/GeometricAdvectMask/GeometricAdvectMask.cpp index 800c4143..87dc99c5 100644 --- a/tests/GeometricAdvectMask/GeometricAdvectMask.cpp +++ b/tests/GeometricAdvectMask/GeometricAdvectMask.cpp @@ -9,6 +9,8 @@ #include #include +namespace ls = viennals; + int main() { omp_set_num_threads(8); @@ -23,18 +25,18 @@ int main() { bounds[5] = extent; } - typename lsDomain::BoundaryType boundaryCons[D]; + typename ls::Domain::BoundaryType boundaryCons[D]; for (unsigned i = 0; i < D - 1; ++i) { boundaryCons[i] = - lsDomain::BoundaryType::REFLECTIVE_BOUNDARY; + ls::Domain::BoundaryType::REFLECTIVE_BOUNDARY; } boundaryCons[D - 1] = - lsDomain::BoundaryType::INFINITE_BOUNDARY; + ls::Domain::BoundaryType::INFINITE_BOUNDARY; - auto mask = lsSmartPointer>::New( + auto mask = ls::SmartPointer>::New( bounds, boundaryCons, gridDelta); - auto levelSet = lsSmartPointer>::New( + auto levelSet = ls::SmartPointer>::New( bounds, boundaryCons, gridDelta); ; @@ -42,33 +44,33 @@ int main() { { NumericType normal[3] = {0., (D == 2) ? 1. : 0., (D == 3) ? 1. : 0.}; NumericType origin[3] = {}; - lsMakeGeometry( - mask, lsSmartPointer>::New(origin, normal)) + ls::MakeGeometry( + mask, ls::SmartPointer>::New(origin, normal)) .apply(); normal[D - 1] = -1.0; origin[D - 1] = -extent / 5.0; - auto maskBottom = lsSmartPointer>::New( + auto maskBottom = ls::SmartPointer>::New( bounds, boundaryCons, gridDelta); - lsMakeGeometry( + ls::MakeGeometry( maskBottom, - lsSmartPointer>::New(origin, normal)) + ls::SmartPointer>::New(origin, normal)) .apply(); - lsBooleanOperation(mask, maskBottom, - lsBooleanOperationEnum::INTERSECT) + ls::BooleanOperation(mask, maskBottom, + ls::BooleanOperationEnum::INTERSECT) .apply(); - auto mesh = lsSmartPointer>::New(); - lsToMesh(mask, mesh).apply(); - lsVTKWriter(mesh, "Plane.vtk").apply(); + auto mesh = ls::SmartPointer>::New(); + ls::ToMesh(mask, mesh).apply(); + ls::VTKWriter(mesh, "Plane.vtk").apply(); - auto maskHole = lsSmartPointer>::New( + auto maskHole = ls::SmartPointer>::New( bounds, boundaryCons, gridDelta); double holeOrigin[3] = {0., 0., origin[D - 1] - 2 * gridDelta}; double axis[3] = {0.0, 0.0, 1.0}; - lsMakeGeometry( + ls::MakeGeometry( maskHole, - lsSmartPointer>::New( + ls::SmartPointer>::New( holeOrigin, axis, 4 * gridDelta - origin[D - 1], extent / 1.5)) .apply(); @@ -76,50 +78,51 @@ int main() { // double maxScalar = extent/5 * 2 * gridDelta; // double min[3] = {minScalar, minScalar, minScalar}; // double max[3] = {maxScalar, maxScalar, maxScalar}; - // lsMakeGeometry(maskHole, - // lsSmartPointer>::New(min, max)).apply(); + // ls::MakeGeometry(maskHole, + // ls::SmartPointer>::New(min, max)).apply(); - lsBooleanOperation( - mask, maskHole, lsBooleanOperationEnum::RELATIVE_COMPLEMENT) + ls::BooleanOperation( + mask, maskHole, ls::BooleanOperationEnum::RELATIVE_COMPLEMENT) .apply(); - lsToSurfaceMesh(mask, mesh).apply(); - lsVTKWriter(mesh, "Mask.vtk").apply(); + ls::ToSurfaceMesh(mask, mesh).apply(); + ls::VTKWriter(mesh, "Mask.vtk").apply(); // make substrate - lsBooleanOperation(maskBottom, - lsBooleanOperationEnum::INVERT) + ls::BooleanOperation(maskBottom, + ls::BooleanOperationEnum::INVERT) .apply(); levelSet->deepCopy(maskBottom); - lsBooleanOperation(levelSet, mask, - lsBooleanOperationEnum::UNION) + ls::BooleanOperation(levelSet, mask, + ls::BooleanOperationEnum::UNION) .apply(); } - auto mesh = lsSmartPointer>::New(); + auto mesh = ls::SmartPointer>::New(); - lsToMesh(levelSet, mesh).apply(); - lsVTKWriter(mesh, "Surface_i_p.vtk").apply(); - lsToSurfaceMesh(levelSet, mesh).apply(); - lsVTKWriter(mesh, "Surface_i.vtk").apply(); - lsToMesh(mask, mesh).apply(); - lsVTKWriter(mesh, "Surface_m_p.vtk").apply(); - lsToSurfaceMesh(mask, mesh).apply(); - lsVTKWriter(mesh, "Surface_m.vtk").apply(); + ls::ToMesh(levelSet, mesh).apply(); + ls::VTKWriter(mesh, "Surface_i_p.vtk").apply(); + ls::ToSurfaceMesh(levelSet, mesh).apply(); + ls::VTKWriter(mesh, "Surface_i.vtk").apply(); + ls::ToMesh(mask, mesh).apply(); + ls::VTKWriter(mesh, "Surface_m_p.vtk").apply(); + ls::ToSurfaceMesh(mask, mesh).apply(); + ls::VTKWriter(mesh, "Surface_m.vtk").apply(); // set up spherical advection dist auto dist = - // lsSmartPointer>::New(-15.0,gridDelta); - lsSmartPointer>::New( + // ls::SmartPointer>::New(-15.0,gridDelta); + ls::SmartPointer>::New( std::array({-gridDelta, -gridDelta, -150.0}), gridDelta); - lsGeometricAdvect(levelSet, dist, mask).apply(); + ls::GeometricAdvect(levelSet, dist, mask).apply(); - lsToMesh(levelSet, mesh).apply(); - lsVTKWriter(mesh, "afterDepoLS.vtk").apply(); - lsToSurfaceMesh(levelSet, mesh).apply(); - lsVTKWriter(mesh, "afterDepo.vtk").apply(); + ls::ToMesh(levelSet, mesh).apply(); + ls::VTKWriter(mesh, "afterDepoLS.vtk").apply(); + ls::ToSurfaceMesh(levelSet, mesh).apply(); + ls::VTKWriter(mesh, "afterDepo.vtk").apply(); return 0; } \ No newline at end of file diff --git a/tests/GeometricAdvectPerformance/GeometricAdvectPerformance.cpp b/tests/GeometricAdvectPerformance/GeometricAdvectPerformance.cpp index 2c3f6603..3806a3ad 100644 --- a/tests/GeometricAdvectPerformance/GeometricAdvectPerformance.cpp +++ b/tests/GeometricAdvectPerformance/GeometricAdvectPerformance.cpp @@ -12,7 +12,9 @@ #include #include -class velocityField : public lsVelocityField { +namespace ls = viennals; + +class velocityField : public ls::VelocityField { double getScalarVelocity(const std::array & /*coordinate*/, int /*material*/, const std::array & /*normalVector*/, @@ -33,36 +35,37 @@ int main() { bounds[5] = 10; } - typename lsDomain::BoundaryType boundaryCons[D]; + typename ls::Domain::BoundaryType boundaryCons[D]; for (unsigned i = 0; i < D - 1; ++i) { boundaryCons[i] = - lsDomain::BoundaryType::REFLECTIVE_BOUNDARY; + ls::Domain::BoundaryType::REFLECTIVE_BOUNDARY; } boundaryCons[D - 1] = - lsDomain::BoundaryType::INFINITE_BOUNDARY; + ls::Domain::BoundaryType::INFINITE_BOUNDARY; - auto substrate = - lsSmartPointer>::New(bounds, boundaryCons, gridDelta); + auto substrate = ls::SmartPointer>::New( + bounds, boundaryCons, gridDelta); double origin[3] = {0., 0., 0.}; double planeNormal[3] = {0., D == 2, D == 3}; - lsMakeGeometry( - substrate, lsSmartPointer>::New(origin, planeNormal)) + ls::MakeGeometry( + substrate, + ls::SmartPointer>::New(origin, planeNormal)) .apply(); { std::cout << "Extracting..." << std::endl; - auto mesh = lsSmartPointer>::New(); - lsToSurfaceMesh(substrate, mesh).apply(); - lsVTKWriter(mesh, "plane.vtk").apply(); + auto mesh = ls::SmartPointer>::New(); + ls::ToSurfaceMesh(substrate, mesh).apply(); + ls::VTKWriter(mesh, "plane.vtk").apply(); } { // create layer used for booling std::cout << "Creating box..." << std::endl; - auto trench = lsSmartPointer>::New(bounds, boundaryCons, - gridDelta); + auto trench = ls::SmartPointer>::New( + bounds, boundaryCons, gridDelta); double minCorner[3] = {-extent - 1, -7.5, -15.}; double maxCorner[3] = {extent + 1, 7.5, 1.0}; if (D == 2) { @@ -71,42 +74,42 @@ int main() { maxCorner[0] = maxCorner[1]; maxCorner[1] = maxCorner[2]; } - lsMakeGeometry( - trench, lsSmartPointer>::New(minCorner, maxCorner)) + ls::MakeGeometry( + trench, ls::SmartPointer>::New(minCorner, maxCorner)) .apply(); { std::cout << "Extracting..." << std::endl; - auto mesh = lsSmartPointer>::New(); - lsToMesh(trench, mesh).apply(); - lsVTKWriter(mesh, "box.vtk").apply(); + auto mesh = ls::SmartPointer>::New(); + ls::ToMesh(trench, mesh).apply(); + ls::VTKWriter(mesh, "box.vtk").apply(); } // Create trench geometry std::cout << "Booling trench..." << std::endl; - lsBooleanOperation(substrate, trench, - lsBooleanOperationEnum::RELATIVE_COMPLEMENT) + ls::BooleanOperation( + substrate, trench, ls::BooleanOperationEnum::RELATIVE_COMPLEMENT) .apply(); } - auto mesh = lsSmartPointer>::New(); + auto mesh = ls::SmartPointer>::New(); - lsToMesh(substrate, mesh).apply(); - lsVTKWriter(mesh, "points.vtk").apply(); - lsToSurfaceMesh(substrate, mesh).apply(); - lsVTKWriter(mesh, "surface.vtk").apply(); + ls::ToMesh(substrate, mesh).apply(); + ls::VTKWriter(mesh, "points.vtk").apply(); + ls::ToSurfaceMesh(substrate, mesh).apply(); + ls::VTKWriter(mesh, "surface.vtk").apply(); // Distance to advect to double depositionDistance = 4.0; // set up spherical advection dist - auto dist = lsSmartPointer>::New( + auto dist = ls::SmartPointer>::New( depositionDistance, gridDelta); - auto newLayer = lsSmartPointer>::New(substrate); + auto newLayer = ls::SmartPointer>::New(substrate); std::cout << "GeometricAdvecting" << std::endl; - lsGeometricAdvect fastAdvectKernel(newLayer, dist); + ls::GeometricAdvect fastAdvectKernel(newLayer, dist); { auto start = std::chrono::high_resolution_clock::now(); @@ -118,10 +121,10 @@ int main() { std::cout << "Fast Advect: " << diff << "ms" << std::endl; } - lsToSurfaceMesh(newLayer, mesh).apply(); - lsVTKWriter(mesh, "GeometricAdvect.vtk").apply(); - // lsToSurfaceMesh(newLayer, mesh).apply(); - // lsVTKWriter(mesh, "finalSurface.vtk").apply(); + ls::ToSurfaceMesh(newLayer, mesh).apply(); + ls::VTKWriter(mesh, "GeometricAdvect.vtk").apply(); + // ls::ToSurfaceMesh(newLayer, mesh).apply(); + // ls::VTKWriter(mesh, "finalSurface.vtk").apply(); // now rund lsAdvect for all other advection schemes // last scheme is SLLFS with i == 9 @@ -129,15 +132,15 @@ int main() { if (i == 4) { continue; } - lsAdvect advectionKernel; - auto nextLayer = lsSmartPointer>::New(substrate); + ls::Advect advectionKernel; + auto nextLayer = ls::SmartPointer>::New(substrate); advectionKernel.insertNextLevelSet(nextLayer); - auto velocities = lsSmartPointer::New(); + auto velocities = ls::SmartPointer::New(); advectionKernel.setVelocityField(velocities); advectionKernel.setAdvectionTime(depositionDistance); advectionKernel.setIntegrationScheme( - static_cast(i)); + static_cast(i)); { auto start = std::chrono::high_resolution_clock::now(); advectionKernel.apply(); @@ -148,8 +151,8 @@ int main() { std::cout << "Advect " << i << ": " << diff << "ms" << std::endl; } - lsToSurfaceMesh(nextLayer, mesh).apply(); - lsVTKWriter(mesh, "Advect-" + std::to_string(i) + ".vtk").apply(); + ls::ToSurfaceMesh(nextLayer, mesh).apply(); + ls::VTKWriter(mesh, "Advect-" + std::to_string(i) + ".vtk").apply(); } return 0; diff --git a/tests/GeometricAdvectTrench/GeometricAdvectTrench.cpp b/tests/GeometricAdvectTrench/GeometricAdvectTrench.cpp index f2799de1..5ff212b6 100644 --- a/tests/GeometricAdvectTrench/GeometricAdvectTrench.cpp +++ b/tests/GeometricAdvectTrench/GeometricAdvectTrench.cpp @@ -9,6 +9,8 @@ #include #include +namespace ls = viennals; + int main() { omp_set_num_threads(12); @@ -23,36 +25,37 @@ int main() { bounds[5] = extent; } - typename lsDomain::BoundaryType boundaryCons[D]; + typename ls::Domain::BoundaryType boundaryCons[D]; for (unsigned i = 0; i < D - 1; ++i) { boundaryCons[i] = - lsDomain::BoundaryType::REFLECTIVE_BOUNDARY; + ls::Domain::BoundaryType::REFLECTIVE_BOUNDARY; } boundaryCons[D - 1] = - lsDomain::BoundaryType::INFINITE_BOUNDARY; + ls::Domain::BoundaryType::INFINITE_BOUNDARY; - auto substrate = - lsSmartPointer>::New(bounds, boundaryCons, gridDelta); + auto substrate = ls::SmartPointer>::New( + bounds, boundaryCons, gridDelta); double origin[3] = {0., 0., 0.}; double planeNormal[3] = {0., D == 2, D == 3}; - lsMakeGeometry( - substrate, lsSmartPointer>::New(origin, planeNormal)) + ls::MakeGeometry( + substrate, + ls::SmartPointer>::New(origin, planeNormal)) .apply(); { std::cout << "Extracting..." << std::endl; - auto mesh = lsSmartPointer>::New(); - lsToSurfaceMesh(substrate, mesh).apply(); - lsVTKWriter(mesh, "plane.vtk").apply(); + auto mesh = ls::SmartPointer>::New(); + ls::ToSurfaceMesh(substrate, mesh).apply(); + ls::VTKWriter(mesh, "plane.vtk").apply(); } { // create layer used for booling std::cout << "Creating box..." << std::endl; - auto trench = lsSmartPointer>::New(bounds, boundaryCons, - gridDelta); + auto trench = ls::SmartPointer>::New( + bounds, boundaryCons, gridDelta); double minCorner[3] = {-extent - 1, -extent / 4., -15.}; double maxCorner[3] = {extent + 1, extent / 4., 1.0}; if (D == 2) { @@ -61,30 +64,30 @@ int main() { maxCorner[0] = maxCorner[1]; maxCorner[1] = maxCorner[2]; } - lsMakeGeometry( - trench, lsSmartPointer>::New(minCorner, maxCorner)) + ls::MakeGeometry( + trench, ls::SmartPointer>::New(minCorner, maxCorner)) .apply(); { std::cout << "Extracting..." << std::endl; - auto mesh = lsSmartPointer>::New(); - lsToMesh(trench, mesh).apply(); - lsVTKWriter(mesh, "box.vtk").apply(); + auto mesh = ls::SmartPointer>::New(); + ls::ToMesh(trench, mesh).apply(); + ls::VTKWriter(mesh, "box.vtk").apply(); } // Create trench geometry std::cout << "Booling trench..." << std::endl; - lsBooleanOperation(substrate, trench, - lsBooleanOperationEnum::RELATIVE_COMPLEMENT) + ls::BooleanOperation( + substrate, trench, ls::BooleanOperationEnum::RELATIVE_COMPLEMENT) .apply(); } - auto mesh = lsSmartPointer>::New(); + auto mesh = ls::SmartPointer>::New(); - lsToMesh(substrate, mesh).apply(); - lsVTKWriter(mesh, "points.vtk").apply(); - lsToSurfaceMesh(substrate, mesh).apply(); - lsVTKWriter(mesh, "surface.vtk").apply(); + ls::ToMesh(substrate, mesh).apply(); + ls::VTKWriter(mesh, "points.vtk").apply(); + ls::ToSurfaceMesh(substrate, mesh).apply(); + ls::VTKWriter(mesh, "surface.vtk").apply(); // set up spherical advection dist // lsSphereDistribution dist(15.0); @@ -94,16 +97,16 @@ int main() { box[1] = 1.1; box[2] = 15; } - auto dist = - lsSmartPointer>::New(box, gridDelta); - lsGeometricAdvect(substrate, dist).apply(); + auto dist = ls::SmartPointer>::New( + box, gridDelta); + ls::GeometricAdvect(substrate, dist).apply(); std::cout << "Writing results..." << std::endl; - lsToMesh(substrate, mesh).apply(); - lsVTKWriter(mesh, "finalLS.vtk").apply(); + ls::ToMesh(substrate, mesh).apply(); + ls::VTKWriter(mesh, "finalLS.vtk").apply(); - lsToSurfaceMesh(substrate, mesh).apply(); - lsVTKWriter(mesh, "finalSurface.vtk").apply(); + ls::ToSurfaceMesh(substrate, mesh).apply(); + ls::VTKWriter(mesh, "finalSurface.vtk").apply(); std::cout << "Done" << std::endl; diff --git a/tests/HullMesh/HullMesh.cpp b/tests/HullMesh/HullMesh.cpp index 85cf5524..7b552adf 100644 --- a/tests/HullMesh/HullMesh.cpp +++ b/tests/HullMesh/HullMesh.cpp @@ -2,15 +2,16 @@ #include #include -#include #include +namespace ls = viennals; + int main() { constexpr int D = 3; // omp_set_num_threads(4); - auto cloud = lsSmartPointer>::New(); + auto cloud = ls::SmartPointer>::New(); cloud->insertNextPoint(hrleVectorType(0, 0, 1)); cloud->insertNextPoint(hrleVectorType(1, 0, 1)); @@ -21,10 +22,10 @@ int main() { cloud->insertNextPoint(hrleVectorType(1, 1, 0.2)); cloud->insertNextPoint(hrleVectorType(0, 1, 0.2)); - auto hull = lsSmartPointer>::New(); - lsConvexHull(hull, cloud).apply(); - lsVTKWriter(hull, lsFileFormatEnum::VTP, - "hull_" + std::to_string(1) + ".vtp") + auto hull = ls::SmartPointer>::New(); + ls::ConvexHull(hull, cloud).apply(); + ls::VTKWriter(hull, ls::FileFormatEnum::VTP, + "hull_" + std::to_string(1) + ".vtp") .apply(); return 0; diff --git a/tests/Make3DSphere/Make3DSphere.cpp b/tests/Make3DSphere/Make3DSphere.cpp index 52095ed2..8dffc6ec 100644 --- a/tests/Make3DSphere/Make3DSphere.cpp +++ b/tests/Make3DSphere/Make3DSphere.cpp @@ -16,6 +16,8 @@ \example Make3DSphere.cpp */ +namespace ls = viennals; + int main() { constexpr int D = 3; @@ -24,45 +26,47 @@ int main() { double gridDelta = 0.4; - auto sphere1 = - lsSmartPointer>::New(gridDelta); //, boundaryCons); + auto sphere1 = ls::SmartPointer>::New( + gridDelta); //, boundaryCons); - auto sphere2 = - lsSmartPointer>::New(gridDelta); //, boundaryCons); + auto sphere2 = ls::SmartPointer>::New( + gridDelta); //, boundaryCons); double origin[3] = {5., 0., 0.}; double radius = 7.3; - lsMakeGeometry( - sphere1, lsSmartPointer>::New(origin, radius)) + ls::MakeGeometry( + sphere1, ls::SmartPointer>::New(origin, radius)) .apply(); origin[0] = -5.; - lsMakeGeometry( - sphere2, lsSmartPointer>::New(origin, radius)) + ls::MakeGeometry( + sphere2, ls::SmartPointer>::New(origin, radius)) .apply(); std::cout << "Number of points: " << sphere1->getDomain().getNumberOfPoints() << std::endl; - auto mesh = lsSmartPointer>::New(); + auto mesh = ls::SmartPointer>::New(); std::cout << "Expanding..." << std::endl; - lsExpand(sphere1, 2).apply(); - lsExpand(sphere2, 2).apply(); + ls::Expand(sphere1, 2).apply(); + ls::Expand(sphere2, 2).apply(); std::cout << "Booling..." << std::endl; - lsBooleanOperation(sphere1, sphere2, lsBooleanOperationEnum::UNION) + ls::BooleanOperation(sphere1, sphere2, + ls::BooleanOperationEnum::UNION) .apply(); std::cout << "Extracting..." << std::endl; - lsToSurfaceMesh(sphere1, mesh).apply(); + ls::ToSurfaceMesh(sphere1, mesh).apply(); mesh->print(); - lsVTKWriter(mesh, "test-" + std::to_string(radius) + ".vtk").apply(); + ls::VTKWriter(mesh, "test-" + std::to_string(radius) + ".vtk") + .apply(); // write voxelised volume mesh { - auto voxelMesh = lsSmartPointer>::New(); - auto voxelMesher = lsToVoxelMesh(voxelMesh); + auto voxelMesh = ls::SmartPointer>::New(); + auto voxelMesher = ls::ToVoxelMesh(voxelMesh); voxelMesher.insertNextLevelSet(sphere2); voxelMesher.insertNextLevelSet(sphere1); @@ -79,7 +83,7 @@ int main() { std::cout << "voxelMesh: " << std::endl; voxelMesh->print(); - lsVTKWriter(voxelMesh, lsFileFormatEnum::VTU, "voxelMesh.vtu") + ls::VTKWriter(voxelMesh, ls::FileFormatEnum::VTU, "voxelMesh.vtu") .apply(); } diff --git a/tests/MakeBox/MakeBox.cpp b/tests/MakeBox/MakeBox.cpp index c2a9308b..8ca04acc 100644 --- a/tests/MakeBox/MakeBox.cpp +++ b/tests/MakeBox/MakeBox.cpp @@ -18,6 +18,8 @@ \example Make3DSphere.cpp */ +namespace ls = viennals; + int main() { constexpr int D = 3; @@ -31,19 +33,19 @@ int main() { bounds[5] = extent; } - typename lsDomain::BoundaryType boundaryCons[D]; + typename ls::Domain::BoundaryType boundaryCons[D]; for (unsigned i = 0; i < D - 1; ++i) { - boundaryCons[i] = lsDomain::BoundaryType::PERIODIC_BOUNDARY; + boundaryCons[i] = ls::Domain::BoundaryType::PERIODIC_BOUNDARY; } - boundaryCons[D - 1] = lsDomain::BoundaryType::INFINITE_BOUNDARY; + boundaryCons[D - 1] = ls::Domain::BoundaryType::INFINITE_BOUNDARY; - auto levelSet = - lsSmartPointer>::New(bounds, boundaryCons, gridDelta); + auto levelSet = ls::SmartPointer>::New( + bounds, boundaryCons, gridDelta); hrleVectorType min(bounds[0] + 10, bounds[2] + extent, 0); hrleVectorType max(bounds[1] - 10, bounds[3] + extent / 2., 4); - lsMakeGeometry(levelSet, - lsSmartPointer>::New(min, max)) + ls::MakeGeometry( + levelSet, ls::SmartPointer>::New(min, max)) .apply(); LSTEST_ASSERT_VALID_LS(levelSet, double, D) @@ -51,11 +53,11 @@ int main() { // std::cout << "Number of points: " << // levelSet->getDomain().getNumberOfPoints() // << std::endl; - // auto mesh = lsSmartPointer>::New(); - // lsToMesh(levelSet, mesh).apply(); - // lsVTKWriter(mesh, "boxLS.vtk").apply(); - // lsToSurfaceMesh(levelSet, mesh).apply(); - // lsVTKWriter(mesh, "box.vtk").apply(); + // auto mesh = ls::SmartPointer>::New(); + // ls::ToMesh(levelSet, mesh).apply(); + // ls::VTKWriter(mesh, "boxLS.vtk").apply(); + // ls::ToSurfaceMesh(levelSet, mesh).apply(); + // ls::VTKWriter(mesh, "box.vtk").apply(); return 0; } diff --git a/tests/MakeGeometry/MakeGeometry.cpp b/tests/MakeGeometry/MakeGeometry.cpp index 6a806e6d..363584c5 100644 --- a/tests/MakeGeometry/MakeGeometry.cpp +++ b/tests/MakeGeometry/MakeGeometry.cpp @@ -7,6 +7,8 @@ #include #include +namespace ls = viennals; + int main() { omp_set_num_threads(1); @@ -21,15 +23,15 @@ int main() { bounds[5] = 20; } - typename lsDomain::BoundaryType boundaryCons[D]; + typename ls::Domain::BoundaryType boundaryCons[D]; for (unsigned i = 0; i < D - 1; ++i) { boundaryCons[i] = - lsDomain::BoundaryType::REFLECTIVE_BOUNDARY; + ls::Domain::BoundaryType::REFLECTIVE_BOUNDARY; } boundaryCons[D - 1] = - lsDomain::BoundaryType::INFINITE_BOUNDARY; + ls::Domain::BoundaryType::INFINITE_BOUNDARY; - auto substrate = lsSmartPointer>::New( + auto substrate = ls::SmartPointer>::New( bounds, boundaryCons, gridDelta); // create a sphere in the level set @@ -37,30 +39,31 @@ int main() { if constexpr (D == 3) origin[2] = 0; NumericType radius = 15.3; - lsMakeGeometry( - substrate, lsSmartPointer>::New(origin, radius)) + ls::MakeGeometry( + substrate, + ls::SmartPointer>::New(origin, radius)) .apply(); origin[0] = 15.0; radius = 8.7; auto secondSphere = - lsSmartPointer>::New(substrate->getGrid()); - lsMakeGeometry( + ls::SmartPointer>::New(substrate->getGrid()); + ls::MakeGeometry( secondSphere, - lsSmartPointer>::New(origin, radius)) + ls::SmartPointer>::New(origin, radius)) .apply(); - lsBooleanOperation(substrate, secondSphere, - lsBooleanOperationEnum::UNION) + ls::BooleanOperation(substrate, secondSphere, + ls::BooleanOperationEnum::UNION) .apply(); - auto mesh = lsSmartPointer>::New(); - lsToSurfaceMesh(substrate, mesh).apply(); - lsVTKWriter(mesh, "twoSpheres.vtk").apply(); + auto mesh = ls::SmartPointer>::New(); + ls::ToSurfaceMesh(substrate, mesh).apply(); + ls::VTKWriter(mesh, "twoSpheres.vtk").apply(); substrate->getDomain().print(); - // for(hrleConstSparseIterator::DomainType> + // for(hrleConstSparseIterator::DomainType> // it(substrate->getDomain()); !it.isFinished(); ++it) { // std::cout << it.getStartIndices() << std::endl; // } diff --git a/tests/MakePlane/MakePlane.cpp b/tests/MakePlane/MakePlane.cpp index c8746445..20bce20c 100644 --- a/tests/MakePlane/MakePlane.cpp +++ b/tests/MakePlane/MakePlane.cpp @@ -19,38 +19,40 @@ \example MakePlane.cpp */ +namespace ls = viennals; + int main() { constexpr int D = 3; double extent = 15.7; double gridDelta = 2.8; double bounds[2 * D] = {-extent, extent, -extent, extent, -extent, extent}; - lsDomain::BoundaryType boundaryCons[3]; + ls::Domain::BoundaryType boundaryCons[3]; for (unsigned i = 0; i < D - 1; ++i) - // boundaryCons[i] = lsDomain::BoundaryType::PERIODIC_BOUNDARY; - boundaryCons[i] = lsDomain::BoundaryType::REFLECTIVE_BOUNDARY; + // boundaryCons[i] = ls::Domain::BoundaryType::PERIODIC_BOUNDARY; + boundaryCons[i] = ls::Domain::BoundaryType::REFLECTIVE_BOUNDARY; - boundaryCons[2] = lsDomain::BoundaryType::INFINITE_BOUNDARY; + boundaryCons[2] = ls::Domain::BoundaryType::INFINITE_BOUNDARY; - auto levelSet = - lsSmartPointer>::New(bounds, boundaryCons, gridDelta); - auto mesh = lsSmartPointer>::New(); + auto levelSet = ls::SmartPointer>::New( + bounds, boundaryCons, gridDelta); + auto mesh = ls::SmartPointer>::New(); const hrleVectorType origin(0., 0., 0.); // const hrleVectorType normal(0., 0., 1.); const hrleVectorType normal(1., 1., 1.); - lsMakeGeometry( - levelSet, lsSmartPointer>::New(origin, normal)) + ls::MakeGeometry( + levelSet, ls::SmartPointer>::New(origin, normal)) .apply(); LSTEST_ASSERT_VALID_LS(levelSet, double, D) - // lsToSurfaceMesh(levelSet, mesh).apply(); - // lsVTKWriter(mesh, "Plane.vtk").apply(); + // ls::ToSurfaceMesh(levelSet, mesh).apply(); + // ls::VTKWriter(mesh, "Plane.vtk").apply(); - // lsToMesh(levelSet, mesh).apply(); - // lsVTKWriter(mesh, "PlanePoints.vtk").apply(); + // ls::ToMesh(levelSet, mesh).apply(); + // ls::VTKWriter(mesh, "PlanePoints.vtk").apply(); return 0; } diff --git a/tests/MakeSphere/MakeSphere.cpp b/tests/MakeSphere/MakeSphere.cpp index b710759a..9caec629 100644 --- a/tests/MakeSphere/MakeSphere.cpp +++ b/tests/MakeSphere/MakeSphere.cpp @@ -18,61 +18,63 @@ \example MakeSphere.cpp */ +namespace ls = viennals; + int main() { constexpr int D = 2; omp_set_num_threads(4); - auto levelSet = lsSmartPointer>::New(); - auto mesh = lsSmartPointer>::New(); + auto levelSet = ls::SmartPointer>::New(); + auto mesh = ls::SmartPointer>::New(); const double radius = 27.3; const hrleVectorType centre(5., 0.); - lsMakeGeometry( - levelSet, lsSmartPointer>::New(centre, radius)) + ls::MakeGeometry( + levelSet, ls::SmartPointer>::New(centre, radius)) .apply(); std::cout << "Initial: " << std::endl; std::cout << "Number of points: " << levelSet->getDomain().getNumberOfPoints() << std::endl; - lsToMesh(levelSet, mesh).apply(); - lsVTKWriter(mesh, "initial.vtk").apply(); + ls::ToMesh(levelSet, mesh).apply(); + ls::VTKWriter(mesh, "initial.vtk").apply(); - lsPrune(levelSet).apply(); + ls::Prune(levelSet).apply(); std::cout << "After prune: " << std::endl; std::cout << "Number of points: " << levelSet->getDomain().getNumberOfPoints() << std::endl; std::cout << "Width: " << levelSet->getLevelSetWidth() << std::endl; - lsToMesh(levelSet, mesh).apply(); - lsVTKWriter(mesh, "after_prune.vtk").apply(); + ls::ToMesh(levelSet, mesh).apply(); + ls::VTKWriter(mesh, "after_prune.vtk").apply(); - lsExpand(levelSet, 4).apply(); + ls::Expand(levelSet, 4).apply(); std::cout << "After Expand: " << std::endl; std::cout << "Number of points: " << levelSet->getDomain().getNumberOfPoints() << std::endl; std::cout << "Width: " << levelSet->getLevelSetWidth() << std::endl; - lsToMesh(levelSet, mesh).apply(); - lsVTKWriter(mesh, "after_expand.vtk").apply(); + ls::ToMesh(levelSet, mesh).apply(); + ls::VTKWriter(mesh, "after_expand.vtk").apply(); - lsReduce(levelSet, 2).apply(); + ls::Reduce(levelSet, 2).apply(); std::cout << "After Reduce: " << std::endl; std::cout << "Number of points: " << levelSet->getDomain().getNumberOfPoints() << std::endl; std::cout << "Width: " << levelSet->getLevelSetWidth() << std::endl; - lsToSurfaceMesh(levelSet, mesh).apply(); - lsVTKWriter(mesh, "Sphere2D.vtk").apply(); + ls::ToSurfaceMesh(levelSet, mesh).apply(); + ls::VTKWriter(mesh, "Sphere2D.vtk").apply(); - lsToMesh(levelSet, mesh).apply(); - lsVTKWriter(mesh, "after_reduce.vtk").apply(); + ls::ToMesh(levelSet, mesh).apply(); + ls::VTKWriter(mesh, "after_reduce.vtk").apply(); - lsToVoxelMesh(levelSet, mesh).apply(); + ls::ToVoxelMesh(levelSet, mesh).apply(); mesh->print(); - lsVTKWriter(mesh, lsFileFormatEnum::VTU, "Sphere.vtu").apply(); + ls::VTKWriter(mesh, ls::FileFormatEnum::VTU, "Sphere.vtu").apply(); return 0; } diff --git a/tests/MarkVoidPoints/MarkVoidPoints.cpp b/tests/MarkVoidPoints/MarkVoidPoints.cpp index 2387204f..96cd2bfe 100644 --- a/tests/MarkVoidPoints/MarkVoidPoints.cpp +++ b/tests/MarkVoidPoints/MarkVoidPoints.cpp @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include @@ -13,41 +12,46 @@ using NumericType = float; constexpr int D = 2; -void outputDomain(lsSmartPointer> domain, +namespace ls = viennals; + +void outputDomain(ls::SmartPointer> domain, std::string fileName) { - auto mesh = lsSmartPointer>::New(); - lsToSurfaceMesh(domain, mesh).apply(); - lsVTKWriter(mesh, lsFileFormatEnum::VTP, fileName + "_surface.vtp").apply(); + auto mesh = ls::SmartPointer>::New(); + ls::ToSurfaceMesh(domain, mesh).apply(); + ls::VTKWriter(mesh, ls::FileFormatEnum::VTP, fileName + "_surface.vtp") + .apply(); - lsToMesh(domain, mesh).apply(); - lsVTKWriter(mesh, lsFileFormatEnum::VTP, fileName + "_points.vtp").apply(); + ls::ToMesh(domain, mesh).apply(); + ls::VTKWriter(mesh, ls::FileFormatEnum::VTP, fileName + "_points.vtp") + .apply(); } -void makeGeometry(lsSmartPointer> domain) { - auto plane = lsSmartPointer>::New(domain->getGrid()); +void makeGeometry(ls::SmartPointer> domain) { + auto plane = + ls::SmartPointer>::New(domain->getGrid()); NumericType origin[D] = {0., 0.35}; NumericType normal[D] = {0., 1.}; - lsMakeGeometry(plane, - lsSmartPointer>::New(origin, normal)) + ls::MakeGeometry( + plane, ls::SmartPointer>::New(origin, normal)) .apply(); - lsBooleanOperation(domain, plane, lsBooleanOperationEnum::UNION).apply(); + ls::BooleanOperation(domain, plane, ls::BooleanOperationEnum::UNION).apply(); origin[0] = -8.; origin[1] = -9.5; double radius = 5.1; for (unsigned i = 0; i < 2; ++i) { auto hole = - lsSmartPointer>::New(domain->getGrid()); + ls::SmartPointer>::New(domain->getGrid()); - lsMakeGeometry( - hole, lsSmartPointer>::New(origin, radius)) + ls::MakeGeometry( + hole, ls::SmartPointer>::New(origin, radius)) .apply(); - lsBooleanOperation(domain, hole, - lsBooleanOperationEnum::RELATIVE_COMPLEMENT) + ls::BooleanOperation(domain, hole, + ls::BooleanOperationEnum::RELATIVE_COMPLEMENT) .apply(); origin[0] += 16.; } @@ -60,18 +64,18 @@ int main() { NumericType gridDelta = 1; double bounds[2 * D] = {-extent, extent, -extent, extent}; - lsBoundaryConditionEnum boundaryCons[D]; - boundaryCons[0] = lsBoundaryConditionEnum::REFLECTIVE_BOUNDARY; - boundaryCons[1] = lsBoundaryConditionEnum::INFINITE_BOUNDARY; + ls::BoundaryConditionEnum boundaryCons[D]; + boundaryCons[0] = ls::BoundaryConditionEnum::REFLECTIVE_BOUNDARY; + boundaryCons[1] = ls::BoundaryConditionEnum::INFINITE_BOUNDARY; - auto domain = lsSmartPointer>::New( + auto domain = ls::SmartPointer>::New( bounds, boundaryCons, gridDelta); makeGeometry(domain); // outputDomain(domain, "initial"); - auto marker = lsMarkVoidPoints(domain); + auto marker = ls::MarkVoidPoints(domain); marker.setSaveComponentIds(true); marker.apply(); @@ -81,7 +85,8 @@ int main() { // check if void points are set correctly bool correct = true; for (auto it = hrleConstSparseIterator< - typename lsDomain::DomainType>(domain->getDomain()); + typename ls::Domain::DomainType>( + domain->getDomain()); !it.isFinished(); ++it) { // skip undefined runs if (!it.isDefined()) diff --git a/tests/MultiMaterialAdvection/MultiMaterialAdvection.cpp b/tests/MultiMaterialAdvection/MultiMaterialAdvection.cpp index 2dd4e939..73d9f080 100644 --- a/tests/MultiMaterialAdvection/MultiMaterialAdvection.cpp +++ b/tests/MultiMaterialAdvection/MultiMaterialAdvection.cpp @@ -15,9 +15,11 @@ \example MultiMaterialAdvection.cpp */ +namespace ls = viennals; + // implement own velocity field for advection // in this case just grow one of the materials -class velocityField : public lsVelocityField { +class velocityField : public ls::VelocityField { public: double getScalarVelocity(const std::array & /*coordinate*/, int material, @@ -50,19 +52,19 @@ int main() { // set up simulation domains and geometry double gridDelta = 0.25; - auto sphere1 = lsSmartPointer>::New(gridDelta); - auto sphere2 = lsSmartPointer>::New(gridDelta); + auto sphere1 = ls::SmartPointer>::New(gridDelta); + auto sphere2 = ls::SmartPointer>::New(gridDelta); double origin[3] = {5., 0., 0.}; double radius = 9.5; - lsMakeGeometry( - sphere1, lsSmartPointer>::New(origin, radius)) + ls::MakeGeometry( + sphere1, ls::SmartPointer>::New(origin, radius)) .apply(); origin[0] = -5.0; radius = 7.3; - lsMakeGeometry( - sphere2, lsSmartPointer>::New(origin, radius)) + ls::MakeGeometry( + sphere2, ls::SmartPointer>::New(origin, radius)) .apply(); // Perform a boolean operation @@ -70,29 +72,30 @@ int main() { // This is required for the advection kernel to correctly // consider both materials. // Higher materials must always "wrap" ALL lower materials - lsBooleanOperation(sphere2, sphere1, lsBooleanOperationEnum::UNION) + ls::BooleanOperation(sphere2, sphere1, + ls::BooleanOperationEnum::UNION) .apply(); { std::cout << "Extracting..." << std::endl; - auto mesh = lsSmartPointer>::New(); - lsToSurfaceMesh(sphere1, mesh).apply(); - lsVTKWriter(mesh, "lower_0.vtk").apply(); + auto mesh = ls::SmartPointer>::New(); + ls::ToSurfaceMesh(sphere1, mesh).apply(); + ls::VTKWriter(mesh, "lower_0.vtk").apply(); - lsToSurfaceMesh(sphere2, mesh).apply(); - lsVTKWriter(mesh, "union_0.vtk").apply(); + ls::ToSurfaceMesh(sphere2, mesh).apply(); + ls::VTKWriter(mesh, "union_0.vtk").apply(); } // ADVECTION // fill vector with lsDomain pointers - std::vector>> lsDomains; + std::vector>> lsDomains; lsDomains.push_back(sphere1); lsDomains.push_back(sphere2); - auto velocities = lsSmartPointer::New(); + auto velocities = ls::SmartPointer::New(); std::cout << "Advecting" << std::endl; - lsAdvect advection(lsDomains, velocities); + ls::Advect advection(lsDomains, velocities); // We do not need normal vectors since our velocityField does not use them // This could be left on, but would decrease efficiency advection.setCalculateNormalVectors(false); @@ -105,13 +108,13 @@ int main() { // Output result { std::cout << "Extracting..." << std::endl; - auto mesh = lsSmartPointer>::New(); - lsToSurfaceMesh(sphere1, mesh).apply(); - lsVTKWriter(mesh, "lower_1.vtk").apply(); + auto mesh = ls::SmartPointer>::New(); + ls::ToSurfaceMesh(sphere1, mesh).apply(); + ls::VTKWriter(mesh, "lower_1.vtk").apply(); - lsToSurfaceMesh(sphere2, mesh).apply(); + ls::ToSurfaceMesh(sphere2, mesh).apply(); mesh->print(); - lsVTKWriter(mesh, "union_1.vtk").apply(); + ls::VTKWriter(mesh, "union_1.vtk").apply(); } return 0; diff --git a/tests/MultiMaterialEtch/MultiMaterialEtch.cpp b/tests/MultiMaterialEtch/MultiMaterialEtch.cpp index 3bccb958..08d8a05e 100644 --- a/tests/MultiMaterialEtch/MultiMaterialEtch.cpp +++ b/tests/MultiMaterialEtch/MultiMaterialEtch.cpp @@ -16,9 +16,11 @@ \example MultiMaterialAdvection.cpp */ +namespace ls = viennals; + // implement own velocity field for advection // in this case just grow one of the materials -class depositionVel : public lsVelocityField { +class depositionVel : public ls::VelocityField { public: double getScalarVelocity(const std::array & /*coordinate*/, int /*material*/, @@ -28,7 +30,7 @@ class depositionVel : public lsVelocityField { } }; -class etchingVel : public lsVelocityField { +class etchingVel : public ls::VelocityField { public: double getScalarVelocity(const std::array & /*coordinate*/, int material, @@ -60,134 +62,141 @@ int main() { bounds[5] = extent; } - typename lsDomain::BoundaryType boundaryCons[D]; + typename ls::Domain::BoundaryType boundaryCons[D]; for (unsigned i = 0; i < D - 1; ++i) { boundaryCons[i] = - lsDomain::BoundaryType::REFLECTIVE_BOUNDARY; + ls::Domain::BoundaryType::REFLECTIVE_BOUNDARY; } boundaryCons[D - 1] = - lsDomain::BoundaryType::INFINITE_BOUNDARY; + ls::Domain::BoundaryType::INFINITE_BOUNDARY; - auto substrate = - lsSmartPointer>::New(bounds, boundaryCons, gridDelta); - auto mask = - lsSmartPointer>::New(bounds, boundaryCons, gridDelta); + auto substrate = ls::SmartPointer>::New( + bounds, boundaryCons, gridDelta); + auto mask = ls::SmartPointer>::New(bounds, boundaryCons, + gridDelta); double planeOrigin[3] = {0., 0., 0.}; double planeNormal[3] = {0., D == 2, D == 3}; - lsMakeGeometry(substrate, lsSmartPointer>::New( - planeOrigin, planeNormal)) + ls::MakeGeometry( + substrate, + ls::SmartPointer>::New(planeOrigin, planeNormal)) .apply(); double maskOrigin[3] = {0., -10 * (D == 2), -10 * (D == 3)}; double maskNormal[3] = {0, -1.0 * (D == 2), -1.0 * (D == 3)}; - lsMakeGeometry( - mask, lsSmartPointer>::New(maskOrigin, maskNormal)) + ls::MakeGeometry( + mask, ls::SmartPointer>::New(maskOrigin, maskNormal)) .apply(); - lsBooleanOperation(mask, substrate, - lsBooleanOperationEnum::INTERSECT) + ls::BooleanOperation(mask, substrate, + ls::BooleanOperationEnum::INTERSECT) .apply(); { std::cout << "Extracting..." << std::endl; - auto mesh = lsSmartPointer>::New(); - lsToSurfaceMesh(mask, mesh).apply(); - lsVTKWriter(mesh, "maskPlane.vtk").apply(); + auto mesh = ls::SmartPointer>::New(); + ls::ToSurfaceMesh(mask, mesh).apply(); + ls::VTKWriter(mesh, "maskPlane.vtk").apply(); } // { // // create box used for mask // std::cout << "Creating box..." << std::endl; - // lsDomain trench(bounds, boundaryCons, gridDelta); + // ls::Domain trench(bounds, boundaryCons, gridDelta); // double minCorner[3] = {-extent / 4., (D==3)?(-extent / 4.):-15, -15.}; // double maxCorner[3] = {extent / 4., (D==3)?(extent / 4.):5.0, 5.0}; - // lsMakeGeometry(trench, lsBox(minCorner, maxCorner)) + // ls::MakeGeometry(trench, ls::Box(minCorner, + // maxCorner)) // .apply(); // { // std::cout << "Extracting..." << std::endl; - // lsMesh<> mesh; - // lsToMesh(trench, mesh).apply(); - // lsVTKWriter(mesh, "box.vtk").apply(); + // Mesh<> mesh; + // ls::ToMesh(trench, mesh).apply(); + // ls::VTKWriter(mesh, "box.vtk").apply(); // } // // Create trench geometry // std::cout << "Booling trench..." << std::endl; - // lsBooleanOperation(mask, trench, - // lsBooleanOperationEnum::RELATIVE_COMPLEMENT) + // ls::BooleanOperation(mask, trench, + // ls::BooleanOperationEnum::RELATIVE_COMPLEMENT) // .apply(); // { // std::cout << "Extracting..." << std::endl; - // lsMesh<> mesh; - // lsToMesh(mask, mesh).apply(); - // lsVTKWriter(mesh, "mask.vtk").apply(); + // Mesh<> mesh; + // ls::ToMesh(mask, mesh).apply(); + // ls::VTKWriter(mesh, "mask.vtk").apply(); // } // } { - auto mesh = lsSmartPointer>::New(); + auto mesh = ls::SmartPointer>::New(); - lsToMesh(substrate, mesh).apply(); - lsVTKWriter(mesh, "points.vtk").apply(); - lsToSurfaceMesh(substrate, mesh).apply(); - lsVTKWriter(mesh, "surface.vtk").apply(); + ls::ToMesh(substrate, mesh).apply(); + ls::VTKWriter(mesh, "points.vtk").apply(); + ls::ToSurfaceMesh(substrate, mesh).apply(); + ls::VTKWriter(mesh, "surface.vtk").apply(); } - auto depoVel = lsSmartPointer::New(); - auto etchVel = lsSmartPointer::New(); + auto depoVel = ls::SmartPointer::New(); + auto etchVel = ls::SmartPointer::New(); std::cout << "Advecting" << std::endl; - lsAdvect deposition(depoVel); + ls::Advect deposition; + deposition.setVelocityField(depoVel); deposition.insertNextLevelSet(mask); deposition.insertNextLevelSet(substrate); deposition.setAdvectionTime(1); - lsAdvect etching(etchVel); + ls::Advect etching; + etching.setVelocityField(etchVel); etching.insertNextLevelSet(mask); etching.insertNextLevelSet(substrate); etching.setAdvectionTime(1); { - auto mesh = lsSmartPointer>::New(); - lsToSurfaceMesh(mask, mesh).apply(); - lsVTKWriter(mesh, "mask0.vtk").apply(); - lsToSurfaceMesh(substrate, mesh).apply(); - lsVTKWriter(mesh, "surface0.vtk").apply(); + auto mesh = ls::SmartPointer>::New(); + ls::ToSurfaceMesh(mask, mesh).apply(); + ls::VTKWriter(mesh, "mask0.vtk").apply(); + ls::ToSurfaceMesh(substrate, mesh).apply(); + ls::VTKWriter(mesh, "surface0.vtk").apply(); } for (unsigned i = 1; i < 10; ++i) { - lsAdvect deposition(depoVel); + ls::Advect deposition; + deposition.setVelocityField(depoVel); deposition.insertNextLevelSet(mask); deposition.insertNextLevelSet(substrate); deposition.setAdvectionTime(1); - lsAdvect etching(etchVel); + ls::Advect etching; + etching.setVelocityField(etchVel); etching.insertNextLevelSet(mask); etching.insertNextLevelSet(substrate); etching.setAdvectionTime(1); deposition.apply(); - auto mesh = lsSmartPointer>::New(); - lsToSurfaceMesh(mask, mesh).apply(); - lsVTKWriter(mesh, "mask" + std::to_string(2 * i) + ".vtk").apply(); - lsToSurfaceMesh(substrate, mesh).apply(); - lsVTKWriter(mesh, "surface" + std::to_string(2 * i) + ".vtk") + auto mesh = ls::SmartPointer>::New(); + ls::ToSurfaceMesh(mask, mesh).apply(); + ls::VTKWriter(mesh, "mask" + std::to_string(2 * i) + ".vtk") + .apply(); + ls::ToSurfaceMesh(substrate, mesh).apply(); + ls::VTKWriter(mesh, "surface" + std::to_string(2 * i) + ".vtk") .apply(); std::cout << "DepoSteps: " << deposition.getNumberOfTimeSteps() << std::endl; etching.apply(); - lsToSurfaceMesh(substrate, mesh).apply(); - lsVTKWriter(mesh, "surface" + std::to_string(2 * i + 1) + ".vtk") + ls::ToSurfaceMesh(substrate, mesh).apply(); + ls::VTKWriter(mesh, "surface" + std::to_string(2 * i + 1) + ".vtk") .apply(); - lsToSurfaceMesh(mask, mesh).apply(); - lsVTKWriter(mesh, "mask" + std::to_string(2 * i + 1) + ".vtk") + ls::ToSurfaceMesh(mask, mesh).apply(); + ls::VTKWriter(mesh, "mask" + std::to_string(2 * i + 1) + ".vtk") .apply(); std::cout << "EtchSteps: " << etching.getNumberOfTimeSteps() << std::endl; } diff --git a/tests/PeriodicBoundary2D/PeriodicBoundary2D.cpp b/tests/PeriodicBoundary2D/PeriodicBoundary2D.cpp index 664b0bdc..2f9ad803 100644 --- a/tests/PeriodicBoundary2D/PeriodicBoundary2D.cpp +++ b/tests/PeriodicBoundary2D/PeriodicBoundary2D.cpp @@ -18,8 +18,10 @@ \example VoidEtching.cpp */ +namespace ls = viennals; + // implement own velocity field -class velocityField : public lsVelocityField { +class velocityField : public ls::VelocityField { public: double getScalarVelocity(const std::array & /*coordinate*/, int /*material*/, @@ -47,24 +49,25 @@ int main() { double gridDelta = 1; double bounds[2 * D] = {-extent, extent, -extent, extent}; - lsDomain::BoundaryType boundaryCons[D]; - boundaryCons[0] = lsDomain::BoundaryType::PERIODIC_BOUNDARY; - boundaryCons[1] = lsDomain::BoundaryType::INFINITE_BOUNDARY; + ls::Domain::BoundaryType boundaryCons[D]; + boundaryCons[0] = ls::Domain::BoundaryType::PERIODIC_BOUNDARY; + boundaryCons[1] = ls::Domain::BoundaryType::INFINITE_BOUNDARY; - auto substrate = - lsSmartPointer>::New(bounds, boundaryCons, gridDelta); + auto substrate = ls::SmartPointer>::New( + bounds, boundaryCons, gridDelta); double origin[D] = {0., 0.}; double planeNormal[D] = {0., 1.}; - lsMakeGeometry( - substrate, lsSmartPointer>::New(origin, planeNormal)) + ls::MakeGeometry( + substrate, + ls::SmartPointer>::New(origin, planeNormal)) .apply(); std::cout << substrate->getGrid().getMinGridPoint() << std::endl; std::cout << substrate->getGrid().getMaxGridPoint() << std::endl; - // for(hrleConstSparseStarIterator::DomainType, 1> + // for(hrleConstSparseStarIterator::DomainType, 1> // it(substrate.getDomain()); !it.isFinished(); it.next()) { // std::cout << it.getIndices() << ": " << it.getCenter().getEndIndices() << // ", "; for(unsigned i = 0; i< 2*D; ++i) std::cout << @@ -74,49 +77,51 @@ int main() { // << " -- " << it.getNeighbor(0).getValue() << std::endl; // } - // for(hrleConstSparseIterator::DomainType> + // for(hrleConstSparseIterator::DomainType> // it(substrate.getDomain()); !it.isFinished(); it.next()) { // std::cout << it.getStartIndices() << " -- " << it.getEndIndices() << // std::endl; // } - auto mesh = lsSmartPointer>::New(); - lsToMesh(substrate, mesh).apply(); - lsVTKWriter(mesh, lsFileFormatEnum::VTP, "normal.vtp").apply(); + auto mesh = ls::SmartPointer>::New(); + ls::ToMesh(substrate, mesh).apply(); + ls::VTKWriter(mesh, ls::FileFormatEnum::VTP, "normal.vtp").apply(); - // lsExpand(substrate, 4).apply(); - // lsToMesh(substrate, mesh).apply(); - // lsVTKWriter(mesh, lsFileFormatEnum::VTP, "expanded.vtp").apply(); + // ls::Expand(substrate, 4).apply(); + // ls::ToMesh(substrate, mesh).apply(); + // ls::VTKWriter(mesh, ls::FileFormatEnum::VTP, + // "expanded.vtp").apply(); - // lsPrune(substrate).apply(); - // lsToMesh(substrate, mesh).apply(); - // lsVTKWriter(mesh, lsFileFormatEnum::VTP, "pruned.vtp").apply(); + // Prune(substrate).apply(); + // ls::ToMesh(substrate, mesh).apply(); + // ls::VTKWriter(mesh, ls::FileFormatEnum::VTP, "pruned.vtp").apply(); // ----------------------------------------------------- { // create spheres used for booling std::cout << "Creating pillar..." << std::endl; - auto pillar = lsSmartPointer>::New(bounds, boundaryCons, - gridDelta); + auto pillar = ls::SmartPointer>::New( + bounds, boundaryCons, gridDelta); double lowerCorner[D] = {5, -1}; double upperCorner[D] = {15, 10}; - lsMakeGeometry( - pillar, lsSmartPointer>::New(lowerCorner, upperCorner)) + ls::MakeGeometry( + pillar, + ls::SmartPointer>::New(lowerCorner, upperCorner)) .apply(); - auto mesh = lsSmartPointer>::New(); - lsToSurfaceMesh(pillar, mesh).apply(); - lsVTKWriter(mesh, lsFileFormatEnum::VTP, "pillar.vtp").apply(); - lsBooleanOperation boolOp(substrate, pillar, - lsBooleanOperationEnum::UNION); + auto mesh = ls::SmartPointer>::New(); + ls::ToSurfaceMesh(pillar, mesh).apply(); + ls::VTKWriter(mesh, ls::FileFormatEnum::VTP, "pillar.vtp").apply(); + ls::BooleanOperation boolOp(substrate, pillar, + ls::BooleanOperationEnum::UNION); boolOp.apply(); } // Now etch the substrate isotropically - auto velocities = lsSmartPointer::New(); + auto velocities = ls::SmartPointer::New(); std::cout << "Advecting" << std::endl; - lsAdvect advectionKernel; + ls::Advect advectionKernel; advectionKernel.insertNextLevelSet(substrate); advectionKernel.setVelocityField(velocities); @@ -129,15 +134,15 @@ int main() { if (true) { std::cout << "\rAdvection step " + std::to_string(i) + " / " << numberOfSteps << std::flush; - auto mesh = lsSmartPointer>::New(); - lsToSurfaceMesh(substrate, mesh).apply(); - lsVTKWriter(mesh, lsFileFormatEnum::VTP, - "pillar-" + std::to_string(i) + ".vtp") + auto mesh = ls::SmartPointer>::New(); + ls::ToSurfaceMesh(substrate, mesh).apply(); + ls::VTKWriter(mesh, ls::FileFormatEnum::VTP, + "pillar-" + std::to_string(i) + ".vtp") .apply(); - lsToMesh(substrate, mesh).apply(); - lsVTKWriter(mesh, lsFileFormatEnum::VTP, - "LS-" + std::to_string(i) + ".vtp") + ls::ToMesh(substrate, mesh).apply(); + ls::VTKWriter(mesh, ls::FileFormatEnum::VTP, + "LS-" + std::to_string(i) + ".vtp") .apply(); } diff --git a/tests/ReadFromFile/ReadFromFile.cpp b/tests/ReadFromFile/ReadFromFile.cpp index 4113aac6..3fd8e2da 100644 --- a/tests/ReadFromFile/ReadFromFile.cpp +++ b/tests/ReadFromFile/ReadFromFile.cpp @@ -9,17 +9,19 @@ \example ReadFromFile.cpp */ +namespace ls = viennals; + int main(int argc, char **argv) { if (argc == 1 || argc > 2) { std::cout << "Usage: filename.vtk" << std::endl; return 0; } - auto mesh = lsSmartPointer>::New(); + auto mesh = ls::SmartPointer>::New(); - lsVTKReader(mesh, std::string(argv[1])).apply(); + ls::VTKReader(mesh, std::string(argv[1])).apply(); - lsVTKWriter(mesh, "test.vtk").apply(); + ls::VTKWriter(mesh, "test.vtk").apply(); return 0; } diff --git a/tests/ReadVolume/ReadVolume.cpp b/tests/ReadVolume/ReadVolume.cpp index 65ff6e89..4ad6f710 100644 --- a/tests/ReadVolume/ReadVolume.cpp +++ b/tests/ReadVolume/ReadVolume.cpp @@ -7,34 +7,36 @@ #include #include +namespace ls = viennals; + int main() { constexpr int D = 2; omp_set_num_threads(1); double gridDelta = 5e-10; double bounds[2 * D] = {-3.5e-8, 3.5e-8, -5e-8, 5e-8}; - lsDomain::BoundaryType boundaryCons[D]; + ls::Domain::BoundaryType boundaryCons[D]; for (unsigned i = 0; i < D; ++i) - boundaryCons[i] = lsDomain::BoundaryType::REFLECTIVE_BOUNDARY; + boundaryCons[i] = ls::Domain::BoundaryType::REFLECTIVE_BOUNDARY; - boundaryCons[1] = lsDomain::BoundaryType::INFINITE_BOUNDARY; + boundaryCons[1] = ls::Domain::BoundaryType::INFINITE_BOUNDARY; - auto domain = - lsSmartPointer>::New(bounds, boundaryCons, gridDelta); + auto domain = ls::SmartPointer>::New( + bounds, boundaryCons, gridDelta); // Read mesh - auto initialMesh = lsSmartPointer>::New(); - lsVTKReader(initialMesh, "initial.vtu").apply(); + auto initialMesh = ls::SmartPointer>::New(); + ls::VTKReader(initialMesh, "initial.vtu").apply(); initialMesh->print(); - lsFromVolumeMesh reader(domain->getGrid(), initialMesh); + ls::FromVolumeMesh reader(domain->getGrid(), initialMesh); reader.apply(); auto levelSets = reader.getLevelSets(); for (unsigned i = 0; i < levelSets.size(); ++i) { - auto mesh = lsSmartPointer>::New(); - lsToSurfaceMesh(levelSets[i], mesh).apply(); - lsVTKWriter(mesh, "LSsurface-" + std::to_string(i) + ".vtk") + auto mesh = ls::SmartPointer>::New(); + ls::ToSurfaceMesh(levelSets[i], mesh).apply(); + ls::VTKWriter(mesh, "LSsurface-" + std::to_string(i) + ".vtk") .apply(); } diff --git a/tests/RemoveStrayPoints/RemoveStrayPoints.cpp b/tests/RemoveStrayPoints/RemoveStrayPoints.cpp index 1b0a0f78..954b7cb8 100644 --- a/tests/RemoveStrayPoints/RemoveStrayPoints.cpp +++ b/tests/RemoveStrayPoints/RemoveStrayPoints.cpp @@ -11,6 +11,8 @@ #include #include +namespace ls = viennals; + int main() { constexpr int D = 2; // omp_set_num_threads(1); @@ -19,31 +21,31 @@ int main() { double gridDelta = 1; double bounds[2 * D] = {-extent, extent, -extent, extent}; - lsDomain::BoundaryType boundaryCons[D]; + ls::Domain::BoundaryType boundaryCons[D]; for (unsigned i = 0; i < D; ++i) - boundaryCons[i] = lsDomain::BoundaryType::REFLECTIVE_BOUNDARY; + boundaryCons[i] = ls::Domain::BoundaryType::REFLECTIVE_BOUNDARY; - boundaryCons[1] = lsDomain::BoundaryType::INFINITE_BOUNDARY; + boundaryCons[1] = ls::Domain::BoundaryType::INFINITE_BOUNDARY; - auto substrate = - lsSmartPointer>::New(bounds, boundaryCons, gridDelta); + auto substrate = ls::SmartPointer>::New( + bounds, boundaryCons, gridDelta); double origin[D] = {0., 0.}; double normal[D] = {0., 1.}; - lsMakeGeometry( - substrate, lsSmartPointer>::New(origin, normal)) + ls::MakeGeometry( + substrate, ls::SmartPointer>::New(origin, normal)) .apply(); { - auto hole = lsSmartPointer>::New(bounds, boundaryCons, - gridDelta); + auto hole = ls::SmartPointer>::New( + bounds, boundaryCons, gridDelta); origin[1] = -5.; - lsMakeGeometry( - hole, lsSmartPointer>::New(origin, 3.)) + ls::MakeGeometry( + hole, ls::SmartPointer>::New(origin, 3.)) .apply(); - lsBooleanOperation(substrate, hole, - lsBooleanOperationEnum::RELATIVE_COMPLEMENT) + ls::BooleanOperation( + substrate, hole, ls::BooleanOperationEnum::RELATIVE_COMPLEMENT) .apply(); } @@ -53,25 +55,26 @@ int main() { // marker.setVoidTopSurface(lsVoidTopSurfaceEnum::LEX_HIGHEST); // marker.setSaveComponentIds(true); // marker.apply(); - // auto explMesh = lsSmartPointer>::New(); - // lsToMesh(substrate, explMesh).apply(); - // lsVTKWriter(explMesh, lsFileFormatEnum::VTP, + // auto explMesh = ls::SmartPointer>::New(); + // ls::ToMesh(substrate, explMesh).apply(); + // ls::VTKWriter(explMesh, ls::FileFormatEnum::VTP, // "before.vtp").apply(); // } // Remove the stray points - lsRemoveStrayPoints cleaner; + ls::RemoveStrayPoints cleaner; cleaner.setLevelSet(substrate); - cleaner.setVoidTopSurface(lsVoidTopSurfaceEnum::LEX_HIGHEST); + cleaner.setVoidTopSurface(ls::VoidTopSurfaceEnum::LEX_HIGHEST); cleaner.apply(); // check if the correct surface was removed LSTEST_ASSERT(substrate->getNumberOfPoints() == 42) // { - // auto mesh = lsSmartPointer>::New(); - // lsToMesh(substrate, mesh).apply(); - // lsVTKWriter(mesh, lsFileFormatEnum::VTP, "after.vtp").apply(); + // auto mesh = ls::SmartPointer>::New(); + // ls::ToMesh(substrate, mesh).apply(); + // ls::VTKWriter(mesh, ls::FileFormatEnum::VTP, + // "after.vtp").apply(); // } return 0; diff --git a/tests/RotateMesh/RotateMesh.cpp b/tests/RotateMesh/RotateMesh.cpp index 04bd4142..27a511f3 100644 --- a/tests/RotateMesh/RotateMesh.cpp +++ b/tests/RotateMesh/RotateMesh.cpp @@ -7,42 +7,44 @@ #include /** - Minimal example showing how to rotate an lsMesh<> + Minimal example showing how to rotate an Mesh<> \example RotateMesh.cpp */ +namespace ls = viennals; + int main() { using NumericType = double; constexpr int D = 3; omp_set_num_threads(4); - auto levelSet = lsSmartPointer>::New(); - auto mesh = lsSmartPointer>::New(); + auto levelSet = ls::SmartPointer>::New(); + auto mesh = ls::SmartPointer>::New(); const NumericType radius = 7.3; const hrleVectorType min(-50, -25., -25.); const hrleVectorType max(0., 0., 0.); - lsMakeGeometry( - levelSet, lsSmartPointer>::New(min, max)) + ls::MakeGeometry( + levelSet, ls::SmartPointer>::New(min, max)) .apply(); // const hrleVectorType centre(5., 10., 0.); - // lsMakeGeometry( - // levelSet, lsSmartPointer>::New(centre, radius)) + // ls::MakeGeometry( + // levelSet, ls::SmartPointer>::New(centre, radius)) // .apply(); - lsToSurfaceMesh(levelSet, mesh).apply(); + ls::ToSurfaceMesh(levelSet, mesh).apply(); - lsVTKWriter(mesh, "Initial.vtk").apply(); + ls::VTKWriter(mesh, "Initial.vtk").apply(); - // auto mesh = lsSmartPointer>::New(); + // auto mesh = ls::SmartPointer>::New(); // mesh->insertNextNode({1., 0., 1.}); hrleVectorType rotAxis{0., 1., 1.}; - lsTransformMesh(mesh, lsTransformEnum::ROTATION, rotAxis, M_PI_4) + ls::TransformMesh(mesh, ls::TransformEnum::ROTATION, rotAxis, M_PI_4) .apply(); - lsVTKWriter(mesh, "Rotated.vtk").apply(); + ls::VTKWriter(mesh, "Rotated.vtk").apply(); return 0; } diff --git a/tests/Serialize/Serialize.cpp b/tests/Serialize/Serialize.cpp index 0317acaa..5a08c870 100644 --- a/tests/Serialize/Serialize.cpp +++ b/tests/Serialize/Serialize.cpp @@ -14,28 +14,31 @@ \example Serialize.cpp */ +namespace ls = viennals; + int main() { constexpr int D = 2; omp_set_num_threads(4); - auto levelSet = lsSmartPointer>::New(); - auto mesh = lsSmartPointer>::New(); + auto levelSet = ls::SmartPointer>::New(); + auto mesh = ls::SmartPointer>::New(); const double radius = 7.3; const hrleVectorType centre(5., 0.); - lsMakeGeometry( - levelSet, lsSmartPointer>::New(centre, radius)) + ls::MakeGeometry( + levelSet, ls::SmartPointer>::New(centre, radius)) .apply(); - lsPointData &data = levelSet->getPointData(); - typename lsPointData::ScalarDataType scalars; - typename lsPointData::VectorDataType vectors; + ls::PointData &data = levelSet->getPointData(); + typename ls::PointData::ScalarDataType scalars; + typename ls::PointData::VectorDataType vectors; for (unsigned i = 0; i < levelSet->getNumberOfPoints(); ++i) { scalars.push_back(i); vectors.push_back( - typename lsPointData::VectorDataType::value_type({double(i)})); + typename ls::PointData::VectorDataType::value_type( + {double(i)})); } data.insertNextScalarData(scalars, "myScalars"); @@ -45,7 +48,7 @@ int main() { levelSet->serialize(stream); { - auto newLevelSet = lsSmartPointer>::New(); + auto newLevelSet = ls::SmartPointer>::New(); newLevelSet->deserialize(stream); if (newLevelSet->getNumberOfPoints() != levelSet->getNumberOfPoints()) { @@ -54,7 +57,7 @@ int main() { return EXIT_FAILURE; } - lsPointData &newData = newLevelSet->getPointData(); + ls::PointData &newData = newLevelSet->getPointData(); auto scalarDataSize = newData.getScalarDataSize(); if (scalarDataSize != levelSet->getPointData().getScalarDataSize()) { std::cout << "Scalar data was not properly deserialized" << std::endl; diff --git a/tests/SmartPointer/SmartPointer.cpp b/tests/SmartPointer/SmartPointer.cpp index be138034..94f6c8f0 100644 --- a/tests/SmartPointer/SmartPointer.cpp +++ b/tests/SmartPointer/SmartPointer.cpp @@ -1,6 +1,7 @@ #include #include -#include + +namespace ls = viennals; constexpr int D = 3; typedef double NumericType; @@ -15,27 +16,27 @@ auto makeLSDomain() { bounds[5] = extent; } - typename lsDomain::BoundaryType boundaryCons[D]; + typename ls::Domain::BoundaryType boundaryCons[D]; for (unsigned i = 0; i < D - 1; ++i) { boundaryCons[i] = - lsDomain::BoundaryType::REFLECTIVE_BOUNDARY; + ls::Domain::BoundaryType::REFLECTIVE_BOUNDARY; } boundaryCons[D - 1] = - lsDomain::BoundaryType::INFINITE_BOUNDARY; + ls::Domain::BoundaryType::INFINITE_BOUNDARY; - return lsSmartPointer>::New(bounds, boundaryCons, - gridDelta); + return ls::SmartPointer>::New(bounds, boundaryCons, + gridDelta); } unsigned long -getNumberOfPoints(lsSmartPointer> domain) { +getNumberOfPoints(ls::SmartPointer> domain) { return domain->getNumberOfPoints(); } int main() { auto domain = makeLSDomain(); - // lsSmartPointer> constDomain = domain; + // ls::SmartPointer> constDomain = domain; std::cout << getNumberOfPoints(domain) << std::endl; diff --git a/tests/VisualizationMesh/VisualizationMesh.cpp b/tests/VisualizationMesh/VisualizationMesh.cpp index 59f3862b..d8021eac 100644 --- a/tests/VisualizationMesh/VisualizationMesh.cpp +++ b/tests/VisualizationMesh/VisualizationMesh.cpp @@ -9,6 +9,8 @@ #include +namespace ls = viennals; + int main() { omp_set_num_threads(4); @@ -23,15 +25,15 @@ int main() { bounds[5] = 20; } - typename lsDomain::BoundaryType boundaryCons[D]; + typename ls::Domain::BoundaryType boundaryCons[D]; for (unsigned i = 0; i < D - 1; ++i) { boundaryCons[i] = - lsDomain::BoundaryType::REFLECTIVE_BOUNDARY; + ls::Domain::BoundaryType::REFLECTIVE_BOUNDARY; } boundaryCons[D - 1] = - lsDomain::BoundaryType::INFINITE_BOUNDARY; + ls::Domain::BoundaryType::INFINITE_BOUNDARY; - auto substrate = lsSmartPointer>::New( + auto substrate = ls::SmartPointer>::New( bounds, boundaryCons, gridDelta); // create a sphere in the level set @@ -39,34 +41,35 @@ int main() { if constexpr (D == 3) origin[2] = 0; NumericType radius = 15.3; - lsMakeGeometry( - substrate, lsSmartPointer>::New(origin, radius)) + ls::MakeGeometry( + substrate, + ls::SmartPointer>::New(origin, radius)) .apply(); origin[0] = 15.0; radius = 8.7; auto secondSphere = - lsSmartPointer>::New(substrate->getGrid()); - lsMakeGeometry( + ls::SmartPointer>::New(substrate->getGrid()); + ls::MakeGeometry( secondSphere, - lsSmartPointer>::New(origin, radius)) + ls::SmartPointer>::New(origin, radius)) .apply(); - lsBooleanOperation(substrate, secondSphere, - lsBooleanOperationEnum::UNION) + ls::BooleanOperation(substrate, secondSphere, + ls::BooleanOperationEnum::UNION) .apply(); - lsExpand(substrate, 3).apply(); - lsExpand(secondSphere, 3).apply(); + ls::Expand(substrate, 3).apply(); + ls::Expand(secondSphere, 3).apply(); - auto mesh = lsSmartPointer>::New(); - lsToSurfaceMesh(substrate, mesh).apply(); - lsVTKWriter(mesh, "surface_1.vtk").apply(); - lsToSurfaceMesh(secondSphere, mesh).apply(); - lsVTKWriter(mesh, "surface_2.vtk").apply(); + auto mesh = ls::SmartPointer>::New(); + ls::ToSurfaceMesh(substrate, mesh).apply(); + ls::VTKWriter(mesh, "surface_1.vtk").apply(); + ls::ToSurfaceMesh(secondSphere, mesh).apply(); + ls::VTKWriter(mesh, "surface_2.vtk").apply(); auto visualizeMesh = - lsSmartPointer>::New(); + ls::SmartPointer>::New(); visualizeMesh->insertNextLevelSet(secondSphere); visualizeMesh->insertNextLevelSet(substrate); visualizeMesh->setExtractHullMesh(true); @@ -74,17 +77,17 @@ int main() { visualizeMesh->apply(); - // lsBooleanOperation(substrate, secondSphere, - // lsBooleanOperationEnum::UNION) + // ls::BooleanOperation(substrate, secondSphere, + // ls::BooleanOperationEnum::UNION) // .apply(); - // auto mesh = lsSmartPointer>::New(); - // lsToSurfaceMesh(substrate, mesh).apply(); - // lsVTKWriter(mesh, "twoSpheres.vtk").apply(); + // auto mesh = ls::SmartPointer>::New(); + // ls::ToSurfaceMesh(substrate, mesh).apply(); + // ls::VTKWriter(mesh, "twoSpheres.vtk").apply(); // substrate->getDomain().print(); - // for(hrleConstSparseIterator::DomainType> + // for(hrleConstSparseIterator::DomainType> // it(substrate->getDomain()); !it.isFinished(); ++it) { // std::cout << it.getStartIndices() << std::endl; // } diff --git a/tests/VoidDetection/VoidDetection.cpp b/tests/VoidDetection/VoidDetection.cpp index c74b079b..4c22baa4 100644 --- a/tests/VoidDetection/VoidDetection.cpp +++ b/tests/VoidDetection/VoidDetection.cpp @@ -14,8 +14,10 @@ \example VoidDetection.cpp */ +namespace ls = viennals; + // implement own velocity field -class velocityField : public lsVelocityField { +class velocityField : public ls::VelocityField { public: double getScalarVelocity(const std::array & /*coordinate*/, int /*material*/, @@ -44,67 +46,68 @@ int main() { double gridDelta = 1; double bounds[2 * D] = {-extent, extent, -extent, extent}; - lsDomain::BoundaryType boundaryCons[D]; + ls::Domain::BoundaryType boundaryCons[D]; for (unsigned i = 0; i < D; ++i) - boundaryCons[i] = lsDomain::BoundaryType::REFLECTIVE_BOUNDARY; + boundaryCons[i] = ls::Domain::BoundaryType::REFLECTIVE_BOUNDARY; - boundaryCons[1] = lsDomain::BoundaryType::INFINITE_BOUNDARY; + boundaryCons[1] = ls::Domain::BoundaryType::INFINITE_BOUNDARY; - auto substrate = - lsSmartPointer>::New(bounds, boundaryCons, gridDelta); + auto substrate = ls::SmartPointer>::New( + bounds, boundaryCons, gridDelta); double origin[D] = {0., 0.}; double normal[D] = {0., 1.}; - lsMakeGeometry( - substrate, lsSmartPointer>::New(origin, normal)) + ls::MakeGeometry( + substrate, ls::SmartPointer>::New(origin, normal)) .apply(); { - auto hole = lsSmartPointer>::New(bounds, boundaryCons, - gridDelta); + auto hole = ls::SmartPointer>::New( + bounds, boundaryCons, gridDelta); origin[1] = -5.; - lsMakeGeometry( - hole, lsSmartPointer>::New(origin, 3.)) + ls::MakeGeometry( + hole, ls::SmartPointer>::New(origin, 3.)) .apply(); - lsBooleanOperation(substrate, hole, - lsBooleanOperationEnum::RELATIVE_COMPLEMENT) + ls::BooleanOperation( + substrate, hole, ls::BooleanOperationEnum::RELATIVE_COMPLEMENT) .apply(); } { - auto explMesh = lsSmartPointer>::New(); + auto explMesh = ls::SmartPointer>::New(); std::cout << "Extracting..." << std::endl; - lsToSurfaceMesh(substrate, explMesh).apply(); + ls::ToSurfaceMesh(substrate, explMesh).apply(); - lsVTKWriter(explMesh, "before.vtp").apply(); + ls::VTKWriter(explMesh, "before.vtp").apply(); } - lsMarkVoidPoints(substrate).apply(); + ls::MarkVoidPoints(substrate).apply(); { std::cout << "Extracting..." << std::endl; - auto mesh = lsSmartPointer>::New(); - lsToMesh(substrate, mesh).apply(); - lsVTKWriter(mesh, "after.vtp").apply(); + auto mesh = ls::SmartPointer>::New(); + ls::ToMesh(substrate, mesh).apply(); + ls::VTKWriter(mesh, "after.vtp").apply(); } // Advection - auto velocities = lsSmartPointer::New(); - lsAdvect advectionKernel(substrate, velocities); + auto velocities = ls::SmartPointer::New(); + ls::Advect advectionKernel(substrate, velocities); advectionKernel.setIgnoreVoids(true); advectionKernel.setSaveAdvectionVelocities(true); for (unsigned i = 0; i < 30; ++i) { { - auto mesh = lsSmartPointer>::New(); - lsToSurfaceMesh(substrate, mesh).apply(); - lsVTKWriter(mesh, "out-" + std::to_string(i) + ".vtp").apply(); + auto mesh = ls::SmartPointer>::New(); + ls::ToSurfaceMesh(substrate, mesh).apply(); + ls::VTKWriter(mesh, "out-" + std::to_string(i) + ".vtp").apply(); - lsMarkVoidPoints(substrate).apply(); - lsToMesh(substrate, mesh).apply(); + ls::MarkVoidPoints(substrate).apply(); + ls::ToMesh(substrate, mesh).apply(); - lsVTKWriter(mesh, "ls-out-" + std::to_string(i) + ".vtp").apply(); + ls::VTKWriter(mesh, "ls-out-" + std::to_string(i) + ".vtp") + .apply(); } advectionKernel.apply(); } From f21e19cac3a6c3444a6229a5ee05610ed15eabf2 Mon Sep 17 00:00:00 2001 From: Tobias Reiter Date: Sat, 25 May 2024 10:26:20 -0400 Subject: [PATCH 02/11] Fix python examples --- examples/AirGapDeposition/AirGapDeposition.py | 37 ++++++++++--------- examples/Deposition/Deposition.py | 33 +++++++++-------- .../GeometricAdvection/GeometricAdvection.py | 33 +++++++++-------- include/viennals/lsPointData.hpp | 4 +- 4 files changed, 55 insertions(+), 52 deletions(-) diff --git a/examples/AirGapDeposition/AirGapDeposition.py b/examples/AirGapDeposition/AirGapDeposition.py index 96d51e31..02a8d92a 100644 --- a/examples/AirGapDeposition/AirGapDeposition.py +++ b/examples/AirGapDeposition/AirGapDeposition.py @@ -6,7 +6,7 @@ # then grown directionally on top. -class velocityField(vls.lsVelocityField): +class velocityField(vls.VelocityField): # coord and normalVec are lists with 3 elements # in 2D coord[2] and normalVec[2] are zero # getScalarVelocity must return a scalar @@ -24,46 +24,47 @@ def getVectorVelocity(self, coord, material, normal, pointId): boundaryCons = (0, 1, 0) # 0 = reflective, 1 = infinite, 2 = periodic # create level set -substrate = vls.lsDomain(bounds, boundaryCons, gridDelta) +substrate = vls.Domain(bounds, boundaryCons, gridDelta) # create plane origin = (0, 0, 0) planeNormal = (0, 1, 0) -vls.lsMakeGeometry(substrate, vls.lsPlane(origin, planeNormal)).apply() +vls.MakeGeometry(substrate, vls.Plane(origin, planeNormal)).apply() print("Extracting") -mesh = vls.lsMesh() -vls.lsToSurfaceMesh(substrate, mesh).apply() -vls.lsVTKWriter(mesh, "plane.vtk").apply() +mesh = vls.Mesh() +vls.ToSurfaceMesh(substrate, mesh).apply() +vls.VTKWriter(mesh, "plane.vtp").apply() # create layer used for booling print("Creating box...") -trench = vls.lsDomain(bounds, boundaryCons, gridDelta) -minCorner = (-extent / 6., -25.) -maxCorner = (extent / 6., 1.) -vls.lsMakeGeometry(trench, vls.lsBox(minCorner, maxCorner)).apply() +trench = vls.Domain(bounds, boundaryCons, gridDelta) +minCorner = (-extent / 6.0, -25.0) +maxCorner = (extent / 6.0, 1.0) +vls.MakeGeometry(trench, vls.Box(minCorner, maxCorner)).apply() print("Extracting") -vls.lsToMesh(trench, mesh).apply() -vls.lsVTKWriter(mesh, "box.vtk").apply() +vls.ToMesh(trench, mesh).apply() +vls.VTKWriter(mesh, "box.vtp").apply() # Create trench geometry print("Booling trench") -vls.lsBooleanOperation(substrate, trench, - vls.lsBooleanOperationEnum.RELATIVE_COMPLEMENT).apply() +vls.BooleanOperation( + substrate, trench, vls.BooleanOperationEnum.RELATIVE_COMPLEMENT +).apply() # Now grow new material # create new levelset for new material, which will be grown # since it has to wrap around the substrate, just copy it print("Creating new layer...") -newLayer = vls.lsDomain(substrate) +newLayer = vls.Domain(substrate) velocities = velocityField() print("Advecting") -advectionKernel = vls.lsAdvect() +advectionKernel = vls.Advect() # the level set to be advected has to be inserted last # the other could be taken as a mask layer for advection @@ -84,7 +85,7 @@ def getVectorVelocity(self, coord, material, normal, pointId): print("Advection step {} / {}".format(i, numberOfSteps)) - vls.lsToSurfaceMesh(newLayer, mesh).apply() - vls.lsVTKWriter(mesh, "trench{}.vtk".format(i)).apply() + vls.ToSurfaceMesh(newLayer, mesh).apply() + vls.VTKWriter(mesh, "trench{}.vtp".format(i)).apply() print("Time passed during advection: {}".format(passedTime)) diff --git a/examples/Deposition/Deposition.py b/examples/Deposition/Deposition.py index 04b645a7..28d890f0 100644 --- a/examples/Deposition/Deposition.py +++ b/examples/Deposition/Deposition.py @@ -6,7 +6,7 @@ # layer of a different material is then grown on top. -class velocityField(vls.lsVelocityField): +class velocityField(vls.VelocityField): # coord and normalVec are lists with 3 elements # in 2D coord[2] and normalVec[2] are zero # getScalarVelocity must return a scalar @@ -27,37 +27,38 @@ def getVectorVelocity(self, coord, material, normal, pointId): boundaryCons = (0, 0, 1) # 0 = reflective, 1 = infinite, 2 = periodic # create level set -substrate = vls.lsDomain(bounds, boundaryCons, gridDelta) +substrate = vls.Domain(bounds, boundaryCons, gridDelta) # create plane origin = (0, 0, 0) planeNormal = (0, 0, 1) -vls.lsMakeGeometry(substrate, vls.lsPlane(origin, planeNormal)).apply() +vls.MakeGeometry(substrate, vls.Plane(origin, planeNormal)).apply() # create layer used for booling print("Creating box...") -trench = vls.lsDomain(bounds, boundaryCons, gridDelta) -minCorner = (-extent - 1, -extent / 4., -15.) -maxCorner = (extent + 1, extent / 4., 1.) -vls.lsMakeGeometry(trench, vls.lsBox(minCorner, maxCorner)).apply() +trench = vls.Domain(bounds, boundaryCons, gridDelta) +minCorner = (-extent - 1, -extent / 4.0, -15.0) +maxCorner = (extent + 1, extent / 4.0, 1.0) +vls.MakeGeometry(trench, vls.Box(minCorner, maxCorner)).apply() # Create trench geometry print("Booling trench") -vls.lsBooleanOperation(substrate, trench, - vls.lsBooleanOperationEnum.RELATIVE_COMPLEMENT).apply() +vls.BooleanOperation( + substrate, trench, vls.BooleanOperationEnum.RELATIVE_COMPLEMENT +).apply() # Now grow new material # create new levelset for new material, which will be grown # since it has to wrap around the substrate, just copy it print("Creating new layer...") -newLayer = vls.lsDomain(substrate) +newLayer = vls.Domain(substrate) velocities = velocityField() print("Advecting") -advectionKernel = vls.lsAdvect() +advectionKernel = vls.Advect() # the level set to be advected has to be inserted last # the other could be taken as a mask layer for advection @@ -70,16 +71,16 @@ def getVectorVelocity(self, coord, material, normal, pointId): counter = 1 passedTime = 0 -mesh = vls.lsMesh() +mesh = vls.Mesh() while passedTime < 4: advectionKernel.apply() passedTime += advectionKernel.getAdvectedTime() - vls.lsToSurfaceMesh(newLayer, mesh).apply() - vls.lsVTKWriter(mesh, "trench-{}.vtk".format(counter)).apply() + vls.ToSurfaceMesh(newLayer, mesh).apply() + vls.VTKWriter(mesh, "trench-{}.vtp".format(counter)).apply() - vls.lsToMesh(newLayer, mesh).apply() - vls.lsVTKWriter(mesh, "LS-{}.vtk".format(counter)).apply() + vls.ToMesh(newLayer, mesh).apply() + vls.VTKWriter(mesh, "LS-{}.vtp".format(counter)).apply() counter = counter + 1 diff --git a/examples/GeometricAdvection/GeometricAdvection.py b/examples/GeometricAdvection/GeometricAdvection.py index 66673d77..3c4022e7 100644 --- a/examples/GeometricAdvection/GeometricAdvection.py +++ b/examples/GeometricAdvection/GeometricAdvection.py @@ -14,41 +14,42 @@ boundaryCons = (0, 0, 1) # 0 = reflective, 1 = infinite, 2 = periodic # create level set -substrate = vls.lsDomain(bounds, boundaryCons, gridDelta) +substrate = vls.Domain(bounds, boundaryCons, gridDelta) # create plane origin = (0, 0, 0) planeNormal = (0, 0, 1) -vls.lsMakeGeometry(substrate, vls.lsPlane(origin, planeNormal)).apply() +vls.MakeGeometry(substrate, vls.Plane(origin, planeNormal)).apply() # create layer used for booling print("Creating box...") -trench = vls.lsDomain(bounds, boundaryCons, gridDelta) -minCorner = (-extent - 1, -extent / 4., -15.) -maxCorner = (extent + 1, extent / 4., 1.) -vls.lsMakeGeometry(trench, vls.lsBox(minCorner, maxCorner)).apply() +trench = vls.Domain(bounds, boundaryCons, gridDelta) +minCorner = (-extent - 1, -extent / 4.0, -15.0) +maxCorner = (extent + 1, extent / 4.0, 1.0) +vls.MakeGeometry(trench, vls.Box(minCorner, maxCorner)).apply() # Create trench geometry print("Booling trench") -vls.lsBooleanOperation(substrate, trench, - vls.lsBooleanOperationEnum.RELATIVE_COMPLEMENT).apply() +vls.BooleanOperation( + substrate, trench, vls.BooleanOperationEnum.RELATIVE_COMPLEMENT +).apply() -mesh = vls.lsMesh() -vls.lsToSurfaceMesh(substrate, mesh).apply() -vls.lsVTKWriter(mesh, "trench-initial.vtk").apply() +mesh = vls.Mesh() +vls.ToSurfaceMesh(substrate, mesh).apply() +vls.VTKWriter(mesh, "trench-initial.vtp").apply() # Now grow new material # create new levelset for new material, which will be grown # since it has to wrap around the substrate, just copy it print("Creating new layer...") -newLayer = vls.lsDomain(substrate) +newLayer = vls.Domain(substrate) print("Advecting") # Advect the level set -dist = vls.lsSphereDistribution(4.0, gridDelta) -vls.lsGeometricAdvect(newLayer, dist).apply() +dist = vls.SphereDistribution(4.0, gridDelta) +vls.GeometricAdvect(newLayer, dist).apply() -vls.lsToSurfaceMesh(newLayer, mesh).apply() -vls.lsVTKWriter(mesh, "trench-final.vtk").apply() +vls.ToSurfaceMesh(newLayer, mesh).apply() +vls.VTKWriter(mesh, "trench-final.vtp").apply() diff --git a/include/viennals/lsPointData.hpp b/include/viennals/lsPointData.hpp index a20b2f1d..5ac06a43 100644 --- a/include/viennals/lsPointData.hpp +++ b/include/viennals/lsPointData.hpp @@ -257,7 +257,7 @@ class PointData { // identifier: "PointData" // 4 byte: number of scalar data sets // 4 byte: number of vector data sets - stream << "PointData"; + stream << "lsPointData"; uint32_t numberOfScalarData = scalarData.size(); uint32_t numberOfVectorData = vectorData.size(); stream.write(reinterpret_cast(&numberOfScalarData), @@ -318,7 +318,7 @@ class PointData { std::istream &deserialize(std::istream &stream) { char identifier[11]; stream.read(identifier, 11); - if (std::string(identifier).compare(0, 11, "PointData")) { + if (std::string(identifier).compare(0, 11, "lsPointData")) { Logger::getInstance() .addWarning("Reading PointData from stream failed. Header could " "not be found.") From df99b5bbc7580f5f4fa9fa9a2ca621bcb036c552 Mon Sep 17 00:00:00 2001 From: Curve Date: Mon, 27 May 2024 14:28:42 +0200 Subject: [PATCH 03/11] fix(ci/python): disable ipo for alpine --- .github/workflows/python.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 5c54895f..9eb4cac3 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -37,6 +37,12 @@ jobs: key: python-${{ matrix.os }} path: build + - name: 🛠️ Disable IPO (Alpine) + if: ${{ matrix.os == 'ubuntu-latest' }} + run: | + sed -i 's/\(DVIENNALS_BUILD_PYTHON=ON"\)/\1,"-DUSE_IPO=off"/g' pyproject.toml + cat pyproject.toml + - name: 🐍 Build and check Python Module (Windows) if: ${{ matrix.os == 'windows-latest' }} run: | From b4e63e18ea36c01bd9b039800645f4cd1aad1d55 Mon Sep 17 00:00:00 2001 From: Tobias Reiter Date: Tue, 28 May 2024 15:00:05 -0400 Subject: [PATCH 04/11] refactor vector util functions --- CMakeLists.txt | 4 +-- include/viennals/lsCalculateNormalVectors.hpp | 6 ++--- include/viennals/lsConvexHull.hpp | 6 ++--- include/viennals/lsDetectFeatures.hpp | 6 ++--- include/viennals/lsEnquistOsher.hpp | 6 ++--- include/viennals/lsExtrude.hpp | 14 +++++----- .../lsGeometricAdvectDistributions.hpp | 26 +++++++++---------- include/viennals/lsLaxFriedrichs.hpp | 6 ++--- include/viennals/lsLocalLaxFriedrichs.hpp | 10 +++---- .../lsLocalLaxFriedrichsAnalytical.hpp | 8 +++--- .../viennals/lsLocalLocalLaxFriedrichs.hpp | 6 ++--- include/viennals/lsMesh.hpp | 16 ++++++------ include/viennals/lsVelocityField.hpp | 15 +++++------ 13 files changed, 64 insertions(+), 65 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d3d328da..0cd90a5a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -105,11 +105,11 @@ CPMAddPackage( NAME ViennaCore GIT_TAG main # TODO: Create Tag GIT_REPOSITORY "https://github.com/ViennaTools/ViennaCore" - OPTIONS "VIENNA_CORE_FORMAT_EXCLUDE docs/") + OPTIONS "VIENNACORE_FORMAT_EXCLUDE docs/") CPMAddPackage( NAME PackageProject - VERSION 1.12.0 + VERSION 1.11.1 GIT_REPOSITORY "https://github.com/TheLartians/PackageProject.cmake" EXCLUDE_FROM_ALL ${VIENNALS_BUILD_PYTHON}) diff --git a/include/viennals/lsCalculateNormalVectors.hpp b/include/viennals/lsCalculateNormalVectors.hpp index 99ab16a3..7681c4ca 100644 --- a/include/viennals/lsCalculateNormalVectors.hpp +++ b/include/viennals/lsCalculateNormalVectors.hpp @@ -57,7 +57,7 @@ template class CalculateNormalVectors { .print(); } - std::vector>> normalVectorsVector( + std::vector>> normalVectorsVector( levelSet->getNumberOfSegments()); double pointsPerSegment = double(2 * levelSet->getDomain().getNumberOfPoints()) / @@ -94,12 +94,12 @@ template class CalculateNormalVectors { continue; } else if (std::abs(center.getValue()) > maxValue) { // push an empty vector to keep ordering correct - Triple tmp = {}; + Vec3D tmp = {}; normalVectors.push_back(tmp); continue; } - Triple n; + Vec3D n; T denominator = 0; for (int i = 0; i < D; i++) { diff --git a/include/viennals/lsConvexHull.hpp b/include/viennals/lsConvexHull.hpp index c8a2d80e..8426007e 100644 --- a/include/viennals/lsConvexHull.hpp +++ b/include/viennals/lsConvexHull.hpp @@ -407,9 +407,9 @@ template class ConvexHull { // if insertion took place, add the point to the nodes if (insertion.second) { - Triple node{points[hullElements[i][j]][0], - points[hullElements[i][j]][1], - (D == 2) ? T(0.) : points[hullElements[i][j]][2]}; + Vec3D node{points[hullElements[i][j]][0], + points[hullElements[i][j]][1], + (D == 2) ? T(0.) : points[hullElements[i][j]][2]}; mesh->nodes.push_back(node); } diff --git a/include/viennals/lsDetectFeatures.hpp b/include/viennals/lsDetectFeatures.hpp index b12ec74d..335ba7ab 100644 --- a/include/viennals/lsDetectFeatures.hpp +++ b/include/viennals/lsDetectFeatures.hpp @@ -176,7 +176,7 @@ template class DetectFeatures { p = omp_get_thread_num(); #endif - Triple zeroVector{}; + Vec3D zeroVector{}; std::vector &flagsSegment = flagsReserve[p]; flagsSegment.reserve( @@ -200,12 +200,12 @@ template class DetectFeatures { continue; } - Triple centerNormal = normals[neighborIt.getCenter().getPointId()]; + Vec3D centerNormal = normals[neighborIt.getCenter().getPointId()]; bool flag = false; for (unsigned dir = 0; dir < (D * D * D); dir++) { - Triple currentNormal = + Vec3D currentNormal = normals[neighborIt.getNeighbor(dir).getPointId()]; if (currentNormal != zeroVector) { diff --git a/include/viennals/lsEnquistOsher.hpp b/include/viennals/lsEnquistOsher.hpp index 1e80d7ee..43fae596 100644 --- a/include/viennals/lsEnquistOsher.hpp +++ b/include/viennals/lsEnquistOsher.hpp @@ -118,7 +118,7 @@ template class EnquistOsher { // Calculate normal vector for velocity calculation // use std::array since it will be exposed to interface - Triple normalVector = {}; + Vec3D normalVector = {}; if (calculateNormalVectors) { T denominator = 0; for (int i = 0; i < D; i++) { @@ -136,12 +136,12 @@ template class EnquistOsher { } // convert coordinate to std array for interface - Triple coordArray = {coordinate[0], coordinate[1], coordinate[2]}; + Vec3D coordArray = {coordinate[0], coordinate[1], coordinate[2]}; double scalarVelocity = velocities->getScalarVelocity( coordArray, material, normalVector, neighborIterator.getCenter().getPointId()); - Triple vectorVelocity = velocities->getVectorVelocity( + Vec3D vectorVelocity = velocities->getVectorVelocity( coordArray, material, normalVector, neighborIterator.getCenter().getPointId()); diff --git a/include/viennals/lsExtrude.hpp b/include/viennals/lsExtrude.hpp index 499d8428..d1de56c1 100644 --- a/include/viennals/lsExtrude.hpp +++ b/include/viennals/lsExtrude.hpp @@ -14,16 +14,16 @@ using namespace viennacore; template class Extrude { SmartPointer> inputLevelSet = nullptr; SmartPointer> outputLevelSet = nullptr; - Pair extent = {0., 0.}; + Vec2D extent = {0., 0.}; int extrudeDim = 0; - Triple> boundaryConds; + std::array, 3> boundaryConds; public: Extrude() {} Extrude(SmartPointer> passedInputLS, - SmartPointer> passedOutputLS, Pair passedExtent, + SmartPointer> passedOutputLS, Vec2D passedExtent, const int passedExtrudeDim, - Triple> passedBoundaryConds) + std::array, 3> passedBoundaryConds) : inputLevelSet(passedInputLS), outputLevelSet(passedOutputLS), extent(passedExtent), extrudeDim(passedExtrudeDim), boundaryConds(passedBoundaryConds) {} @@ -38,15 +38,15 @@ template class Extrude { } // Set the min and max extent in the extruded dimension - void setExtent(Pair passedExtent) { extent = passedExtent; } + void setExtent(Vec2D passedExtent) { extent = passedExtent; } // Set which index of the added dimension (x: 0, y: 1, z: 2) void setExtrudeDimension(const int passedExtrudeDim) { extrudeDim = passedExtrudeDim; } - void - setBoundaryConditions(Triple> passedBoundaryConds) { + void setBoundaryConditions( + std::array, 3> passedBoundaryConds) { boundaryConds = passedBoundaryConds; } diff --git a/include/viennals/lsGeometricAdvectDistributions.hpp b/include/viennals/lsGeometricAdvectDistributions.hpp index d4c06b85..297c8174 100644 --- a/include/viennals/lsGeometricAdvectDistributions.hpp +++ b/include/viennals/lsGeometricAdvectDistributions.hpp @@ -20,8 +20,8 @@ template class GeometricAdvectDistribution { /// center is inside the distribution. If there is no quick /// check due to the complexity of the distribution, always /// return true or do not overload this function. - virtual bool isInside(const Triple &initial, - const Triple &candidate, + virtual bool isInside(const Vec3D &initial, + const Vec3D &candidate, double eps = 0.) const { return true; } @@ -29,8 +29,8 @@ template class GeometricAdvectDistribution { /// Returns the signed distance of a point relative to the distributions /// center. This is the signed manhatten distance to the nearest surface /// point. - virtual T getSignedDistance(const Triple &initial, - const Triple &candidate, + virtual T getSignedDistance(const Vec3D &initial, + const Vec3D &candidate, unsigned long initialPointId) const = 0; /// Sets bounds to the bounding box of the distribution. @@ -51,8 +51,8 @@ class SphereDistribution : public GeometricAdvectDistribution { SphereDistribution(const T passedRadius, const T delta) : radius(passedRadius), radius2(radius * radius), gridDelta(delta) {} - bool isInside(const Triple &initial, - const Triple &candidate, + bool isInside(const Vec3D &initial, + const Vec3D &candidate, double eps = 0.) const override { hrleCoordType dot = 0.; for (unsigned i = 0; i < D; ++i) { @@ -66,11 +66,11 @@ class SphereDistribution : public GeometricAdvectDistribution { return false; } - T getSignedDistance(const Triple &initial, - const Triple &candidate, + T getSignedDistance(const Vec3D &initial, + const Vec3D &candidate, unsigned long /*initialPointId*/) const override { T distance = std::numeric_limits::max(); - Triple v{}; + Vec3D v{}; for (unsigned i = 0; i < D; ++i) { v[i] = candidate[i] - initial[i]; } @@ -132,8 +132,8 @@ class BoxDistribution : public GeometricAdvectDistribution { } } - bool isInside(const Triple &initial, - const Triple &candidate, + bool isInside(const Vec3D &initial, + const Vec3D &candidate, double eps = 0.) const override { for (unsigned i = 0; i < D; ++i) { if (std::abs(candidate[i] - initial[i]) > @@ -144,8 +144,8 @@ class BoxDistribution : public GeometricAdvectDistribution { return true; } - T getSignedDistance(const Triple &initial, - const Triple &candidate, + T getSignedDistance(const Vec3D &initial, + const Vec3D &candidate, unsigned long /*initialPointId*/) const override { T distance = std::numeric_limits::lowest(); for (unsigned i = 0; i < D; ++i) { diff --git a/include/viennals/lsLaxFriedrichs.hpp b/include/viennals/lsLaxFriedrichs.hpp index d8040645..53aa7092 100644 --- a/include/viennals/lsLaxFriedrichs.hpp +++ b/include/viennals/lsLaxFriedrichs.hpp @@ -58,7 +58,7 @@ template class LaxFriedrichs { T grad = 0.; T dissipation = 0.; - Triple normalVector = {}; + Vec3D normalVector = {}; T normalModulus = 0; const bool calcNormals = calculateNormalVectors; @@ -133,12 +133,12 @@ template class LaxFriedrichs { } // convert coordinate to std array for interface - Triple coordArray = {coordinate[0], coordinate[1], coordinate[2]}; + Vec3D coordArray = {coordinate[0], coordinate[1], coordinate[2]}; double scalarVelocity = velocities->getScalarVelocity( coordArray, material, normalVector, neighborIterator.getCenter().getPointId()); - Triple vectorVelocity = velocities->getVectorVelocity( + Vec3D vectorVelocity = velocities->getVectorVelocity( coordArray, material, normalVector, neighborIterator.getCenter().getPointId()); diff --git a/include/viennals/lsLocalLaxFriedrichs.hpp b/include/viennals/lsLocalLaxFriedrichs.hpp index df59a2e9..061dc9d2 100644 --- a/include/viennals/lsLocalLaxFriedrichs.hpp +++ b/include/viennals/lsLocalLaxFriedrichs.hpp @@ -70,7 +70,7 @@ template class LocalLaxFriedrichs { neighborIterator.goToIndicesSequential(indices); // convert coordinate to std array for interface - Triple coordArray = {coordinate[0], coordinate[1], coordinate[2]}; + Vec3D coordArray = {coordinate[0], coordinate[1], coordinate[2]}; T gradPos[D]; T gradNeg[D]; @@ -78,7 +78,7 @@ template class LocalLaxFriedrichs { T grad = 0.; T dissipation = 0.; - Triple normalVector = {}; + Vec3D normalVector = {}; T normalModulus = 0; for (int i = 0; i < D; i++) { // iterate over dimensions @@ -156,7 +156,7 @@ template class LocalLaxFriedrichs { double scalarVelocity = velocities->getScalarVelocity( coordArray, material, normalVector, neighborIterator.getCenter().getPointId()); - Triple vectorVelocity = velocities->getVectorVelocity( + Vec3D vectorVelocity = velocities->getVectorVelocity( coordArray, material, normalVector, neighborIterator.getCenter().getPointId()); @@ -184,11 +184,11 @@ template class LocalLaxFriedrichs { hrleVectorType neighborIndex(minIndex); for (unsigned i = 0; i < numNeighbors; ++i) { - Triple coords; + Vec3D coords; for (unsigned dir = 0; dir < D; ++dir) { coords[dir] = coordinate[dir] + neighborIndex[dir] * gridDelta; } - Triple normal = {}; + Vec3D normal = {}; double normalModulus = 0.; auto center = neighborIterator.getNeighbor(neighborIndex).getValue(); for (unsigned dir = 0; dir < D; ++dir) { diff --git a/include/viennals/lsLocalLaxFriedrichsAnalytical.hpp b/include/viennals/lsLocalLaxFriedrichsAnalytical.hpp index 0c4eae98..5eebd992 100644 --- a/include/viennals/lsLocalLaxFriedrichsAnalytical.hpp +++ b/include/viennals/lsLocalLaxFriedrichsAnalytical.hpp @@ -69,7 +69,7 @@ template class LocalLaxFriedrichsAnalytical { neighborIterator.goToIndicesSequential(indices); // convert coordinate to std array for interface - Triple coordArray = {coordinate[0], coordinate[1], coordinate[2]}; + Vec3D coordArray = {coordinate[0], coordinate[1], coordinate[2]}; T gradPos[D]; T gradNeg[D]; @@ -77,7 +77,7 @@ template class LocalLaxFriedrichsAnalytical { T grad = 0.; T dissipation = 0.; - Triple normalVector = {}; + Vec3D normalVector = {}; T normalModulus = 0; for (int i = 0; i < D; i++) { // iterate over dimensions @@ -155,7 +155,7 @@ template class LocalLaxFriedrichsAnalytical { double scalarVelocity = velocities->getScalarVelocity( coordArray, material, normalVector, neighborIterator.getCenter().getPointId()); - Triple vectorVelocity = velocities->getVectorVelocity( + Vec3D vectorVelocity = velocities->getVectorVelocity( coordArray, material, normalVector, neighborIterator.getCenter().getPointId()); @@ -184,7 +184,7 @@ template class LocalLaxFriedrichsAnalytical { hrleVectorType neighborIndex(minIndex); for (unsigned i = 0; i < numNeighbors; ++i) { - Triple normal = {}; + Vec3D normal = {}; auto center = neighborIterator.getNeighbor(neighborIndex).getValue(); for (unsigned dir = 0; dir < D; ++dir) { hrleVectorType unity(0); diff --git a/include/viennals/lsLocalLocalLaxFriedrichs.hpp b/include/viennals/lsLocalLocalLaxFriedrichs.hpp index 2b2ff73c..e2095c14 100644 --- a/include/viennals/lsLocalLocalLaxFriedrichs.hpp +++ b/include/viennals/lsLocalLocalLaxFriedrichs.hpp @@ -50,7 +50,7 @@ template class LocalLocalLaxFriedrichs { neighborIterator.goToIndicesSequential(indices); // convert coordinate to std array for interface - Triple coordArray = {coordinate[0], coordinate[1], coordinate[2]}; + Vec3D coordArray = {coordinate[0], coordinate[1], coordinate[2]}; T gradPos[D]; T gradNeg[D]; @@ -58,7 +58,7 @@ template class LocalLocalLaxFriedrichs { T grad = 0.; T dissipation = 0.; - Triple normalVector = {}; + Vec3D normalVector = {}; T normalModulus = 0; for (int i = 0; i < D; i++) { // iterate over dimensions @@ -131,7 +131,7 @@ template class LocalLocalLaxFriedrichs { double scalarVelocity = velocities->getScalarVelocity( coordArray, material, normalVector, neighborIterator.getCenter().getPointId()); - Triple vectorVelocity = velocities->getVectorVelocity( + Vec3D vectorVelocity = velocities->getVectorVelocity( coordArray, material, normalVector, neighborIterator.getCenter().getPointId()); diff --git a/include/viennals/lsMesh.hpp b/include/viennals/lsMesh.hpp index 82a011bb..682252a1 100644 --- a/include/viennals/lsMesh.hpp +++ b/include/viennals/lsMesh.hpp @@ -20,7 +20,7 @@ using namespace viennacore; /// elements. template class Mesh { public: - std::vector> nodes; + std::vector> nodes; std::vector> vertices; std::vector> lines; std::vector> triangles; @@ -28,14 +28,14 @@ template class Mesh { std::vector> hexas; PointData pointData; PointData cellData; - Triple minimumExtent; - Triple maximumExtent; + Vec3D minimumExtent; + Vec3D maximumExtent; private: // iterator typedef using VectorIt = typename PointData::VectorDataType::iterator; // find function to avoid including the whole algorithm header - VectorIt find(VectorIt first, VectorIt last, const Triple &value) { + VectorIt find(VectorIt first, VectorIt last, const Vec3D &value) { for (; first != last; ++first) { if (*first == value) { return first; @@ -57,9 +57,9 @@ template class Mesh { }; public: - const std::vector> &getNodes() const { return nodes; } + const std::vector> &getNodes() const { return nodes; } - std::vector> &getNodes() { return nodes; } + std::vector> &getNodes() { return nodes; } template ::type = 0> std::vector> &getElements() { @@ -94,7 +94,7 @@ template class Mesh { const PointData &getCellData() const { return cellData; } - unsigned insertNextNode(const Triple &node) { + unsigned insertNextNode(const Vec3D &node) { nodes.push_back(node); return nodes.size() - 1; } @@ -150,7 +150,7 @@ template class Mesh { } void removeDuplicateNodes() { - std::vector> newNodes; + std::vector> newNodes; // can just push first point since it cannot be duplicate newNodes.push_back(nodes[0]); // now check for duplicates diff --git a/include/viennals/lsVelocityField.hpp b/include/viennals/lsVelocityField.hpp index 0e37f4ef..c931d096 100644 --- a/include/viennals/lsVelocityField.hpp +++ b/include/viennals/lsVelocityField.hpp @@ -16,19 +16,18 @@ template class VelocityField { /// Should return a scalar value for the velocity at coordinate /// for a point of material with the given normalVector. - virtual T getScalarVelocity(const Triple & /*coordinate*/, - int /*material*/, - const Triple & /*normalVector*/, + virtual T getScalarVelocity(const Vec3D & /*coordinate*/, int /*material*/, + const Vec3D & /*normalVector*/, unsigned long /*pointId*/) { return 0; } /// Like getScalarVelocity, but returns a velocity value for each /// cartesian direction. - virtual Triple getVectorVelocity(const Triple & /*coordinate*/, - int /*material*/, - const Triple & /*normalVector*/, - unsigned long /*pointId*/) { + virtual Vec3D getVectorVelocity(const Vec3D & /*coordinate*/, + int /*material*/, + const Vec3D & /*normalVector*/, + unsigned long /*pointId*/) { return {0, 0, 0}; } @@ -36,7 +35,7 @@ template class VelocityField { /// this is called to provide the analytical solution for the alpha /// values, needed for stable integration. virtual T getDissipationAlpha(int /*direction*/, int /*material*/, - const Triple & /*centralDifferences*/) { + const Vec3D & /*centralDifferences*/) { return 0; } From add101064bca8755f5bf7097e9395a07b8a353c3 Mon Sep 17 00:00:00 2001 From: Tobias Reiter Date: Fri, 31 May 2024 12:14:11 -0400 Subject: [PATCH 05/11] add MaterialMap to Python wrapping --- python/pyWrap.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/python/pyWrap.cpp b/python/pyWrap.cpp index 7253dffa..1195192b 100644 --- a/python/pyWrap.cpp +++ b/python/pyWrap.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -747,6 +748,20 @@ PYBIND11_MODULE(VIENNALS_MODULE_NAME, module) { PointData::getVectorData) .def("getVectorDataLabel", &PointData::getVectorDataLabel); + // MaterialMap + pybind11::class_>(module, + "MaterialMap") + // constructors + .def(pybind11::init(&SmartPointer::New<>)) + // methods + .def("insertNextMaterial", &MaterialMap::insertNextMaterial, + "Insert a new material into the map.") + .def("setMaterialId", &MaterialMap::setMaterialId) + .def("getNumberOfLayers", &MaterialMap::getNumberOfLayers, + "Get the number of level-sets in the material map.") + .def("getNumberOfMaterials", &MaterialMap::getNumberOfMaterials) + .def("getMaterialId", &MaterialMap::getMaterialId); + // Mesh pybind11::class_, SmartPointer>>(module, "Mesh") // constructors From 848e813101eb6ce40efa5a673cf611cef723e609 Mon Sep 17 00:00:00 2001 From: Tobias Reiter Date: Fri, 14 Jun 2024 14:21:17 +0200 Subject: [PATCH 06/11] Add logger wrapper and format project --- CMakeLists.txt | 7 +++--- README.md | 6 ++--- include/viennals/lsBooleanOperation.hpp | 2 +- include/viennals/lsFiniteDifferences.hpp | 2 +- include/viennals/lsFromMesh.hpp | 2 +- include/viennals/lsGeometricAdvect.hpp | 2 +- include/viennals/lsPrune.hpp | 3 ++- include/viennals/lsReduce.hpp | 4 ++-- include/viennals/lsToMesh.hpp | 2 +- pyproject.toml | 2 +- python/pyWrap.cpp | 28 ++++++++++++++++++++++++ 11 files changed, 45 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6477169a..010b9a73 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.20 FATAL_ERROR) project( ViennaLS LANGUAGES CXX - VERSION 3.2.0) + VERSION 4.0.0) # -------------------------------------------------------------------------------------------------------- # Library options @@ -103,9 +103,10 @@ include(cmake/vtk.cmake) CPMAddPackage( NAME ViennaCore - GIT_TAG main # TODO: Create Tag + GIT_TAG v1.0.0 GIT_REPOSITORY "https://github.com/ViennaTools/ViennaCore" - OPTIONS "VIENNACORE_FORMAT_EXCLUDE docs/") + OPTIONS "VIENNACORE_FORMAT_EXCLUDE docs/" + EXCLUDE_FROM_ALL ${VIENNALS_BUILD_PYTHON}) CPMAddPackage( NAME PackageProject diff --git a/README.md b/README.md index db420a37..a46fc45a 100644 --- a/README.md +++ b/README.md @@ -139,7 +139,7 @@ We recommend using [CPM.cmake](https://github.com/cpm-cmake/CPM.cmake) to consum * Installation with CPM ```cmake - CPMAddPackage("gh:viennatools/viennals@3.0.0") + CPMAddPackage("gh:viennatools/viennals@4.0.0") ``` * With a local installation @@ -180,11 +180,11 @@ cmake --build build --target format ## Authors -Current contributors: Lado Filipovic, Paul Manstetten, Xaver Klemenschits and Josef Weinbub +Current contributors: Tobias Reiter, Noah Karnel Founder and initial developer: Otmar Ertl -Contact us via: viennats@iue.tuwien.ac.at +Contact us via: viennatools@iue.tuwien.ac.at ViennaLS was developed under the aegis of the 'Institute for Microelectronics' at the 'TU Wien'. http://www.iue.tuwien.ac.at/ diff --git a/include/viennals/lsBooleanOperation.hpp b/include/viennals/lsBooleanOperation.hpp index da44d251..d06f55a9 100644 --- a/include/viennals/lsBooleanOperation.hpp +++ b/include/viennals/lsBooleanOperation.hpp @@ -277,7 +277,7 @@ template class BooleanOperation { SmartPointer> passedlsDomainB, BooleanOperationEnum passedOperation = BooleanOperationEnum::INTERSECT) : levelSetA(passedlsDomainA), levelSetB(passedlsDomainB), - operation(passedOperation){}; + operation(passedOperation) {}; /// Set which level set to perform the boolean operation on. void setLevelSet(SmartPointer> passedlsDomain) { diff --git a/include/viennals/lsFiniteDifferences.hpp b/include/viennals/lsFiniteDifferences.hpp index 1e64c0ae..3b4b74fd 100644 --- a/include/viennals/lsFiniteDifferences.hpp +++ b/include/viennals/lsFiniteDifferences.hpp @@ -22,7 +22,7 @@ class FiniteDifferences { template static V square(V x) { return x * x; } public: - FiniteDifferences(){}; + FiniteDifferences() {}; static unsigned getNumberOfValues(DifferentiationSchemeEnum s) { switch (s) { diff --git a/include/viennals/lsFromMesh.hpp b/include/viennals/lsFromMesh.hpp index 930d95d5..6bff4de1 100644 --- a/include/viennals/lsFromMesh.hpp +++ b/include/viennals/lsFromMesh.hpp @@ -21,7 +21,7 @@ template class FromMesh { bool sortPointList = true; public: - FromMesh(){}; + FromMesh() {}; FromMesh(SmartPointer> passedLevelSet, const SmartPointer> passedMesh) diff --git a/include/viennals/lsGeometricAdvect.hpp b/include/viennals/lsGeometricAdvect.hpp index fce371bd..59685425 100644 --- a/include/viennals/lsGeometricAdvect.hpp +++ b/include/viennals/lsGeometricAdvect.hpp @@ -469,7 +469,7 @@ template class GeometricAdvect { } } } // domainBounds for - } // parallel region + } // parallel region // copy all points into the first vector { diff --git a/include/viennals/lsPrune.hpp b/include/viennals/lsPrune.hpp index ec34f193..d6f3497c 100644 --- a/include/viennals/lsPrune.hpp +++ b/include/viennals/lsPrune.hpp @@ -56,7 +56,8 @@ template class Prune { public: Prune() {} - Prune(SmartPointer> passedlsDomain) : levelSet(passedlsDomain){}; + Prune(SmartPointer> passedlsDomain) + : levelSet(passedlsDomain) {}; void setLevelSet(SmartPointer> passedlsDomain) { levelSet = passedlsDomain; diff --git a/include/viennals/lsReduce.hpp b/include/viennals/lsReduce.hpp index 073420ba..47cfcf88 100644 --- a/include/viennals/lsReduce.hpp +++ b/include/viennals/lsReduce.hpp @@ -24,12 +24,12 @@ template class Reduce { Reduce() {} Reduce(SmartPointer> passedlsDomain) - : levelSet(passedlsDomain){}; + : levelSet(passedlsDomain) {}; Reduce(SmartPointer> passedlsDomain, int passedWidth, bool passedNoNewSegment = false) : levelSet(passedlsDomain), width(passedWidth), - noNewSegment(passedNoNewSegment){}; + noNewSegment(passedNoNewSegment) {}; void setLevelSet(SmartPointer> passedlsDomain) { levelSet = passedlsDomain; diff --git a/include/viennals/lsToMesh.hpp b/include/viennals/lsToMesh.hpp index a9df1e3f..85129883 100644 --- a/include/viennals/lsToMesh.hpp +++ b/include/viennals/lsToMesh.hpp @@ -26,7 +26,7 @@ template class ToMesh { static constexpr long long maxDomainExtent = 1e6; public: - ToMesh(){}; + ToMesh() {}; ToMesh(const SmartPointer> passedLevelSet, SmartPointer> passedMesh, bool passedOnlyDefined = true, diff --git a/pyproject.toml b/pyproject.toml index 63ee6e88..fb32279c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["scikit-build-core", "pybind11"] build-backend = "scikit_build_core.build" [project] -version = "3.1.0" +version = "4.0.0" name = "ViennaLS_Python" readme = "README.md" license = {file = "LICENSE"} diff --git a/python/pyWrap.cpp b/python/pyWrap.cpp index 1195192b..5a1e2967 100644 --- a/python/pyWrap.cpp +++ b/python/pyWrap.cpp @@ -54,6 +54,7 @@ #include #include +#include #include using namespace viennals; @@ -147,6 +148,33 @@ PYBIND11_MODULE(VIENNALS_MODULE_NAME, module) { // wrap omp_set_num_threads to control number of threads module.def("setNumThreads", &omp_set_num_threads); + // Logger + pybind11::enum_(module, "LogLevel", pybind11::module_local()) + .value("ERROR", LogLevel::ERROR) + .value("WARNING", LogLevel::WARNING) + .value("INFO", LogLevel::INFO) + .value("TIMING", LogLevel::TIMING) + .value("INTERMEDIATE", LogLevel::INTERMEDIATE) + .value("DEBUG", LogLevel::DEBUG) + .export_values(); + + pybind11::class_>(module, "Logger", + pybind11::module_local()) + .def_static("setLogLevel", &Logger::setLogLevel) + .def_static("getLogLevel", &Logger::getLogLevel) + .def_static("getInstance", &Logger::getInstance, + pybind11::return_value_policy::reference) + .def("addDebug", &Logger::addDebug) + .def("addTiming", + (Logger & (Logger::*)(std::string, double)) & Logger::addTiming) + .def("addTiming", (Logger & (Logger::*)(std::string, double, double)) & + Logger::addTiming) + .def("addInfo", &Logger::addInfo) + .def("addWarning", &Logger::addWarning) + .def("addError", &Logger::addError, pybind11::arg("s"), + pybind11::arg("shouldAbort") = true) + .def("print", [](Logger &instance) { instance.print(std::cout); }); + // Advect pybind11::class_, SmartPointer>>(module, "Advect") // constructors From 1b5c161f0af7083925d0600f4bc4b31bf5a4ca2d Mon Sep 17 00:00:00 2001 From: Tobias Reiter Date: Fri, 14 Jun 2024 15:19:33 +0200 Subject: [PATCH 07/11] Add warning is non-existent data is accessed in lsPointData --- include/viennals/lsPointData.hpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/viennals/lsPointData.hpp b/include/viennals/lsPointData.hpp index 5ac06a43..baae835c 100644 --- a/include/viennals/lsPointData.hpp +++ b/include/viennals/lsPointData.hpp @@ -99,6 +99,11 @@ class PointData { if (int i = getScalarDataIndex(searchLabel); i != -1) { return &(scalarData[i]); } + Logger::getInstance() + .addWarning("PointData attempted to access scalar data labeled '" + + searchLabel + + "', which does not exist. Returning nullptr instead.") + .print(); return nullptr; } @@ -106,6 +111,11 @@ class PointData { if (int i = getScalarDataIndex(searchLabel); i != -1) { return &(scalarData[i]); } + Logger::getInstance() + .addWarning("PointData attempted to access scalar data labeled '" + + searchLabel + + "', which does not exist. Returning nullptr instead.") + .print(); return nullptr; } @@ -146,6 +156,11 @@ class PointData { if (int i = getVectorDataIndex(searchLabel); i != -1) { return &(vectorData[i]); } + Logger::getInstance() + .addWarning("PointData attempted to access scalar data labeled '" + + searchLabel + + "', which does not exist. Returning nullptr instead.") + .print(); return nullptr; } @@ -153,6 +168,11 @@ class PointData { if (int i = getVectorDataIndex(searchLabel); i != -1) { return &(vectorData[i]); } + Logger::getInstance() + .addWarning("PointData attempted to access scalar data labeled '" + + searchLabel + + "', which does not exist. Returning nullptr instead.") + .print(); return nullptr; } From 116770dd90f1053dd878c343418e10130641b68c Mon Sep 17 00:00:00 2001 From: Tobias Reiter Date: Fri, 14 Jun 2024 15:51:53 +0200 Subject: [PATCH 08/11] Add noWarning option is lsPointData --- .../VolumeToLevelSets/VolumeToLevelSets.cpp | 4 +- include/viennals/lsAdvect.hpp | 2 +- include/viennals/lsBooleanOperation.hpp | 2 +- include/viennals/lsCalculateCurvatures.hpp | 6 +- include/viennals/lsDetectFeatures.hpp | 2 +- include/viennals/lsFromMesh.hpp | 2 +- include/viennals/lsFromVolumeMesh.hpp | 2 +- include/viennals/lsMarkVoidPoints.hpp | 4 +- include/viennals/lsPointData.hpp | 56 +++++++++++-------- include/viennals/lsRemoveStrayPoints.hpp | 2 +- 10 files changed, 45 insertions(+), 37 deletions(-) diff --git a/examples/VolumeToLevelSets/VolumeToLevelSets.cpp b/examples/VolumeToLevelSets/VolumeToLevelSets.cpp index 30607ce6..afa3a7ed 100644 --- a/examples/VolumeToLevelSets/VolumeToLevelSets.cpp +++ b/examples/VolumeToLevelSets/VolumeToLevelSets.cpp @@ -30,9 +30,7 @@ int main(int argc, char *argv[]) { mesh->getCellData().getScalarData("Material"); std::vector translator = {3, 2, 4, 7, 7, 6, 5, 7, 1, 0}; - if (materialData == nullptr) { - std::cout << "Could not get material data" << std::endl; - } else { + if (materialData != nullptr) { for (auto &cell : *materialData) { cell = translator[std::round(cell)]; } diff --git a/include/viennals/lsAdvect.hpp b/include/viennals/lsAdvect.hpp index 51bb630e..eef389aa 100644 --- a/include/viennals/lsAdvect.hpp +++ b/include/viennals/lsAdvect.hpp @@ -398,7 +398,7 @@ template class Advect { MarkVoidPoints(levelSets.back()).apply(); auto &pointData = levelSets.back()->getPointData(); voidMarkerPointer = - pointData.getScalarData(MarkVoidPoints::voidPointLabel); + pointData.getScalarData(MarkVoidPoints::voidPointLabel, true); if (voidMarkerPointer == nullptr) { Logger::getInstance() .addWarning("Advect: Cannot find void point markers. Not " diff --git a/include/viennals/lsBooleanOperation.hpp b/include/viennals/lsBooleanOperation.hpp index d06f55a9..89e54856 100644 --- a/include/viennals/lsBooleanOperation.hpp +++ b/include/viennals/lsBooleanOperation.hpp @@ -150,7 +150,7 @@ template class BooleanOperation { // scalars for (unsigned i = 0; i < AData.getScalarDataSize(); ++i) { auto scalarDataLabel = AData.getScalarDataLabel(i); - auto BPointer = BData.getScalarData(scalarDataLabel); + auto BPointer = BData.getScalarData(scalarDataLabel, true); if (BPointer != nullptr) { auto APointer = AData.getScalarData(i); // copy all data into the new scalarData diff --git a/include/viennals/lsCalculateCurvatures.hpp b/include/viennals/lsCalculateCurvatures.hpp index e3716095..b2d41bb0 100644 --- a/include/viennals/lsCalculateCurvatures.hpp +++ b/include/viennals/lsCalculateCurvatures.hpp @@ -173,7 +173,8 @@ template class CalculateCurvatures { // insert into pointData of levelSet if (calculateMean) { auto &pointData = levelSet->getPointData(); - auto scalarDataPointer = pointData.getScalarData(meanCurvatureLabel); + auto scalarDataPointer = + pointData.getScalarData(meanCurvatureLabel, true); // if it does not exist, insert new normals vector if (scalarDataPointer == nullptr) { pointData.insertNextScalarData(meanCurvaturesVector[0], @@ -186,7 +187,8 @@ template class CalculateCurvatures { if (calculateGauss) { auto &pointData = levelSet->getPointData(); - auto scalarDataPointer = pointData.getScalarData(gaussianCurvatureLabel); + auto scalarDataPointer = + pointData.getScalarData(gaussianCurvatureLabel, true); // if it does not exist, insert new normals vector if (scalarDataPointer == nullptr) { pointData.insertNextScalarData(gaussCurvaturesVector[0], diff --git a/include/viennals/lsDetectFeatures.hpp b/include/viennals/lsDetectFeatures.hpp index 335ba7ab..26bb8ed2 100644 --- a/include/viennals/lsDetectFeatures.hpp +++ b/include/viennals/lsDetectFeatures.hpp @@ -71,7 +71,7 @@ template class DetectFeatures { // insert into pointData of levelSet auto &pointData = levelSet->getPointData(); - auto vectorDataPointer = pointData.getScalarData(featureMarkersLabel); + auto vectorDataPointer = pointData.getScalarData(featureMarkersLabel, true); // if it does not exist, insert new feature vector if (vectorDataPointer == nullptr) { pointData.insertNextScalarData(flaggedCells, featureMarkersLabel); diff --git a/include/viennals/lsFromMesh.hpp b/include/viennals/lsFromMesh.hpp index 6bff4de1..3b04f1bc 100644 --- a/include/viennals/lsFromMesh.hpp +++ b/include/viennals/lsFromMesh.hpp @@ -53,7 +53,7 @@ template class FromMesh { auto &domain = levelSet->getDomain(); auto &nodes = mesh->getNodes(); - auto values = mesh->cellData.getScalarData("LSValues"); + auto values = mesh->cellData.getScalarData("LSValues", true); if (values == nullptr) { Logger::getInstance() diff --git a/include/viennals/lsFromVolumeMesh.hpp b/include/viennals/lsFromVolumeMesh.hpp index f6f3478a..b5d1b7e4 100644 --- a/include/viennals/lsFromVolumeMesh.hpp +++ b/include/viennals/lsFromVolumeMesh.hpp @@ -70,7 +70,7 @@ template class FromVolumeMesh { // get the unique material numbers for explicit booling std::vector materialInts; typename PointData::ScalarDataType *materialData = - mesh->cellData.getScalarData("Material"); + mesh->cellData.getScalarData("Material", true); if (materialData != nullptr) { // make unique list of materialIds materialInts = diff --git a/include/viennals/lsMarkVoidPoints.hpp b/include/viennals/lsMarkVoidPoints.hpp index cb8c6257..f6447d6e 100644 --- a/include/viennals/lsMarkVoidPoints.hpp +++ b/include/viennals/lsMarkVoidPoints.hpp @@ -303,7 +303,7 @@ template class MarkVoidPoints { } auto &pointData = domain->getPointData(); - auto voidMarkersPointer = pointData.getScalarData(voidPointLabel); + auto voidMarkersPointer = pointData.getScalarData(voidPointLabel, true); // if vector data does not exist if (voidMarkersPointer == nullptr) { pointData.insertNextScalarData(voidPointMarkers, voidPointLabel); @@ -313,7 +313,7 @@ template class MarkVoidPoints { if (saveComponents) { auto componentMarkersPointer = - pointData.getScalarData("ConnectedComponentId"); + pointData.getScalarData("ConnectedComponentId", true); // if vector data does not exist if (componentMarkersPointer == nullptr) { pointData.insertNextScalarData(componentMarkers, diff --git a/include/viennals/lsPointData.hpp b/include/viennals/lsPointData.hpp index baae835c..188044e6 100644 --- a/include/viennals/lsPointData.hpp +++ b/include/viennals/lsPointData.hpp @@ -95,27 +95,31 @@ class PointData { return indexPointerOrNull(scalarData, index); } - ScalarDataType *getScalarData(std::string searchLabel) { + ScalarDataType *getScalarData(std::string searchLabel, + bool noWarning = false) { if (int i = getScalarDataIndex(searchLabel); i != -1) { return &(scalarData[i]); } - Logger::getInstance() - .addWarning("PointData attempted to access scalar data labeled '" + - searchLabel + - "', which does not exist. Returning nullptr instead.") - .print(); + if (!noWarning) + Logger::getInstance() + .addWarning("PointData attempted to access scalar data labeled '" + + searchLabel + + "', which does not exist. Returning nullptr instead.") + .print(); return nullptr; } - const ScalarDataType *getScalarData(std::string searchLabel) const { + const ScalarDataType *getScalarData(std::string searchLabel, + bool noWarning = false) const { if (int i = getScalarDataIndex(searchLabel); i != -1) { return &(scalarData[i]); } - Logger::getInstance() - .addWarning("PointData attempted to access scalar data labeled '" + - searchLabel + - "', which does not exist. Returning nullptr instead.") - .print(); + if (!noWarning) + Logger::getInstance() + .addWarning("PointData attempted to access scalar data labeled '" + + searchLabel + + "', which does not exist. Returning nullptr instead.") + .print(); return nullptr; } @@ -152,27 +156,31 @@ class PointData { return indexPointerOrNull(vectorData, index); } - VectorDataType *getVectorData(std::string searchLabel) { + VectorDataType *getVectorData(std::string searchLabel, + bool noWarning = false) { if (int i = getVectorDataIndex(searchLabel); i != -1) { return &(vectorData[i]); } - Logger::getInstance() - .addWarning("PointData attempted to access scalar data labeled '" + - searchLabel + - "', which does not exist. Returning nullptr instead.") - .print(); + if (!noWarning) + Logger::getInstance() + .addWarning("PointData attempted to access vector data labeled '" + + searchLabel + + "', which does not exist. Returning nullptr instead.") + .print(); return nullptr; } - const VectorDataType *getVectorData(std::string searchLabel) const { + const VectorDataType *getVectorData(std::string searchLabel, + bool noWarning = false) const { if (int i = getVectorDataIndex(searchLabel); i != -1) { return &(vectorData[i]); } - Logger::getInstance() - .addWarning("PointData attempted to access scalar data labeled '" + - searchLabel + - "', which does not exist. Returning nullptr instead.") - .print(); + if (!noWarning) + Logger::getInstance() + .addWarning("PointData attempted to access vector data labeled '" + + searchLabel + + "', which does not exist. Returning nullptr instead.") + .print(); return nullptr; } diff --git a/include/viennals/lsRemoveStrayPoints.hpp b/include/viennals/lsRemoveStrayPoints.hpp index b80cb2ef..d4c03a45 100644 --- a/include/viennals/lsRemoveStrayPoints.hpp +++ b/include/viennals/lsRemoveStrayPoints.hpp @@ -54,7 +54,7 @@ template class RemoveStrayPoints { } auto voidMarkers = - levelSet->getPointData().getScalarData("VoidPointMarkers"); + levelSet->getPointData().getScalarData("VoidPointMarkers", true); if (voidMarkers == nullptr) { Logger::getInstance() .addWarning("RemoveStrayPoints: No scalar data for void point " From 4eb7a6bcde0729cf9d14f67d848ac9629f80710e Mon Sep 17 00:00:00 2001 From: Tobias Reiter Date: Fri, 14 Jun 2024 16:01:21 +0200 Subject: [PATCH 09/11] Fix bindings --- include/viennals/lsBooleanOperation.hpp | 2 +- include/viennals/lsCalculateNormalVectors.hpp | 2 +- python/pyWrap.cpp | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/viennals/lsBooleanOperation.hpp b/include/viennals/lsBooleanOperation.hpp index 89e54856..eea20122 100644 --- a/include/viennals/lsBooleanOperation.hpp +++ b/include/viennals/lsBooleanOperation.hpp @@ -168,7 +168,7 @@ template class BooleanOperation { // vectors for (unsigned i = 0; i < AData.getVectorDataSize(); ++i) { auto vectorDataLabel = AData.getVectorDataLabel(i); - auto BPointer = BData.getVectorData(vectorDataLabel); + auto BPointer = BData.getVectorData(vectorDataLabel, true); if (BPointer != nullptr) { auto APointer = AData.getVectorData(i); // copy all data into the new vectorData diff --git a/include/viennals/lsCalculateNormalVectors.hpp b/include/viennals/lsCalculateNormalVectors.hpp index 7681c4ca..b8703bbd 100644 --- a/include/viennals/lsCalculateNormalVectors.hpp +++ b/include/viennals/lsCalculateNormalVectors.hpp @@ -142,7 +142,7 @@ template class CalculateNormalVectors { // insert into pointData of levelSet auto &pointData = levelSet->getPointData(); - auto vectorDataPointer = pointData.getVectorData(normalVectorsLabel); + auto vectorDataPointer = pointData.getVectorData(normalVectorsLabel, true); // if it does not exist, insert new normals vector if (vectorDataPointer == nullptr) { pointData.insertNextVectorData(normalVectorsVector[0], diff --git a/python/pyWrap.cpp b/python/pyWrap.cpp index 5a1e2967..714dff14 100644 --- a/python/pyWrap.cpp +++ b/python/pyWrap.cpp @@ -764,16 +764,16 @@ PYBIND11_MODULE(VIENNALS_MODULE_NAME, module) { .def("getScalarData", (PointData::ScalarDataType * (PointData::*)(int)) & PointData::getScalarData) - .def("getScalarData", - (PointData::ScalarDataType * (PointData::*)(std::string)) & - PointData::getScalarData) + .def("getScalarData", (PointData::ScalarDataType * + (PointData::*)(std::string, bool)) & + PointData::getScalarData) .def("getScalarDataLabel", &PointData::getScalarDataLabel) .def("getVectorData", (PointData::VectorDataType * (PointData::*)(int)) & PointData::getVectorData) - .def("getVectorData", - (PointData::VectorDataType * (PointData::*)(std::string)) & - PointData::getVectorData) + .def("getVectorData", (PointData::VectorDataType * + (PointData::*)(std::string, bool)) & + PointData::getVectorData) .def("getVectorDataLabel", &PointData::getVectorDataLabel); // MaterialMap From 46eaf70f4174127b2f15b3fc8c814f1a0d1ad6b8 Mon Sep 17 00:00:00 2001 From: Tobias Reiter Date: Mon, 17 Jun 2024 09:25:19 +0200 Subject: [PATCH 10/11] Format --- include/viennals/lsBooleanOperation.hpp | 2 +- include/viennals/lsFiniteDifferences.hpp | 2 +- include/viennals/lsFromMesh.hpp | 2 +- include/viennals/lsPrune.hpp | 3 +-- include/viennals/lsReduce.hpp | 4 ++-- include/viennals/lsToMesh.hpp | 2 +- 6 files changed, 7 insertions(+), 8 deletions(-) diff --git a/include/viennals/lsBooleanOperation.hpp b/include/viennals/lsBooleanOperation.hpp index eea20122..30207517 100644 --- a/include/viennals/lsBooleanOperation.hpp +++ b/include/viennals/lsBooleanOperation.hpp @@ -277,7 +277,7 @@ template class BooleanOperation { SmartPointer> passedlsDomainB, BooleanOperationEnum passedOperation = BooleanOperationEnum::INTERSECT) : levelSetA(passedlsDomainA), levelSetB(passedlsDomainB), - operation(passedOperation) {}; + operation(passedOperation){}; /// Set which level set to perform the boolean operation on. void setLevelSet(SmartPointer> passedlsDomain) { diff --git a/include/viennals/lsFiniteDifferences.hpp b/include/viennals/lsFiniteDifferences.hpp index 3b4b74fd..1e64c0ae 100644 --- a/include/viennals/lsFiniteDifferences.hpp +++ b/include/viennals/lsFiniteDifferences.hpp @@ -22,7 +22,7 @@ class FiniteDifferences { template static V square(V x) { return x * x; } public: - FiniteDifferences() {}; + FiniteDifferences(){}; static unsigned getNumberOfValues(DifferentiationSchemeEnum s) { switch (s) { diff --git a/include/viennals/lsFromMesh.hpp b/include/viennals/lsFromMesh.hpp index 3b04f1bc..9252b6e0 100644 --- a/include/viennals/lsFromMesh.hpp +++ b/include/viennals/lsFromMesh.hpp @@ -21,7 +21,7 @@ template class FromMesh { bool sortPointList = true; public: - FromMesh() {}; + FromMesh(){}; FromMesh(SmartPointer> passedLevelSet, const SmartPointer> passedMesh) diff --git a/include/viennals/lsPrune.hpp b/include/viennals/lsPrune.hpp index d6f3497c..ec34f193 100644 --- a/include/viennals/lsPrune.hpp +++ b/include/viennals/lsPrune.hpp @@ -56,8 +56,7 @@ template class Prune { public: Prune() {} - Prune(SmartPointer> passedlsDomain) - : levelSet(passedlsDomain) {}; + Prune(SmartPointer> passedlsDomain) : levelSet(passedlsDomain){}; void setLevelSet(SmartPointer> passedlsDomain) { levelSet = passedlsDomain; diff --git a/include/viennals/lsReduce.hpp b/include/viennals/lsReduce.hpp index 47cfcf88..073420ba 100644 --- a/include/viennals/lsReduce.hpp +++ b/include/viennals/lsReduce.hpp @@ -24,12 +24,12 @@ template class Reduce { Reduce() {} Reduce(SmartPointer> passedlsDomain) - : levelSet(passedlsDomain) {}; + : levelSet(passedlsDomain){}; Reduce(SmartPointer> passedlsDomain, int passedWidth, bool passedNoNewSegment = false) : levelSet(passedlsDomain), width(passedWidth), - noNewSegment(passedNoNewSegment) {}; + noNewSegment(passedNoNewSegment){}; void setLevelSet(SmartPointer> passedlsDomain) { levelSet = passedlsDomain; diff --git a/include/viennals/lsToMesh.hpp b/include/viennals/lsToMesh.hpp index 85129883..a9df1e3f 100644 --- a/include/viennals/lsToMesh.hpp +++ b/include/viennals/lsToMesh.hpp @@ -26,7 +26,7 @@ template class ToMesh { static constexpr long long maxDomainExtent = 1e6; public: - ToMesh() {}; + ToMesh(){}; ToMesh(const SmartPointer> passedLevelSet, SmartPointer> passedMesh, bool passedOnlyDefined = true, From 72fc613f22dcf7892448117b6451abe999f41728 Mon Sep 17 00:00:00 2001 From: Tobias Reiter Date: Mon, 17 Jun 2024 09:37:54 +0200 Subject: [PATCH 11/11] Fix shared library build --- include/viennals/lsGeometricAdvect.hpp | 2 +- lib/specialisations.cpp | 64 ++++++++++++++------------ 2 files changed, 35 insertions(+), 31 deletions(-) diff --git a/include/viennals/lsGeometricAdvect.hpp b/include/viennals/lsGeometricAdvect.hpp index 59685425..fce371bd 100644 --- a/include/viennals/lsGeometricAdvect.hpp +++ b/include/viennals/lsGeometricAdvect.hpp @@ -469,7 +469,7 @@ template class GeometricAdvect { } } } // domainBounds for - } // parallel region + } // parallel region // copy all points into the first vector { diff --git a/lib/specialisations.cpp b/lib/specialisations.cpp index 8ce7a127..a8b1badd 100644 --- a/lib/specialisations.cpp +++ b/lib/specialisations.cpp @@ -27,35 +27,39 @@ #include #include +namespace viennals { + // now call the specialize macro to precompile them -PRECOMPILE_SPECIALIZE_PRECISION(lsPointData) -PRECOMPILE_SPECIALIZE_PRECISION(lsMesh) -PRECOMPILE_SPECIALIZE(lsAdvect) -PRECOMPILE_SPECIALIZE(lsBooleanOperation) -PRECOMPILE_SPECIALIZE(lsCalculateCurvatures) -PRECOMPILE_SPECIALIZE(lsCalculateNormalVectors) -PRECOMPILE_SPECIALIZE(lsCheck) -PRECOMPILE_SPECIALIZE(lsConvexHull) -PRECOMPILE_SPECIALIZE(lsDomain) -PRECOMPILE_SPECIALIZE(lsExpand) -PRECOMPILE_SPECIALIZE(lsGeometricAdvect) -PRECOMPILE_SPECIALIZE(lsDetectFeatures) -PRECOMPILE_SPECIALIZE(lsFromMesh) -PRECOMPILE_SPECIALIZE(lsFromSurfaceMesh) -PRECOMPILE_SPECIALIZE(lsFromVolumeMesh) -PRECOMPILE_SPECIALIZE(lsSphere) -PRECOMPILE_SPECIALIZE(lsPlane) -PRECOMPILE_SPECIALIZE(lsBox) -PRECOMPILE_SPECIALIZE(lsPointCloud) -PRECOMPILE_SPECIALIZE(lsMakeGeometry) -PRECOMPILE_SPECIALIZE(lsPrune) -PRECOMPILE_SPECIALIZE(lsReader) -PRECOMPILE_SPECIALIZE(lsReduce) -PRECOMPILE_SPECIALIZE(lsToDiskMesh) -PRECOMPILE_SPECIALIZE(lsToMesh) -PRECOMPILE_SPECIALIZE(lsToSurfaceMesh) -PRECOMPILE_SPECIALIZE(lsToVoxelMesh) -PRECOMPILE_SPECIALIZE(lsWriter) +PRECOMPILE_SPECIALIZE_PRECISION(PointData) +PRECOMPILE_SPECIALIZE_PRECISION(Mesh) +PRECOMPILE_SPECIALIZE(Advect) +PRECOMPILE_SPECIALIZE(BooleanOperation) +PRECOMPILE_SPECIALIZE(CalculateCurvatures) +PRECOMPILE_SPECIALIZE(CalculateNormalVectors) +PRECOMPILE_SPECIALIZE(Check) +PRECOMPILE_SPECIALIZE(ConvexHull) +PRECOMPILE_SPECIALIZE(Domain) +PRECOMPILE_SPECIALIZE(Expand) +PRECOMPILE_SPECIALIZE(GeometricAdvect) +PRECOMPILE_SPECIALIZE(DetectFeatures) +PRECOMPILE_SPECIALIZE(FromMesh) +PRECOMPILE_SPECIALIZE(FromSurfaceMesh) +PRECOMPILE_SPECIALIZE(FromVolumeMesh) +PRECOMPILE_SPECIALIZE(Sphere) +PRECOMPILE_SPECIALIZE(Plane) +PRECOMPILE_SPECIALIZE(Box) +PRECOMPILE_SPECIALIZE(PointCloud) +PRECOMPILE_SPECIALIZE(MakeGeometry) +PRECOMPILE_SPECIALIZE(Prune) +PRECOMPILE_SPECIALIZE(Reader) +PRECOMPILE_SPECIALIZE(Reduce) +PRECOMPILE_SPECIALIZE(ToDiskMesh) +PRECOMPILE_SPECIALIZE(ToMesh) +PRECOMPILE_SPECIALIZE(ToSurfaceMesh) +PRECOMPILE_SPECIALIZE(ToVoxelMesh) +PRECOMPILE_SPECIALIZE(Writer) #ifdef VIENNALS_USE_VTK -PRECOMPILE_SPECIALIZE(lsWriteVisualizationMesh) -#endif \ No newline at end of file +PRECOMPILE_SPECIALIZE(WriteVisualizationMesh) +#endif + +} // namespace viennals \ No newline at end of file