Skip to content

Commit

Permalink
Use ViennaCore in models and examples
Browse files Browse the repository at this point in the history
  • Loading branch information
tobre1 committed May 29, 2024
1 parent 1fa07e3 commit de6b51b
Show file tree
Hide file tree
Showing 60 changed files with 828 additions and 893 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ CPMFindPackage(
CPMFindPackage(
NAME ViennaLS
VERSION 3.1.0
GIT_TAG viennacore
GIT_REPOSITORY "https://github.com/ViennaTools/ViennaLS"
EXCLUDE_FROM_ALL ${VIENNAPS_BUILD_PYTHON})

Expand Down
15 changes: 8 additions & 7 deletions examples/GDSReader/GDSReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@
#include <psGDSReader.hpp>

namespace ps = viennaps;
namespace ls = viennals;

int main(int argc, char **argv) {
using NumericType = double;
constexpr int D = 3;

// read GDS mask file
const NumericType gridDelta = 0.01;
lsBoundaryConditionEnum<D> boundaryConds[D] = {
lsBoundaryConditionEnum<D>::REFLECTIVE_BOUNDARY,
lsBoundaryConditionEnum<D>::REFLECTIVE_BOUNDARY,
lsBoundaryConditionEnum<D>::INFINITE_BOUNDARY};
ls::BoundaryConditionEnum<D> boundaryConds[D] = {
ls::BoundaryConditionEnum<D>::REFLECTIVE_BOUNDARY,
ls::BoundaryConditionEnum<D>::REFLECTIVE_BOUNDARY,
ls::BoundaryConditionEnum<D>::INFINITE_BOUNDARY};
auto mask = ps::SmartPointer<ps::GDSGeometry<NumericType, D>>::New(gridDelta);
mask->setBoundaryConditions(boundaryConds);
ps::GDSReader<NumericType, D>(mask, "mask.gds").apply();
Expand All @@ -24,10 +25,10 @@ int main(int argc, char **argv) {
// substrate plane
NumericType origin[D] = {0., 0., 0.};
NumericType normal[D] = {0., 0., 1.};
auto plane = lsSmartPointer<lsDomain<NumericType, D>>::New(
auto plane = ps::SmartPointer<ls::Domain<NumericType, D>>::New(
bounds, boundaryConds, gridDelta);
lsMakeGeometry<NumericType, D>(
plane, lsSmartPointer<lsPlane<NumericType, D>>::New(origin, normal))
ls::MakeGeometry<NumericType, D>(
plane, ps::SmartPointer<ls::Plane<NumericType, D>>::New(origin, normal))
.apply();

geometry->insertNextLevelSet(plane);
Expand Down
7 changes: 4 additions & 3 deletions examples/KDTreeBenchmark/KDTreeBenchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#endif

#include <compact/psKDTree.hpp>
#include <psSmartPointer.hpp>

inline double getTime() {
#ifdef _OPENMP
Expand Down Expand Up @@ -42,6 +41,8 @@ std::vector<std::vector<T>> generatePoints(unsigned N, unsigned D) {
return data;
}

namespace ps = viennaps;

int main(int argc, char *argv[]) {
using NumericType = double;
static constexpr int D = 3;
Expand Down Expand Up @@ -80,10 +81,10 @@ int main(int argc, char *argv[]) {

{
std::cout << "Growing Tree...\n";
psSmartPointer<psKDTree<NumericType>> tree = nullptr;
ps::SmartPointer<ps::KDTree<NumericType>> tree = nullptr;
auto startTime = getTime();
for (unsigned i = 0; i < repetitions; ++i) {
tree = psSmartPointer<psKDTree<NumericType>>::New(points);
tree = ps::SmartPointer<ps::KDTree<NumericType>>::New(points);
tree->build();
}
auto endTime = getTime();
Expand Down
27 changes: 15 additions & 12 deletions examples/atomicLayerDeposition/geometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,36 +21,38 @@ void makeLShape(psSmartPointer<psDomain<NumericType, D>> domain,
bounds[2] = -gridDelta;
bounds[3] = params.get("verticalDepth") + gridDelta;

typename lsDomain<NumericType, D>::BoundaryType boundaryCons[D];
typename ls::Domain<NumericType, D>::BoundaryType boundaryCons[D];

for (int i = 0; i < D - 1; i++) {
boundaryCons[i] =
lsDomain<NumericType, D>::BoundaryType::REFLECTIVE_BOUNDARY;
ls::Domain<NumericType, D>::BoundaryType::REFLECTIVE_BOUNDARY;
}
boundaryCons[D - 1] =
lsDomain<NumericType, D>::BoundaryType::INFINITE_BOUNDARY;
ls::Domain<NumericType, D>::BoundaryType::INFINITE_BOUNDARY;

{
auto substrate = lsSmartPointer<lsDomain<NumericType, D>>::New(
auto substrate = ps::SmartPointer<ls::Domain<NumericType, D>>::New(
bounds, boundaryCons, gridDelta);
NumericType normal[D] = {0.};
NumericType origin[D] = {0.};
normal[D - 1] = 1.;
origin[D - 1] = params.get("verticalDepth");
lsMakeGeometry<NumericType, D>(
substrate, lsSmartPointer<lsPlane<NumericType, D>>::New(origin, normal))
ls::MakeGeometry<NumericType, D>(
substrate,
ps::SmartPointer<ls::Plane<NumericType, D>>::New(origin, normal))
.apply();
domain->insertNextLevelSetAsMaterial(substrate, material);
}

{
auto vertBox =
lsSmartPointer<lsDomain<NumericType, D>>::New(domain->getGrid());
ps::SmartPointer<ls::Domain<NumericType, D>>::New(domain->getGrid());
NumericType minPoint[D] = {-params.get("verticalWidth") / 2.0, 0.};
NumericType maxPoint[D] = {params.get("verticalWidth") / 2.0,
params.get("verticalDepth")};
lsMakeGeometry<NumericType, D>(
vertBox, lsSmartPointer<lsBox<NumericType, D>>::New(minPoint, maxPoint))
ls::MakeGeometry<NumericType, D>(
vertBox,
ps::SmartPointer<lsBox<NumericType, D>>::New(minPoint, maxPoint))
.apply();

domain->applyBooleanOperation(vertBox,
Expand All @@ -59,14 +61,15 @@ void makeLShape(psSmartPointer<psDomain<NumericType, D>> domain,

{
auto horiBox =
lsSmartPointer<lsDomain<NumericType, D>>::New(domain->getGrid());
ps::SmartPointer<ls::Domain<NumericType, D>>::New(domain->getGrid());
NumericType minPoint[D] = {-params.get("verticalWidth") / 2.0, 0.};
NumericType maxPoint[D] = {-params.get("verticalWidth") / 2.0 +
params.get("horizontalWidth"),
params.get("horizontalHeight")};

lsMakeGeometry<NumericType, D>(
horiBox, lsSmartPointer<lsBox<NumericType, D>>::New(minPoint, maxPoint))
ls::MakeGeometry<NumericType, D>(
horiBox,
ps::SmartPointer<lsBox<NumericType, D>>::New(minPoint, maxPoint))
.apply();

domain->applyBooleanOperation(horiBox,
Expand Down
15 changes: 8 additions & 7 deletions examples/cantileverWetEtching/cantileverWetEtching.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <models/psAnisotropicProcess.hpp>

namespace ps = viennaps;
namespace ls = viennals;

int main(int argc, char **argv) {
using NumericType = double;
Expand Down Expand Up @@ -35,11 +36,11 @@ int main(int argc, char **argv) {
const NumericType gridDelta = 5.; // um

// Read GDS file and convert to level set
typename lsDomain<NumericType, D>::BoundaryType boundaryCons[D];
typename ls::Domain<NumericType, D>::BoundaryType boundaryCons[D];
for (int i = 0; i < D - 1; i++)
boundaryCons[i] = lsDomain<NumericType, D>::BoundaryType::
boundaryCons[i] = ls::Domain<NumericType, D>::BoundaryType::
REFLECTIVE_BOUNDARY; // boundary conditions in x and y direction
boundaryCons[D - 1] = lsDomain<NumericType, D>::BoundaryType::
boundaryCons[D - 1] = ls::Domain<NumericType, D>::BoundaryType::
INFINITE_BOUNDARY; // open boundary in z direction
auto gds_mask =
ps::SmartPointer<ps::GDSGeometry<NumericType, D>>::New(gridDelta);
Expand All @@ -56,10 +57,10 @@ int main(int argc, char **argv) {
NumericType origin[D] = {0., 0., 0.}; // surface origin
NumericType normal[D] = {0., 0., 1.}; // surface normal
double *bounds = gds_mask->getBounds(); // extent of GDS mask
auto plane = lsSmartPointer<lsDomain<NumericType, D>>::New(
auto plane = ps::SmartPointer<ls::Domain<NumericType, D>>::New(
bounds, boundaryCons, gridDelta);
lsMakeGeometry<NumericType, D>(
plane, lsSmartPointer<lsPlane<NumericType, D>>::New(origin, normal))
ls::MakeGeometry<NumericType, D>(
plane, ps::SmartPointer<ls::Plane<NumericType, D>>::New(origin, normal))
.apply();

// Set up domain
Expand All @@ -79,7 +80,7 @@ int main(int argc, char **argv) {
process.setProcessModel(model);
process.setProcessDuration(5. * 60.); // 5 minutes of etching
process.setIntegrationScheme(
lsIntegrationSchemeEnum::STENCIL_LOCAL_LAX_FRIEDRICHS_1ST_ORDER);
ls::IntegrationSchemeEnum::STENCIL_LOCAL_LAX_FRIEDRICHS_1ST_ORDER);

for (int n = 0; n < minutes; n++) {
process.apply(); // run process
Expand Down
39 changes: 21 additions & 18 deletions examples/exampleProcess/exampleProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "velocityField.hpp"

namespace ps = viennaps;
namespace ls = viennals;

int main() {
using NumericType = double;
Expand All @@ -33,53 +34,55 @@ int main() {
double bounds[2 * D] = {0};
for (int i = 0; i < 2 * D; ++i)
bounds[i] = i % 2 == 0 ? -extent : extent;
lsDomain<NumericType, D>::BoundaryType boundaryCons[D];
ls::Domain<NumericType, D>::BoundaryType boundaryCons[D];
for (int i = 0; i < D - 1; ++i)
boundaryCons[i] =
lsDomain<NumericType, D>::BoundaryType::REFLECTIVE_BOUNDARY;
ls::Domain<NumericType, D>::BoundaryType::REFLECTIVE_BOUNDARY;
boundaryCons[D - 1] =
lsDomain<NumericType, D>::BoundaryType::INFINITE_BOUNDARY;
ls::Domain<NumericType, D>::BoundaryType::INFINITE_BOUNDARY;

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

NumericType normal[3] = {0.};
NumericType origin[3] = {0.};
normal[D - 1] = -1.;
lsMakeGeometry<NumericType, D>(
mask, lsSmartPointer<lsPlane<NumericType, D>>::New(origin, normal))
ls::MakeGeometry<NumericType, D>(
mask, ps::SmartPointer<ls::Plane<NumericType, D>>::New(origin, normal))
.apply();

auto maskCut = lsSmartPointer<lsDomain<NumericType, D>>::New(
auto maskCut = ps::SmartPointer<ls::Domain<NumericType, D>>::New(
bounds, boundaryCons, gridDelta);
normal[D - 1] = 1.;
origin[D - 1] = 2.;
lsMakeGeometry<NumericType, D>(
maskCut, lsSmartPointer<lsPlane<NumericType, D>>::New(origin, normal))
ls::MakeGeometry<NumericType, D>(
maskCut,
ps::SmartPointer<ls::Plane<NumericType, D>>::New(origin, normal))
.apply();

lsBooleanOperation<NumericType, D>(mask, maskCut,
lsBooleanOperationEnum::INTERSECT)
ls::BooleanOperation<NumericType, D>(mask, maskCut,
ls::BooleanOperationEnum::INTERSECT)
.apply();

origin[D - 1] = 0;
normal[D - 1] = 1.;
lsMakeGeometry<NumericType, D>(
maskCut, lsSmartPointer<lsCylinder<NumericType, D>>::New(
ls::MakeGeometry<NumericType, D>(
maskCut, ps::SmartPointer<ls::Cylinder<NumericType, D>>::New(
origin, normal, 2. + gridDelta, 5.))
.apply();

lsBooleanOperation<NumericType, D>(
mask, maskCut, lsBooleanOperationEnum::RELATIVE_COMPLEMENT)
ls::BooleanOperation<NumericType, D>(
mask, maskCut, ls::BooleanOperationEnum::RELATIVE_COMPLEMENT)
.apply();

domain->insertNextLevelSetAsMaterial(mask, ps::Material::Mask);

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

lsMakeGeometry<NumericType, D>(
substrate, lsSmartPointer<lsPlane<NumericType, D>>::New(origin, normal))
ls::MakeGeometry<NumericType, D>(
substrate,
ps::SmartPointer<ls::Plane<NumericType, D>>::New(origin, normal))
.apply();

domain->insertNextLevelSetAsMaterial(substrate, ps::Material::Si);
Expand Down
18 changes: 9 additions & 9 deletions examples/exampleProcess/particles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,28 @@ class Particle
Particle(const NumericType pSticking, const NumericType pPower)
: stickingProbability(pSticking), sourcePower(pPower) {}
void surfaceCollision(NumericType rayWeight,
const viennaray::Triple<NumericType> &rayDir,
const viennaray::Triple<NumericType> &geomNormal,
const viennaray::Vec3D<NumericType> &rayDir,
const viennaray::Vec3D<NumericType> &geomNormal,
const unsigned int primID, const int materialId,
viennaray::TracingData<NumericType> &localData,
const viennaray::TracingData<NumericType> *globalData,
RNG &rngState) override final {
viennaray::RNG &rngState) override final {
// collect data for this hit
localData.getVectorData(0)[primID] += rayWeight;
}
std::pair<NumericType, viennaray::Triple<NumericType>>
std::pair<NumericType, viennaray::Vec3D<NumericType>>
surfaceReflection(NumericType rayWeight,
const viennaray::Triple<NumericType> &rayDir,
const viennaray::Triple<NumericType> &geomNormal,
const viennaray::Vec3D<NumericType> &rayDir,
const viennaray::Vec3D<NumericType> &geomNormal,
const unsigned int primId, const int materialId,
const viennaray::TracingData<NumericType> *globalData,
RNG &rngState) override final {
viennaray::RNG &rngState) override final {
auto direction =
viennaray::ReflectionDiffuse<NumericType, D>(geomNormal, rngState);
return std::pair<NumericType, viennaray::Triple<NumericType>>{
return std::pair<NumericType, viennaray::Vec3D<NumericType>>{
stickingProbability, direction};
}
void initNew(RNG &rngState) override final {}
void initNew(viennaray::RNG &rngState) override final {}
NumericType getSourceDistributionPower() const override final {
return sourcePower;
}
Expand Down
9 changes: 5 additions & 4 deletions examples/exampleProcess/surfaceModel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class SurfaceModel : public viennaps::SurfaceModel<NumericType> {
void initializeCoverages(unsigned numGeometryPoints) override {
std::vector<NumericType> someCoverages(numGeometryPoints, 0);

coverages = viennaps::SmartPointer<lsPointData<NumericType>>::New();
coverages = viennaps::SmartPointer<viennals::PointData<NumericType>>::New();
coverages->insertNextScalarData(someCoverages, "coverages");
}

Expand All @@ -22,16 +22,17 @@ class SurfaceModel : public viennaps::SurfaceModel<NumericType> {
}

viennaps::SmartPointer<std::vector<NumericType>> calculateVelocities(
viennaps::SmartPointer<lsPointData<NumericType>> rates,
viennaps::SmartPointer<viennals::PointData<NumericType>> rates,
const std::vector<std::array<NumericType, 3>> &coordinates,
const std::vector<NumericType> &materialIds) override {
// use coverages and rates here to calculate the velocity here
return viennaps::SmartPointer<std::vector<NumericType>>::New(
*rates->getScalarData("particleRate"));
}

void updateCoverages(viennaps::SmartPointer<lsPointData<NumericType>> rates,
const std::vector<NumericType> &materialIds) override {
void updateCoverages(
viennaps::SmartPointer<viennals::PointData<NumericType>> rates,
const std::vector<NumericType> &materialIds) override {
// update coverages
}
};
Loading

0 comments on commit de6b51b

Please sign in to comment.