diff --git a/CMakeLists.txt b/CMakeLists.txt index 7f04f444..3464423d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -114,13 +114,13 @@ CPMFindPackage( CPMFindPackage( NAME ViennaLS - GIT_TAG viennacore + VERSION 4.0.0 GIT_REPOSITORY "https://github.com/ViennaTools/ViennaLS" EXCLUDE_FROM_ALL ${VIENNAPS_BUILD_PYTHON}) CPMFindPackage( NAME ViennaCS - GIT_TAG main + VERSION 1.0.0 GIT_REPOSITORY "https://github.com/ViennaTools/ViennaCS" EXCLUDE_FROM_ALL ${VIENNAPS_BUILD_PYTHON}) diff --git a/examples/KDTreeBenchmark/KDTreeBenchmark.cpp b/examples/KDTreeBenchmark/KDTreeBenchmark.cpp index e0360c48..1cb75c3a 100644 --- a/examples/KDTreeBenchmark/KDTreeBenchmark.cpp +++ b/examples/KDTreeBenchmark/KDTreeBenchmark.cpp @@ -6,7 +6,8 @@ #include #endif -#include +#include +#include inline double getTime() { #ifdef _OPENMP @@ -41,7 +42,7 @@ std::vector> generatePoints(unsigned N, unsigned D) { return data; } -namespace ps = viennaps; +using namespace viennacore; int main(int argc, char *argv[]) { using NumericType = double; @@ -81,10 +82,10 @@ int main(int argc, char *argv[]) { { std::cout << "Growing Tree...\n"; - ps::SmartPointer> tree = nullptr; + SmartPointer> tree = nullptr; auto startTime = getTime(); for (unsigned i = 0; i < repetitions; ++i) { - tree = ps::SmartPointer>::New(points); + tree = SmartPointer>::New(points); tree->build(); } auto endTime = getTime(); diff --git a/examples/interpolationDemo/interpolationDemo.cpp b/examples/interpolationDemo/interpolationDemo.cpp index ea442174..714892f5 100644 --- a/examples/interpolationDemo/interpolationDemo.cpp +++ b/examples/interpolationDemo/interpolationDemo.cpp @@ -19,6 +19,7 @@ #include namespace fs = std::filesystem; +namespace ps = viennaps; template void doEstimation(DataSource &dataSource, Estimator &estimator, @@ -58,7 +59,7 @@ int main(int argc, char *argv[]) { int numSamples = 40; { - psCSVDataSource dataSource( + ps::CSVDataSource dataSource( (dataPath / "griddata.csv").string()); // Quick demo of the positional and named parameters feature @@ -96,13 +97,13 @@ int main(int argc, char *argv[]) { // End of parameter demo - psRectilinearGridInterpolation estimator; + ps::RectilinearGridInterpolation estimator; estimator.setDataDimensions(InputDim, OutputDim); auto data = dataSource.getData(); estimator.setData(data); - psCSVDataSource writer("grid_output.csv"); + ps::CSVDataSource writer("grid_output.csv"); writer.setHeader( "x, y, z, data\nData generated by rectilinear interpolation " "on rectilinear grid"); @@ -114,13 +115,13 @@ int main(int argc, char *argv[]) { int OutputDim = 1; { - psCSVDataSource dataSource( + ps::CSVDataSource dataSource( (dataPath / "scatterdata.csv").string()); int numberOfNeighbors = 5; NumericType distanceExponent = 2.; - psNearestNeighborsInterpolation estimator; + ps::NearestNeighborsInterpolation estimator; estimator.setDistanceExponent(distanceExponent); estimator.setNumberOfNeighbors(numberOfNeighbors); estimator.setDataDimensions(InputDim, OutputDim); @@ -128,7 +129,7 @@ int main(int argc, char *argv[]) { auto data = dataSource.getData(); estimator.setData(data); - psCSVDataSource writer("nn_std_output.csv"); + ps::CSVDataSource writer("nn_std_output.csv"); writer.setHeader("x, y, z, data\nData generated by nearest neighbors " "interpolation using standard deviation scaling"); @@ -136,14 +137,14 @@ int main(int argc, char *argv[]) { } { - psCSVDataSource dataSource( + ps::CSVDataSource dataSource( (dataPath / "scatterdata.csv").string()); int numberOfNeighbors = 5; NumericType distanceExponent = 1. / 5.; - psNearestNeighborsInterpolation> + ps::NearestNeighborsInterpolation> estimator; estimator.setDistanceExponent(distanceExponent); estimator.setNumberOfNeighbors(numberOfNeighbors); @@ -152,7 +153,7 @@ int main(int argc, char *argv[]) { auto data = dataSource.getData(); estimator.setData(data); - psCSVDataSource writer("nn_median_output.csv"); + ps::CSVDataSource writer("nn_median_output.csv"); writer.setHeader("x, y, z, data\nData generated by nearest neighbors " "interpolation using median distance scaling."); diff --git a/examples/volumeModel/CMakeLists.txt b/examples/volumeModel/CMakeLists.txt deleted file mode 100644 index 525f896b..00000000 --- a/examples/volumeModel/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -project(volumeModel LANGUAGES CXX) - -add_executable(${PROJECT_NAME} "${PROJECT_NAME}.cpp") -target_link_libraries(${PROJECT_NAME} PRIVATE ViennaPS) - -configure_file(volumeModel.py ${CMAKE_CURRENT_BINARY_DIR}/volumeModel.py COPYONLY) -configure_file(config.txt ${CMAKE_CURRENT_BINARY_DIR}/config.txt COPYONLY) - -add_dependencies(ViennaPS_Examples ${PROJECT_NAME}) -viennacore_setup_bat(${PROJECT_NAME} ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/examples/volumeModel/config.txt b/examples/volumeModel/config.txt deleted file mode 100644 index b5079fbc..00000000 --- a/examples/volumeModel/config.txt +++ /dev/null @@ -1,13 +0,0 @@ -# Config params for plasma damage volume example -# Domain -gridDelta=0.25 -xExtent=15 -yExtent=7 - -# Geometry -finWidth=5 -finHeight=15 - -# Process -ionEnergy=100. -meanFreePath=0.75 \ No newline at end of file diff --git a/examples/volumeModel/parameters.hpp b/examples/volumeModel/parameters.hpp deleted file mode 100644 index 98d47cb0..00000000 --- a/examples/volumeModel/parameters.hpp +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once - -#include -#include - -#include - -template struct Parameters { - // Domain - T gridDelta = 0.25; - T xExtent = 15.; - T yExtent = 7.; - - // Geometry - T finWidth = 5.; - T finHeight = 15.; - - // Process - T meanFreePath = 0.75; - T ionEnergy = 100.; - - Parameters() {} - - void fromMap(std::unordered_map &m) { - psUtils::AssignItems( // - m, // - psUtils::Item{"gridDelta", gridDelta}, // - psUtils::Item{"xExtent", xExtent}, // - psUtils::Item{"yExtent", yExtent}, // - psUtils::Item{"finWidth", finWidth}, // - psUtils::Item{"finHeight", finHeight}, // - psUtils::Item{"meanFreePath", meanFreePath}, // - psUtils::Item{"ionEnergy", ionEnergy} // - ); - } -}; diff --git a/examples/volumeModel/volumeModel.cpp b/examples/volumeModel/volumeModel.cpp deleted file mode 100644 index 1159a048..00000000 --- a/examples/volumeModel/volumeModel.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include -#include - -#include - -#include "parameters.hpp" - -int main(int argc, char *argv[]) { - using NumericType = float; - constexpr int D = 3; - - // Parse the parameters - ps::utils::Parameters params; - if (argc > 1) { - params.readConfigFile(argv[1]); - } else { - std::cout << "Usage: " << argv[0] << " " << std::endl; - return 1; - } - - auto geometry = psSmartPointer>::New(); - psMakeFin(geometry, params.gridDelta, params.xExtent, - params.yExtent, params.finWidth, params.finHeight, - 0. /*taper angle*/, 0. /* base height*/, - false /*periodic boundary*/, false /*create mask*/, - psMaterial::Si /*material*/) - .apply(); - - // generate cell set with depth 5 - geometry->generateCellSet(-5. /*depth*/, psMaterial::Si, - false /*cell set below surface*/); - - auto model = psSmartPointer>::New( - params.ionEnergy /* mean ion energy (eV) */, - params.meanFreePath /* damage ion mean free path */, - psMaterial::None /*mask material (no mask)*/); - - psProcess(geometry, model, 0.) - .apply(); // apply only damage model - - geometry->getCellSet()->writeVTU("DamageModel.vtu"); -} diff --git a/examples/volumeModel/volumeModel.py b/examples/volumeModel/volumeModel.py deleted file mode 100644 index 45d21567..00000000 --- a/examples/volumeModel/volumeModel.py +++ /dev/null @@ -1,38 +0,0 @@ -import viennaps3d as vps -from argparse import ArgumentParser - -# parse config file name -parser = ArgumentParser( - prog="volumeModel", description="Run a plasma damage process on a fin geometry." -) -parser.add_argument("filename") -args = parser.parse_args() - -params = vps.ReadConfigFile(args.filename) - -geometry = vps.Domain() -vps.MakeFin( - domain=geometry, - gridDelta=params["gridDelta"], - xExtent=params["xExtent"], - yExtent=params["yExtent"], - finWidth=params["finWidth"], - finHeight=params["finHeight"], -).apply() - - -# generate cell set with depth 5 -geometry.generateCellSet(-5.0, False) - -model = vps.PlasmaDamage( - ionEnergy=params["ionEnergy"], meanFreePath=params["meanFreePath"], maskMaterial=-1 -) - -process = vps.Process() -process.setDomain(geometry) -process.setProcessModel(model) -process.setProcessDuration(0) # apply only damage model - -process.apply() - -geometry.getCellSet().writeVTU("DamageModel.vtu") diff --git a/include/viennaps/compact/psDataScaler.hpp b/include/viennaps/compact/psDataScaler.hpp index e980adee..cf19a395 100644 --- a/include/viennaps/compact/psDataScaler.hpp +++ b/include/viennaps/compact/psDataScaler.hpp @@ -5,8 +5,12 @@ #include #include +namespace viennaps { + +using namespace viennacore; + // Base class for data scalers -template class psDataScaler { +template class DataScaler { protected: using ItemType = std::vector; using ItemVectorType = std::vector; @@ -21,8 +25,8 @@ template class psDataScaler { // Class that calculates scaling factors based on standard deviation template -class psStandardScaler : public psDataScaler { - using Parent = psDataScaler; +class StandardScaler : public DataScaler { + using Parent = DataScaler; using typename Parent::ItemType; using typename Parent::ItemVectorType; @@ -32,7 +36,7 @@ class psStandardScaler : public psDataScaler { const ItemVectorType &data; public: - psStandardScaler(const ItemVectorType &passedData) : data(passedData) {} + StandardScaler(const ItemVectorType &passedData) : data(passedData) {} void apply() override { if (data.empty()) @@ -75,8 +79,8 @@ class psStandardScaler : public psDataScaler { // Class that calculates scaling factors based on median distances template -class psMedianDistanceScaler : public psDataScaler { - using Parent = psDataScaler; +class MedianDistanceScaler : public DataScaler { + using Parent = DataScaler; using typename Parent::ItemType; using typename Parent::ItemVectorType; @@ -86,7 +90,7 @@ class psMedianDistanceScaler : public psDataScaler { const ItemVectorType &data; public: - psMedianDistanceScaler(const ItemVectorType &passedData) : data(passedData) {} + MedianDistanceScaler(const ItemVectorType &passedData) : data(passedData) {} void apply() override { if (data.empty()) @@ -122,3 +126,5 @@ class psMedianDistanceScaler : public psDataScaler { } } }; + +} // namespace viennaps diff --git a/include/viennaps/compact/psNearestNeighborsInterpolation.hpp b/include/viennaps/compact/psNearestNeighborsInterpolation.hpp index 90badeb1..58d9ca17 100644 --- a/include/viennaps/compact/psNearestNeighborsInterpolation.hpp +++ b/include/viennaps/compact/psNearestNeighborsInterpolation.hpp @@ -8,7 +8,7 @@ #include "psDataScaler.hpp" #include "psValueEstimator.hpp" -#include +#include #include #include @@ -17,7 +17,7 @@ namespace viennaps { using namespace viennacore; template -auto extractInputData(psSmartPointer data, SizeType InputDim, +auto extractInputData(SmartPointer data, SizeType InputDim, SizeType OutputDim) { VectorType inputData; using ElementType = typename VectorType::value_type; @@ -35,15 +35,16 @@ auto extractInputData(psSmartPointer data, SizeType InputDim, // Class providing nearest neighbors interpolation template > + typename DataScaler = StandardScaler> class NearestNeighborsInterpolation - : public psValueEstimator { + : public ValueEstimator { - static_assert(std::is_base_of_v, DataScaler>, - "NearestNeighborsInterpolation: the provided DataScaler " - "does not inherit from psDataScaler."); + static_assert( + std::is_base_of_v, DataScaler>, + "NearestNeighborsInterpolation: the provided DataScaler " + "does not inherit from viennaps::DataScaler."); - using Parent = psValueEstimator; + using Parent = ValueEstimator; using typename Parent::ItemType; using typename Parent::SizeType; @@ -71,7 +72,7 @@ class NearestNeighborsInterpolation bool initialize() override { if (!data || (data && data->empty())) { - psLogger::getInstance() + Logger::getInstance() .addWarning( "NearestNeighborsInterpolation: the provided data is empty.") .print(); @@ -79,7 +80,7 @@ class NearestNeighborsInterpolation } if (data->at(0).size() != inputDim + outputDim) { - psLogger::getInstance() + Logger::getInstance() .addWarning("NearestNeighborsInterpolation: the sum of the provided " "InputDimension and OutputDimension does not match the " "dimension of the provided data.") @@ -105,7 +106,7 @@ class NearestNeighborsInterpolation std::optional> estimate(const ItemType &input) override { if (input.size() != inputDim) { - psLogger::getInstance() + Logger::getInstance() .addWarning("NearestNeighborsInterpolation: No input data provided.") .print(); return {}; diff --git a/include/viennaps/compact/psRectilinearGridInterpolation.hpp b/include/viennaps/compact/psRectilinearGridInterpolation.hpp index 7e4ed48d..083aaa76 100644 --- a/include/viennaps/compact/psRectilinearGridInterpolation.hpp +++ b/include/viennaps/compact/psRectilinearGridInterpolation.hpp @@ -4,15 +4,19 @@ #include #include -#include "../psLogger.hpp" #include "psValueEstimator.hpp" +#include + +namespace viennaps { + +using namespace viennacore; + // Class providing linear interpolation on rectilinear data grids template -class psRectilinearGridInterpolation - : public psValueEstimator { +class RectilinearGridInterpolation : public ValueEstimator { - using Parent = psValueEstimator; + using Parent = ValueEstimator; using typename Parent::ItemType; using typename Parent::SizeType; @@ -62,7 +66,7 @@ class psRectilinearGridInterpolation uniqueValues[axis].insert((start + i)->at(axis)); if (rangeSize != i - tmp) { - psLogger::getInstance() + Logger::getInstance() .addWarning("Data is not arranged in a rectilinear grid!") .print(); equalSize = false; @@ -85,19 +89,19 @@ class psRectilinearGridInterpolation } public: - psRectilinearGridInterpolation() {} + RectilinearGridInterpolation() {} bool initialize() override { if (!data || (data && data->empty())) { - psLogger::getInstance() + Logger::getInstance() .addWarning( - "psRectilinearGridInterpolation: the provided data is empty.") + "RectilinearGridInterpolation: the provided data is empty.") .print(); return false; } if (data->at(0).size() != inputDim + outputDim) { - psLogger::getInstance() + Logger::getInstance() .addWarning( "psNearestNeighborsInterpolation: the sum of the provided " "InputDimension and OutputDimension does not match the " @@ -115,7 +119,7 @@ class psRectilinearGridInterpolation auto equalSize = rearrange(localData.begin(), localData.end(), 0, true); if (!equalSize) { - psLogger::getInstance() + Logger::getInstance() .addWarning("Data is not arranged in a rectilinear grid!") .print(); return false; @@ -123,7 +127,7 @@ class psRectilinearGridInterpolation for (int i = 0; i < inputDim; ++i) if (uniqueValues[i].empty()) { - psLogger::getInstance() + Logger::getInstance() .addWarning("The grid has no values along dimension " + std::to_string(i)) .print(); @@ -235,3 +239,5 @@ class psRectilinearGridInterpolation return {{result, isInside}}; } }; + +} // namespace viennaps diff --git a/include/viennaps/compact/psValueEstimator.hpp b/include/viennaps/compact/psValueEstimator.hpp index 7be9e560..b4e6148e 100644 --- a/include/viennaps/compact/psValueEstimator.hpp +++ b/include/viennaps/compact/psValueEstimator.hpp @@ -4,16 +4,17 @@ #include #include -#include "../psSmartPointer.hpp" +namespace viennaps { -template -class psValueEstimator { +using namespace viennacore; + +template class ValueEstimator { public: using SizeType = size_t; using ItemType = std::vector; using VectorType = std::vector; - using VectorPtr = psSmartPointer>; - using ConstPtr = psSmartPointer>; + using VectorPtr = SmartPointer>; + using ConstPtr = SmartPointer>; protected: SizeType inputDim{0}; @@ -39,3 +40,5 @@ class psValueEstimator { virtual std::optional> estimate(const ItemType &input) = 0; }; + +} // namespace viennaps