From 05d9c65885412f7f18a8b023f4b2f79df513cad4 Mon Sep 17 00:00:00 2001 From: Fanny CHOPOT <fanny.chopot.ocre@cea.fr> Date: Fri, 4 May 2018 16:07:28 +0200 Subject: [PATCH] ajout nouveau maillage non uniforme --- src/main.cpp | 2 +- src/mesh/Mesh.hpp | 54 ++++++++++++++++++++++++++--------------------- 2 files changed, 31 insertions(+), 25 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index b6c3216bc..babd25dcb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -196,7 +196,7 @@ int main(int argc, char *argv[]) const Kokkos::View<const Rd*> xj = mesh_data.xj(); const Kokkos::View<const Rd*> uj = unknowns.uj(); double pi = 4.*std::atan(1.); - std::ofstream fout("comparaison_u_k_non_cst_maill_non_unif_640"); + std::ofstream fout("comparaison_u_k_non_cst_maill_non_unif_320"); for (size_t j=0; j<mesh.numberOfCells(); ++j) { //fout << xj[j][0] << ' ' << uj[j][0] << ' ' << std::sin(pi*xj[j][0])*std::exp(-2.*pi*pi*0.2) <<'\n'; //cas k constant fout << xj[j][0] << ' ' << uj[j][0] << ' ' << std::sin(pi*xj[j][0])*std::exp(-0.2) <<'\n'; // cas k non constant diff --git a/src/mesh/Mesh.hpp b/src/mesh/Mesh.hpp index a1d12a0ab..f28169f83 100644 --- a/src/mesh/Mesh.hpp +++ b/src/mesh/Mesh.hpp @@ -62,36 +62,42 @@ public: // pas non constant - //Mesh(const Connectivity& connectivity) - // : m_connectivity(connectivity), - // m_xr("xr", connectivity.numberOfNodes()) - //{ - // const double delta_x = 1./connectivity.numberOfCells(); - // Kokkos::parallel_for(connectivity.numberOfNodes(), KOKKOS_LAMBDA(const int& r){ - // if (r%2 == 0) { - // m_xr[r][0] = r*delta_x; - // } - // else { - // m_xr[r][0] = (r*2+1)*0.5*delta_x; - // } - // }); - //} - - // pas non constant avec fonction x^2 - - Mesh(const Connectivity& connectivity) - : m_connectivity(connectivity), - m_xr("xr", connectivity.numberOfNodes()) + Mesh(const Connectivity& connectivity) + : m_connectivity(connectivity), + m_xr("xr", connectivity.numberOfNodes()) { const double delta_x = 1./connectivity.numberOfCells(); Kokkos::parallel_for(connectivity.numberOfNodes(), KOKKOS_LAMBDA(const int& r){ - m_xr[r][0] = r*delta_x; - }); - Kokkos::parallel_for(connectivity.numberOfNodes(), KOKKOS_LAMBDA(const int& r){ - m_xr[r][0] = m_xr[r][0]*m_xr[r][0]; + if (r%4 == 1) { + m_xr[r][0] = (r*2+1)*0.5*delta_x; + } + else { + if (r%4==3) { + m_xr[r][0] = ((r*3-1)/3.)*delta_x; + } + else + { + m_xr[r][0] = r*delta_x; + } + } }); } + // pas non constant avec fonction x^2 (mauvais choix pas, hyper lent) + + // Mesh(const Connectivity& connectivity) + // : m_connectivity(connectivity), + // m_xr("xr", connectivity.numberOfNodes()) + //{ + // const double delta_x = 1./connectivity.numberOfCells(); + // Kokkos::parallel_for(connectivity.numberOfNodes(), KOKKOS_LAMBDA(const int& r){ + // m_xr[r][0] = r*delta_x; + // }); + // Kokkos::parallel_for(connectivity.numberOfNodes(), KOKKOS_LAMBDA(const int& r){ + // m_xr[r][0] = m_xr[r][0]*m_xr[r][0]; + // }); + //} + ~Mesh() { ; -- GitLab