Skip to content

Commit

Permalink
refactor with namespace viennals
Browse files Browse the repository at this point in the history
  • Loading branch information
tobre1 committed May 24, 2024
1 parent 8280ddd commit 655ec5b
Show file tree
Hide file tree
Showing 103 changed files with 3,095 additions and 2,997 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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/")
Expand All @@ -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()
Expand Down
52 changes: 28 additions & 24 deletions examples/AirGapDeposition/AirGapDeposition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<NumericType> {
class velocityField : public ls::VelocityField<NumericType> {
public:
NumericType
getScalarVelocity(const std::array<NumericType, 3> & /*coordinate*/,
Expand Down Expand Up @@ -50,51 +52,53 @@ int main() {
NumericType gridDelta = 0.5;

hrleCoordType bounds[2 * D] = {-extent, extent, -extent, extent};
lsDomain<NumericType, D>::BoundaryType boundaryCons[D];
boundaryCons[0] = lsDomain<NumericType, D>::BoundaryType::REFLECTIVE_BOUNDARY;
boundaryCons[1] = lsDomain<NumericType, D>::BoundaryType::INFINITE_BOUNDARY;
ls::Domain<NumericType, D>::BoundaryType boundaryCons[D];
boundaryCons[0] =
ls::Domain<NumericType, D>::BoundaryType::REFLECTIVE_BOUNDARY;
boundaryCons[1] = ls::Domain<NumericType, D>::BoundaryType::INFINITE_BOUNDARY;

auto substrate = lsSmartPointer<lsDomain<NumericType, D>>::New(
auto substrate = ls::SmartPointer<ls::Domain<NumericType, D>>::New(
bounds, boundaryCons, gridDelta);

NumericType origin[2] = {0., 0.};
NumericType planeNormal[2] = {0., 1.};

{
auto plane =
lsSmartPointer<lsPlane<NumericType, D>>::New(origin, planeNormal);
lsMakeGeometry<NumericType, D>(substrate, plane).apply();
ls::SmartPointer<ls::Plane<NumericType, D>>::New(origin, planeNormal);
ls::MakeGeometry<NumericType, D>(substrate, plane).apply();
}

{
std::cout << "Extracting..." << std::endl;
auto mesh = lsSmartPointer<lsMesh<NumericType>>::New();
lsToSurfaceMesh<NumericType, D>(substrate, mesh).apply();
lsVTKWriter<NumericType>(mesh, "plane.vtp").apply();
auto mesh = ls::SmartPointer<ls::Mesh<NumericType>>::New();
ls::ToSurfaceMesh<NumericType, D>(substrate, mesh).apply();
ls::VTKWriter<NumericType>(mesh, "plane.vtp").apply();
}

{
// create layer used for booling
std::cout << "Creating box..." << std::endl;
auto trench = lsSmartPointer<lsDomain<NumericType, D>>::New(
auto trench = ls::SmartPointer<ls::Domain<NumericType, D>>::New(
bounds, boundaryCons, gridDelta);
NumericType xlimit = extent / 6.;
NumericType minCorner[D] = {-xlimit, -25.};
NumericType maxCorner[D] = {xlimit, 1.};
auto box = lsSmartPointer<lsBox<NumericType, D>>::New(minCorner, maxCorner);
lsMakeGeometry<NumericType, D>(trench, box).apply();
auto box =
ls::SmartPointer<ls::Box<NumericType, D>>::New(minCorner, maxCorner);
ls::MakeGeometry<NumericType, D>(trench, box).apply();

{
std::cout << "Extracting..." << std::endl;
auto mesh = lsSmartPointer<lsMesh<NumericType>>::New();
lsToMesh<NumericType, D>(trench, mesh).apply();
lsVTKWriter<NumericType>(mesh, "box.vtp").apply();
auto mesh = ls::SmartPointer<ls::Mesh<NumericType>>::New();
ls::ToMesh<NumericType, D>(trench, mesh).apply();
ls::VTKWriter<NumericType>(mesh, "box.vtp").apply();
}

// Create trench geometry
std::cout << "Booling trench..." << std::endl;
lsBooleanOperation<NumericType, D>(
substrate, trench, lsBooleanOperationEnum::RELATIVE_COMPLEMENT)
ls::BooleanOperation<NumericType, D>(
substrate, trench, ls::BooleanOperationEnum::RELATIVE_COMPLEMENT)
.apply();
}

Expand All @@ -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<lsDomain<NumericType, D>>::New(substrate);
auto newLayer = ls::SmartPointer<ls::Domain<NumericType, D>>::New(substrate);

auto velocities = lsSmartPointer<velocityField>::New();
auto velocities = ls::SmartPointer<velocityField>::New();

std::cout << "Advecting" << std::endl;
lsAdvect<NumericType, D> advectionKernel;
ls::Advect<NumericType, D> advectionKernel;

// the level set to be advected has to be inserted last
// the other could be taken as a mask layer for advection
Expand All @@ -129,9 +133,9 @@ int main() {

std::cout << "\rAdvection step " + std::to_string(i) + " / "
<< numberOfSteps << std::flush;
auto mesh = lsSmartPointer<lsMesh<NumericType>>::New();
lsToSurfaceMesh<NumericType, D>(newLayer, mesh).apply();
lsVTKWriter<NumericType>(mesh, "trench" + std::to_string(i) + ".vtp")
auto mesh = ls::SmartPointer<ls::Mesh<NumericType>>::New();
ls::ToSurfaceMesh<NumericType, D>(newLayer, mesh).apply();
ls::VTKWriter<NumericType>(mesh, "trench" + std::to_string(i) + ".vtp")
.apply();
}
std::cout << std::endl;
Expand Down
50 changes: 27 additions & 23 deletions examples/Deposition/Deposition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
\example Deposition.cpp
*/

namespace ls = viennals;

using NumericType = float;

// implement own velocity field
class velocityField : public lsVelocityField<NumericType> {
class velocityField : public ls::VelocityField<NumericType> {
public:
NumericType
getScalarVelocity(const std::array<NumericType, 3> & /*coordinate*/,
Expand Down Expand Up @@ -51,57 +53,58 @@ int main() {
NumericType gridDelta = 0.5;

double bounds[2 * D] = {-extent, extent, -extent, extent, -extent, extent};
lsDomain<NumericType, D>::BoundaryType boundaryCons[D];
ls::Domain<NumericType, D>::BoundaryType boundaryCons[D];
for (unsigned i = 0; i < D - 1; ++i)
boundaryCons[i] =
lsDomain<NumericType, D>::BoundaryType::REFLECTIVE_BOUNDARY;
boundaryCons[2] = lsDomain<NumericType, D>::BoundaryType::INFINITE_BOUNDARY;
ls::Domain<NumericType, D>::BoundaryType::REFLECTIVE_BOUNDARY;
boundaryCons[2] = ls::Domain<NumericType, D>::BoundaryType::INFINITE_BOUNDARY;

auto substrate = lsSmartPointer<lsDomain<NumericType, D>>::New(
auto substrate = ls::SmartPointer<ls::Domain<NumericType, D>>::New(
bounds, boundaryCons, gridDelta);

NumericType origin[3] = {0., 0., 0.};
NumericType planeNormal[3] = {0., 0., 1.};

{
auto plane =
lsSmartPointer<lsPlane<NumericType, D>>::New(origin, planeNormal);
lsMakeGeometry<NumericType, D>(substrate, plane).apply();
ls::SmartPointer<ls::Plane<NumericType, D>>::New(origin, planeNormal);
ls::MakeGeometry<NumericType, D>(substrate, plane).apply();
}

{
auto trench = lsSmartPointer<lsDomain<NumericType, D>>::New(
auto trench = ls::SmartPointer<ls::Domain<NumericType, D>>::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<lsBox<NumericType, D>>::New(minCorner, maxCorner);
lsMakeGeometry<NumericType, D>(trench, box).apply();
auto box =
ls::SmartPointer<ls::Box<NumericType, D>>::New(minCorner, maxCorner);
ls::MakeGeometry<NumericType, D>(trench, box).apply();

// Create trench geometry
lsBooleanOperation<NumericType, D>(
substrate, trench, lsBooleanOperationEnum::RELATIVE_COMPLEMENT)
ls::BooleanOperation<NumericType, D>(
substrate, trench, ls::BooleanOperationEnum::RELATIVE_COMPLEMENT)
.apply();
}

{
std::cout << "Extracting..." << std::endl;
auto mesh = lsSmartPointer<lsMesh<NumericType>>::New();
lsToSurfaceMesh<NumericType, D>(substrate, mesh).apply();
lsVTKWriter<NumericType>(mesh, "trench-0.vtp").apply();
auto mesh = ls::SmartPointer<ls::Mesh<NumericType>>::New();
ls::ToSurfaceMesh<NumericType, D>(substrate, mesh).apply();
ls::VTKWriter<NumericType>(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<lsDomain<NumericType, D>>::New(substrate);
auto newLayer = ls::SmartPointer<ls::Domain<NumericType, D>>::New(substrate);

auto velocities = lsSmartPointer<velocityField>::New();
auto velocities = ls::SmartPointer<velocityField>::New();

std::cout << "Advecting" << std::endl;
lsAdvect<NumericType, D> advectionKernel;
ls::Advect<NumericType, D> advectionKernel;

// the level set to be advected has to be inserted last
// the other could be taken as a mask layer for advection
Expand All @@ -115,13 +118,14 @@ int main() {
time += advectionKernel.getAdvectedTime()) {
advectionKernel.apply();

auto mesh = lsSmartPointer<lsMesh<NumericType>>::New();
lsToSurfaceMesh<NumericType, D>(newLayer, mesh).apply();
lsVTKWriter<NumericType>(mesh, "trench-" + std::to_string(counter) + ".vtp")
auto mesh = ls::SmartPointer<ls::Mesh<NumericType>>::New();
ls::ToSurfaceMesh<NumericType, D>(newLayer, mesh).apply();
ls::VTKWriter<NumericType>(mesh,
"trench-" + std::to_string(counter) + ".vtp")
.apply();

lsToMesh<NumericType, D>(newLayer, mesh).apply();
lsVTKWriter<NumericType>(mesh, "LS-" + std::to_string(counter) + ".vtp")
ls::ToMesh<NumericType, D>(newLayer, mesh).apply();
ls::VTKWriter<NumericType>(mesh, "LS-" + std::to_string(counter) + ".vtp")
.apply();

++counter;
Expand Down
43 changes: 23 additions & 20 deletions examples/GeometricAdvection/GeometricAdvection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
\example GeometricAdvection.cpp
*/

namespace ls = viennals;

using NumericType = float;

int main() {
Expand All @@ -30,61 +32,62 @@ int main() {
NumericType gridDelta = 0.5;

double bounds[2 * D] = {-extent, extent, -extent, extent, -extent, extent};
lsDomain<NumericType, D>::BoundaryType boundaryCons[D];
ls::Domain<NumericType, D>::BoundaryType boundaryCons[D];
for (unsigned i = 0; i < D - 1; ++i)
boundaryCons[i] =
lsDomain<NumericType, D>::BoundaryType::REFLECTIVE_BOUNDARY;
boundaryCons[2] = lsDomain<NumericType, D>::BoundaryType::INFINITE_BOUNDARY;
ls::Domain<NumericType, D>::BoundaryType::REFLECTIVE_BOUNDARY;
boundaryCons[2] = ls::Domain<NumericType, D>::BoundaryType::INFINITE_BOUNDARY;

auto substrate = lsSmartPointer<lsDomain<NumericType, D>>::New(
auto substrate = ls::SmartPointer<ls::Domain<NumericType, D>>::New(
bounds, boundaryCons, gridDelta);

{
NumericType origin[3] = {0., 0., 0.};
NumericType planeNormal[3] = {0., 0., 1.};
auto plane =
lsSmartPointer<lsPlane<NumericType, D>>::New(origin, planeNormal);
lsMakeGeometry<NumericType, D>(substrate, plane).apply();
ls::SmartPointer<ls::Plane<NumericType, D>>::New(origin, planeNormal);
ls::MakeGeometry<NumericType, D>(substrate, plane).apply();
}

{
auto trench = lsSmartPointer<lsDomain<NumericType, D>>::New(
auto trench = ls::SmartPointer<ls::Domain<NumericType, D>>::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<lsBox<NumericType, D>>::New(minCorner, maxCorner);
lsMakeGeometry<NumericType, D>(trench, box).apply();
auto box =
ls::SmartPointer<ls::Box<NumericType, D>>::New(minCorner, maxCorner);
ls::MakeGeometry<NumericType, D>(trench, box).apply();
// Create trench geometry
lsBooleanOperation<NumericType, D>(
substrate, trench, lsBooleanOperationEnum::RELATIVE_COMPLEMENT)
ls::BooleanOperation<NumericType, D>(
substrate, trench, ls::BooleanOperationEnum::RELATIVE_COMPLEMENT)
.apply();
}

{
std::cout << "Extracting..." << std::endl;
auto mesh = lsSmartPointer<lsMesh<NumericType>>::New();
lsToSurfaceMesh<NumericType, D>(substrate, mesh).apply();
lsVTKWriter<NumericType>(mesh, "trench-0.vtp").apply();
auto mesh = ls::SmartPointer<ls::Mesh<NumericType>>::New();
ls::ToSurfaceMesh<NumericType, D>(substrate, mesh).apply();
ls::VTKWriter<NumericType>(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<lsDomain<NumericType, D>>::New(substrate);
auto newLayer = ls::SmartPointer<ls::Domain<NumericType, D>>::New(substrate);

std::cout << "Advecting" << std::endl;
// Grow the layer uniformly by 4 as in deposition example
auto dist = lsSmartPointer<lsSphereDistribution<hrleCoordType, D>>::New(
auto dist = ls::SmartPointer<ls::SphereDistribution<hrleCoordType, D>>::New(
4.0, gridDelta);
lsGeometricAdvect<NumericType, D>(newLayer, dist).apply();
ls::GeometricAdvect<NumericType, D>(newLayer, dist).apply();

{
auto mesh = lsSmartPointer<lsMesh<NumericType>>::New();
lsToSurfaceMesh<NumericType, D>(newLayer, mesh).apply();
lsVTKWriter<NumericType>(mesh, "trench-final.vtp").apply();
auto mesh = ls::SmartPointer<ls::Mesh<NumericType>>::New();
ls::ToSurfaceMesh<NumericType, D>(newLayer, mesh).apply();
ls::VTKWriter<NumericType>(mesh, "trench-final.vtp").apply();
}

return 0;
Expand Down
Loading

0 comments on commit 655ec5b

Please sign in to comment.