From d5f120df15eaebb1977e30cc58b9d2dc6401d053 Mon Sep 17 00:00:00 2001 From: Massimiliano Meneghin Date: Tue, 18 Jul 2023 09:19:30 -0400 Subject: [PATCH] Upgrading the domain level tutorial. --- CMakeLists.txt | 2 +- tutorials/CMakeLists.txt | 2 +- .../the-bases/domainLevel/domainLevel.cpp | 8 +++---- .../the-bases/domainLevel/expandSphere.cu | 10 ++++----- .../the-bases/domainLevel/expandSphere.h | 5 ++--- tutorials/the-bases/domainLevel/grad.cu | 22 +++++++++---------- tutorials/the-bases/domainLevel/grad.h | 8 ++++--- 7 files changed, 29 insertions(+), 28 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e4640a1a..11a374e8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,7 +79,7 @@ add_subdirectory("libNeonSet") add_subdirectory("libNeonDomain") add_subdirectory("libNeonSkeleton") #add_subdirectory("libNeonSolver") -#add_subdirectory("tutorials") +add_subdirectory("tutorials") add_subdirectory("apps") add_subdirectory("benchmarks") diff --git a/tutorials/CMakeLists.txt b/tutorials/CMakeLists.txt index 35b36fc7..e24fae96 100644 --- a/tutorials/CMakeLists.txt +++ b/tutorials/CMakeLists.txt @@ -1,4 +1,4 @@ cmake_minimum_required(VERSION 3.19 FATAL_ERROR) add_subdirectory("the-bases") -add_subdirectory("staggered-grids") +# add_subdirectory("staggered-grids") diff --git a/tutorials/the-bases/domainLevel/domainLevel.cpp b/tutorials/the-bases/domainLevel/domainLevel.cpp index 00c6ea68..55c52a1a 100644 --- a/tutorials/the-bases/domainLevel/domainLevel.cpp +++ b/tutorials/the-bases/domainLevel/domainLevel.cpp @@ -40,7 +40,7 @@ int main(int, char**) Neon::index_3d dim(n, n, n); // Size of the domain const double voxelEdge = 1.0; // Size of a voxel edge - using Grid = Neon::domain::eGrid; // Selecting one of the grid provided by Neon + using Grid = Neon::dGrid; // Selecting one of the grid provided by Neon Neon::domain::Stencil gradStencil([] { // We use a center difference scheme to compute the grad // The order of the points is important, @@ -118,9 +118,9 @@ int main(int, char**) 3, // <- Number of field's component per grid point. 0); // <- Default value for non active points. - Neon::set::HuOptions huOptions(Neon::set::TransferMode::get, - true); - sphereSdf.haloUpdate(huOptions); + sphereSdf.newHaloUpdate(Neon::set::StencilSemantic::standard, + Neon::set::TransferMode::get, + Neon::Execution::device).run(Neon::Backend::mainStreamIdx); computeGrad(sphereSdf, grad, voxelEdge).run(Neon::Backend::mainStreamIdx); grad.updateHostData(Neon::Backend::mainStreamIdx); diff --git a/tutorials/the-bases/domainLevel/expandSphere.cu b/tutorials/the-bases/domainLevel/expandSphere.cu index 56db7f17..04702a00 100644 --- a/tutorials/the-bases/domainLevel/expandSphere.cu +++ b/tutorials/the-bases/domainLevel/expandSphere.cu @@ -1,5 +1,5 @@ #include "Neon/Neon.h" -#include "Neon/domain/eGrid.h" +#include "Neon/domain/Grids.h" #include "Neon/skeleton/Skeleton.h" #include "expandSphere.h" @@ -8,15 +8,15 @@ auto expandedLevelSet(Field& sdf, double expantion) ->Neon::set::Container { - return sdf.getGrid().getContainer( + return sdf.getGrid().newContainer( "ExpandedLevelSet", [&, expantion](Neon::set::Loader& L) { auto& px = L.load(sdf); return [=] NEON_CUDA_HOST_DEVICE( - const typename Field::Cell& cell) mutable { - px(cell, 0) -= expantion; + const typename Field::Idx& gidx) mutable { + px(gidx, 0) -= expantion; }; }); } -template auto expandedLevelSet>(Neon::domain::eGrid::Field& sdf, double expation) -> Neon::set::Container; \ No newline at end of file +template auto expandedLevelSet>(Neon::dGrid::Field& sdf, double expation) -> Neon::set::Container; \ No newline at end of file diff --git a/tutorials/the-bases/domainLevel/expandSphere.h b/tutorials/the-bases/domainLevel/expandSphere.h index 480e5811..5b085c3f 100644 --- a/tutorials/the-bases/domainLevel/expandSphere.h +++ b/tutorials/the-bases/domainLevel/expandSphere.h @@ -1,11 +1,10 @@ #pragma once #include "Neon/Neon.h" -#include "Neon/domain/eGrid.h" -#include "Neon/skeleton/Skeleton.h" +#include "Neon/domain/Grids.h" template auto expandedLevelSet(Field& sdf, double expantion) -> Neon::set::Container; -extern template auto expandedLevelSet>(Neon::domain::eGrid::Field& sdf, double expation) -> Neon::set::Container; \ No newline at end of file +extern template auto expandedLevelSet>(Neon::dGrid::Field& sdf, double expation) -> Neon::set::Container; \ No newline at end of file diff --git a/tutorials/the-bases/domainLevel/grad.cu b/tutorials/the-bases/domainLevel/grad.cu index 722793e8..7b0a6d3f 100644 --- a/tutorials/the-bases/domainLevel/grad.cu +++ b/tutorials/the-bases/domainLevel/grad.cu @@ -1,5 +1,5 @@ #include "Neon/Neon.h" -#include "Neon/domain/eGrid.h" +#include "Neon/domain/Grids.h" #include "Neon/skeleton/Skeleton.h" #include "expandSphere.h" @@ -26,11 +26,11 @@ auto computeGrad(const Field& levelSetField /** input scalar field we want to co // {-1, 0, 0}, // {0, -1, 0}, // {0, 0, -1} - return levelSetField.getGrid().getContainer( + return levelSetField.getGrid().newContainer( "computeGrad", [&, h](Neon::set::Loader& L) { // Loading the sdf field for a stencil type of computation // as we will be using a 6 point stencil to compute the gradient - auto& levelSet = L.load(levelSetField, Neon::Compute::STENCIL); + auto& levelSet = L.load(levelSetField, Neon::Pattern::STENCIL); auto& grad = L.load(gradField); // We can nicely compute the inverse of the spacing in the loading lambda @@ -38,26 +38,26 @@ auto computeGrad(const Field& levelSetField /** input scalar field we want to co return [=] NEON_CUDA_HOST_DEVICE( - const typename Field::Cell& cell) mutable { + const typename Field::Idx& gidx) mutable { // Central difference for (int i = 0; i < 3; i++) { auto upIdx = i; auto dwIdx = i + 3; - auto [valUp, isValidUp] = levelSet.nghVal(cell, upIdx, 0, 0); - auto [valDw, isValidDw] = levelSet.nghVal(cell, dwIdx, 0, 0); + auto [valUp, isValidUp] = levelSet.nghVal(gidx, upIdx, 0, 0); + auto [valDw, isValidDw] = levelSet.nghVal(gidx, dwIdx, 0, 0); if (!isValidUp || !isValidDw) { - grad(cell, 0) = 0; - grad(cell, 1) = 0; - grad(cell, 2) = 0; + grad(gidx, 0) = 0; + grad(gidx, 1) = 0; + grad(gidx, 2) = 0; break; } else { - grad(cell, i) = (valUp - valDw) / twiceOverH; + grad(gidx, i) = (valUp - valDw) / twiceOverH; } } }; }); } -template auto computeGrad>(const Neon::domain::eGrid::Field& levelSet, Neon::domain::eGrid::Field& grad, double h) -> Neon::set::Container; \ No newline at end of file +template auto computeGrad>(const Neon::dGrid::Field& levelSet, Neon::dGrid::Field& grad, double h) -> Neon::set::Container; \ No newline at end of file diff --git a/tutorials/the-bases/domainLevel/grad.h b/tutorials/the-bases/domainLevel/grad.h index cf9be1a4..f998c855 100644 --- a/tutorials/the-bases/domainLevel/grad.h +++ b/tutorials/the-bases/domainLevel/grad.h @@ -1,13 +1,15 @@ #pragma once #include "Neon/Neon.h" -#include "Neon/domain/eGrid.h" +#include "Neon/domain/Grids.h" #include "Neon/skeleton/Skeleton.h" template -auto computeGrad(const Field& sdfField, +auto computeGrad(const Field& gidx, Field& gradField, double h) -> Neon::set::Container; -extern template auto computeGrad>(const Neon::domain::eGrid::Field& sdf, Neon::domain::eGrid::Field& grad, double h) -> Neon::set::Container; \ No newline at end of file +extern template auto computeGrad>(const Neon::dGrid::Field& gidx, + Neon::dGrid::Field& grad, + double h) -> Neon::set::Container; \ No newline at end of file