diff --git a/src/main.cpp b/src/main.cpp index e9745cc6f3234c8d8be252ffe6dcf46d033747ed..4d53e063a115cc72018440a70bdf2bdae74b3d4e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -184,7 +184,8 @@ int main(int argc, char *argv[]) double pi = 4.*std::atan(1.); std::ofstream fout("comparaison u"); 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'; + // 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/scheme/FiniteVolumesDiffusion.hpp b/src/scheme/FiniteVolumesDiffusion.hpp index 1af81019ebb395d508b6ab34097e3579801f4a69..548e87c0c0fda773b42ebcf75c12495c3a030cc6 100644 --- a/src/scheme/FiniteVolumesDiffusion.hpp +++ b/src/scheme/FiniteVolumesDiffusion.hpp @@ -91,18 +91,21 @@ private: Kokkos::parallel_for(m_mesh.numberOfFaces(), KOKKOS_LAMBDA(const int& l) { Rdd sum = zero; + double sum2 = 0.; 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)); + sum2 += kj(cell_here); } + + // k = x - //Fl(l) = ((kj(cell_nodes(j,r)) + kj(cell_nodes(j-1,r)))/(2*Vl(j))) - //* ((uj(j,r),Cjr(j,r))+ (uj(j-1,r),Cjr(j-1,r))) ; //tensorProduct(uj(j,r),Cjr(j,r)) ? + m_Fl(l) = ((sum2*0.5)/Vl(l))*sum; // k = 2 - m_Fl(l)= (2./Vl(l))*sum; + // m_Fl(l)= (2./Vl(l))*sum; }); @@ -201,13 +204,27 @@ public: const Kokkos::View<const unsigned short*> cell_nb_faces = m_connectivity.cellNbFaces(); + const Kokkos::View<const unsigned int**>& cell_nodes = m_connectivity.cellNodes(); + + const Kokkos::View<const unsigned short*> cell_nb_nodes + = m_connectivity.cellNbNodes(); + Kokkos::parallel_for(m_mesh.numberOfCells(), KOKKOS_LAMBDA(const int& j){ double minVl = std::numeric_limits<double>::max(); for (int ll=0; ll<cell_nb_faces(j); ++ll) { minVl = std::min(minVl, Vl(cell_faces(j, ll))); } // k=2 => (kj(j+1) + 2*kj(j) + kj(j-1)) = 8 - dt_j[j]= 0.5*rhoj(j)*Vj(j)*(2./8.)*minVl; + // dt_j[j]= 0.5*rhoj(j)*Vj(j)*(2./8.)*minVl; + + // k=x + double sum = 0.; + for (int m = 0; m < cell_nb_nodes(j); ++m) { + sum += kj(cell_nodes(j,m)); + } + + dt_j[j]= 0.5*rhoj(j)*Vj(j)*(1./(2.*kj(j) + sum))*minVl; + }); // for (int j=0; j<m_mesh.numberOfCells(); ++j) { @@ -227,6 +244,7 @@ public: { Kokkos::View<double*> rhoj = unknowns.rhoj(); Kokkos::View<Rd*> uj = unknowns.uj(); + Kokkos::View<Rd*> Sj = unknowns.Sj(); Kokkos::View<double*> Ej = unknowns.Ej(); Kokkos::View<double*> ej = unknowns.ej(); @@ -261,7 +279,7 @@ public: momentum_fluxes += Fl(l)*Cjr(j,R); energy_fluxes += (Gl(l), Cjr(j,R)); } - uj[j] -= (dt*inv_mj[j]) * momentum_fluxes; + uj[j] -= std::exp(-t)*dt*Vj(j)*Sj(j)+(dt*inv_mj[j]) * momentum_fluxes; Ej[j] -= (dt*inv_mj[j]) * energy_fluxes; }); diff --git a/src/scheme/FiniteVolumesEulerUnknowns.hpp b/src/scheme/FiniteVolumesEulerUnknowns.hpp index 14e248ac54d8773f0f0b01ea152b2d8d3667571c..77eb543034da57f98df83234c0b407fad887473a 100644 --- a/src/scheme/FiniteVolumesEulerUnknowns.hpp +++ b/src/scheme/FiniteVolumesEulerUnknowns.hpp @@ -26,6 +26,7 @@ private: Kokkos::View<double*> m_mj; Kokkos::View<double*> m_inv_mj; Kokkos::View<double*> m_kj; + Kokkos::View<Rd*> m_Sj; public: Kokkos::View<double*> rhoj() @@ -128,6 +129,11 @@ public: return m_kj; } + Kokkos::View<Rd*> Sj() + { + return m_Sj; + } + // --- Acoustic Solver --- // void initializeSod() @@ -222,8 +228,13 @@ void initializeSod() }); Kokkos::parallel_for(m_mesh.numberOfCells(), KOKKOS_LAMBDA(const int& j){ - m_kj[j] = 2; + //m_kj[j] = 2; // k constant + m_kj[j] = xj[j][0]; // k non constant, k = x }); + + Kokkos::parallel_for(m_mesh.numberOfCells(), KOKKOS_LAMBDA(const int& j){ + m_Sj[j] = std::sin(pi*xj[j][0])*(xj[j][0]-1.) - std::cos(xj[j][0]*pi); + }); } @@ -239,7 +250,8 @@ void initializeSod() m_cj("cj",m_mesh.numberOfCells()), m_mj("mj",m_mesh.numberOfCells()), m_inv_mj("inv_mj",m_mesh.numberOfCells()), - m_kj("kj",m_mesh.numberOfCells()) + m_kj("kj",m_mesh.numberOfCells()), + m_Sj("Sj",m_mesh.numberOfCells()) { ; }