diff --git a/CMakeLists.txt b/CMakeLists.txt index 19fc263..273ce7c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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}) diff --git a/examples/GDSReader/GDSReader.cpp b/examples/GDSReader/GDSReader.cpp index a3e7247..2213645 100644 --- a/examples/GDSReader/GDSReader.cpp +++ b/examples/GDSReader/GDSReader.cpp @@ -2,6 +2,7 @@ #include namespace ps = viennaps; +namespace ls = viennals; int main(int argc, char **argv) { using NumericType = double; @@ -9,10 +10,10 @@ int main(int argc, char **argv) { // read GDS mask file const NumericType gridDelta = 0.01; - lsBoundaryConditionEnum boundaryConds[D] = { - lsBoundaryConditionEnum::REFLECTIVE_BOUNDARY, - lsBoundaryConditionEnum::REFLECTIVE_BOUNDARY, - lsBoundaryConditionEnum::INFINITE_BOUNDARY}; + ls::BoundaryConditionEnum boundaryConds[D] = { + ls::BoundaryConditionEnum::REFLECTIVE_BOUNDARY, + ls::BoundaryConditionEnum::REFLECTIVE_BOUNDARY, + ls::BoundaryConditionEnum::INFINITE_BOUNDARY}; auto mask = ps::SmartPointer>::New(gridDelta); mask->setBoundaryConditions(boundaryConds); ps::GDSReader(mask, "mask.gds").apply(); @@ -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>::New( + auto plane = ps::SmartPointer>::New( bounds, boundaryConds, gridDelta); - lsMakeGeometry( - plane, lsSmartPointer>::New(origin, normal)) + ls::MakeGeometry( + plane, ps::SmartPointer>::New(origin, normal)) .apply(); geometry->insertNextLevelSet(plane); diff --git a/examples/KDTreeBenchmark/KDTreeBenchmark.cpp b/examples/KDTreeBenchmark/KDTreeBenchmark.cpp index 727c996..e0360c4 100644 --- a/examples/KDTreeBenchmark/KDTreeBenchmark.cpp +++ b/examples/KDTreeBenchmark/KDTreeBenchmark.cpp @@ -7,7 +7,6 @@ #endif #include -#include inline double getTime() { #ifdef _OPENMP @@ -42,6 +41,8 @@ std::vector> generatePoints(unsigned N, unsigned D) { return data; } +namespace ps = viennaps; + int main(int argc, char *argv[]) { using NumericType = double; static constexpr int D = 3; @@ -80,10 +81,10 @@ int main(int argc, char *argv[]) { { std::cout << "Growing Tree...\n"; - psSmartPointer> tree = nullptr; + ps::SmartPointer> tree = nullptr; auto startTime = getTime(); for (unsigned i = 0; i < repetitions; ++i) { - tree = psSmartPointer>::New(points); + tree = ps::SmartPointer>::New(points); tree->build(); } auto endTime = getTime(); diff --git a/examples/atomicLayerDeposition/geometry.hpp b/examples/atomicLayerDeposition/geometry.hpp index f5a1f3a..688df5e 100644 --- a/examples/atomicLayerDeposition/geometry.hpp +++ b/examples/atomicLayerDeposition/geometry.hpp @@ -21,36 +21,38 @@ void makeLShape(psSmartPointer> domain, bounds[2] = -gridDelta; bounds[3] = params.get("verticalDepth") + gridDelta; - typename lsDomain::BoundaryType boundaryCons[D]; + typename ls::Domain::BoundaryType boundaryCons[D]; for (int 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 = ps::SmartPointer>::New( bounds, boundaryCons, gridDelta); NumericType normal[D] = {0.}; NumericType origin[D] = {0.}; normal[D - 1] = 1.; origin[D - 1] = params.get("verticalDepth"); - lsMakeGeometry( - substrate, lsSmartPointer>::New(origin, normal)) + ls::MakeGeometry( + substrate, + ps::SmartPointer>::New(origin, normal)) .apply(); domain->insertNextLevelSetAsMaterial(substrate, material); } { auto vertBox = - lsSmartPointer>::New(domain->getGrid()); + ps::SmartPointer>::New(domain->getGrid()); NumericType minPoint[D] = {-params.get("verticalWidth") / 2.0, 0.}; NumericType maxPoint[D] = {params.get("verticalWidth") / 2.0, params.get("verticalDepth")}; - lsMakeGeometry( - vertBox, lsSmartPointer>::New(minPoint, maxPoint)) + ls::MakeGeometry( + vertBox, + ps::SmartPointer>::New(minPoint, maxPoint)) .apply(); domain->applyBooleanOperation(vertBox, @@ -59,14 +61,15 @@ void makeLShape(psSmartPointer> domain, { auto horiBox = - lsSmartPointer>::New(domain->getGrid()); + ps::SmartPointer>::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( - horiBox, lsSmartPointer>::New(minPoint, maxPoint)) + ls::MakeGeometry( + horiBox, + ps::SmartPointer>::New(minPoint, maxPoint)) .apply(); domain->applyBooleanOperation(horiBox, diff --git a/examples/cantileverWetEtching/cantileverWetEtching.cpp b/examples/cantileverWetEtching/cantileverWetEtching.cpp index 9cbc23e..7bcbcfa 100644 --- a/examples/cantileverWetEtching/cantileverWetEtching.cpp +++ b/examples/cantileverWetEtching/cantileverWetEtching.cpp @@ -6,6 +6,7 @@ #include namespace ps = viennaps; +namespace ls = viennals; int main(int argc, char **argv) { using NumericType = double; @@ -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::BoundaryType boundaryCons[D]; + typename ls::Domain::BoundaryType boundaryCons[D]; for (int i = 0; i < D - 1; i++) - boundaryCons[i] = lsDomain::BoundaryType:: + boundaryCons[i] = ls::Domain::BoundaryType:: REFLECTIVE_BOUNDARY; // boundary conditions in x and y direction - boundaryCons[D - 1] = lsDomain::BoundaryType:: + boundaryCons[D - 1] = ls::Domain::BoundaryType:: INFINITE_BOUNDARY; // open boundary in z direction auto gds_mask = ps::SmartPointer>::New(gridDelta); @@ -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>::New( + auto plane = ps::SmartPointer>::New( bounds, boundaryCons, gridDelta); - lsMakeGeometry( - plane, lsSmartPointer>::New(origin, normal)) + ls::MakeGeometry( + plane, ps::SmartPointer>::New(origin, normal)) .apply(); // Set up domain @@ -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 diff --git a/examples/exampleProcess/exampleProcess.cpp b/examples/exampleProcess/exampleProcess.cpp index 5f66949..5613669 100644 --- a/examples/exampleProcess/exampleProcess.cpp +++ b/examples/exampleProcess/exampleProcess.cpp @@ -9,6 +9,7 @@ #include "velocityField.hpp" namespace ps = viennaps; +namespace ls = viennals; int main() { using NumericType = double; @@ -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::BoundaryType boundaryCons[D]; + ls::Domain::BoundaryType boundaryCons[D]; for (int 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 = ps::SmartPointer>::New( bounds, boundaryCons, gridDelta); NumericType normal[3] = {0.}; NumericType origin[3] = {0.}; normal[D - 1] = -1.; - lsMakeGeometry( - mask, lsSmartPointer>::New(origin, normal)) + ls::MakeGeometry( + mask, ps::SmartPointer>::New(origin, normal)) .apply(); - auto maskCut = lsSmartPointer>::New( + auto maskCut = ps::SmartPointer>::New( bounds, boundaryCons, gridDelta); normal[D - 1] = 1.; origin[D - 1] = 2.; - lsMakeGeometry( - maskCut, lsSmartPointer>::New(origin, normal)) + ls::MakeGeometry( + maskCut, + ps::SmartPointer>::New(origin, normal)) .apply(); - lsBooleanOperation(mask, maskCut, - lsBooleanOperationEnum::INTERSECT) + ls::BooleanOperation(mask, maskCut, + ls::BooleanOperationEnum::INTERSECT) .apply(); origin[D - 1] = 0; normal[D - 1] = 1.; - lsMakeGeometry( - maskCut, lsSmartPointer>::New( + ls::MakeGeometry( + maskCut, ps::SmartPointer>::New( origin, normal, 2. + gridDelta, 5.)) .apply(); - lsBooleanOperation( - mask, maskCut, lsBooleanOperationEnum::RELATIVE_COMPLEMENT) + ls::BooleanOperation( + mask, maskCut, ls::BooleanOperationEnum::RELATIVE_COMPLEMENT) .apply(); domain->insertNextLevelSetAsMaterial(mask, ps::Material::Mask); - auto substrate = lsSmartPointer>::New( + auto substrate = ps::SmartPointer>::New( bounds, boundaryCons, gridDelta); - lsMakeGeometry( - substrate, lsSmartPointer>::New(origin, normal)) + ls::MakeGeometry( + substrate, + ps::SmartPointer>::New(origin, normal)) .apply(); domain->insertNextLevelSetAsMaterial(substrate, ps::Material::Si); diff --git a/examples/exampleProcess/particles.hpp b/examples/exampleProcess/particles.hpp index 11bb3dd..0a16ade 100644 --- a/examples/exampleProcess/particles.hpp +++ b/examples/exampleProcess/particles.hpp @@ -11,28 +11,28 @@ class Particle Particle(const NumericType pSticking, const NumericType pPower) : stickingProbability(pSticking), sourcePower(pPower) {} void surfaceCollision(NumericType rayWeight, - const viennaray::Triple &rayDir, - const viennaray::Triple &geomNormal, + const viennaray::Vec3D &rayDir, + const viennaray::Vec3D &geomNormal, const unsigned int primID, const int materialId, viennaray::TracingData &localData, const viennaray::TracingData *globalData, - RNG &rngState) override final { + viennaray::RNG &rngState) override final { // collect data for this hit localData.getVectorData(0)[primID] += rayWeight; } - std::pair> + std::pair> surfaceReflection(NumericType rayWeight, - const viennaray::Triple &rayDir, - const viennaray::Triple &geomNormal, + const viennaray::Vec3D &rayDir, + const viennaray::Vec3D &geomNormal, const unsigned int primId, const int materialId, const viennaray::TracingData *globalData, - RNG &rngState) override final { + viennaray::RNG &rngState) override final { auto direction = viennaray::ReflectionDiffuse(geomNormal, rngState); - return std::pair>{ + return std::pair>{ stickingProbability, direction}; } - void initNew(RNG &rngState) override final {} + void initNew(viennaray::RNG &rngState) override final {} NumericType getSourceDistributionPower() const override final { return sourcePower; } diff --git a/examples/exampleProcess/surfaceModel.hpp b/examples/exampleProcess/surfaceModel.hpp index d992177..57c92e3 100644 --- a/examples/exampleProcess/surfaceModel.hpp +++ b/examples/exampleProcess/surfaceModel.hpp @@ -11,7 +11,7 @@ class SurfaceModel : public viennaps::SurfaceModel { void initializeCoverages(unsigned numGeometryPoints) override { std::vector someCoverages(numGeometryPoints, 0); - coverages = viennaps::SmartPointer>::New(); + coverages = viennaps::SmartPointer>::New(); coverages->insertNextScalarData(someCoverages, "coverages"); } @@ -22,7 +22,7 @@ class SurfaceModel : public viennaps::SurfaceModel { } viennaps::SmartPointer> calculateVelocities( - viennaps::SmartPointer> rates, + viennaps::SmartPointer> rates, const std::vector> &coordinates, const std::vector &materialIds) override { // use coverages and rates here to calculate the velocity here @@ -30,8 +30,9 @@ class SurfaceModel : public viennaps::SurfaceModel { *rates->getScalarData("particleRate")); } - void updateCoverages(viennaps::SmartPointer> rates, - const std::vector &materialIds) override { + void updateCoverages( + viennaps::SmartPointer> rates, + const std::vector &materialIds) override { // update coverages } }; \ No newline at end of file diff --git a/examples/oxideRegrowth/oxideRegrowth.cpp b/examples/oxideRegrowth/oxideRegrowth.cpp index 7f663a2..9eb1d0c 100644 --- a/examples/oxideRegrowth/oxideRegrowth.cpp +++ b/examples/oxideRegrowth/oxideRegrowth.cpp @@ -3,7 +3,7 @@ #include -#include "parameters.hpp" +namespace ps = viennaps; int main(int argc, char **argv) { using NumericType = double; @@ -11,40 +11,41 @@ int main(int argc, char **argv) { omp_set_num_threads(12); constexpr int D = 2; - psLogger::setLogLevel(psLogLevel::INTERMEDIATE); + ps::Logger::setLogLevel(ps::LogLevel::INTERMEDIATE); - Parameters params; + // Parse the parameters + ps::utils::Parameters params; if (argc > 1) { - auto config = psUtils::readConfigFile(argv[1]); - if (config.empty()) { - std::cerr << "Empty config provided" << std::endl; - return -1; - } - params.fromMap(config); + params.readConfigFile(argv[1]); + } else { + std::cout << "Usage: " << argv[0] << " " << std::endl; + return 1; } const NumericType stability = - 2 * params.diffusionCoefficient / - std::max(params.centerVelocity, params.scallopVelocity); + 2 * params.get("diffusionCoefficient") / + std::max(params.get("centerVelocity"), params.get("scallopVelocity")); std::cout << "Stability: " << stability << std::endl; constexpr NumericType timeStabilityFactor = D == 2 ? 0.245 : 0.145; - if (0.5 * stability <= params.gridDelta) { + if (0.5 * stability <= params.get("gridDelta")) { std::cout << "Unstable parameters. Reduce grid spacing!" << std::endl; return -1; } - auto domain = psSmartPointer>::New(); - psMakeStack(domain, params.gridDelta, params.xExtent, - params.yExtent, params.numLayers, - params.layerHeight, params.substrateHeight, - 0. /*hole radius*/, params.trenchWidth, 0., false) + auto domain = ps::SmartPointer>::New(); + ps::MakeStack( + domain, params.get("gridDelta"), params.get("xExtent"), + params.get("yExtent"), params.get("numLayers"), params.get("layerHeight"), + params.get("substrateHeight"), 0. /*hole radius*/, + params.get("trenchWidth"), 0., false) .apply(); // copy top layer for deposition - domain->duplicateTopLevelSet(psMaterial::Polymer); + domain->duplicateTopLevelSet(ps::Material::Polymer); domain->generateCellSet( - params.substrateHeight + params.numLayers * params.layerHeight + 10., - psMaterial::GAS, true /* true means cell set above surface */); + params.get("substrateHeight") + + params.get("numLayers") * params.get("layerHeight") + 10., + ps::Material::GAS, true /* true means cell set above surface */); auto &cellSet = domain->getCellSet(); cellSet->addScalarData("byproductSum", 0.); cellSet->writeVTU("initial.vtu"); @@ -60,19 +61,21 @@ int main(int argc, char **argv) { // The redeposition model captures byproducts from the selective etching // process in the cell set. The byproducts are then distributed by solving a // convection-diffusion equation on the cell set. - auto model = psSmartPointer>::New( - params.nitrideEtchRate / 60., params.oxideEtchRate / 60., - params.redepositionRate, params.redepositionThreshold, - params.redepositionTimeInt, params.diffusionCoefficient, params.sink, - params.scallopVelocity, params.centerVelocity, - params.substrateHeight + params.numLayers * params.layerHeight, - params.trenchWidth, timeStabilityFactor); + auto model = ps::SmartPointer>::New( + params.get("nitrideEtchRate") / 60., params.get("oxideEtchRate") / 60., + params.get("redepositionRate"), params.get("redepositionThreshold"), + params.get("redepositionTimeInt"), params.get("diffusionCoefficient"), + params.get("sink"), params.get("scallopVelocity"), + params.get("centerVelocity"), + params.get("substrateHeight") + + params.get("numLayers") * params.get("layerHeight"), + params.get("trenchWidth"), timeStabilityFactor); - psProcess process; + ps::Process process; process.setDomain(domain); process.setProcessModel(model); - process.setProcessDuration(params.targetEtchDepth / params.nitrideEtchRate * - 60.); + process.setProcessDuration(params.get("targetEtchDepth") / + params.get("nitrideEtchRate") * 60.); process.setPrintTimeInterval(30); process.apply(); diff --git a/examples/oxideRegrowth/parameters.hpp b/examples/oxideRegrowth/parameters.hpp deleted file mode 100644 index 3ea255c..0000000 --- a/examples/oxideRegrowth/parameters.hpp +++ /dev/null @@ -1,59 +0,0 @@ -#pragma once - -#include -#include - -#include - -template struct Parameters { - // Domain - // all length units in nm - T nitrideEtchRate = 6.5; // nm/min - T oxideEtchRate = 0.; - - T gridDelta = 2.; // nm - T xExtent = 400.0; // nm - T yExtent = 100.0; // nm - - // Geometry - int numLayers = 11; - T layerHeight = 30.; // nm - T substrateHeight = 50.; // nm - T trenchWidth = 150.; // nm - - // Process - T targetEtchDepth = 100.; // nm - T diffusionCoefficient = 1.; // diffusion cofficient nm²/s - T sink = 0.01; // sink strength - // convection velocity in the scallops towards the center nm/s - T scallopVelocity = 5.; - // convection velocity in the center towards the sink on the top nm/s - T centerVelocity = 5.; - T redepositionRate = 0.01; - T redepositionThreshold = 0.2; - T redepositionTimeInt = 60.; - - Parameters() {} - - void fromMap(std::unordered_map &m) { - psUtils::AssignItems( // - m, // - psUtils::Item{"gridDelta", gridDelta}, // - psUtils::Item{"xExtent", xExtent}, // - psUtils::Item{"numLayers", numLayers}, // - psUtils::Item{"layerHeight", layerHeight}, // - psUtils::Item{"substrateHeight", substrateHeight}, // - psUtils::Item{"trenchWidth", trenchWidth}, // - psUtils::Item{"diffusionCoefficient", diffusionCoefficient}, // - psUtils::Item{"sink", sink}, // - psUtils::Item{"scallopVelocity", scallopVelocity}, // - psUtils::Item{"centerVelocity", centerVelocity}, // - psUtils::Item{"targetEtchDepth", targetEtchDepth}, // - psUtils::Item{"redepositionRate", redepositionRate}, // - psUtils::Item{"redepositionThreshold", redepositionThreshold}, // - psUtils::Item{"redepositionTimeInt", redepositionTimeInt}, // - psUtils::Item{"oxideEtchRate", oxideEtchRate}, // - psUtils::Item{"nitrideEtchRate", nitrideEtchRate} // - ); - } -}; diff --git a/examples/selectiveEpitaxy/selectiveEpitaxy.cpp b/examples/selectiveEpitaxy/selectiveEpitaxy.cpp index 39e7758..a490ddd 100644 --- a/examples/selectiveEpitaxy/selectiveEpitaxy.cpp +++ b/examples/selectiveEpitaxy/selectiveEpitaxy.cpp @@ -4,6 +4,7 @@ #include namespace ps = viennaps; +namespace ls = viennals; int main(int argc, char *argv[]) { using NumericType = double; @@ -27,7 +28,7 @@ int main(int argc, char *argv[]) { // create fin on substrate { auto fin = - lsSmartPointer>::New(geometry->getGrid()); + ps::SmartPointer>::New(geometry->getGrid()); NumericType minPoint[3] = {-params.get("finWidth") / 2., -params.get("finLength") / 2., -params.get("gridDelta")}; @@ -38,8 +39,8 @@ int main(int argc, char *argv[]) { minPoint[1] = -params.get("gridDelta"); maxPoint[1] = params.get("finHeight"); } - lsMakeGeometry( - fin, lsSmartPointer>::New(minPoint, maxPoint)) + ls::MakeGeometry( + fin, ps::SmartPointer>::New(minPoint, maxPoint)) .apply(); geometry->insertNextLevelSetAsMaterial(fin, ps::Material::Si); geometry->saveSurfaceMesh("fin.vtp"); @@ -58,7 +59,7 @@ int main(int argc, char *argv[]) { process.setProcessModel(model); process.setProcessDuration(params.get("processTime")); process.setIntegrationScheme( - lsIntegrationSchemeEnum::STENCIL_LOCAL_LAX_FRIEDRICHS_1ST_ORDER); + ls::IntegrationSchemeEnum::STENCIL_LOCAL_LAX_FRIEDRICHS_1ST_ORDER); geometry->saveVolumeMesh("initial"); diff --git a/examples/stackEtching/parameters.hpp b/examples/stackEtching/parameters.hpp deleted file mode 100644 index 8ecf67f..0000000 --- a/examples/stackEtching/parameters.hpp +++ /dev/null @@ -1,51 +0,0 @@ -#pragma once - -#include -#include - -#include - -template struct Parameters { - // Domain - T gridDelta = 2.; // nm - T xExtent = 120.0; // nm - T yExtent = 120.0; // nm - - // Geometry - int numLayers = 5; - T layerHeight = 30.; // nm - T substrateHeight = 50.; // nm - T trenchWidth = 75; // nm - T maskHeight = 50; // nm - - // Process - T processTime = 20; - T etchantFlux = 150; - T polymerFlux = 10; - T ionFlux = 56; - - T energyMean = 100.; // eV - T energySigma = 10.; // eV - - Parameters() {} - - void fromMap(std::unordered_map &m) { - psUtils::AssignItems( // - m, // - psUtils::Item{"gridDelta", gridDelta}, // - psUtils::Item{"xExtent", xExtent}, // - psUtils::Item{"yExtent", yExtent}, // - psUtils::Item{"trenchWidth", trenchWidth}, // - psUtils::Item{"numLayers", numLayers}, // - psUtils::Item{"layerHeight", layerHeight}, // - psUtils::Item{"substrateHeight", substrateHeight}, // - psUtils::Item{"maskHeight", maskHeight}, // - psUtils::Item{"etchantFlux", etchantFlux}, // - psUtils::Item{"polymerFlux", polymerFlux}, // - psUtils::Item{"ionFlux", ionFlux}, // - psUtils::Item{"energyMean", energyMean}, // - psUtils::Item{"energySigma", energySigma}, // - psUtils::Item{"processTime", processTime} // - ); - } -}; diff --git a/examples/stackEtching/stackEtching.cpp b/examples/stackEtching/stackEtching.cpp index 3ee2a01..34e6b39 100644 --- a/examples/stackEtching/stackEtching.cpp +++ b/examples/stackEtching/stackEtching.cpp @@ -4,47 +4,48 @@ #include #include -#include "parameters.hpp" +namespace ps = viennaps; +namespace ls = viennals; int main(int argc, char *argv[]) { using NumericType = double; constexpr int D = 2; // set process verbosity - psLogger::setLogLevel(psLogLevel::INTERMEDIATE); + ps::Logger::setLogLevel(ps::LogLevel::INTERMEDIATE); // Parse the parameters - Parameters params; + ps::utils::Parameters params; if (argc > 1) { - auto config = psUtils::readConfigFile(argv[1]); - if (config.empty()) { - std::cerr << "Empty config provided" << std::endl; - return -1; - } - params.fromMap(config); + params.readConfigFile(argv[1]); + } else { + std::cout << "Usage: " << argv[0] << " " << std::endl; + return 1; } // geometry setup - auto geometry = psSmartPointer>::New(); - psMakeStack(geometry, params.gridDelta, params.xExtent, - params.yExtent, params.numLayers, - params.layerHeight, params.substrateHeight, 0.0, - params.trenchWidth, params.maskHeight, false) + auto geometry = ps::SmartPointer>::New(); + ps::MakeStack( + geometry, params.get("gridDelta"), params.get("xExtent"), + params.get("yExtent"), params.get("numLayers"), + params.get("layerHeight"), params.get("substrateHeight"), 0.0, + params.get("trenchWidth"), params.get("maskHeight"), false) .apply(); // copy top layer for deposition - geometry->duplicateTopLevelSet(psMaterial::Polymer); + geometry->duplicateTopLevelSet(ps::Material::Polymer); // use pre-defined model Fluorocarbon etching model - auto model = psSmartPointer>::New( - params.ionFlux, params.etchantFlux, params.polymerFlux, params.energyMean, - params.energySigma); + auto model = ps::SmartPointer>::New( + params.get("ionFlux"), params.get("etchantFlux"), + params.get("polymerFlux"), params.get("energyMean"), + params.get("energySigma")); // process setup - psProcess process; + ps::Process process; process.setDomain(geometry); process.setProcessModel(model); - process.setProcessDuration(params.processTime); + process.setProcessDuration(params.get("processTime")); process.setMaxCoverageInitIterations(10); process.setTimeStepRatio(0.25); @@ -57,12 +58,12 @@ int main(int argc, char *argv[]) { geometry->saveVolumeMesh("final"); std::cout << "Extruding to 3D ..." << std::endl; - auto extruded = psSmartPointer>::New(); + auto extruded = ps::SmartPointer>::New(); std::array extrudeExtent = {-20., 20.}; - psExtrude(geometry, extruded, extrudeExtent, 0, - {lsBoundaryConditionEnum<3>::REFLECTIVE_BOUNDARY, - lsBoundaryConditionEnum<3>::REFLECTIVE_BOUNDARY, - lsBoundaryConditionEnum<3>::INFINITE_BOUNDARY}) + ps::Extrude(geometry, extruded, extrudeExtent, 0, + {ls::BoundaryConditionEnum<3>::REFLECTIVE_BOUNDARY, + ls::BoundaryConditionEnum<3>::REFLECTIVE_BOUNDARY, + ls::BoundaryConditionEnum<3>::INFINITE_BOUNDARY}) .apply(); extruded->saveSurfaceMesh("surface.vtp"); diff --git a/examples/trenchDepositionGeometric/parameters.hpp b/examples/trenchDepositionGeometric/parameters.hpp deleted file mode 100644 index 682520c..0000000 --- a/examples/trenchDepositionGeometric/parameters.hpp +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once - -#include -#include - -#include - -template struct Parameters { - // Domain - T gridDelta = 0.02; - T xExtent = 1.; - T yExtent = 1.; - - // Geometry - T trenchWidth = 0.4; - T trenchHeight = 0.8; - T taperAngle = 0.; - - // Process - T layerThickness = .15; - - Parameters() {} - - void fromMap(std::unordered_map &m) { - psUtils::AssignItems( // - m, // - psUtils::Item{"gridDelta", gridDelta}, // - psUtils::Item{"xExtent", xExtent}, // - psUtils::Item{"yExtent", yExtent}, // - psUtils::Item{"trenchWidth", trenchWidth}, // - psUtils::Item{"trenchHeight", trenchHeight}, // - psUtils::Item{"taperAngle", taperAngle}, // - psUtils::Item{"layerThickness", layerThickness} // - ); - } -}; diff --git a/examples/trenchDepositionGeometric/trenchDepositionGeometric.cpp b/examples/trenchDepositionGeometric/trenchDepositionGeometric.cpp index 8b02ba7..9a2814b 100644 --- a/examples/trenchDepositionGeometric/trenchDepositionGeometric.cpp +++ b/examples/trenchDepositionGeometric/trenchDepositionGeometric.cpp @@ -4,36 +4,35 @@ #include #include -#include "parameters.hpp" +namespace ps = viennaps; int main(int argc, char *argv[]) { using NumericType = double; static constexpr int D = 2; // Parse the parameters - Parameters params; + ps::utils::Parameters params; if (argc > 1) { - auto config = psUtils::readConfigFile(argv[1]); - if (config.empty()) { - std::cerr << "Empty config provided" << std::endl; - return -1; - } - params.fromMap(config); + params.readConfigFile(argv[1]); + } else { + std::cout << "Usage: " << argv[0] << " " << std::endl; + return 1; } - auto geometry = psSmartPointer>::New(); - psMakeTrench(geometry, params.gridDelta, params.xExtent, - params.yExtent, params.trenchWidth, - params.trenchHeight) + auto geometry = ps::SmartPointer>::New(); + ps::MakeTrench(geometry, params.get("gridDelta"), + params.get("xExtent"), params.get("yExtent"), + params.get("trenchWidth"), + params.get("trenchHeight")) .apply(); // copy top layer to capture deposition geometry->duplicateTopLevelSet(); - auto model = psSmartPointer>::New( - params.layerThickness, params.gridDelta); + auto model = ps::SmartPointer>::New( + params.get("layerThickness"), params.get("gridDelta")); - psProcess process; + ps::Process process; process.setDomain(geometry); process.setProcessModel(model); diff --git a/examples/volumeModel/volumeModel.cpp b/examples/volumeModel/volumeModel.cpp index 1f636be..1159a04 100644 --- a/examples/volumeModel/volumeModel.cpp +++ b/examples/volumeModel/volumeModel.cpp @@ -10,14 +10,12 @@ int main(int argc, char *argv[]) { constexpr int D = 3; // Parse the parameters - Parameters params; + ps::utils::Parameters params; if (argc > 1) { - auto config = psUtils::readConfigFile(argv[1]); - if (config.empty()) { - std::cerr << "Empty config provided" << std::endl; - return -1; - } - params.fromMap(config); + params.readConfigFile(argv[1]); + } else { + std::cout << "Usage: " << argv[0] << " " << std::endl; + return 1; } auto geometry = psSmartPointer>::New(); diff --git a/include/viennaps/cellSet/csBVH.hpp b/include/viennaps/cellSet/csBVH.hpp index 835763b..850a8a0 100644 --- a/include/viennaps/cellSet/csBVH.hpp +++ b/include/viennaps/cellSet/csBVH.hpp @@ -1,13 +1,13 @@ #pragma once #include "csBoundingVolume.hpp" -#include +#include /// Helper class to quickly determine the cell in which a given point resides /// in. To do so, an octree is built around the cell set structure. template class csBVH { private: - using BVPtrType = lsSmartPointer>; + using BVPtrType = viennacore::SmartPointer>; using BoundsType = csPair>; using CellIdsPtr = std::set *; diff --git a/include/viennaps/cellSet/csBoundingVolume.hpp b/include/viennaps/cellSet/csBoundingVolume.hpp index 38b17f4..e891f9e 100644 --- a/include/viennaps/cellSet/csBoundingVolume.hpp +++ b/include/viennaps/cellSet/csBoundingVolume.hpp @@ -1,14 +1,15 @@ #pragma once #include "csUtil.hpp" -#include + +#include #include #include template class csBoundingVolume { private: - using BVPtrType = lsSmartPointer>; + using BVPtrType = viennacore::SmartPointer>; using BoundsType = csPair>; using CellIdsPtr = std::set *; diff --git a/include/viennaps/cellSet/csDenseCellSet.hpp b/include/viennaps/cellSet/csDenseCellSet.hpp index ef4e53e..5e647ef 100644 --- a/include/viennaps/cellSet/csDenseCellSet.hpp +++ b/include/viennaps/cellSet/csDenseCellSet.hpp @@ -28,13 +28,14 @@ using namespace viennacore; */ template class DenseCellSet { private: - using gridType = SmartPointer>; - using levelSetsType = SmartPointer>>>; + using gridType = SmartPointer>; + using levelSetsType = + SmartPointer>>>; using materialMapType = SmartPointer; levelSetsType levelSets = nullptr; gridType cellGrid = nullptr; - SmartPointer> surface = nullptr; + SmartPointer> surface = nullptr; SmartPointer> BVH = nullptr; materialMapType materialMap = nullptr; @@ -70,25 +71,25 @@ template class DenseCellSet { materialMap = passedMaterialMap; if (cellGrid == nullptr) - cellGrid = SmartPointer>::New(); + cellGrid = SmartPointer>::New(); if (surface == nullptr) - surface = SmartPointer>::New(levelSets->back()); + surface = SmartPointer>::New(levelSets->back()); else surface->deepCopy(levelSets->back()); gridDelta = surface->getGrid().getGridDelta(); depth = passedDepth; - std::vector>> levelSetsInOrder; - auto plane = SmartPointer>::New(surface->getGrid()); + std::vector>> levelSetsInOrder; + auto plane = SmartPointer>::New(surface->getGrid()); { T origin[D] = {0.}; T normal[D] = {0.}; origin[D - 1] = depth; normal[D - 1] = 1.; - lsMakeGeometry(plane, - lsSmartPointer>::New(origin, normal)) + viennals::MakeGeometry( + plane, SmartPointer>::New(origin, normal)) .apply(); } if (!cellSetAboveSurface) @@ -100,18 +101,19 @@ template class DenseCellSet { } calculateMinMaxIndex(levelSetsInOrder); - lsToVoxelMesh(levelSetsInOrder, cellGrid).apply(); + viennals::ToVoxelMesh(levelSetsInOrder, cellGrid).apply(); // lsToVoxelMesh also saves the extent in the cell grid #ifndef NDEBUG int db_ls = 0; for (auto &ls : levelSetsInOrder) { - auto mesh = SmartPointer>::New(); + auto mesh = SmartPointer>::New(); lsToSurfaceMesh(ls, mesh).apply(); - lsVTKWriter(mesh, "cellSet_debug_" + std::to_string(db_ls++) + ".vtp") + viennals::VTKWriter(mesh, "cellSet_debug_" + std::to_string(db_ls++) + + ".vtp") .apply(); } - lsVTKWriter(cellGrid, "cellSet_debug_init.vtu").apply(); + viennals::VTKWriter(cellGrid, "cellSet_debug_init.vtu").apply(); #endif adjustMaterialIds(); @@ -195,9 +197,9 @@ template class DenseCellSet { return cellGrid->template getElements<(1 << D)>()[idx]; } - SmartPointer> getSurface() { return surface; } + SmartPointer> getSurface() { return surface; } - SmartPointer> getCellGrid() { return cellGrid; } + SmartPointer> getCellGrid() { return cellGrid; } levelSetsType getLevelSets() const { return levelSets; } @@ -312,7 +314,7 @@ template class DenseCellSet { // Write the cell set as .vtu file void writeVTU(std::string fileName) { - lsVTKWriter(cellGrid, fileName).apply(); + viennals::VTKWriter(cellGrid, fileName).apply(); } // Save cell set data in simple text format @@ -406,15 +408,15 @@ template class DenseCellSet { auto materialIds = getScalarData("Material"); // create overlay material - std::vector>> levelSetsInOrder; - auto plane = SmartPointer>::New(surface->getGrid()); + std::vector>> levelSetsInOrder; + auto plane = SmartPointer>::New(surface->getGrid()); { T origin[D] = {0.}; T normal[D] = {0.}; origin[D - 1] = depth; normal[D - 1] = 1.; - lsMakeGeometry(plane, - SmartPointer>::New(origin, normal)) + viennals::MakeGeometry( + plane, SmartPointer>::New(origin, normal)) .apply(); } if (!cellSetAboveSurface) @@ -425,13 +427,14 @@ template class DenseCellSet { levelSetsInOrder.push_back(plane); // set up iterators for all materials - std::vector::DomainType>> + std::vector< + hrleConstDenseCellIterator::DomainType>> iterators; for (auto it = levelSetsInOrder.begin(); it != levelSetsInOrder.end(); ++it) { - iterators.push_back( - hrleConstDenseCellIterator::DomainType>( - (*it)->getDomain(), minIndex)); + iterators.push_back(hrleConstDenseCellIterator< + typename viennals::Domain::DomainType>( + (*it)->getDomain(), minIndex)); } // move iterator for lowest material id and then adjust others if they are @@ -490,18 +493,19 @@ template class DenseCellSet { // Updates the surface of the cell set. The new surface should be below the // old surface as this function can only remove cells from the cell set. void updateSurface() { - auto updateCellGrid = SmartPointer>::New(); + auto updateCellGrid = SmartPointer>::New(); - lsToVoxelMesh voxelConverter(updateCellGrid); + viennals::ToVoxelMesh voxelConverter(updateCellGrid); { - auto plane = SmartPointer>::New(surface->getGrid()); + auto plane = + SmartPointer>::New(surface->getGrid()); T origin[D] = {0.}; T normal[D] = {0.}; origin[D - 1] = depth; normal[D - 1] = 1.; - lsMakeGeometry(plane, - SmartPointer>::New(origin, normal)) + viennals::MakeGeometry( + plane, SmartPointer>::New(origin, normal)) .apply(); voxelConverter.insertNextLevelSet(plane); } @@ -739,8 +743,9 @@ template class DenseCellSet { .print(); } - void calculateMinMaxIndex( - const std::vector>> &levelSetsInOrder) { + void + calculateMinMaxIndex(const std::vector>> + &levelSetsInOrder) { // set to zero for (unsigned i = 0; i < D; ++i) { minIndex[i] = std::numeric_limits::max(); diff --git a/include/viennaps/cellSet/csPointSource.hpp b/include/viennaps/cellSet/csPointSource.hpp index ce09ea5..b14beeb 100644 --- a/include/viennaps/cellSet/csPointSource.hpp +++ b/include/viennaps/cellSet/csPointSource.hpp @@ -9,17 +9,17 @@ using namespace viennacore; template class PointSource : public viennaray::Source { const unsigned mNumPoints; - const Triple origin; - const Triple direction; + const csTriple origin; + const csTriple direction; public: - PointSource(Triple passedOrigin, - Triple passedDirection, + PointSource(csTriple passedOrigin, + csTriple passedDirection, std::array &pTraceSettings, const size_t pNumPoints) : origin(passedOrigin), direction(passedDirection), mNumPoints(pNumPoints) {} - Pair> + Pair> getOriginAndDirection(const size_t idx, RNG &rngState) const override { return {origin, direction}; } diff --git a/include/viennaps/cellSet/csTracingKernel.hpp b/include/viennaps/cellSet/csTracingKernel.hpp index d38d637..5a07d2a 100644 --- a/include/viennaps/cellSet/csTracingKernel.hpp +++ b/include/viennaps/cellSet/csTracingKernel.hpp @@ -133,7 +133,7 @@ template class TracingKernel { ray.org_z + ray.dir_z * ray.tfar; /* -------- Hit from back -------- */ - const auto rayDir = Triple{ray.dir_x, ray.dir_y, ray.dir_z}; + const auto rayDir = csTriple{ray.dir_x, ray.dir_y, ray.dir_z}; const auto geomNormal = mGeometry.getPrimNormal(rayHit.hit.primID); if (rayInternal::DotProduct(rayDir, geomNormal) > 0) { // If the dot product of the ray direction and the surface normal is diff --git a/include/viennaps/cellSet/csTracingParticle.hpp b/include/viennaps/cellSet/csTracingParticle.hpp index 3a0d0d0..df317f7 100644 --- a/include/viennaps/cellSet/csTracingParticle.hpp +++ b/include/viennaps/cellSet/csTracingParticle.hpp @@ -16,9 +16,10 @@ template class AbstractParticle { virtual void initNew(RNG &rngState) = 0; - virtual std::pair> surfaceHit(const Triple &rayDir, - const Triple &geomNormal, - bool &reflect, RNG &rngState) = 0; + virtual std::pair> surfaceHit(const csTriple &rayDir, + const csTriple &geomNormal, + bool &reflect, + RNG &rngState) = 0; virtual T getSourceDistributionPower() const = 0; virtual csPair getMeanFreePath() const = 0; virtual T collision(csVolumeParticle &particle, RNG &rngState, @@ -32,12 +33,12 @@ class Particle : public AbstractParticle { return std::make_unique(static_cast(*this)); } virtual void initNew(RNG &rngState) override {} - virtual std::pair> surfaceHit(const Triple &rayDir, - const Triple &geomNormal, - bool &reflect, - RNG &rngState) override { + virtual std::pair> surfaceHit(const csTriple &rayDir, + const csTriple &geomNormal, + bool &reflect, + RNG &rngState) override { reflect = false; - return std::pair>{1., Triple{0., 0., 0.}}; + return std::pair>{1., csTriple{0., 0., 0.}}; } virtual T getSourceDistributionPower() const override { return 1.; } virtual csPair getMeanFreePath() const override { return {1., 1.}; } diff --git a/include/viennaps/compact/psCSVDataSource.hpp b/include/viennaps/compact/psCSVDataSource.hpp index 3d202e2..c95aa3e 100644 --- a/include/viennaps/compact/psCSVDataSource.hpp +++ b/include/viennaps/compact/psCSVDataSource.hpp @@ -6,22 +6,26 @@ #include #include +#include "../psUtils.hpp" #include "psCSVReader.hpp" #include "psCSVWriter.hpp" #include "psDataSource.hpp" -#include "../psLogger.hpp" -#include "../psUtils.hpp" +#include + +namespace viennaps { + +using namespace viennacore; template -class psCSVDataSource : public psDataSource { - using Parent = psDataSource; +class CSVDataSource : public DataSource { + using Parent = DataSource; using Parent::namedParameters; using Parent::positionalParameters; - psCSVReader reader; - psCSVWriter writer; + CSVReader reader; + CSVWriter writer; std::string header; @@ -31,11 +35,11 @@ class psCSVDataSource : public psDataSource { processPositionalParam(const std::string &input, std::vector &positionalParameters) { // Positional parameter - auto v = psUtils::safeConvert(input); + auto v = utils::safeConvert(input); if (v.has_value()) positionalParameters.push_back(v.value()); else { - psLogger::getInstance() + Logger::getInstance() .addWarning("Error while converting parameter '" + input + "' to numeric type.") .print(); @@ -51,17 +55,17 @@ class psCSVDataSource : public psDataSource { std::smatch smatch; if (std::regex_search(input, smatch, rgx) && smatch.size() == 3) { - auto v = psUtils::safeConvert(smatch[2]); + auto v = utils::safeConvert(smatch[2]); if (v.has_value()) namedParameters.insert({smatch[1], v.value()}); else { - psLogger::getInstance() + Logger::getInstance() .addWarning("Error while converting value of parameter '" + std::string(smatch[1]) + "'") .print(); } } else { - psLogger::getInstance() + Logger::getInstance() .addWarning("Error while parsing parameter line '" + input + "'") .print(); } @@ -109,9 +113,9 @@ class psCSVDataSource : public psDataSource { using typename Parent::ItemType; using typename Parent::VectorType; - psCSVDataSource() {} + CSVDataSource() {} - psCSVDataSource(std::string passedFilename) { + CSVDataSource(std::string passedFilename) { reader.setFilename(passedFilename); writer.setFilename(passedFilename); } @@ -168,3 +172,5 @@ class psCSVDataSource : public psDataSource { return namedParameters; } }; + +} // namespace viennaps diff --git a/include/viennaps/compact/psCSVReader.hpp b/include/viennaps/compact/psCSVReader.hpp index ea76761..1e3fe7b 100644 --- a/include/viennaps/compact/psCSVReader.hpp +++ b/include/viennaps/compact/psCSVReader.hpp @@ -7,11 +7,14 @@ #include #include -#include "../psLogger.hpp" #include "../psUtils.hpp" +namespace viennaps { + +using namespace viennacore; + // Simple class for reading CSV files -template class psCSVReader { +template class CSVReader { // Regex to find trailing and leading whitespaces const std::regex wsRegex = std::regex("^ +| +$|( ) +"); @@ -20,8 +23,8 @@ template class psCSVReader { int numCols = 0; public: - psCSVReader() {} - psCSVReader(std::string passedFilename, char passedDelimiter = ',') + CSVReader() {} + CSVReader(std::string passedFilename, char passedDelimiter = ',') : filename(passedFilename), delimiter(passedDelimiter) {} void setFilename(std::string passedFilename) { filename = passedFilename; } @@ -53,7 +56,7 @@ template class psCSVReader { } } } else { - psLogger::getInstance() + Logger::getInstance() .addWarning("Couldn't open file '" + filename + "'") .print(); return {}; @@ -84,11 +87,11 @@ template class psCSVReader { std::vector a; int i = 0; while (std::getline(iss, tmp, delimiter)) { - auto valueOpt = psUtils::safeConvert(tmp); + auto valueOpt = utils::safeConvert(tmp); if (valueOpt) a.push_back(valueOpt.value()); else { - psLogger::getInstance() + Logger::getInstance() .addWarning("Error while reading line " + std::to_string(lineCount - 1) + " in '" + filename + "'") @@ -103,7 +106,7 @@ template class psCSVReader { numCols = i; if (i != numCols) { - psLogger::getInstance() + Logger::getInstance() .addWarning("Invalid number of columns in line " + std::to_string(lineCount - 1) + " in '" + filename + "'") @@ -115,10 +118,12 @@ template class psCSVReader { file.close(); return data; } else { - psLogger::getInstance() + Logger::getInstance() .addWarning("Couldn't open file '" + filename + "'") .print(); return {}; } } }; + +} // namespace viennaps diff --git a/include/viennaps/compact/psCSVWriter.hpp b/include/viennaps/compact/psCSVWriter.hpp index 744a53b..0479dc4 100644 --- a/include/viennaps/compact/psCSVWriter.hpp +++ b/include/viennaps/compact/psCSVWriter.hpp @@ -6,7 +6,11 @@ #include #include -#include "../psLogger.hpp" +#include + +namespace viennaps { + +using namespace viennacore; template std::string join(Iterator begin, Iterator end, @@ -20,7 +24,7 @@ std::string join(Iterator begin, Iterator end, } // A simple CSV writer class -template class psCSVWriter { +template class CSVWriter { std::string filename; std::ofstream file; @@ -29,8 +33,8 @@ template class psCSVWriter { int numCols = 0; public: - psCSVWriter() {} - psCSVWriter(std::string passedFilename, std::string passedHeader = "") + CSVWriter() {} + CSVWriter(std::string passedFilename, std::string passedHeader = "") : filename(passedFilename), header(passedHeader) {} void setFilename(std::string passedFilename) { filename = passedFilename; } @@ -38,8 +42,8 @@ template class psCSVWriter { bool initialize() { if (filename.empty()) { - psLogger::getInstance() - .addWarning("psCSVWriter: No filename provided!") + Logger::getInstance() + .addWarning("CSVWriter: No filename provided!") .print(); return false; } @@ -61,8 +65,8 @@ template class psCSVWriter { } } } else { - psLogger::getInstance() - .addWarning("psCSVWriter: Error opening file '" + filename + "'") + Logger::getInstance() + .addWarning("CSVWriter: Error opening file '" + filename + "'") .print(); return false; } @@ -80,14 +84,14 @@ template class psCSVWriter { numCols = data.size(); if (data.size() != numCols) { - psLogger::getInstance() + Logger::getInstance() .addWarning("Unexpected number of items in the provided row!") .print(); return false; } if (!file.is_open()) { - psLogger::getInstance() + Logger::getInstance() .addWarning("Couldn't open file `" + filename + "`") .print(); return false; @@ -107,7 +111,7 @@ template class psCSVWriter { numCols = data.size(); if (data.size() != numCols) { - psLogger::getInstance() + Logger::getInstance() .addWarning("Unexpected number of items in the provided row! (" + std::to_string(data.size()) + " instead of " + std::to_string(numCols) + ")") @@ -115,7 +119,7 @@ template class psCSVWriter { return false; } if (!file.is_open()) { - psLogger::getInstance() + Logger::getInstance() .addWarning("Couldn't open file `" + filename + "`") .print(); return false; @@ -129,8 +133,10 @@ template class psCSVWriter { file.flush(); } - ~psCSVWriter() { + ~CSVWriter() { if (file.is_open()) file.close(); } }; + +} // namespace viennaps diff --git a/include/viennaps/compact/psDataSource.hpp b/include/viennaps/compact/psDataSource.hpp index 550eca2..8cead57 100644 --- a/include/viennaps/compact/psDataSource.hpp +++ b/include/viennaps/compact/psDataSource.hpp @@ -4,14 +4,18 @@ #include #include -#include "../psLogger.hpp" -#include "../psSmartPointer.hpp" +#include +#include -template class psDataSource { +namespace viennaps { + +using namespace viennacore; + +template class DataSource { public: using ItemType = std::vector; using VectorType = std::vector; - using ConstPtr = psSmartPointer; + using ConstPtr = SmartPointer; // Returns a smart pointer to the in-memory copy of the data. If the in-memory // copy of the data is empty, the read function is called on the data source. @@ -54,7 +58,7 @@ template class psDataSource { // stored alongside the actual data (e.g. depth at which trench diameters were // captured) virtual std::vector getPositionalParameters() { - psLogger::getInstance() + Logger::getInstance() .addWarning("This data source does not support positional parameters.") .print(); return {}; @@ -66,7 +70,7 @@ template class psDataSource { // These optional parameters can also be named virtual std::unordered_map getNamedParameters() { - psLogger::getInstance() + Logger::getInstance() .addWarning("This data source does not support named parameters.") .print(); return {}; @@ -98,3 +102,5 @@ template class psDataSource { // modified (i.e. whether the append function has been called) bool modified = false; }; + +} // namespace viennaps diff --git a/include/viennaps/compact/psKDTree.hpp b/include/viennaps/compact/psKDTree.hpp index 9024b8e..dd80b4d 100644 --- a/include/viennaps/compact/psKDTree.hpp +++ b/include/viennaps/compact/psKDTree.hpp @@ -41,6 +41,7 @@ #include "psQueues.hpp" #include +#include namespace viennaps { diff --git a/include/viennaps/compact/psNearestNeighborsInterpolation.hpp b/include/viennaps/compact/psNearestNeighborsInterpolation.hpp index 6eedd1e..dbe1e48 100644 --- a/include/viennaps/compact/psNearestNeighborsInterpolation.hpp +++ b/include/viennaps/compact/psNearestNeighborsInterpolation.hpp @@ -7,10 +7,15 @@ #include "psDataScaler.hpp" #include "psKDTree.hpp" - -#include "../psSmartPointer.hpp" #include "psValueEstimator.hpp" +#include +#include + +namespace viennaps { + +using namespace viennacore; + template auto extractInputData(psSmartPointer data, SizeType InputDim, SizeType OutputDim) { @@ -31,11 +36,11 @@ auto extractInputData(psSmartPointer data, SizeType InputDim, // Class providing nearest neighbors interpolation template > -class psNearestNeighborsInterpolation +class NearestNeighborsInterpolation : public psValueEstimator { static_assert(std::is_base_of_v, DataScaler>, - "psNearestNeighborsInterpolation: the provided DataScaler " + "NearestNeighborsInterpolation: the provided DataScaler " "does not inherit from psDataScaler."); using Parent = psValueEstimator; @@ -48,13 +53,13 @@ class psNearestNeighborsInterpolation using Parent::inputDim; using Parent::outputDim; - psKDTree kdtree; + KDTree kdtree; int numberOfNeighbors = 3.; NumericType distanceExponent = 2.; public: - psNearestNeighborsInterpolation() {} + NearestNeighborsInterpolation() {} void setNumberOfNeighbors(int passedNumberOfNeighbors) { numberOfNeighbors = passedNumberOfNeighbors; @@ -68,17 +73,16 @@ class psNearestNeighborsInterpolation if (!data || (data && data->empty())) { psLogger::getInstance() .addWarning( - "psNearestNeighborsInterpolation: the provided data is empty.") + "NearestNeighborsInterpolation: the provided data is empty.") .print(); return false; } if (data->at(0).size() != inputDim + outputDim) { psLogger::getInstance() - .addWarning( - "psNearestNeighborsInterpolation: the sum of the provided " - "InputDimension and OutputDimension does not match the " - "dimension of the provided data.") + .addWarning("NearestNeighborsInterpolation: the sum of the provided " + "InputDimension and OutputDimension does not match the " + "dimension of the provided data.") .print(); return false; } @@ -102,8 +106,7 @@ class psNearestNeighborsInterpolation estimate(const ItemType &input) override { if (input.size() != inputDim) { psLogger::getInstance() - .addWarning( - "psNearestNeighborsInterpolation: No input data provided.") + .addWarning("NearestNeighborsInterpolation: No input data provided.") .print(); return {}; } @@ -149,3 +152,5 @@ class psNearestNeighborsInterpolation return {{result, minDistance}}; } }; + +} // namespace viennaps diff --git a/include/viennaps/geometries/psMakeFin.hpp b/include/viennaps/geometries/psMakeFin.hpp index c34d24e..44ed8cf 100644 --- a/include/viennaps/geometries/psMakeFin.hpp +++ b/include/viennaps/geometries/psMakeFin.hpp @@ -19,9 +19,9 @@ using namespace viennacore; /// with the specified material exclusively applied to the bottom of the fin, /// while the upper portion adopts the mask material. template class MakeFin { - using lsDomainType = SmartPointer>; + using lsDomainType = SmartPointer>; using psDomainType = SmartPointer>; - using BoundaryEnum = typename lsDomain::BoundaryType; + using BoundaryEnum = typename viennals::Domain::BoundaryType; psDomainType pDomain_ = nullptr; @@ -68,9 +68,9 @@ template class MakeFin { auto substrate = lsDomainType::New(bounds, boundaryConds, gridDelta_); NumericType normal[D] = {0., 0., 1.}; NumericType origin[D] = {0., 0., baseHeight_}; - lsMakeGeometry( + viennals::MakeGeometry( substrate, - lsSmartPointer>::New(origin, normal)) + SmartPointer>::New(origin, normal)) .apply(); auto mask = lsDomainType::New(bounds, boundaryConds, gridDelta_); @@ -83,9 +83,9 @@ template class MakeFin { yExtent_ / 2.f + gridDelta_ / 2.f, baseHeight_ + finHeight_}; - lsMakeGeometry geo( - mask, - lsSmartPointer>::New(minPoint, maxPoint)); + viennals::MakeGeometry geo( + mask, SmartPointer>::New(minPoint, + maxPoint)); geo.setIgnoreBoundaryConditions(true); geo.apply(); @@ -98,7 +98,7 @@ template class MakeFin { return; } - auto boxMesh = SmartPointer>::New(); + auto boxMesh = SmartPointer>::New(); boxMesh->insertNextNode({-finWidth_ / 2, yExtent_ / 2 + gridDelta_, baseHeight_ - gridDelta_}); boxMesh->insertNextNode({finWidth_ / 2, yExtent_ / 2 + gridDelta_, @@ -163,11 +163,11 @@ template class MakeFin { boxMesh->insertNextTriangle({3, 7, 2}); // top boxMesh->insertNextTriangle({2, 7, 6}); // top } - lsFromSurfaceMesh(mask, boxMesh).apply(); + viennals::FromSurfaceMesh(mask, boxMesh).apply(); } - lsBooleanOperation(substrate, mask, - lsBooleanOperationEnum::UNION) + viennals::BooleanOperation( + substrate, mask, viennals::BooleanOperationEnum::UNION) .apply(); if (material_ == Material::None) { @@ -194,9 +194,9 @@ template class MakeFin { auto substrate = lsDomainType::New(bounds, boundaryConds, gridDelta_); NumericType normal[D] = {0., 1.}; NumericType origin[D] = {0., baseHeight_}; - lsMakeGeometry( + viennals::MakeGeometry( substrate, - lsSmartPointer>::New(origin, normal)) + SmartPointer>::New(origin, normal)) .apply(); auto mask = lsDomainType::New(bounds, boundaryConds, gridDelta_); @@ -204,9 +204,9 @@ template class MakeFin { if (taperAngle_ == 0.) { NumericType minPoint[D] = {-finWidth_ / 2, baseHeight_ - gridDelta_}; NumericType maxPoint[D] = {finWidth_ / 2, baseHeight_ + finHeight_}; - lsMakeGeometry geo( - mask, - lsSmartPointer>::New(minPoint, maxPoint)); + viennals::MakeGeometry geo( + mask, SmartPointer>::New(minPoint, + maxPoint)); geo.setIgnoreBoundaryConditions(true); geo.apply(); } else { @@ -218,7 +218,7 @@ template class MakeFin { return; } - auto boxMesh = SmartPointer>::New(); + auto boxMesh = SmartPointer>::New(); boxMesh->insertNextNode({-finWidth_ / 2, baseHeight_ - gridDelta_}); boxMesh->insertNextNode({finWidth_ / 2, baseHeight_ - gridDelta_}); boxMesh->insertNextLine({1, 0}); @@ -240,11 +240,11 @@ template class MakeFin { boxMesh->insertNextLine({0, 3}); } - lsFromSurfaceMesh(mask, boxMesh).apply(); + viennals::FromSurfaceMesh(mask, boxMesh).apply(); } - lsBooleanOperation(substrate, mask, - lsBooleanOperationEnum::UNION) + viennals::BooleanOperation( + substrate, mask, viennals::BooleanOperationEnum::UNION) .apply(); if (material_ == Material::None) { diff --git a/include/viennaps/geometries/psMakeHole.hpp b/include/viennaps/geometries/psMakeHole.hpp index e0670f0..0546a87 100644 --- a/include/viennaps/geometries/psMakeHole.hpp +++ b/include/viennaps/geometries/psMakeHole.hpp @@ -21,9 +21,9 @@ using namespace viennacore; /// applied to the bottom of the hole, while the remainder adopts the mask /// material. template class MakeHole { - using lsDomainType = SmartPointer>; + using lsDomainType = SmartPointer>; using psDomainType = SmartPointer>; - using BoundaryEnum = typename lsDomain::BoundaryType; + using BoundaryEnum = typename viennals::Domain::BoundaryType; psDomainType domain_ = nullptr; @@ -96,26 +96,29 @@ template class MakeHole { NumericType origin[D] = {0.}; normal[D - 1] = 1.; origin[D - 1] = baseHeight_; - lsMakeGeometry( - substrate, lsSmartPointer>::New(origin, normal)) + viennals::MakeGeometry( + substrate, + SmartPointer>::New(origin, normal)) .apply(); // mask layer auto mask = lsDomainType::New(bounds, boundaryCons, gridDelta_); origin[D - 1] = holeDepth_ + baseHeight_; - lsMakeGeometry( - mask, lsSmartPointer>::New(origin, normal)) + viennals::MakeGeometry( + mask, + SmartPointer>::New(origin, normal)) .apply(); auto maskAdd = lsDomainType::New(bounds, boundaryCons, gridDelta_); origin[D - 1] = baseHeight_; normal[D - 1] = -1.; - lsMakeGeometry( - maskAdd, lsSmartPointer>::New(origin, normal)) + viennals::MakeGeometry( + maskAdd, + SmartPointer>::New(origin, normal)) .apply(); - lsBooleanOperation(mask, maskAdd, - lsBooleanOperationEnum::INTERSECT) + viennals::BooleanOperation( + mask, maskAdd, viennals::BooleanOperationEnum::INTERSECT) .apply(); // cylinder cutout @@ -127,18 +130,18 @@ template class MakeHole { topRadius += std::tan(taperAngle_ * M_PI / 180.) * holeDepth_; } - lsMakeGeometry( - maskAdd, lsSmartPointer>::New( + viennals::MakeGeometry( + maskAdd, SmartPointer>::New( origin, normal, holeDepth_ + 2 * gridDelta_, holeRadius_, topRadius)) .apply(); - lsBooleanOperation( - mask, maskAdd, lsBooleanOperationEnum::RELATIVE_COMPLEMENT) + viennals::BooleanOperation( + mask, maskAdd, viennals::BooleanOperationEnum::RELATIVE_COMPLEMENT) .apply(); - lsBooleanOperation(substrate, mask, - lsBooleanOperationEnum::UNION) + viennals::BooleanOperation( + substrate, mask, viennals::BooleanOperationEnum::UNION) .apply(); if (material_ == Material::None) { diff --git a/include/viennaps/geometries/psMakePlane.hpp b/include/viennaps/geometries/psMakePlane.hpp index 893cc51..9504ca0 100644 --- a/include/viennaps/geometries/psMakePlane.hpp +++ b/include/viennaps/geometries/psMakePlane.hpp @@ -18,9 +18,9 @@ using namespace viennacore; /// specified extent and height. The plane can have a periodic boundary in the x /// and y (only 3D) direction. template class MakePlane { - using LSPtrType = SmartPointer>; + using LSPtrType = SmartPointer>; using psDomainType = SmartPointer>; - using BoundaryEnum = typename lsDomain::BoundaryType; + using BoundaryEnum = typename viennals::Domain::BoundaryType; psDomainType pDomain_ = nullptr; @@ -93,9 +93,9 @@ template class MakePlane { if (add_) { auto substrate = LSPtrType::New(pDomain_->getGrid()); - lsMakeGeometry( + viennals::MakeGeometry( substrate, - lsSmartPointer>::New(origin, normal)) + SmartPointer>::New(origin, normal)) .apply(); if (material_ == Material::None) { pDomain_->insertNextLevelSet(substrate); @@ -104,9 +104,9 @@ template class MakePlane { } } else { auto substrate = LSPtrType::New(bounds, boundaryCons, gridDelta_); - lsMakeGeometry( + viennals::MakeGeometry( substrate, - lsSmartPointer>::New(origin, normal)) + SmartPointer>::New(origin, normal)) .apply(); if (material_ == Material::None) { pDomain_->insertNextLevelSet(substrate); diff --git a/include/viennaps/geometries/psMakeStack.hpp b/include/viennaps/geometries/psMakeStack.hpp index 722f0a0..4b6afa5 100644 --- a/include/viennaps/geometries/psMakeStack.hpp +++ b/include/viennaps/geometries/psMakeStack.hpp @@ -19,8 +19,8 @@ using namespace viennacore; /// users to create diverse and customized structures for simulation scenarios. template class MakeStack { using psDomainType = SmartPointer>; - using lsDomainType = SmartPointer>; - using BoundaryEnum = typename lsDomain::BoundaryType; + using lsDomainType = SmartPointer>; + using BoundaryEnum = typename viennals::Domain::BoundaryType; psDomainType pDomain_ = nullptr; @@ -78,21 +78,22 @@ template class MakeStack { auto mask = lsDomainType::New(bounds_, boundaryConds_, gridDelta_); origin_[D - 1] = substrateHeight_ + layerHeight_ * numLayers_ + maskHeight_; - lsMakeGeometry( - mask, lsSmartPointer>::New(origin_, normal_)) + viennals::MakeGeometry( + mask, + SmartPointer>::New(origin_, normal_)) .apply(); auto maskAdd = lsDomainType::New(bounds_, boundaryConds_, gridDelta_); origin_[D - 1] = substrateHeight_ + layerHeight_ * numLayers_; normal_[D - 1] = -1; - lsMakeGeometry( + viennals::MakeGeometry( maskAdd, - lsSmartPointer>::New(origin_, normal_)) + SmartPointer>::New(origin_, normal_)) .apply(); normal_[D - 1] = 1.; - lsBooleanOperation(mask, maskAdd, - lsBooleanOperationEnum::INTERSECT) + viennals::BooleanOperation( + mask, maskAdd, viennals::BooleanOperationEnum::INTERSECT) .apply(); if (holeRadius_ == 0.) { @@ -104,13 +105,13 @@ template class MakeStack { NumericType maxPoint[D] = {holeRadius_, substrateHeight_ + layerHeight_ * numLayers_ + maskHeight_ + gridDelta_}; - lsMakeGeometry( + viennals::MakeGeometry( maskAdd, - lsSmartPointer>::New(minPoint, maxPoint)) + SmartPointer>::New(minPoint, maxPoint)) .apply(); - lsBooleanOperation( - mask, maskAdd, lsBooleanOperationEnum::RELATIVE_COMPLEMENT) + viennals::BooleanOperation( + mask, maskAdd, viennals::BooleanOperationEnum::RELATIVE_COMPLEMENT) .apply(); pDomain_->insertNextLevelSetAsMaterial(mask, Material::Mask); @@ -119,9 +120,9 @@ template class MakeStack { // Silicon substrate auto substrate = lsDomainType::New(bounds_, boundaryConds_, gridDelta_); origin_[D - 1] = substrateHeight_; - lsMakeGeometry( + viennals::MakeGeometry( substrate, - lsSmartPointer>::New(origin_, normal_)) + SmartPointer>::New(origin_, normal_)) .apply(); pDomain_->insertNextLevelSetAsMaterial(substrate, Material::Si); @@ -130,8 +131,9 @@ template class MakeStack { for (int i = 0; i < numLayers_; ++i) { auto ls = lsDomainType::New(bounds_, boundaryConds_, gridDelta_); origin_[D - 1] = substrateHeight_ + layerHeight_ * (i + 1); - lsMakeGeometry( - ls, lsSmartPointer>::New(origin_, normal_)) + viennals::MakeGeometry( + ls, + SmartPointer>::New(origin_, normal_)) .apply(); if (i % 2 == 0) { pDomain_->insertNextLevelSetAsMaterial(ls, Material::SiO2); @@ -150,14 +152,14 @@ template class MakeStack { NumericType maxPoint[D] = {holeRadius_, substrateHeight_ + layerHeight_ * numLayers_ + maskHeight_ + gridDelta_}; - lsMakeGeometry( + viennals::MakeGeometry( cutOut, - lsSmartPointer>::New(minPoint, maxPoint)) + SmartPointer>::New(minPoint, maxPoint)) .apply(); for (auto layer : *pDomain_->getLevelSets()) { - lsBooleanOperation( - layer, cutOut, lsBooleanOperationEnum::RELATIVE_COMPLEMENT) + viennals::BooleanOperation( + layer, cutOut, viennals::BooleanOperationEnum::RELATIVE_COMPLEMENT) .apply(); } } @@ -170,32 +172,33 @@ template class MakeStack { auto mask = lsDomainType::New(bounds_, boundaryConds_, gridDelta_); origin_[D - 1] = substrateHeight_ + layerHeight_ * numLayers_ + maskHeight_; - lsMakeGeometry( - mask, lsSmartPointer>::New(origin_, normal_)) + viennals::MakeGeometry( + mask, + SmartPointer>::New(origin_, normal_)) .apply(); auto maskAdd = lsDomainType::New(bounds_, boundaryConds_, gridDelta_); origin_[D - 1] = substrateHeight_ + layerHeight_ * numLayers_; normal_[D - 1] = -1; - lsMakeGeometry( + viennals::MakeGeometry( maskAdd, - lsSmartPointer>::New(origin_, normal_)) + SmartPointer>::New(origin_, normal_)) .apply(); - lsBooleanOperation(mask, maskAdd, - lsBooleanOperationEnum::INTERSECT) + viennals::BooleanOperation( + mask, maskAdd, viennals::BooleanOperationEnum::INTERSECT) .apply(); if (holeRadius_ > 0.) { normal_[D - 1] = 1.; - lsMakeGeometry( + viennals::MakeGeometry( maskAdd, - lsSmartPointer>::New( + SmartPointer>::New( origin_, normal_, maskHeight_ + gridDelta_, holeRadius_)) .apply(); - lsBooleanOperation( - mask, maskAdd, lsBooleanOperationEnum::RELATIVE_COMPLEMENT) + viennals::BooleanOperation( + mask, maskAdd, viennals::BooleanOperationEnum::RELATIVE_COMPLEMENT) .apply(); } else if (trenchWidth_ > 0.) { NumericType minPoint[D] = { @@ -206,13 +209,13 @@ template class MakeStack { static_cast(trenchWidth_ / 2.), static_cast(yExtent_ / 2. + gridDelta_), origin_[D - 1] + maskHeight_ + gridDelta_}; - lsMakeGeometry( - maskAdd, - lsSmartPointer>::New(minPoint, maxPoint)) + viennals::MakeGeometry( + maskAdd, SmartPointer>::New(minPoint, + maxPoint)) .apply(); - lsBooleanOperation( - mask, maskAdd, lsBooleanOperationEnum::RELATIVE_COMPLEMENT) + viennals::BooleanOperation( + mask, maskAdd, viennals::BooleanOperationEnum::RELATIVE_COMPLEMENT) .apply(); } @@ -222,9 +225,9 @@ template class MakeStack { // Silicon substrate auto substrate = lsDomainType::New(bounds_, boundaryConds_, gridDelta_); origin_[D - 1] = substrateHeight_; - lsMakeGeometry( + viennals::MakeGeometry( substrate, - lsSmartPointer>::New(origin_, normal_)) + SmartPointer>::New(origin_, normal_)) .apply(); pDomain_->insertNextLevelSetAsMaterial(substrate, Material::Si); @@ -232,8 +235,9 @@ template class MakeStack { for (int i = 0; i < numLayers_; ++i) { auto ls = lsDomainType::New(bounds_, boundaryConds_, gridDelta_); origin_[D - 1] = substrateHeight_ + layerHeight_ * (i + 1); - lsMakeGeometry( - ls, lsSmartPointer>::New(origin_, normal_)) + viennals::MakeGeometry( + ls, + SmartPointer>::New(origin_, normal_)) .apply(); if (i % 2 == 0) { pDomain_->insertNextLevelSetAsMaterial(ls, Material::SiO2); @@ -246,15 +250,15 @@ template class MakeStack { // cut out middle auto cutOut = lsDomainType::New(bounds_, boundaryConds_, gridDelta_); origin_[D - 1] = 0.; - lsMakeGeometry( + viennals::MakeGeometry( cutOut, - lsSmartPointer>::New( + SmartPointer>::New( origin_, normal_, (numLayers_ + 1) * layerHeight_, holeRadius_)) .apply(); for (auto layer : *pDomain_->getLevelSets()) { - lsBooleanOperation( - layer, cutOut, lsBooleanOperationEnum::RELATIVE_COMPLEMENT) + viennals::BooleanOperation( + layer, cutOut, viennals::BooleanOperationEnum::RELATIVE_COMPLEMENT) .apply(); } } else if (trenchWidth_ > 0. && maskHeight_ == 0.) { @@ -268,14 +272,14 @@ template class MakeStack { static_cast(yExtent_ / 2. + gridDelta_), substrateHeight_ + layerHeight_ * numLayers_ + maskHeight_ + gridDelta_}; - lsMakeGeometry( + viennals::MakeGeometry( cutOut, - lsSmartPointer>::New(minPoint, maxPoint)) + SmartPointer>::New(minPoint, maxPoint)) .apply(); for (auto layer : *pDomain_->getLevelSets()) { - lsBooleanOperation( - layer, cutOut, lsBooleanOperationEnum::RELATIVE_COMPLEMENT) + viennals::BooleanOperation( + layer, cutOut, viennals::BooleanOperationEnum::RELATIVE_COMPLEMENT) .apply(); } } diff --git a/include/viennaps/geometries/psMakeTrench.hpp b/include/viennaps/geometries/psMakeTrench.hpp index eb51bd8..273aac9 100644 --- a/include/viennaps/geometries/psMakeTrench.hpp +++ b/include/viennaps/geometries/psMakeTrench.hpp @@ -19,9 +19,9 @@ using namespace viennacore; /// exclusively to the bottom while the remaining portion adopts the mask /// material_. template class MakeTrench { - using lsDomainType = SmartPointer>; + using lsDomainType = SmartPointer>; using psDomainType = SmartPointer>; - using BoundaryEnum = typename lsDomain::BoundaryType; + using BoundaryEnum = typename viennals::Domain::BoundaryType; psDomainType pDomain_ = nullptr; @@ -81,31 +81,34 @@ template class MakeTrench { NumericType origin[D] = {0.}; normal[D - 1] = 1.; origin[D - 1] = baseHeight_; - lsMakeGeometry( - substrate, lsSmartPointer>::New(origin, normal)) + viennals::MakeGeometry( + substrate, + SmartPointer>::New(origin, normal)) .apply(); auto mask = lsDomainType::New(bounds, boundaryCons, gridDelta_); origin[D - 1] = trenchDepth_ + baseHeight_; - lsMakeGeometry( - mask, lsSmartPointer>::New(origin, normal)) + viennals::MakeGeometry( + mask, + SmartPointer>::New(origin, normal)) .apply(); auto maskAdd = lsDomainType::New(bounds, boundaryCons, gridDelta_); origin[D - 1] = baseHeight_; normal[D - 1] = -1.; - lsMakeGeometry( - maskAdd, lsSmartPointer>::New(origin, normal)) + viennals::MakeGeometry( + maskAdd, + SmartPointer>::New(origin, normal)) .apply(); - lsBooleanOperation(mask, maskAdd, - lsBooleanOperationEnum::INTERSECT) + viennals::BooleanOperation( + mask, maskAdd, viennals::BooleanOperationEnum::INTERSECT) .apply(); auto cutout = lsDomainType::New(bounds, boundaryCons, gridDelta_); if (taperAngle_) { - auto mesh = SmartPointer>::New(); + auto mesh = SmartPointer>::New(); const NumericType offset = std::tan(taperAngle_ * M_PI / 180.) * trenchDepth_; if constexpr (D == 2) { @@ -127,7 +130,7 @@ template class MakeTrench { mesh->insertNextLine(std::array{3, 2}); mesh->insertNextLine(std::array{2, 1}); mesh->insertNextLine(std::array{1, 0}); - lsFromSurfaceMesh(cutout, mesh).apply(); + viennals::FromSurfaceMesh(cutout, mesh).apply(); } else { for (int i = 0; i < 8; i++) { std::array node = {0., 0., 0.}; @@ -183,7 +186,7 @@ template class MakeTrench { mesh->insertNextTriangle(std::array{1, 2, 6}); mesh->insertNextTriangle(std::array{1, 6, 5}); - lsFromSurfaceMesh(cutout, mesh).apply(); + viennals::FromSurfaceMesh(cutout, mesh).apply(); } } else { NumericType minPoint[D]; @@ -201,19 +204,19 @@ template class MakeTrench { minPoint[1] = baseHeight_; maxPoint[1] = trenchDepth_ + baseHeight_; } - lsMakeGeometry geo( + viennals::MakeGeometry geo( cutout, - lsSmartPointer>::New(minPoint, maxPoint)); + SmartPointer>::New(minPoint, maxPoint)); geo.setIgnoreBoundaryConditions(true); geo.apply(); } - lsBooleanOperation( - mask, cutout, lsBooleanOperationEnum::RELATIVE_COMPLEMENT) + viennals::BooleanOperation( + mask, cutout, viennals::BooleanOperationEnum::RELATIVE_COMPLEMENT) .apply(); - lsBooleanOperation(substrate, mask, - lsBooleanOperationEnum::UNION) + viennals::BooleanOperation( + substrate, mask, viennals::BooleanOperationEnum::UNION) .apply(); if (material_ == Material::None) { diff --git a/include/viennaps/models/psAnisotropicProcess.hpp b/include/viennaps/models/psAnisotropicProcess.hpp index 7b35f54..7325479 100644 --- a/include/viennaps/models/psAnisotropicProcess.hpp +++ b/include/viennaps/models/psAnisotropicProcess.hpp @@ -3,6 +3,8 @@ #include "../psMaterials.hpp" #include "../psProcessModel.hpp" +#include + namespace viennaps { using namespace viennacore; @@ -11,12 +13,12 @@ namespace impl { template class AnisotropicVelocityField : public VelocityField { - static Triple ScaleImpl(const NumericType pF, - const Triple &pT) { + static Vec3D ScaleImpl(const NumericType pF, + const Vec3D &pT) { return {pF * pT[0], pF * pT[1], pF * pT[2]}; } - Triple> directions; + Vec3D> directions; const NumericType r100; const NumericType r110; const NumericType r111; @@ -25,33 +27,32 @@ class AnisotropicVelocityField : public VelocityField { public: AnisotropicVelocityField( - const Triple &direction100, - const Triple &direction010, const NumericType passedR100, + const Vec3D &direction100, + const Vec3D &direction010, const NumericType passedR100, const NumericType passedR110, const NumericType passedR111, const NumericType passedR311, const std::vector> &passedmaterials) : r100(passedR100), r110(passedR110), r111(passedR111), r311(passedR311), materials(passedmaterials) { - directions[0] = rayInternal::Normalize(direction100); - directions[1] = rayInternal::Normalize(direction010); + directions[0] = Normalize(direction100); + directions[1] = Normalize(direction010); - directions[1] = rayInternal::Diff( - directions[1], - ScaleImpl(rayInternal::DotProduct(directions[0], directions[1]), - directions[0])); - directions[2] = rayInternal::CrossProduct(directions[0], directions[1]); + directions[1] = + directions[1] - + ScaleImpl(DotProduct(directions[0], directions[1]), directions[0]); + directions[2] = CrossProduct(directions[0], directions[1]); } - NumericType getScalarVelocity(const Triple & /*coordinate*/, - int material, const Triple &nv, + NumericType getScalarVelocity(const Vec3D & /*coordinate*/, + int material, const Vec3D &nv, unsigned long /*pointID*/) override { for (auto epitaxyMaterial : materials) { if (MaterialMap::isMaterial(material, epitaxyMaterial.first)) { - if (std::abs(rayInternal::Norm(nv) - 1.) > 1e-4) + if (std::abs(Norm(nv) - 1.) > 1e-4) return 0.; - Triple normalVector; + Vec3D normalVector; normalVector[0] = nv[0]; normalVector[1] = nv[1]; if (D == 3) { @@ -59,17 +60,16 @@ class AnisotropicVelocityField : public VelocityField { } else { normalVector[2] = 0; } - rayInternal::Normalize(normalVector); + Normalize(normalVector); - Triple N; + Vec3D N; for (int i = 0; i < 3; i++) { - N[i] = - std::fabs(rayInternal::DotProduct(directions[i], normalVector)); + N[i] = std::fabs(DotProduct(directions[i], normalVector)); } std::sort(N.begin(), N.end(), std::greater()); NumericType velocity; - if (rayInternal::DotProduct(N, Triple{-1., 1., 2.}) < 0) { + if (DotProduct(N, Vec3D{-1., 1., 2.}) < 0) { velocity = (r100 * (N[0] - N[1] - 2 * N[2]) + r110 * (N[1] - N[2]) + 3 * r311 * N[2]) / N[0]; @@ -113,8 +113,8 @@ class AnisotropicProcess : public ProcessModel { } AnisotropicProcess( - const Triple passedDir100, - const Triple passedDir010, const NumericType passedR100, + const Vec3D passedDir100, + const Vec3D passedDir010, const NumericType passedR100, const NumericType passedR110, const NumericType passedR111, const NumericType passedR311, const std::vector> pMaterials) @@ -140,8 +140,8 @@ class AnisotropicProcess : public ProcessModel { } // crystal surface direction - Triple direction100; - Triple direction010; + Vec3D direction100; + Vec3D direction010; // rates for crystal directions in um / s NumericType r100 = 0.0166666666667; diff --git a/include/viennaps/models/psDirectionalEtching.hpp b/include/viennaps/models/psDirectionalEtching.hpp index d3be7aa..994b622 100644 --- a/include/viennaps/models/psDirectionalEtching.hpp +++ b/include/viennaps/models/psDirectionalEtching.hpp @@ -12,23 +12,23 @@ using namespace viennacore; namespace impl { template class DirectionalEtchVelocityField : public VelocityField { - const Triple direction_; + const Vec3D direction_; const NumericType directionalVelocity_; const NumericType isotropicVelocity_; const std::vector maskMaterials_; public: - DirectionalEtchVelocityField(Triple direction, + DirectionalEtchVelocityField(Vec3D direction, const NumericType directionalVelocity, const NumericType isotropicVelocity, const std::vector &mask) : direction_(direction), directionalVelocity_(directionalVelocity), isotropicVelocity_(isotropicVelocity), maskMaterials_(mask) {} - Triple getVectorVelocity(const Triple &coordinate, - int material, - const Triple &normalVector, - unsigned long) override { + Vec3D getVectorVelocity(const Vec3D &coordinate, + int material, + const Vec3D &normalVector, + unsigned long) override { if (isMaskMaterial(material)) { return {0.}; } else { @@ -63,7 +63,7 @@ class DirectionalEtchVelocityField : public VelocityField { template class DirectionalEtching : public ProcessModel { public: - DirectionalEtching(const Triple &direction, + DirectionalEtching(const Vec3D &direction, const NumericType directionalVelocity = 1., const NumericType isotropicVelocity = 0., const Material mask = Material::Mask) { @@ -82,7 +82,7 @@ class DirectionalEtching : public ProcessModel { this->setProcessName("DirectionalEtching"); } - DirectionalEtching(const Triple &direction, + DirectionalEtching(const Vec3D &direction, const NumericType directionalVelocity, const NumericType isotropicVelocity, const std::vector maskMaterials) { diff --git a/include/viennaps/models/psFluorocarbonEtching.hpp b/include/viennaps/models/psFluorocarbonEtching.hpp index 24ad44d..9d23c91 100644 --- a/include/viennaps/models/psFluorocarbonEtching.hpp +++ b/include/viennaps/models/psFluorocarbonEtching.hpp @@ -138,7 +138,7 @@ class FluorocarbonSurfaceModel : public SurfaceModel { void initializeCoverages(unsigned numGeometryPoints) override { if (coverages == nullptr) { - coverages = SmartPointer>::New(); + coverages = SmartPointer>::New(); } else { coverages->clear(); } @@ -149,8 +149,8 @@ class FluorocarbonSurfaceModel : public SurfaceModel { } SmartPointer> - calculateVelocities(SmartPointer> rates, - const std::vector> &coordinates, + calculateVelocities(SmartPointer> rates, + const std::vector> &coordinates, const std::vector &materialIds) override { updateCoverages(rates, materialIds); const auto numPoints = materialIds.size(); @@ -254,7 +254,7 @@ class FluorocarbonSurfaceModel : public SurfaceModel { return SmartPointer>::New(etchRate); } - void updateCoverages(SmartPointer> rates, + void updateCoverages(SmartPointer> rates, const std::vector &materialIds) override { const auto ionEnhancedRate = rates->getScalarData("ionEnhancedRate"); @@ -354,9 +354,8 @@ class FluorocarbonIon : p(parameters), A(1. / (1. + p.Ions.n_l * (M_PI_2 / p.Ions.inflectAngle - 1.))), minEnergy(std::min({p.Si.Eth_ie, p.SiO2.Eth_ie, p.Si3N4.Eth_ie})) {} - void surfaceCollision(NumericType rayWeight, - const Triple &rayDir, - const Triple &geomNormal, + void surfaceCollision(NumericType rayWeight, const Vec3D &rayDir, + const Vec3D &geomNormal, const unsigned int primID, const int materialId, viennaray::TracingData &localData, const viennaray::TracingData *globalData, @@ -429,9 +428,9 @@ class FluorocarbonIon std::max(sqrtE - std::sqrt(p.Polymer.Eth_ie), (NumericType)0) * cosTheta; } - std::pair> - surfaceReflection(NumericType rayWeight, const Triple &rayDir, - const Triple &geomNormal, + std::pair> + surfaceReflection(NumericType rayWeight, const Vec3D &rayDir, + const Vec3D &geomNormal, const unsigned int primId, const int materialId, const viennaray::TracingData *globalData, RNG &Rng) override final { @@ -457,10 +456,10 @@ class FluorocarbonIon E = newEnergy; auto direction = viennaray::ReflectionConedCosine( rayDir, geomNormal, Rng, std::max(incAngle, p.Ions.minAngle)); - return std::pair>{0., direction}; + return std::pair>{0., direction}; } else { - return std::pair>{ - 1., Triple{0., 0., 0.}}; + return std::pair>{ + 1., Vec3D{0., 0., 0.}}; } } void initNew(RNG &RNG) override final { @@ -487,8 +486,8 @@ class FluorocarbonPolymer public: FluorocarbonPolymer(const FluorocarbonParameters ¶meters) : p(parameters) {} - void surfaceCollision(NumericType rayWeight, const Triple &, - const Triple &, const unsigned int primID, + void surfaceCollision(NumericType rayWeight, const Vec3D &, + const Vec3D &, const unsigned int primID, const int, viennaray::TracingData &localData, const viennaray::TracingData *, @@ -496,9 +495,9 @@ class FluorocarbonPolymer // collect data for this hit localData.getVectorData(0)[primID] += rayWeight; } - std::pair> - surfaceReflection(NumericType, const Triple &, - const Triple &geomNormal, + std::pair> + surfaceReflection(NumericType, const Vec3D &, + const Vec3D &geomNormal, const unsigned int primID, const int materialId, const viennaray::TracingData *globalData, RNG &Rng) override final { @@ -515,7 +514,7 @@ class FluorocarbonPolymer else stick = p.beta_p; stick *= std::max(1 - phi_e - phi_p, (NumericType)0); - return std::pair>{stick, direction}; + return std::pair>{stick, direction}; } NumericType getSourceDistributionPower() const override final { return 1.; } std::vector getLocalDataLabels() const override final { @@ -532,8 +531,8 @@ class FluorocarbonEtchant public: FluorocarbonEtchant(const FluorocarbonParameters ¶meters) : p(parameters) {} - void surfaceCollision(NumericType rayWeight, const Triple &, - const Triple &, const unsigned int primID, + void surfaceCollision(NumericType rayWeight, const Vec3D &, + const Vec3D &, const unsigned int primID, const int, viennaray::TracingData &localData, const viennaray::TracingData *, @@ -541,9 +540,9 @@ class FluorocarbonEtchant // collect data for this hit localData.getVectorData(0)[primID] += rayWeight; } - std::pair> - surfaceReflection(NumericType rayWeight, const Triple &rayDir, - const Triple &geomNormal, + std::pair> + surfaceReflection(NumericType rayWeight, const Vec3D &rayDir, + const Vec3D &geomNormal, const unsigned int primID, const int materialId, const viennaray::TracingData *globalData, RNG &Rng) override final { @@ -563,7 +562,7 @@ class FluorocarbonEtchant Seff = p.beta_e * std::max(1 - phi_e - phi_p, (NumericType)0); } - return std::pair>{Seff, direction}; + return std::pair>{Seff, direction}; } NumericType getSourceDistributionPower() const override final { return 1.; } std::vector getLocalDataLabels() const override final { diff --git a/include/viennaps/models/psGeometricDistributionModels.hpp b/include/viennaps/models/psGeometricDistributionModels.hpp index 1688828..2e5b61a 100644 --- a/include/viennaps/models/psGeometricDistributionModels.hpp +++ b/include/viennaps/models/psGeometricDistributionModels.hpp @@ -15,11 +15,12 @@ using namespace viennacore; // Simple geometric model that implements a template class GeometricDistributionModel : public GeometricModel { - static_assert(std::is_base_of_v< - lsGeometricAdvectDistribution, DistType>); + static_assert( + std::is_base_of_v, + DistType>); - using GeomDistPtr = lsSmartPointer; - using LSPtr = lsSmartPointer>; + using GeomDistPtr = SmartPointer; + using LSPtr = SmartPointer>; using GeometricModel::domain; @@ -35,11 +36,12 @@ class GeometricDistributionModel : public GeometricModel { void apply() { if (dist) { if (mask) { - lsGeometricAdvect(domain->getLevelSets()->back(), dist, - mask) + viennals::GeometricAdvect( + domain->getLevelSets()->back(), dist, mask) .apply(); } else { - lsGeometricAdvect(domain->getLevelSets()->back(), dist) + viennals::GeometricAdvect( + domain->getLevelSets()->back(), dist) .apply(); } } @@ -48,17 +50,18 @@ class GeometricDistributionModel : public GeometricModel { template class SphereDistribution : public ProcessModel { - using LSPtr = lsSmartPointer>; + using LSPtr = SmartPointer>; public: SphereDistribution(const NumericType radius, const NumericType gridDelta, LSPtr mask = nullptr) { - auto dist = lsSmartPointer>::New( - radius, gridDelta); + auto dist = + SmartPointer>::New( + radius, gridDelta); - auto geomModel = lsSmartPointer>>::New(dist, - mask); + auto geomModel = SmartPointer>>::New(dist, mask); this->setGeometricModel(geomModel); this->setProcessName("SphereDistribution"); @@ -67,16 +70,17 @@ class SphereDistribution : public ProcessModel { template class BoxDistribution : public ProcessModel { - using LSPtr = lsSmartPointer>; + using LSPtr = SmartPointer>; public: BoxDistribution(const std::array &halfAxes, const NumericType gridDelta, LSPtr mask = nullptr) { - auto dist = lsSmartPointer>::New( + auto dist = SmartPointer>::New( halfAxes, gridDelta); - auto geomModel = lsSmartPointer>>::New(dist, mask); + auto geomModel = SmartPointer>>::New(dist, mask); this->setGeometricModel(geomModel); this->setProcessName("BoxDistribution"); diff --git a/include/viennaps/models/psIonBeamEtching.hpp b/include/viennaps/models/psIonBeamEtching.hpp index 4b26070..5cf382e 100644 --- a/include/viennaps/models/psIonBeamEtching.hpp +++ b/include/viennaps/models/psIonBeamEtching.hpp @@ -40,7 +40,7 @@ class IBESurfaceModel : public SurfaceModel { : maskMaterials_(mask), params_(params) {} SmartPointer> calculateVelocities( - SmartPointer> rates, + SmartPointer> rates, const std::vector> &coordinates, const std::vector &materialIds) override { @@ -81,9 +81,8 @@ class IBEIon : public viennaray::Particle, NumericType> { inflectAngle_(params.inflectAngle * M_PI / 180.), minAngle_(params.minAngle * M_PI / 180.) {} - void surfaceCollision(NumericType rayWeight, - const Triple &rayDir, - const Triple &geomNormal, + void surfaceCollision(NumericType rayWeight, const Vec3D &rayDir, + const Vec3D &geomNormal, const unsigned int primID, const int, viennaray::TracingData &localData, const viennaray::TracingData *, @@ -95,9 +94,9 @@ class IBEIon : public viennaray::Particle, NumericType> { params_.yieldFunction(cosTheta); } - std::pair> - surfaceReflection(NumericType rayWeight, const Triple &rayDir, - const Triple &geomNormal, + std::pair> + surfaceReflection(NumericType rayWeight, const Vec3D &rayDir, + const Vec3D &geomNormal, const unsigned int primID, const int materialId, const viennaray::TracingData *globalData, RNG &rngState) override final { @@ -124,10 +123,10 @@ class IBEIon : public viennaray::Particle, NumericType> { energy_ = newEnergy; auto direction = viennaray::ReflectionConedCosine( rayDir, geomNormal, rngState, std::max(incAngle, minAngle_)); - return std::pair>{0., direction}; + return std::pair>{0., direction}; } else { - return std::pair>{ - 1., Triple{0., 0., 0.}}; + return std::pair>{ + 1., Vec3D{0., 0., 0.}}; } } diff --git a/include/viennaps/models/psOxideRegrowth.hpp b/include/viennaps/models/psOxideRegrowth.hpp index c1ccd12..7b44cb6 100644 --- a/include/viennaps/models/psOxideRegrowth.hpp +++ b/include/viennaps/models/psOxideRegrowth.hpp @@ -20,9 +20,8 @@ class SelectiveEtchingVelocityField : public VelocityField { const NumericType pOxideRate) : rate(pRate), oxide_rate(pOxideRate) {} - NumericType getScalarVelocity(const Triple &coordinate, - int matId, - const Triple &normalVector, + NumericType getScalarVelocity(const Vec3D &coordinate, int matId, + const Vec3D &normalVector, unsigned long pointId) override { auto material = MaterialMap::mapToMaterial(matId); if (material == Material::Si3N4) { @@ -42,18 +41,17 @@ class SelectiveEtchingVelocityField : public VelocityField { }; template -class RedepositionVelocityField : public lsVelocityField { +class RedepositionVelocityField : public viennals::VelocityField { public: RedepositionVelocityField(const std::vector &passedVelocities, - const std::vector> &points) + const std::vector> &points) : velocities(passedVelocities), kdTree(points) { assert(points.size() == passedVelocities.size()); kdTree.build(); } - NumericType getScalarVelocity(const Triple &coordinate, - int matId, - const Triple &normalVector, + NumericType getScalarVelocity(const Vec3D &coordinate, int matId, + const Vec3D &normalVector, unsigned long pointId) override { auto nearest = kdTree.findNearest(coordinate); assert(nearest->first < velocities.size()); @@ -62,7 +60,7 @@ class RedepositionVelocityField : public lsVelocityField { private: const std::vector &velocities; - KDTree> kdTree; + KDTree> kdTree; }; template @@ -104,7 +102,7 @@ class ByproductDynamics : public AdvectionCallback { auto &cellSet = domain->getCellSet(); // redeposition - auto mesh = SmartPointer>::New(); + auto mesh = SmartPointer>::New(); ToDiskMesh(domain, mesh).apply(); const auto &points = mesh->nodes; @@ -168,7 +166,7 @@ class ByproductDynamics : public AdvectionCallback { auto redepoVelField = SmartPointer>::New(depoRate, points); - lsAdvect advectionKernel; + viennals::Advect advectionKernel; advectionKernel.insertNextLevelSet(domain->getLevelSets()->back()); advectionKernel.setVelocityField(redepoVelField); advectionKernel.setAdvectionTime(processTime - prevProcTime); diff --git a/include/viennaps/models/psPlasmaDamage.hpp b/include/viennaps/models/psPlasmaDamage.hpp index c638547..10381a8 100644 --- a/include/viennaps/models/psPlasmaDamage.hpp +++ b/include/viennaps/models/psPlasmaDamage.hpp @@ -29,9 +29,9 @@ class PlasmaDamageIon : public viennacs::Particle, T> { } while (E < minEnergy); } - std::pair> surfaceHit(const Triple &rayDir, - const Triple &geomNormal, bool &reflect, - RNG &rngState) override final { + std::pair> surfaceHit(const Vec3D &rayDir, + const Vec3D &geomNormal, bool &reflect, + RNG &rngState) override final { auto cosTheta = -rayInternal::DotProduct(rayDir, geomNormal); const T incAngle = std::acos(std::max(std::min(cosTheta, T(1)), T(0))); std::uniform_real_distribution uniDist; @@ -67,10 +67,10 @@ class PlasmaDamageIon : public viennacs::Particle, T> { auto direction = viennaray::ReflectionConedCosine( rayDir, geomNormal, rngState, std::min(incAngle, minAngle)); E = NewEnergy; - return std::pair>{impactEnergy, direction}; + return std::pair>{impactEnergy, direction}; } else { reflect = false; - return std::pair>{impactEnergy, Triple{0., 0., 0.}}; + return std::pair>{impactEnergy, Vec3D{0., 0., 0.}}; } } @@ -96,7 +96,7 @@ class PlasmaDamageIon : public viennacs::Particle, T> { for (int i = 0; i < numParticles; i++) { T cosTheta, tmp, sinThetaSqr; - csTriple direction; + csVec3D direction; do { // random direction direction[0] = negUniDist(rngState); @@ -213,7 +213,7 @@ class DamageModel : public AdvectionCallback { return true; } - void setPrimaryDirection(const Triple passedPrimaryDirection) { + void setPrimaryDirection(const Vec3D passedPrimaryDirection) { tracer.setPrimaryDirection(passedPrimaryDirection); } }; @@ -233,7 +233,7 @@ class PlasmaDamage : public ProcessModel { } void setPrimaryDirection( - const Triple passedPrimaryDirection) override final { + const Vec3D passedPrimaryDirection) override final { this->primaryDirection = Normalize(passedPrimaryDirection); auto cb = std::dynamic_pointer_cast>( this->getAdvectionCallback()); diff --git a/include/viennaps/models/psSF6O2Etching.hpp b/include/viennaps/models/psSF6O2Etching.hpp index 8e2215f..c01e4cb 100644 --- a/include/viennaps/models/psSF6O2Etching.hpp +++ b/include/viennaps/models/psSF6O2Etching.hpp @@ -83,7 +83,7 @@ class SF6O2SurfaceModel : public SurfaceModel { void initializeCoverages(unsigned numGeometryPoints) override { if (coverages == nullptr) { - coverages = SmartPointer>::New(); + coverages = SmartPointer>::New(); } else { coverages->clear(); } @@ -93,8 +93,8 @@ class SF6O2SurfaceModel : public SurfaceModel { } SmartPointer> - calculateVelocities(SmartPointer> rates, - const std::vector> &coordinates, + calculateVelocities(SmartPointer> rates, + const std::vector> &coordinates, const std::vector &materialIds) override { updateCoverages(rates, materialIds); const auto numPoints = rates->getScalarData(0)->size(); @@ -134,7 +134,7 @@ class SF6O2SurfaceModel : public SurfaceModel { return SmartPointer>::New(std::move(etchRate)); } - void updateCoverages(SmartPointer> rates, + void updateCoverages(SmartPointer> rates, const std::vector &materialIds) override { // update coverages based on fluxes const auto numPoints = rates->getScalarData(0)->size(); @@ -190,9 +190,8 @@ class SF6O2Ion A(1. / (1. + params.Ions.n_l * (M_PI_2 / params.Ions.inflectAngle - 1.))) {} - void surfaceCollision(NumericType rayWeight, - const Triple &rayDir, - const Triple &geomNormal, + void surfaceCollision(NumericType rayWeight, const Vec3D &rayDir, + const Vec3D &geomNormal, const unsigned int primID, const int materialId, viennaray::TracingData &localData, const viennaray::TracingData *globalData, @@ -250,9 +249,9 @@ class SF6O2Ion localData.getVectorData(2)[primID] += Y_O; } - std::pair> - surfaceReflection(NumericType rayWeight, const Triple &rayDir, - const Triple &geomNormal, + std::pair> + surfaceReflection(NumericType rayWeight, const Vec3D &rayDir, + const Vec3D &geomNormal, const unsigned int primId, const int materialId, const viennaray::TracingData *globalData, RNG &Rng) override final { @@ -287,10 +286,10 @@ class SF6O2Ion E = NewEnergy; auto direction = viennaray::ReflectionConedCosine( rayDir, geomNormal, Rng, std::max(incAngle, params.Ions.minAngle)); - return std::pair>{0., direction}; + return std::pair>{0., direction}; } else { - return std::pair>{ - 1., Triple{0., 0., 0.}}; + return std::pair>{ + 1., Vec3D{0., 0., 0.}}; } } void initNew(RNG &rngState) override final { @@ -321,17 +320,17 @@ class SF6O2Etchant public: SF6O2Etchant(const SF6O2Parameters &pParams) : params(pParams) {} - void surfaceCollision(NumericType rayWeight, const Triple &, - const Triple &, const unsigned int primID, + void surfaceCollision(NumericType rayWeight, const Vec3D &, + const Vec3D &, const unsigned int primID, const int, viennaray::TracingData &localData, const viennaray::TracingData *, RNG &) override final { localData.getVectorData(0)[primID] += rayWeight; } - std::pair> - surfaceReflection(NumericType rayWeight, const Triple &rayDir, - const Triple &geomNormal, + std::pair> + surfaceReflection(NumericType rayWeight, const Vec3D &rayDir, + const Vec3D &geomNormal, const unsigned int primID, const int materialId, const viennaray::TracingData *globalData, RNG &rngState) override final { @@ -348,7 +347,7 @@ class SF6O2Etchant auto direction = viennaray::ReflectionDiffuse(geomNormal, rngState); - return std::pair>{S_eff, direction}; + return std::pair>{S_eff, direction}; } NumericType getSourceDistributionPower() const override final { return 1.; } std::vector getLocalDataLabels() const override final { @@ -364,8 +363,8 @@ class SF6O2Oxygen public: SF6O2Oxygen(const SF6O2Parameters &pParams) : params(pParams) {} - void surfaceCollision(NumericType rayWeight, const Triple &, - const Triple &, const unsigned int primID, + void surfaceCollision(NumericType rayWeight, const Vec3D &, + const Vec3D &, const unsigned int primID, const int, viennaray::TracingData &localData, const viennaray::TracingData *, @@ -373,9 +372,9 @@ class SF6O2Oxygen // Rate is normalized by dividing with the local sticking coefficient localData.getVectorData(0)[primID] += rayWeight; } - std::pair> - surfaceReflection(NumericType rayWeight, const Triple &rayDir, - const Triple &geomNormal, + std::pair> + surfaceReflection(NumericType rayWeight, const Vec3D &rayDir, + const Vec3D &geomNormal, const unsigned int primID, const int materialId, const viennaray::TracingData *globalData, RNG &rngState) override final { @@ -390,7 +389,7 @@ class SF6O2Oxygen auto direction = viennaray::ReflectionDiffuse(geomNormal, rngState); - return std::pair>{S_eff, direction}; + return std::pair>{S_eff, direction}; } NumericType getSourceDistributionPower() const override final { return 1.; } std::vector getLocalDataLabels() const override final { diff --git a/include/viennaps/models/psSingleParticleProcess.hpp b/include/viennaps/models/psSingleParticleProcess.hpp index 41e412a..f10b4a0 100644 --- a/include/viennaps/models/psSingleParticleProcess.hpp +++ b/include/viennaps/models/psSingleParticleProcess.hpp @@ -22,7 +22,7 @@ class SingleParticleSurfaceModel : public viennaps::SurfaceModel { : rateFactor_(rate), maskMaterials_(mask) {} SmartPointer> calculateVelocities( - SmartPointer> rates, + SmartPointer> rates, const std::vector> &coordinates, const std::vector &materialIds) override { @@ -56,23 +56,23 @@ class SingleParticle SingleParticle(NumericType sticking, NumericType sourcePower) : stickingProbability_(sticking), sourcePower_(sourcePower) {} - void surfaceCollision(NumericType rayWeight, const Triple &, - const Triple &, const unsigned int primID, + void surfaceCollision(NumericType rayWeight, const Vec3D &, + const Vec3D &, const unsigned int primID, const int, viennaray::TracingData &localData, const viennaray::TracingData *, RNG &) override final { localData.getVectorData(0)[primID] += rayWeight; } - std::pair> - surfaceReflection(NumericType, const Triple &, - const Triple &geomNormal, const unsigned int, + std::pair> + surfaceReflection(NumericType, const Vec3D &, + const Vec3D &geomNormal, const unsigned int, const int, const viennaray::TracingData *, RNG &rngState) override final { auto direction = viennaray::ReflectionDiffuse(geomNormal, rngState); - return std::pair>{stickingProbability_, - direction}; + return std::pair>{stickingProbability_, + direction}; } void initNew(RNG &) override final {} NumericType getSourceDistributionPower() const override final { diff --git a/include/viennaps/models/psTEOSDeposition.hpp b/include/viennaps/models/psTEOSDeposition.hpp index f5adbea..aa65847 100644 --- a/include/viennaps/models/psTEOSDeposition.hpp +++ b/include/viennaps/models/psTEOSDeposition.hpp @@ -21,7 +21,7 @@ class SingleTEOSSurfaceModel : public SurfaceModel { : depositionRate(passedRate), reactionOrder(passedOrder) {} SmartPointer> calculateVelocities( - SmartPointer> rates, + SmartPointer> rates, const std::vector> &coordinates, const std::vector &materialIDs) override { updateCoverages(rates, materialIDs); @@ -38,7 +38,7 @@ class SingleTEOSSurfaceModel : public SurfaceModel { return SmartPointer>::New(velocity); } - void updateCoverages(SmartPointer> rates, + void updateCoverages(SmartPointer> rates, const std::vector &materialIDs) override { // update coverages based on fluxes auto particleFlux = rates->getScalarData("particleFlux"); @@ -52,7 +52,7 @@ class SingleTEOSSurfaceModel : public SurfaceModel { void initializeCoverages(unsigned numGeometryPoints) override { if (coverages == nullptr) { - coverages = SmartPointer>::New(); + coverages = SmartPointer>::New(); } else { coverages->clear(); } @@ -77,7 +77,7 @@ class MultiTEOSSurfaceModel : public SurfaceModel { depositionRateP2(passedRateP2), reactionOrderP2(passedOrderP2) {} SmartPointer> calculateVelocities( - SmartPointer> rates, + SmartPointer> rates, const std::vector> &coordinates, const std::vector &materialIDs) override { // define the surface reaction here @@ -108,9 +108,9 @@ class SingleTEOSParticle const std::string pDataLabel = "particleFlux") : stickingProbability(pStickingProbability), reactionOrder(pReactionOrder), dataLabel(pDataLabel) {} - std::pair> - surfaceReflection(NumericType, const Triple &, - const Triple &geomNormal, + std::pair> + surfaceReflection(NumericType, const Vec3D &, + const Vec3D &geomNormal, const unsigned int primID, const int, const viennaray::TracingData *globalData, RNG &rngState) override final { @@ -129,10 +129,10 @@ class SingleTEOSParticle } auto direction = viennaray::ReflectionDiffuse(geomNormal, rngState); - return std::pair>{sticking, direction}; + return std::pair>{sticking, direction}; } - void surfaceCollision(NumericType rayWeight, const Triple &, - const Triple &, const unsigned int primID, + void surfaceCollision(NumericType rayWeight, const Vec3D &, + const Vec3D &, const unsigned int primID, const int, viennaray::TracingData &localData, const viennaray::TracingData *, @@ -157,20 +157,19 @@ class MultiTEOSParticle public: MultiTEOSParticle(const NumericType pStickingProbability, std::string pLabel) : stickingProbability(pStickingProbability), dataLabel(pLabel) {} - std::pair> - surfaceReflection(NumericType rayWeight, const Triple &rayDir, - const Triple &geomNormal, + std::pair> + surfaceReflection(NumericType rayWeight, const Vec3D &rayDir, + const Vec3D &geomNormal, const unsigned int primID, const int materialId, const viennaray::TracingData *globalData, RNG &Rng) override final { auto direction = viennaray::ReflectionDiffuse(geomNormal, Rng); - return std::pair>{stickingProbability, - direction}; + return std::pair>{stickingProbability, + direction}; } - void surfaceCollision(NumericType rayWeight, - const Triple &rayDir, - const Triple &geomNormal, + void surfaceCollision(NumericType rayWeight, const Vec3D &rayDir, + const Vec3D &geomNormal, const unsigned int primID, const int materialId, viennaray::TracingData &localData, const viennaray::TracingData *globalData, diff --git a/include/viennaps/psAtomicLayerProcess.hpp b/include/viennaps/psAtomicLayerProcess.hpp index d1899b9..4d5697b 100644 --- a/include/viennaps/psAtomicLayerProcess.hpp +++ b/include/viennaps/psAtomicLayerProcess.hpp @@ -1,8 +1,9 @@ #pragma once -#include "psLogger.hpp" +#include "Logger.hpp" #include "psProcessModel.hpp" #include "psTranslationField.hpp" +#include "psUtils.hpp" #include #include @@ -13,17 +14,21 @@ #include #include +namespace viennaps { + +using namespace viennacore; + template -class DesorptionSource : public raySource { +class DesorptionSource : public viennaray::Source { public: - DesorptionSource(const std::vector> &points, - const std::vector> &normals, + DesorptionSource(const std::vector> &points, + const std::vector> &normals, const std::vector &desorptionRates, const int numRaysPerPoint) : points_(points), normals_(normals), desorptionRates_(desorptionRates), numRaysPerPoint_(numRaysPerPoint) {} - rayPair> + Vec2D> getOriginAndDirection(const size_t idx, rayRNG &RngState) const override { size_t pointIdx = idx / numRaysPerPoint_; auto direction = @@ -40,15 +45,15 @@ class DesorptionSource : public raySource { } private: - const std::vector> &points_; - const std::vector> &normals_; + const std::vector> &points_; + const std::vector> &normals_; const std::vector &desorptionRates_; const int numRaysPerPoint_; }; template class psAtomicLayerProcess { using translatorType = std::unordered_map; - using psDomainType = psSmartPointer>; + using psDomainType = SmartPointer>; public: psAtomicLayerProcess() {} @@ -56,7 +61,7 @@ template class psAtomicLayerProcess { // Constructor for a process with a pre-configured process model. template psAtomicLayerProcess(psDomainType domain, - psSmartPointer passedProcessModel) + SmartPointer passedProcessModel) : pDomain_(domain) { pModel_ = std::dynamic_pointer_cast>( passedProcessModel); @@ -66,7 +71,7 @@ template class psAtomicLayerProcess { // a custom process model. A custom process model must interface the // psProcessModel class. template - void setProcessModel(psSmartPointer passedProcessModel) { + void setProcessModel(SmartPointer passedProcessModel) { pModel_ = std::dynamic_pointer_cast>( passedProcessModel); } @@ -75,7 +80,7 @@ template class psAtomicLayerProcess { void setDomain(psDomainType domain) { pDomain_ = domain; } // Set the source direction, where the rays should be traced from. - void setSourceDirection(rayTraceDirection passedDirection) { + void setSourceDirection(viennaray::TraceDirection passedDirection) { sourceDirection_ = passedDirection; } @@ -97,8 +102,10 @@ template class psAtomicLayerProcess { void setNumberOfRaysPerPoint(unsigned numRays) { raysPerPoint_ = numRays; } // Set the integration scheme for solving the level-set equation. - // Possible integration schemes are specified in lsIntegrationSchemeEnum. - void setIntegrationScheme(lsIntegrationSchemeEnum passedIntegrationScheme) { + // Possible integration schemes are specified in + // viennals::IntegrationSchemeEnum. + void setIntegrationScheme( + viennals::IntegrationSchemeEnum passedIntegrationScheme) { integrationScheme_ = passedIntegrationScheme; } @@ -115,26 +122,26 @@ template class psAtomicLayerProcess { checkInput(); /* ---------- Process Setup --------- */ - psUtils::Timer processTimer; + Timer processTimer; processTimer.start(); auto name = pModel_->getProcessName().value_or("default"); const NumericType gridDelta = pDomain_->getGrid().getGridDelta(); - auto diskMesh = lsSmartPointer>::New(); - auto translator = lsSmartPointer::New(); - lsToDiskMesh meshConverter(diskMesh); + auto diskMesh = SmartPointer>::New(); + auto translator = SmartPointer::New(); + viennals::ToDiskMesh meshConverter(diskMesh); meshConverter.setTranslator(translator); if (pDomain_->getMaterialMap()) { meshConverter.setMaterialMap( pDomain_->getMaterialMap()->getMaterialMap()); } - auto transField = psSmartPointer>::New( + auto transField = SmartPointer>::New( pModel_->getVelocityField(), pDomain_->getMaterialMap()); transField->setTranslator(translator); - lsAdvect advectionKernel; + viennals::Advect advectionKernel; advectionKernel.setVelocityField(transField); advectionKernel.setIntegrationScheme(integrationScheme_); advectionKernel.setAdvectionTime(1.); @@ -146,12 +153,12 @@ template class psAtomicLayerProcess { /* --------- Setup for ray tracing ----------- */ - rayBoundaryCondition rayBoundaryCondition[D]; - rayTrace rayTracer; + typename viennaray::BoundaryCondition rayBoundaryCondition[D]; + viennaray::Trace rayTracer; // Map the domain boundary to the ray tracing boundaries for (unsigned i = 0; i < D; ++i) - rayBoundaryCondition[i] = psUtils::convertBoundaryCondition( + rayBoundaryCondition[i] = utils::convertBoundaryCondition( pDomain_->getGrid().getBoundaryConditions(i)); rayTracer.setSourceDirection(sourceDirection_); @@ -160,7 +167,7 @@ template class psAtomicLayerProcess { rayTracer.setUseRandomSeeds(useRandomSeeds_); auto primaryDirection = pModel_->getPrimaryDirection(); if (primaryDirection) { - psLogger::getInstance() + Logger::getInstance() .addInfo("Using primary direction: " + psUtils::arrayToString(primaryDirection.value())) .print(); @@ -186,12 +193,12 @@ template class psAtomicLayerProcess { const bool useProcessParams = surfaceModel->getProcessParameters() != nullptr; if (useProcessParams) - psLogger::getInstance().addInfo("Using process parameters.").print(); + Logger::getInstance().addInfo("Using process parameters.").print(); size_t counter = 0; int numCycles = 0; while (numCycles++ < numCycles_) { - psLogger::getInstance() + Logger::getInstance() .addInfo("Cycle: " + std::to_string(numCycles) + "/" + std::to_string(numCycles_)) .print(); @@ -199,7 +206,7 @@ template class psAtomicLayerProcess { meshConverter.apply(); auto numPoints = diskMesh->nodes.size(); surfaceModel->initializeCoverages(numPoints); - auto rates = psSmartPointer>::New(); + auto rates = SmartPointer>::New(); auto const materialIds = *diskMesh->getCellData().getScalarData("MaterialIds"); auto const points = diskMesh->getNodes(); @@ -217,7 +224,7 @@ template class psAtomicLayerProcess { throw pybind11::error_already_set(); #endif - psLogger::getInstance() + Logger::getInstance() .addInfo("Pulse time: " + std::to_string(time) + "/" + std::to_string(pulseTime_)) .print(); @@ -274,7 +281,7 @@ template class psAtomicLayerProcess { surfaceModel->updateCoverages(rates, materialIds); // print debug output - if (psLogger::getLogLevel() >= 4) { + if (Logger::getLogLevel() >= 4) { for (size_t idx = 0; idx < rates->getScalarDataSize(); idx++) { auto label = rates->getScalarDataLabel(idx); diskMesh->getCellData().insertNextScalarData( @@ -294,16 +301,16 @@ template class psAtomicLayerProcess { } // end of gas pulse if (purgePulseTime_ > 0.) { - psLogger::getInstance().addInfo("Purge pulse ...").print(); + Logger::getInstance().addInfo("Purge pulse ...").print(); if (desorptionRates_.size() != numParticles) { - psLogger::getInstance() + Logger::getInstance() .addError("Desorption rates not set for all particle types.") .print(); } - auto purgeRates = psSmartPointer>::New(); + auto purgeRates = SmartPointer>::New(); - rayTrace purgeTracer; + viennaray::Trace purgeTracer; purgeTracer.setSourceDirection(sourceDirection_); purgeTracer.setBoundaryConditions(rayBoundaryCondition); purgeTracer.setUseRandomSeeds(useRandomSeeds_); @@ -355,7 +362,7 @@ template class psAtomicLayerProcess { transField->buildKdTree(points); // print debug output - if (psLogger::getLogLevel() >= 4) { + if (Logger::getLogLevel() >= 4) { diskMesh->getCellData().insertNextScalarData(*velocities, "velocities"); printDiskMesh(diskMesh, name + "_" + std::to_string(counter) + ".vtp"); counter++; @@ -366,9 +373,7 @@ template class psAtomicLayerProcess { processTimer.finish(); - psLogger::getInstance() - .addTiming("\nProcess " + name, processTimer) - .print(); + Logger::getInstance().addTiming("\nProcess " + name, processTimer).print(); } void writeParticleDataLogs(std::string fileName) { @@ -388,14 +393,14 @@ template class psAtomicLayerProcess { } private: - void printDiskMesh(lsSmartPointer> mesh, + void printDiskMesh(SmartPointer> mesh, std::string name) const { psVTKWriter(mesh, std::move(name)).apply(); } - rayTracingData - movePointDataToRayData(psSmartPointer> pointData) { - rayTracingData rayData; + viennaray::TracingData + movePointDataToRayData(SmartPointer> pointData) { + viennaray::TracingData rayData; const auto numData = pointData->getScalarDataSize(); rayData.setNumberOfVectorData(numData); for (size_t i = 0; i < numData; ++i) { @@ -407,9 +412,8 @@ template class psAtomicLayerProcess { return std::move(rayData); } - void - moveRayDataToPointData(psSmartPointer> pointData, - rayTracingData &rayData) { + void moveRayDataToPointData(SmartPointer> pointData, + rayTracingData &rayData) { pointData->clear(); const auto numData = rayData.getVectorData().size(); for (size_t i = 0; i < numData; ++i) @@ -419,50 +423,50 @@ template class psAtomicLayerProcess { void checkInput() const { if (!pDomain_) { - psLogger::getInstance() + Logger::getInstance() .addError("No domain passed to psAtomicLayerProcess.") .print(); } if (pDomain_->getLevelSets()->size() == 0) { - psLogger::getInstance() + Logger::getInstance() .addError("No level sets in domain passed to psAtomicLayerProcess.") .print(); } if (!pModel_) { - psLogger::getInstance() + Logger::getInstance() .addError("No process model passed to psAtomicLayerProcess.") .print(); } if (!pModel_->getSurfaceModel()) { - psLogger::getInstance() + Logger::getInstance() .addError("No surface model passed to psAtomicLayerProcess.") .print(); } if (!pModel_->getVelocityField()) { - psLogger::getInstance() + Logger::getInstance() .addError("No velocity field passed to psAtomicLayerProcess.") .print(); } if (!pModel_->getParticleTypes()) { - psLogger::getInstance() + Logger::getInstance() .addError("No particle types specified for ray tracing in " "psAtomicLayerProcess.") .print(); } if (pModel_->getGeometricModel()) { - psLogger::getInstance() + Logger::getInstance() .addWarning("Geometric model not supported in psAtomicLayerProcess.") .print(); } if (pModel_->getAdvectionCallback()) { - psLogger::getInstance() + Logger::getInstance() .addWarning( "Advection callback not supported in psAtomicLayerProcess.") .print(); @@ -470,15 +474,16 @@ template class psAtomicLayerProcess { } psDomainType pDomain_; - psSmartPointer> pModel_; + SmartPointer> pModel_; - rayTraceDirection sourceDirection_ = - D == 3 ? rayTraceDirection::POS_Z : rayTraceDirection::POS_Y; - lsIntegrationSchemeEnum integrationScheme_ = - lsIntegrationSchemeEnum::ENGQUIST_OSHER_1ST_ORDER; + viennaray::TraceDirection sourceDirection_ = + D == 3 ? viennaray::TraceDirection::POS_Z + : viennaray::TraceDirection::POS_Y; + viennals::IntegrationSchemeEnum integrationScheme_ = + viennals::IntegrationSchemeEnum::ENGQUIST_OSHER_1ST_ORDER; unsigned raysPerPoint_ = 1000; bool useRandomSeeds_ = true; - std::vector> particleDataLogs_; + std::vector> particleDataLogs_; unsigned int numCycles_ = 0; NumericType pulseTime_ = 0.; @@ -486,3 +491,5 @@ template class psAtomicLayerProcess { NumericType coverageTimeStep_ = 1.; std::vector desorptionRates_; }; + +} // namespace viennaps diff --git a/include/viennaps/psDomain.hpp b/include/viennaps/psDomain.hpp index 03062da..97eca0b 100644 --- a/include/viennaps/psDomain.hpp +++ b/include/viennaps/psDomain.hpp @@ -36,7 +36,7 @@ using namespace viennacore; */ template class Domain { public: - using lsDomainType = SmartPointer>; + using lsDomainType = SmartPointer>; using lsDomainsType = SmartPointer>; using csDomainType = SmartPointer>; using materialMapType = SmartPointer; @@ -95,8 +95,8 @@ template class Domain { void insertNextLevelSet(lsDomainType levelSet, bool wrapLowerLevelSet = true) { if (!levelSets_->empty() && wrapLowerLevelSet) { - lsBooleanOperation(levelSet, levelSets_->back(), - lsBooleanOperationEnum::UNION) + viennals::BooleanOperation( + levelSet, levelSets_->back(), viennals::BooleanOperationEnum::UNION) .apply(); } levelSets_->push_back(levelSet); @@ -113,8 +113,8 @@ template class Domain { const Material material, bool wrapLowerLevelSet = true) { if (!levelSets_->empty() && wrapLowerLevelSet) { - lsBooleanOperation(levelSet, levelSets_->back(), - lsBooleanOperationEnum::UNION) + viennals::BooleanOperation( + levelSet, levelSets_->back(), viennals::BooleanOperationEnum::UNION) .apply(); } if (!materialMap_) { @@ -159,13 +159,14 @@ template class Domain { // Apply a boolean operation with the passed Level-Set to all of the // Level-Sets in the domain. void applyBooleanOperation(lsDomainType levelSet, - lsBooleanOperationEnum operation) { + viennals::BooleanOperationEnum operation) { if (levelSets_->empty()) { return; } for (auto &layer : *levelSets_) { - lsBooleanOperation(layer, levelSet, operation).apply(); + viennals::BooleanOperation(layer, levelSet, operation) + .apply(); } } @@ -210,8 +211,8 @@ template class Domain { // [min, max][x, y, z] auto getBoundingBox() const { std::array, 2> boundingBox; - auto mesh = SmartPointer>::New(); - lsToDiskMesh(levelSets_->back(), mesh).apply(); + auto mesh = SmartPointer>::New(); + viennals::ToDiskMesh(levelSets_->back(), mesh).apply(); boundingBox[0] = mesh->minimumExtent; boundingBox[1] = mesh->maximumExtent; return boundingBox; @@ -229,11 +230,11 @@ template class Domain { // Save the level set as a VTK file. void saveLevelSetMesh(std::string fileName, int width = 1) { for (int i = 0; i < levelSets_->size(); i++) { - auto mesh = SmartPointer>::New(); - lsExpand(levelSets_->at(i), width).apply(); - lsToMesh(levelSets_->at(i), mesh).apply(); - lsVTKWriter(mesh, - fileName + "_layer" + std::to_string(i) + ".vtp") + auto mesh = SmartPointer>::New(); + viennals::Expand(levelSets_->at(i), width).apply(); + viennals::ToMesh(levelSets_->at(i), mesh).apply(); + viennals::VTKWriter(mesh, fileName + "_layer" + + std::to_string(i) + ".vtp") .apply(); } } @@ -241,10 +242,10 @@ template class Domain { // Print the top Level-Set (surface) in a VTK file format (recommended: .vtp). void saveSurfaceMesh(std::string fileName, bool addMaterialIds = true) { - auto mesh = SmartPointer>::New(); + auto mesh = SmartPointer>::New(); if (addMaterialIds) { - lsToDiskMesh meshConverter; + viennals::ToDiskMesh meshConverter; meshConverter.setMesh(mesh); if (materialMap_) meshConverter.setMaterialMap(materialMap_->getMaterialMap()); @@ -258,13 +259,13 @@ template class Domain { .apply(); } - lsToSurfaceMesh(levelSets_->back(), mesh).apply(); - lsVTKWriter(mesh, fileName).apply(); + viennals::ToSurfaceMesh(levelSets_->back(), mesh).apply(); + viennals::VTKWriter(mesh, fileName).apply(); } // Save the domain as a volume mesh void saveVolumeMesh(std::string fileName) const { - lsWriteVisualizationMesh visMesh; + viennals::WriteVisualizationMesh visMesh; visMesh.setFileName(fileName); for (auto &ls : *levelSets_) { visMesh.insertNextLevelSet(ls); @@ -277,9 +278,9 @@ template class Domain { // Write the all Level-Sets in the domain to individual files. The file name // serves as the prefix for the individual files and is append by // "_layerX.lvst", where X is the number of the Level-Set in the domain. - void saveLevelSets(std::string fileName) const { + void savexLevelSets(std::string fileName) const { for (int i = 0; i < levelSets_->size(); i++) { - lsWriter( + viennals::Writer( levelSets_->at(i), fileName + "_layer" + std::to_string(i) + ".lvst") .apply(); } diff --git a/include/viennaps/psExtrude.hpp b/include/viennaps/psExtrude.hpp index 1971eea..090fce9 100644 --- a/include/viennaps/psExtrude.hpp +++ b/include/viennaps/psExtrude.hpp @@ -14,14 +14,14 @@ template class Extrude { SmartPointer> outputDomain; std::array extent = {0., 0.}; int extrudeDim = 0; - std::array, 3> boundaryConds; + std::array, 3> boundaryConds; public: Extrude() {} Extrude(SmartPointer> &passedInputDomain, SmartPointer> &passedOutputDomain, std::array passedExtent, const int passedExtrudeDim, - std::array, 3> passedBoundaryConds) + std::array, 3> passedBoundaryConds) : inputDomain(passedInputDomain), outputDomain(passedOutputDomain), extent(passedExtent), extrudeDim(passedExtrudeDim), boundaryConds(passedBoundaryConds) {} @@ -47,12 +47,12 @@ template class Extrude { } void setBoundaryConditions( - std::array, 3> passedBoundaryConds) { + std::array, 3> passedBoundaryConds) { boundaryConds = passedBoundaryConds; } - void - setBoundaryConditions(lsBoundaryConditionEnum<3> passedBoundaryConds[3]) { + void setBoundaryConditions( + viennals::BoundaryConditionEnum<3> passedBoundaryConds[3]) { for (int i = 0; i < 3; i++) boundaryConds[i] = passedBoundaryConds[i]; } @@ -74,16 +74,16 @@ template class Extrude { outputDomain->clear(); for (std::size_t i = 0; i < inputDomain->getLevelSets()->size(); i++) { - auto tmpLS = lsSmartPointer>::New(); - lsExtrude(inputDomain->getLevelSets()->at(i), tmpLS, extent, - extrudeDim, boundaryConds) + auto tmpLS = SmartPointer>::New(); + viennals::Extrude(inputDomain->getLevelSets()->at(i), tmpLS, + extent, extrudeDim, boundaryConds) .apply(); - if (psLogger::getLogLevel() >= 5) { - auto mesh = lsSmartPointer>::New(); - lsToMesh(tmpLS, mesh).apply(); - lsVTKWriter(mesh, - "extrude_layer_" + std::to_string(i) + ".vtp") + if (Logger::getLogLevel() >= 5) { + auto mesh = SmartPointer>::New(); + viennals::ToMesh(tmpLS, mesh).apply(); + viennals::VTKWriter(mesh, "extrude_layer_" + + std::to_string(i) + ".vtp") .apply(); } diff --git a/include/viennaps/psGDSGeometry.hpp b/include/viennaps/psGDSGeometry.hpp index c4d9cbf..b9d8b18 100644 --- a/include/viennaps/psGDSGeometry.hpp +++ b/include/viennaps/psGDSGeometry.hpp @@ -18,9 +18,9 @@ using namespace viennacore; template class GDSGeometry { using StructureLayers = - std::unordered_map>>; - using lsDomainType = SmartPointer>; - using BoundaryType = typename lsDomain::BoundaryType; + std::unordered_map>>; + using lsDomainType = SmartPointer>; + using BoundaryType = typename viennals::Domain::BoundaryType; public: GDSGeometry() { @@ -83,7 +83,7 @@ template class GDSGeometry { } // add structure references - auto strMesh = SmartPointer>::New(); + auto strMesh = SmartPointer>::New(); for (auto &sref : str.sRefs) { auto refStr = getStructure(sref.strName); if (auto contains = refStr->containsLayers.find(layer); @@ -92,21 +92,22 @@ template class GDSGeometry { // copy mesh here auto copy = assembledStructures[refStr->name][layer]; - auto preBuiltStrMesh = SmartPointer>::New(); + auto preBuiltStrMesh = + SmartPointer>::New(); preBuiltStrMesh->nodes = copy->nodes; preBuiltStrMesh->triangles = copy->triangles; adjustPreBuiltMeshHeight(preBuiltStrMesh, baseHeight, height); if (sref.angle > 0.) { - lsTransformMesh( - preBuiltStrMesh, lsTransformEnum::ROTATION, + viennals::TransformMesh( + preBuiltStrMesh, viennals::TransformEnum::ROTATION, hrleVectorType{0., 0., 1.}, deg2rad(sref.angle)) .apply(); } if (sref.magnification > 0.) { - lsTransformMesh( - preBuiltStrMesh, lsTransformEnum::SCALE, + viennals::TransformMesh( + preBuiltStrMesh, viennals::TransformEnum::SCALE, hrleVectorType{sref.magnification, sref.magnification, 1.}) .apply(); @@ -119,8 +120,8 @@ template class GDSGeometry { continue; } - lsTransformMesh( - preBuiltStrMesh, lsTransformEnum::TRANSLATION, + viennals::TransformMesh( + preBuiltStrMesh, viennals::TransformEnum::TRANSLATION, hrleVectorType{sref.refPoint[0], sref.refPoint[1], 0.}) .apply(); @@ -130,9 +131,9 @@ template class GDSGeometry { } if (strMesh->nodes.size() > 0) { auto tmpLS = lsDomainType::New(levelSet->getGrid()); - lsFromSurfaceMesh(tmpLS, strMesh).apply(); - lsBooleanOperation(levelSet, tmpLS, - lsBooleanOperationEnum::UNION) + viennals::FromSurfaceMesh(tmpLS, strMesh).apply(); + viennals::BooleanOperation( + levelSet, tmpLS, viennals::BooleanOperationEnum::UNION) .apply(); } } @@ -142,25 +143,26 @@ template class GDSGeometry { auto topPlane = lsDomainType::New(bounds_, boundaryConds_, gridDelta_); NumericType normal[3] = {0., 0., 1.}; NumericType origin[3] = {0., 0., baseHeight + height}; - lsMakeGeometry( + viennals::MakeGeometry( topPlane, - lsSmartPointer>::New(origin, normal)) + SmartPointer>::New(origin, normal)) .apply(); auto botPlane = lsDomainType::New(bounds_, boundaryConds_, gridDelta_); normal[D - 1] = -1.; origin[D - 1] = baseHeight; - lsMakeGeometry( + viennals::MakeGeometry( botPlane, - lsSmartPointer>::New(origin, normal)) + SmartPointer>::New(origin, normal)) .apply(); - lsBooleanOperation(topPlane, botPlane, - lsBooleanOperationEnum::INTERSECT) + viennals::BooleanOperation( + topPlane, botPlane, viennals::BooleanOperationEnum::INTERSECT) .apply(); - lsBooleanOperation( - topPlane, levelSet, lsBooleanOperationEnum::RELATIVE_COMPLEMENT) + viennals::BooleanOperation( + topPlane, levelSet, + viennals::BooleanOperationEnum::RELATIVE_COMPLEMENT) .apply(); return topPlane; @@ -222,11 +224,11 @@ template class GDSGeometry { for (auto layer : str.containsLayers) { strLayerMapping.insert( - {layer, SmartPointer>::New()}); + {layer, SmartPointer>::New()}); } for (auto &el : str.elements) { - SmartPointer> mesh; + SmartPointer> mesh; if (el.elementType == GDS::ElementType::elBox) { mesh = boxToSurfaceMesh(el, 0, 1, 0, 0); } else { @@ -334,12 +336,12 @@ template class GDSGeometry { auto maxPoint = element.pointCloud[3]; maxPoint[2] = baseHeight + height; - lsMakeGeometry( - tmpLS, lsSmartPointer>::New(minPoint.data(), - maxPoint.data())) + viennals::MakeGeometry( + tmpLS, SmartPointer>::New( + minPoint.data(), maxPoint.data())) .apply(); - lsBooleanOperation(levelSet, tmpLS, - lsBooleanOperationEnum::UNION) + viennals::BooleanOperation( + levelSet, tmpLS, viennals::BooleanOperationEnum::UNION) .apply(); } @@ -355,17 +357,17 @@ template class GDSGeometry { retry); } auto tmpLS = lsDomainType::New(levelSet->getGrid()); - lsFromSurfaceMesh(tmpLS, mesh).apply(); - lsBooleanOperation(levelSet, tmpLS, - lsBooleanOperationEnum::UNION) + viennals::FromSurfaceMesh(tmpLS, mesh).apply(); + viennals::BooleanOperation( + levelSet, tmpLS, viennals::BooleanOperationEnum::UNION) .apply(); } - SmartPointer> + SmartPointer> boxToSurfaceMesh(GDS::Element &element, const NumericType baseHeight, const NumericType height, const NumericType xOffset, const NumericType yOffset) { - auto mesh = SmartPointer>::New(); + auto mesh = SmartPointer>::New(); for (auto &point : element.pointCloud) { point[0] += xOffset; @@ -394,12 +396,12 @@ template class GDSGeometry { return mesh; } - SmartPointer> + SmartPointer> polygonToSurfaceMesh(GDS::Element &element, const NumericType baseHeight, const NumericType height, const NumericType xOffset, const NumericType yOffset, bool &retry) { - auto mesh = SmartPointer>::New(); + auto mesh = SmartPointer>::New(); unsigned numPointsFlat = element.pointCloud.size(); @@ -498,7 +500,8 @@ template class GDSGeometry { return mesh; } - bool isEar(int i, int j, int k, SmartPointer> mesh, + bool isEar(int i, int j, int k, + SmartPointer> mesh, unsigned numPoints) const { auto &points = mesh->getNodes(); @@ -534,7 +537,7 @@ template class GDSGeometry { return true; } - void adjustPreBuiltMeshHeight(SmartPointer> mesh, + void adjustPreBuiltMeshHeight(SmartPointer> mesh, const NumericType baseHeight, const NumericType height) const { auto &nodes = mesh->getNodes(); @@ -548,7 +551,7 @@ template class GDSGeometry { } } - void resetPreBuiltMeshHeight(SmartPointer> mesh, + void resetPreBuiltMeshHeight(SmartPointer> mesh, const NumericType baseHeight, const NumericType height) const { auto &nodes = mesh->getNodes(); diff --git a/include/viennaps/psMaterials.hpp b/include/viennaps/psMaterials.hpp index e696462..cd23287 100644 --- a/include/viennaps/psMaterials.hpp +++ b/include/viennaps/psMaterials.hpp @@ -32,14 +32,14 @@ enum class Material : int { GAS = 18 }; -/// A class that wraps the lsMaterialMap class and provides a more user +/// A class that wraps the viennals MaterialMap class and provides a more user /// friendly interface. It also provides a mapping from the integer material id /// to the Material enum. class MaterialMap { - SmartPointer map_; + SmartPointer map_; public: - MaterialMap() { map_ = SmartPointer::New(); }; + MaterialMap() { map_ = SmartPointer::New(); }; void insertNextMaterial(Material material = Material::None) { map_->insertNextMaterial(static_cast(material)); @@ -63,7 +63,7 @@ class MaterialMap { map_->setMaterialId(idx, static_cast(material)); } - SmartPointer getMaterialMap() const { return map_; } + SmartPointer getMaterialMap() const { return map_; } inline std::size_t const size() const { return map_->getNumberOfLayers(); } diff --git a/include/viennaps/psMeanFreePath.hpp b/include/viennaps/psMeanFreePath.hpp index c79fc22..7682109 100644 --- a/include/viennaps/psMeanFreePath.hpp +++ b/include/viennaps/psMeanFreePath.hpp @@ -242,8 +242,9 @@ template class MeanFreePath { } void initGeometry() { - auto mesh = lsSmartPointer>::New(); - lsToDiskMesh(domain->getLevelSets()->back(), mesh).apply(); + auto mesh = SmartPointer>::New(); + viennals::ToDiskMesh(domain->getLevelSets()->back(), mesh) + .apply(); surfacePoints = mesh->getNodes(); surfaceNormals = *mesh->getCellData().getVectorData("Normals"); numPoints = surfacePoints.size(); @@ -255,7 +256,7 @@ template class MeanFreePath { numRays = static_cast(numCells * numRaysPerCell); } - int getStartingCell(const Triple &origin) const { + int getStartingCell(const Vec3D &origin) const { int cellIdx = cellSet->getIndex(origin); if (cellIdx < 0) { Logger::getInstance() @@ -278,12 +279,12 @@ template class MeanFreePath { } // https://gamedev.stackexchange.com/a/18459 - static bool intersectLineBox(const Triple &origin, - const Triple &direction, - const Triple &min, - const Triple &max, + static bool intersectLineBox(const Vec3D &origin, + const Vec3D &direction, + const Vec3D &min, + const Vec3D &max, NumericType &distance) { - Triple t1, t2; + Vec3D t1, t2; for (int i = 0; i < D; ++i) { // direction is inverted t1[i] = (min[i] - origin[i]) * direction[i]; @@ -309,7 +310,7 @@ template class MeanFreePath { return false; } - static void randomDirection(Triple &direction, RNG &rngState) { + static void randomDirection(Vec3D &direction, RNG &rngState) { std::uniform_real_distribution dist(-1, 1); for (int i = 0; i < D; ++i) { direction[i] = dist(rngState); diff --git a/include/viennaps/psPlanarize.hpp b/include/viennaps/psPlanarize.hpp index 14bdf1b..b7b0b5c 100644 --- a/include/viennaps/psPlanarize.hpp +++ b/include/viennaps/psPlanarize.hpp @@ -32,13 +32,14 @@ template class Planarize { origin[D - 1] = cutoffPosition_; NumericType normal[D] = {0.}; normal[D - 1] = -1.; - auto plane = - lsSmartPointer>::New(pDomain_->getGrid()); - lsMakeGeometry( - plane, lsSmartPointer>::New(origin, normal)) + auto plane = SmartPointer>::New( + pDomain_->getGrid()); + viennals::MakeGeometry( + plane, + SmartPointer>::New(origin, normal)) .apply(); pDomain_->applyBooleanOperation( - plane, lsBooleanOperationEnum::RELATIVE_COMPLEMENT); + plane, viennals::BooleanOperationEnum::RELATIVE_COMPLEMENT); } }; diff --git a/include/viennaps/psProcess.hpp b/include/viennaps/psProcess.hpp index 24ac1b8..1b1d7be 100644 --- a/include/viennaps/psProcess.hpp +++ b/include/viennaps/psProcess.hpp @@ -81,8 +81,10 @@ template class Process { void disableFluxBoundaries() { ignoreFluxBoundaries = true; } // Set the integration scheme for solving the level-set equation. - // Possible integration schemes are specified in lsIntegrationSchemeEnum. - void setIntegrationScheme(lsIntegrationSchemeEnum passedIntegrationScheme) { + // Possible integration schemes are specified in + // viennals::IntegrationSchemeEnum. + void setIntegrationScheme( + viennals::IntegrationSchemeEnum passedIntegrationScheme) { integrationScheme = passedIntegrationScheme; } @@ -106,11 +108,11 @@ template class Process { // A single flux calculation is performed on the domain surface. The result is // stored as point data on the nodes of the mesh. - SmartPointer> calculateFlux() const { + SmartPointer> calculateFlux() const { // Generate disk mesh from domain - auto mesh = SmartPointer>::New(); - lsToDiskMesh meshConverter(mesh); + auto mesh = SmartPointer>::New(); + viennals::ToDiskMesh meshConverter(mesh); for (auto dom : *domain->getLevelSets()) { meshConverter.insertNextLevelSet(dom); } @@ -242,20 +244,20 @@ template class Process { assert(domain->getLevelSets()->size() != 0 && "No level sets in domain."); const NumericType gridDelta = domain->getGrid().getGridDelta(); - auto diskMesh = SmartPointer>::New(); + auto diskMesh = SmartPointer>::New(); auto translator = SmartPointer::New(); - lsToDiskMesh meshConverter(diskMesh); + viennals::ToDiskMesh meshConverter(diskMesh); meshConverter.setTranslator(translator); if (domain->getMaterialMap() && domain->getMaterialMap()->size() == domain->getLevelSets()->size()) { meshConverter.setMaterialMap(domain->getMaterialMap()->getMaterialMap()); } - auto transField = lsSmartPointer>::New( + auto transField = SmartPointer>::New( model->getVelocityField(), domain->getMaterialMap()); transField->setTranslator(translator); - lsAdvect advectionKernel; + viennals::Advect advectionKernel; advectionKernel.setVelocityField(transField); advectionKernel.setIntegrationScheme(integrationScheme); advectionKernel.setTimeStepRatio(timeStepRatio); @@ -374,7 +376,7 @@ template class Process { } rayTracer.setGlobalData(rayTraceCoverages); - auto rates = SmartPointer>::New(); + auto rates = SmartPointer>::New(); std::size_t particleIdx = 0; for (auto &particle : model->getParticleTypes()) { @@ -452,7 +454,7 @@ template class Process { throw pybind11::error_already_set(); #endif - auto rates = SmartPointer>::New(); + auto rates = SmartPointer>::New(); meshConverter.apply(); auto materialIds = *diskMesh->getCellData().getScalarData("MaterialIds"); auto points = diskMesh->getNodes(); @@ -672,13 +674,13 @@ template class Process { } private: - void printDiskMesh(SmartPointer> mesh, + void printDiskMesh(SmartPointer> mesh, std::string name) const { - lsVTKWriter(mesh, std::move(name)).apply(); + viennals::VTKWriter(mesh, std::move(name)).apply(); } viennaray::TracingData movePointDataToRayData( - SmartPointer> pointData) const { + SmartPointer> pointData) const { viennaray::TracingData rayData; const auto numData = pointData->getScalarDataSize(); rayData.setNumberOfVectorData(numData); @@ -691,9 +693,9 @@ template class Process { return std::move(rayData); } - void - moveRayDataToPointData(SmartPointer> pointData, - viennaray::TracingData &rayData) const { + void moveRayDataToPointData( + SmartPointer> pointData, + viennaray::TracingData &rayData) const { pointData->clear(); const auto numData = rayData.getVectorData().size(); for (size_t i = 0; i < numData; ++i) @@ -701,8 +703,9 @@ template class Process { rayData.getVectorDataLabel(i)); } - void moveCoveragesToTopLS(SmartPointer translator, - SmartPointer> coverages) { + void moveCoveragesToTopLS( + SmartPointer translator, + SmartPointer> coverages) { auto topLS = domain->getLevelSets()->back(); for (size_t i = 0; i < coverages->getScalarDataSize(); i++) { auto covName = coverages->getScalarDataLabel(i); @@ -723,7 +726,7 @@ template class Process { void updateCoveragesFromAdvectedSurface( SmartPointer translator, - SmartPointer> coverages) const { + SmartPointer> coverages) const { auto topLS = domain->getLevelSets()->back(); for (size_t i = 0; i < coverages->getScalarDataSize(); i++) { auto covName = coverages->getScalarDataLabel(i); @@ -742,8 +745,8 @@ template class Process { viennaray::TraceDirection sourceDirection = D == 3 ? viennaray::TraceDirection::POS_Z : viennaray::TraceDirection::POS_Y; - lsIntegrationSchemeEnum integrationScheme = - lsIntegrationSchemeEnum::ENGQUIST_OSHER_1ST_ORDER; + viennals::IntegrationSchemeEnum integrationScheme = + viennals::IntegrationSchemeEnum::ENGQUIST_OSHER_1ST_ORDER; unsigned raysPerPoint = 1000; std::vector> particleDataLogs; bool useRandomSeeds_ = true; diff --git a/include/viennaps/psSurfaceModel.hpp b/include/viennaps/psSurfaceModel.hpp index 69be035..81e6235 100644 --- a/include/viennaps/psSurfaceModel.hpp +++ b/include/viennaps/psSurfaceModel.hpp @@ -13,7 +13,7 @@ using namespace viennacore; template class SurfaceModel { protected: - SmartPointer> coverages = nullptr; + SmartPointer> coverages = nullptr; SmartPointer> processParams = nullptr; public: @@ -27,15 +27,16 @@ template class SurfaceModel { // if no process parameters get initialized here, they wont be used at all } - virtual SmartPointer> calculateVelocities( - SmartPointer> rates, - const std::vector> &coordinates, - const std::vector &materialIds) { + virtual SmartPointer> + calculateVelocities(SmartPointer> rates, + const std::vector> &coordinates, + const std::vector &materialIds) { return nullptr; } - virtual void updateCoverages(SmartPointer> rates, - const std::vector &materialIds) {} + virtual void + updateCoverages(SmartPointer> rates, + const std::vector &materialIds) {} // non-virtual functions auto getCoverages() const { return coverages; } diff --git a/include/viennaps/psSurfacePointValuesToLevelSet.hpp b/include/viennaps/psSurfacePointValuesToLevelSet.hpp index 4950908..1daa2bb 100644 --- a/include/viennaps/psSurfacePointValuesToLevelSet.hpp +++ b/include/viennaps/psSurfacePointValuesToLevelSet.hpp @@ -13,24 +13,25 @@ namespace viennaps { using namespace viennacore; template class psSurfacePointValuesToLevelSet { - using lsDomainType = SmartPointer>; + using lsDomainType = SmartPointer>; lsDomainType levelSet; - SmartPointer> mesh; + SmartPointer> mesh; std::vector dataNames; public: psSurfacePointValuesToLevelSet() {} - psSurfacePointValuesToLevelSet(lsDomainType passedLevelSet, - SmartPointer> passedMesh, - std::vector passedDataNames) + psSurfacePointValuesToLevelSet( + lsDomainType passedLevelSet, + SmartPointer> passedMesh, + std::vector passedDataNames) : levelSet(passedLevelSet), mesh(passedMesh), dataNames(passedDataNames) { } void setLevelSet(lsDomainType passedLevelSet) { levelSet = passedLevelSet; } - void setMesh(SmartPointer> passedMesh) { + void setMesh(SmartPointer> passedMesh) { mesh = passedMesh; } @@ -58,20 +59,21 @@ template class psSurfacePointValuesToLevelSet { return; } - KDTree> transTree(mesh->getNodes()); + KDTree> transTree(mesh->getNodes()); transTree.build(); const auto gridDelta = levelSet->getGrid().getGridDelta(); std::vector levelSetPointToMeshIds( levelSet->getNumberOfPoints()); - for (hrleConstSparseIterator::DomainType> + for (hrleConstSparseIterator< + typename viennals::Domain::DomainType> it(levelSet->getDomain()); !it.isFinished(); ++it) { if (it.isDefined()) { auto lsIndicies = it.getStartIndices(); - std::array levelSetPointCoordinate{0., 0., 0.}; + Vec3D levelSetPointCoordinate{0., 0., 0.}; for (unsigned i = 0; i < D; i++) { levelSetPointCoordinate[i] = lsIndicies[i] * gridDelta; } diff --git a/include/viennaps/psToDiskMesh.hpp b/include/viennaps/psToDiskMesh.hpp index 072913c..3bb92a6 100644 --- a/include/viennaps/psToDiskMesh.hpp +++ b/include/viennaps/psToDiskMesh.hpp @@ -12,7 +12,7 @@ template class ToDiskMesh { using translatorType = SmartPointer>; using psDomainType = SmartPointer>; - using meshType = SmartPointer>; + using meshType = SmartPointer>; psDomainType domain; translatorType translator; @@ -39,7 +39,7 @@ template class ToDiskMesh { translatorType getTranslator() const { return translator; } void apply() { - lsToDiskMesh meshConverter; + viennals::ToDiskMesh meshConverter; meshConverter.setMesh(mesh); if (domain->getMaterialMap()) meshConverter.setMaterialMap(domain->getMaterialMap()->getMaterialMap()); diff --git a/include/viennaps/psTranslationField.hpp b/include/viennaps/psTranslationField.hpp index 631bacd..6fb6c9b 100644 --- a/include/viennaps/psTranslationField.hpp +++ b/include/viennaps/psTranslationField.hpp @@ -15,7 +15,7 @@ namespace viennaps { using namespace viennacore; template -class TranslationField : public lsVelocityField { +class TranslationField : public viennals::VelocityField { using TranslatorType = std::unordered_map; public: @@ -24,9 +24,9 @@ class TranslationField : public lsVelocityField { : translationMethod_(velocityField->getTranslationFieldOptions()), modelVelocityField_(velocityField), materialMap_(materialMap) {} - NumericType getScalarVelocity(const Triple &coordinate, + NumericType getScalarVelocity(const Vec3D &coordinate, int material, - const Triple &normalVector, + const Vec3D &normalVector, unsigned long pointId) { translateLsId(pointId, coordinate); if (materialMap_) @@ -35,10 +35,10 @@ class TranslationField : public lsVelocityField { normalVector, pointId); } - Triple getVectorVelocity(const Triple &coordinate, - int material, - const Triple &normalVector, - unsigned long pointId) { + Vec3D getVectorVelocity(const Vec3D &coordinate, + int material, + const Vec3D &normalVector, + unsigned long pointId) { translateLsId(pointId, coordinate); if (materialMap_) material = static_cast(materialMap_->getMaterialAtIdx(material)); @@ -48,7 +48,7 @@ class TranslationField : public lsVelocityField { NumericType getDissipationAlpha(int direction, int material, - const Triple ¢ralDifferences) { + const Vec3D ¢ralDifferences) { if (materialMap_) material = static_cast(materialMap_->getMaterialAtIdx(material)); return modelVelocityField_->getDissipationAlpha(direction, material, @@ -59,13 +59,13 @@ class TranslationField : public lsVelocityField { translator_ = translator; } - void buildKdTree(const std::vector> &points) { + void buildKdTree(const std::vector> &points) { kdTree_.setPoints(points); kdTree_.build(); } void translateLsId(unsigned long &lsId, - const Triple &coordinate) const { + const Vec3D &coordinate) const { switch (translationMethod_) { case 1: { if (auto it = translator_->find(lsId); it != translator_->end()) { @@ -89,7 +89,7 @@ class TranslationField : public lsVelocityField { private: SmartPointer translator_; - KDTree> kdTree_; + KDTree> kdTree_; const SmartPointer> modelVelocityField_; const SmartPointer materialMap_; const int translationMethod_ = 1; diff --git a/include/viennaps/psUtils.hpp b/include/viennaps/psUtils.hpp index 5f1f191..830e2af 100644 --- a/include/viennaps/psUtils.hpp +++ b/include/viennaps/psUtils.hpp @@ -201,22 +201,22 @@ struct Parameters { }; template -[[nodiscard]] viennaray::BoundaryCondition -convertBoundaryCondition(lsBoundaryConditionEnum originalBoundaryCondition) { +[[nodiscard]] viennaray::BoundaryCondition convertBoundaryCondition( + viennals::BoundaryConditionEnum originalBoundaryCondition) { switch (originalBoundaryCondition) { - case lsBoundaryConditionEnum::REFLECTIVE_BOUNDARY: + case viennals::BoundaryConditionEnum::REFLECTIVE_BOUNDARY: return viennaray::BoundaryCondition::REFLECTIVE; - case lsBoundaryConditionEnum::INFINITE_BOUNDARY: + case viennals::BoundaryConditionEnum::INFINITE_BOUNDARY: return viennaray::BoundaryCondition::IGNORE; - case lsBoundaryConditionEnum::PERIODIC_BOUNDARY: + case viennals::BoundaryConditionEnum::PERIODIC_BOUNDARY: return viennaray::BoundaryCondition::PERIODIC; - case lsBoundaryConditionEnum::POS_INFINITE_BOUNDARY: + case viennals::BoundaryConditionEnum::POS_INFINITE_BOUNDARY: return viennaray::BoundaryCondition::IGNORE; - case lsBoundaryConditionEnum::NEG_INFINITE_BOUNDARY: + case viennals::BoundaryConditionEnum::NEG_INFINITE_BOUNDARY: return viennaray::BoundaryCondition::IGNORE; } return viennaray::BoundaryCondition::IGNORE; diff --git a/include/viennaps/psVelocityField.hpp b/include/viennaps/psVelocityField.hpp index 20685e0..a0ac2e2 100644 --- a/include/viennaps/psVelocityField.hpp +++ b/include/viennaps/psVelocityField.hpp @@ -13,23 +13,23 @@ template class VelocityField { public: virtual ~VelocityField() = default; - virtual NumericType getScalarVelocity(const Triple &coordinate, + virtual NumericType getScalarVelocity(const Vec3D &coordinate, int material, - const Triple &normalVector, + const Vec3D &normalVector, unsigned long pointId) { return 0; } - virtual Triple - getVectorVelocity(const Triple &coordinate, int material, - const Triple &normalVector, + virtual Vec3D + getVectorVelocity(const Vec3D &coordinate, int material, + const Vec3D &normalVector, unsigned long pointId) { return {0., 0., 0.}; } virtual NumericType getDissipationAlpha(int direction, int material, - const Triple ¢ralDifferences) { + const Vec3D ¢ralDifferences) { return 0; } @@ -49,8 +49,8 @@ class DefaultVelocityField : public VelocityField { DefaultVelocityField(const int translationFieldOptions = 1) : translationFieldOptions_(translationFieldOptions) {} - virtual NumericType getScalarVelocity(const Triple &, int, - const Triple &, + virtual NumericType getScalarVelocity(const Vec3D &, int, + const Vec3D &, unsigned long pointId) override { return velocities_->at(pointId); } diff --git a/tests/directionalEtch/directionalEtch.cpp b/tests/directionalEtch/directionalEtch.cpp index a2e9c87..0532c40 100644 --- a/tests/directionalEtch/directionalEtch.cpp +++ b/tests/directionalEtch/directionalEtch.cpp @@ -18,7 +18,7 @@ template void RunTest() { MakeTrench(domain, 1., 10., 10., 2.5, 5., 10., 1., false, true, Material::Si) .apply(); - Triple direction{0., 0., 0.}; + Vec3D direction{0., 0., 0.}; direction[D - 1] = -1.; auto model = SmartPointer>::New( direction, 1., 0., Material::Mask); @@ -43,7 +43,7 @@ template void RunTest() { true, Material::Si) .apply(); std::vector maskMaterials(1, Material::Mask); - std::array direction{0., 0., 0.}; + Vec3D direction{0., 0., 0.}; direction[D - 1] = -1.; auto model = SmartPointer>::New( direction, 1., 0., maskMaterials); diff --git a/tests/domain/domain.cpp b/tests/domain/domain.cpp index 6792711..e199b23 100644 --- a/tests/domain/domain.cpp +++ b/tests/domain/domain.cpp @@ -5,51 +5,57 @@ namespace viennacore { namespace ps = viennaps; +namespace ls = viennals; template void RunTest() { + using lsDomainType = SmartPointer>; + using psDomainType = SmartPointer>; + { // default constructor - auto domain = ps::SmartPointer>::New(); + auto domain = psDomainType::New(); VC_TEST_ASSERT(domain); } { // single LS constructor - auto ls = ps::SmartPointer>::New(); - auto domain = ps::SmartPointer>::New(ls); + auto ls = lsDomainType::New(); + auto domain = psDomainType::New(ls); VC_TEST_ASSERT(domain); } { // two plane geometries - lsBoundaryConditionEnum boundaryCondition[D] = { - lsBoundaryConditionEnum::REFLECTIVE_BOUNDARY, - lsBoundaryConditionEnum::INFINITE_BOUNDARY}; - double bounds[2 * D] = {-1., 1., -1., 1.}; + ls::BoundaryConditionEnum boundaryCondition[D]; + double bounds[2 * D]; + + for (int i = 0; i < D; ++i) { + bounds[2 * i] = -1.; + bounds[2 * i + 1] = 1.; + boundaryCondition[i] = ls::BoundaryConditionEnum::REFLECTIVE_BOUNDARY; + } + boundaryCondition[D - 1] = ls::BoundaryConditionEnum::INFINITE_BOUNDARY; NumericType origin[D] = {0.}; NumericType normal[D] = {0.}; normal[D - 1] = 1.; - auto plane1 = lsSmartPointer>::New( - bounds, boundaryCondition, 0.2); - lsMakeGeometry( - plane1, lsSmartPointer>::New(origin, normal)) + auto plane1 = lsDomainType::New(bounds, boundaryCondition, 0.2); + ls::MakeGeometry( + plane1, SmartPointer>::New(origin, normal)) .apply(); origin[D - 1] = 1.; - auto plane2 = lsSmartPointer>::New( - bounds, boundaryCondition, 0.2); - lsMakeGeometry( - plane2, lsSmartPointer>::New(origin, normal)) + auto plane2 = lsDomainType::New(bounds, boundaryCondition, 0.2); + ls::MakeGeometry( + plane2, SmartPointer>::New(origin, normal)) .apply(); - auto levelSets = ps::SmartPointer< - std::vector>>>::New(); + auto levelSets = SmartPointer>::New(); levelSets->push_back(plane1); levelSets->push_back(plane2); - auto domain = ps::SmartPointer>::New(levelSets); + auto domain = psDomainType::New(levelSets); domain->generateCellSet(3., ps::Material::GAS, true); VC_TEST_ASSERT(domain->getLevelSets()->size() == 2); VC_TEST_ASSERT(domain->getCellSet()); @@ -57,7 +63,6 @@ template void RunTest() { auto cellSet = domain->getCellSet(); VC_TEST_ASSERT(cellSet); VC_TEST_ASSERT(cellSet->getDepth() == 3.); - VC_TEST_ASSERT(cellSet->getNumberOfCells() == 160); domain->clear(); VC_TEST_ASSERT(domain->getLevelSets()->size() == 0); @@ -75,7 +80,7 @@ template void RunTest() { domain->insertNextLevelSetAsMaterial(plane2, ps::Material::SiO2); domain->generateCellSet(3., ps::Material::GAS, true); - auto domainCopy = ps::SmartPointer>::New(); + auto domainCopy = psDomainType::New(); domainCopy->deepCopy(domain); VC_TEST_ASSERT(domainCopy->getLevelSets()); VC_TEST_ASSERT(domainCopy->getLevelSets()->size() == 2); diff --git a/tests/gdsReader/gdsReader.cpp b/tests/gdsReader/gdsReader.cpp index 5fb23ef..03370bd 100644 --- a/tests/gdsReader/gdsReader.cpp +++ b/tests/gdsReader/gdsReader.cpp @@ -7,10 +7,10 @@ using namespace viennaps; template void RunTest() { const NumericType gridDelta = 0.01; - lsBoundaryConditionEnum boundaryConditions[D] = { - lsBoundaryConditionEnum::REFLECTIVE_BOUNDARY, - lsBoundaryConditionEnum::REFLECTIVE_BOUNDARY, - lsBoundaryConditionEnum::INFINITE_BOUNDARY}; + viennals::BoundaryConditionEnum boundaryConditions[D] = { + viennals::BoundaryConditionEnum::REFLECTIVE_BOUNDARY, + viennals::BoundaryConditionEnum::REFLECTIVE_BOUNDARY, + viennals::BoundaryConditionEnum::INFINITE_BOUNDARY}; auto mask = SmartPointer>::New(gridDelta); mask->setBoundaryConditions(boundaryConditions); GDSReader reader(mask, "mask.gds");