diff --git a/src/main.cpp b/src/main.cpp index 5ee44852013e22219f609a57edf21a3a938d8b1a..84cdf276d7ffdf0cc0e6ee0bd640a66f7f15f365 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -216,7 +216,7 @@ int main(int argc, char *argv[]) double pi = 4.*std::atan(1.); std::ofstream fout("comparaison E"); for (size_t j=0; j<mesh.numberOfCells(); ++j) { - fout << xj[j][0] << ' ' << Ej[j] << ' ' << (-(std::cos(pi*xj[j][0])*std::cos(pi*xj[j][0]))+(std::sin(pi*xj[j][0])*std::sin(pi*xj[j][0])))*(pi*0.5)*(std::exp(-4.*pi*0.2)-1.) + 2. <<'\n'; // cas k constant + fout << xj[j][0] << ' ' << Ej[j] << ' ' << (-(std::cos(pi*xj[j][0])*std::cos(pi*xj[j][0]))+(std::sin(pi*xj[j][0])*std::sin(pi*xj[j][0])))*0.5*(std::exp(-4.*pi*pi*0.2)-1.) + 2. <<'\n'; // cas k constant } } diff --git a/src/mesh/Mesh.hpp b/src/mesh/Mesh.hpp index f28169f8377aa39f97f4e5ba6a4eb41edcc5be1a..9de8bc118eae4fcf8fac8ad870e4a7f20c5930ee 100644 --- a/src/mesh/Mesh.hpp +++ b/src/mesh/Mesh.hpp @@ -50,21 +50,24 @@ public: // pas 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){ - // m_xr[r][0] = r*delta_x; - // }); - //} + + 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; + }); + } + // pas non constant + /* Mesh(const Connectivity& connectivity) - : m_connectivity(connectivity), - m_xr("xr", connectivity.numberOfNodes()) + : 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){ @@ -72,31 +75,17 @@ public: 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; - } - } + 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() { diff --git a/src/scheme/FiniteVolumesDiffusion.hpp b/src/scheme/FiniteVolumesDiffusion.hpp index ecac5a30b3324952978186ba9efbdb4772118a14..c9aeb725d03d59a1d12bd965345b95f6b1067d1c 100644 --- a/src/scheme/FiniteVolumesDiffusion.hpp +++ b/src/scheme/FiniteVolumesDiffusion.hpp @@ -95,7 +95,7 @@ private: for (int j=0; j<face_nb_cells(l); ++j) { int cell_here = face_cells(l,j); int local_face_number_in_cell = face_cell_local_face(l,j); - sum -= tensorProduct(uj(cell_here, local_face_number_in_cell), Cjr(cell_here, local_face_number_in_cell)); + sum -= tensorProduct(uj(cell_here), Cjr(cell_here, local_face_number_in_cell)); sum2 += kj(cell_here); } @@ -123,11 +123,10 @@ private: Rd sum = zero; for (int j=0; j<face_nb_cells(l); ++j) { int cell_here = face_cells(l,j); - int local_face_number_in_cell = face_cell_local_face(l,j); - sum += uj(cell_here, local_face_number_in_cell); + sum += uj(cell_here); } - m_Gl(l) = (1./face_nb_cells(l))*Fl(l)*sum; + m_Gl(l) = (1./face_nb_cells(l))*Fl(l)*sum; }); @@ -263,8 +262,8 @@ public: const Kokkos::View<const double*> inv_mj = unknowns.invMj(); Kokkos::parallel_for(m_mesh.numberOfCells(), KOKKOS_LAMBDA(const int& j) { Rd momentum_fluxes = zero; - double energy_fluxes = 0; - int l = 0.; + double energy_fluxes = 0.; + int l = 0; for (int R=0; R<cell_nb_faces(j); ++R) { l = cell_faces(j,R); momentum_fluxes += Fl(l)*Cjr(j,R); diff --git a/src/scheme/FiniteVolumesEulerUnknowns.hpp b/src/scheme/FiniteVolumesEulerUnknowns.hpp index a39dd415754e1f7ca9252950a7847e28a49a4d0f..c00df47701bd190d8145f9b1e587127acd2a0b90 100644 --- a/src/scheme/FiniteVolumesEulerUnknowns.hpp +++ b/src/scheme/FiniteVolumesEulerUnknowns.hpp @@ -134,6 +134,11 @@ public: return m_Sj; } + const Kokkos::View<const double*> Sj() const + { + return m_Sj; + } + // --- Acoustic Solver --- // void initializeSod() @@ -193,33 +198,20 @@ void initializeSod() double pi = 4.*std::atan(1.); Kokkos::parallel_for(m_mesh.numberOfCells(), KOKKOS_LAMBDA(const int& j){ - - m_rhoj[j]=1; - + m_rhoj[j]=1.; }); Kokkos::parallel_for(m_mesh.numberOfCells(), KOKKOS_LAMBDA(const int& j){ - m_pj[j]=1; - + m_pj[j]=1.; }); Kokkos::parallel_for(m_mesh.numberOfCells(), KOKKOS_LAMBDA(const int& j){ - if (j == m_mesh.numberOfCells()) { - m_uj[j] = zero; - } - else { - if (j == 0) { - m_uj[j] = zero; - } - else { - m_uj[j] = std::sin(pi*xj[j][0]); - } - } - + m_uj[j] = std::sin(pi*xj[j][0]); }); Kokkos::parallel_for(m_mesh.numberOfCells(), KOKKOS_LAMBDA(const int& j){ m_gammaj[j] = 2.; + }); BlockPerfectGas block_eos(m_rhoj, m_ej, m_pj, m_gammaj, m_cj);