Skip to content
Snippets Groups Projects
Commit 867e9833 authored by Fanny CHOPOT's avatar Fanny CHOPOT
Browse files

un premier code

parent ee48e5b5
Branches
Tags
No related merge requests found
...@@ -76,7 +76,7 @@ private: ...@@ -76,7 +76,7 @@ private:
Kokkos::View<Rd**> // Fonction qui calcule F_jr Kokkos::View<Rd**> // Fonction qui calcule F_jr
computeFjr(const Kokkos::View<const Rd**>& Cjr, computeFjr(const Kokkos::View<const Rd**>& Cjr,
const Kokkos::View<const Rd*>& uj, const Kokkos::View<const Rd*>& uj,
const Kokkos::View<const double*>& Vj, const Kokkos::View<const Rd*>& xr,
const Kokkos::View<const double*>& kj) { const Kokkos::View<const double*>& kj) {
const Kokkos::View<const unsigned int**>& cell_nodes = m_connectivity.cellNodes(); const Kokkos::View<const unsigned int**>& cell_nodes = m_connectivity.cellNodes();
const Kokkos::View<const unsigned short*> cell_nb_nodes const Kokkos::View<const unsigned short*> cell_nb_nodes
...@@ -84,7 +84,7 @@ private: ...@@ -84,7 +84,7 @@ private:
Kokkos::parallel_for(m_mesh.numberOfCells(), KOKKOS_LAMBDA(const int& j) { Kokkos::parallel_for(m_mesh.numberOfCells(), KOKKOS_LAMBDA(const int& j) {
for (int r=0; r<cell_nb_nodes[j]; ++r) { for (int r=0; r<cell_nb_nodes[j]; ++r) {
m_Fjr(j,r) = ((kj(j,r) + kj(j,r-1))/(2*Vj(j)))*(uj(j,r)*Cjr(j,r) + uj(j,r-1)*Cjr(j,r-1)); m_Fjr(j,r) = ((kj(cell_nodes(j,r)) + kj(cell_nodes(j,r)-1))/(2*(xj(cell_nodes(j,r))-xj(cell_nodes(j,r)-1))))*uj(j,r)*Cjr(j,r);
} }
}); });
...@@ -93,14 +93,14 @@ private: ...@@ -93,14 +93,14 @@ private:
Kokkos::View<Rd**> // Fonction qui calcule G_jr Kokkos::View<Rd**> // Fonction qui calcule G_jr
computeGjr(const Kokkos::View<const Rd*>& uj, computeGjr(const Kokkos::View<const Rd*>& uj,
const Kokkos::View<const double*>& Fjr, { const Kokkos::View<const double*>& Fjr) {
const Kokkos::View<const unsigned int**>& cell_nodes = m_connectivity.cellNodes(); const Kokkos::View<const unsigned int**>& cell_nodes = m_connectivity.cellNodes();
const Kokkos::View<const unsigned short*> cell_nb_nodes const Kokkos::View<const unsigned short*> cell_nb_nodes
= m_connectivity.cellNbNodes(); = m_connectivity.cellNbNodes();
Kokkos::parallel_for(m_mesh.numberOfCells(), KOKKOS_LAMBDA(const int& j) { Kokkos::parallel_for(m_mesh.numberOfCells(), KOKKOS_LAMBDA(const int& j) {
for (int r=0; r<cell_nb_nodes[j]; ++r) { for (int r=0; r<cell_nb_nodes[j]; ++r) {
m_Gjr(j,r) = ((ujr(j,r) + ujr(j,r-1))/2)*Fjr(j,r); m_Gjr(j,r) = ((uj(cell_nodes(j,r)) + uj(cell_nodes(j,r)-1))/2)*Fjr(j,r);
} }
}); });
...@@ -125,7 +125,7 @@ private: ...@@ -125,7 +125,7 @@ private:
} }
// Enchaine les operations pour calculer les flux (Fjr et ur) pour // A MODIFIER // Enchaine les operations pour calculer les flux (Fjr et Gjr) pour
// pouvoir derouler le schema // pouvoir derouler le schema
KOKKOS_INLINE_FUNCTION KOKKOS_INLINE_FUNCTION
void computeExplicitFluxes(const Kokkos::View<const Rd*>& xr, void computeExplicitFluxes(const Kokkos::View<const Rd*>& xr,
...@@ -134,7 +134,7 @@ private: ...@@ -134,7 +134,7 @@ private:
const Kokkos::View<const Rd*>& uj, const Kokkos::View<const Rd*>& uj,
const Kokkos::View<const Rd**>& Cjr) { const Kokkos::View<const Rd**>& Cjr) {
Kokkos::View<Rd**> Fjr = m_Fjr; Kokkos::View<Rd**> Fjr = m_Fjr;
Fjr = computeFjr(Cjr, uj, xj,kj); Fjr = computeFjr(Cjr, uj, xr, kj);
Kokkos::View<Rd**> Gjr = m_Gjr; Kokkos::View<Rd**> Gjr = m_Gjr;
Gjr = computeGjr(uj, Fjr); Gjr = computeGjr(uj, Fjr);
} }
...@@ -157,11 +157,14 @@ public: ...@@ -157,11 +157,14 @@ public:
// Calcule une evaluation du pas de temps verifiant le CFL parabolique // Calcule une evaluation du pas de temps verifiant le CFL parabolique
// Utilise la reduction definie dans la structure ReduceMin. Ici, dx_j=V_j // Utilise la reduction definie dans la structure ReduceMin. Ici, dx_j=V_j
KOKKOS_INLINE_FUNCTION KOKKOS_INLINE_FUNCTION
double diffusion_dt(const Kokkos::View<const double*>& Vj) const { double diffusion_dt(const Kokkos::View<const double*>& Vj,
const Kokkos::View<const double*>& rhoj,
const Kokkos::View<const Rd*>& xr,
const Kokkos::View<const Rd*>& kj) const {
Kokkos::View<double*> dt_j("dt_j", m_mesh.numberOfCells()); Kokkos::View<double*> dt_j("dt_j", m_mesh.numberOfCells());
Kokkos::parallel_for(m_mesh.numberOfCells(), KOKKOS_LAMBDA(const int& j){ Kokkos::parallel_for(m_mesh.numberOfCells(), KOKKOS_LAMBDA(const int& j){
m_CFL[j] = rhoj[j]*(xr(r); // La tu mets la formule pour chaque maille // CONFUSION j et r !!! m_CFL(j) = rhoj(j)*Vj(j)*min(xj(j+1)-xj(j), xj(j)-xj(j-1))*(2./(kj(j+1) + 2*kj(j) + kj(j-1)));
}); });
double dt = std::numeric_limits<double>::max(); double dt = std::numeric_limits<double>::max();
...@@ -187,7 +190,7 @@ public: ...@@ -187,7 +190,7 @@ public:
Kokkos::View<Rd*> xr = m_mesh.xr(); Kokkos::View<Rd*> xr = m_mesh.xr();
// Calcule les flux // Calcule les flux
computeExplicitFluxes(xr, xj, rhoj, uj, Vj, Cjr); computeExplicitFluxes(xr, xj, rhoj, uj, Cjr);
const Kokkos::View<const Rd**> Fjr = m_Fjr; const Kokkos::View<const Rd**> Fjr = m_Fjr;
const Kokkos::View<const unsigned short*> cell_nb_nodes const Kokkos::View<const unsigned short*> cell_nb_nodes
...@@ -203,7 +206,7 @@ public: ...@@ -203,7 +206,7 @@ public:
for (int R=0; R<cell_nb_nodes[j]; ++R) { for (int R=0; R<cell_nb_nodes[j]; ++R) {
const int r=cell_nodes(j,R); const int r=cell_nodes(j,R);
momentum_fluxes += Fjr(j,R); momentum_fluxes += Fjr(j,R);
energy_fluxes += (Fjr(j,R), ur[r]); energy_fluxes += Gjr(j,R);
} }
uj[j] -= (dt*inv_mj[j]) * momentum_fluxes; uj[j] -= (dt*inv_mj[j]) * momentum_fluxes;
Ej[j] -= (dt*inv_mj[j]) * energy_fluxes; Ej[j] -= (dt*inv_mj[j]) * energy_fluxes;
...@@ -214,6 +217,9 @@ public: ...@@ -214,6 +217,9 @@ public:
ej[j] = Ej[j] - 0.5 * (uj[j],uj[j]); ej[j] = Ej[j] - 0.5 * (uj[j],uj[j]);
}); });
// met a jour les quantites (geometriques) associees au maillage
m_mesh_data.updateAllData();
// Calcul de rho avec la formule Mj = Vj rhoj // Calcul de rho avec la formule Mj = Vj rhoj
const Kokkos::View<const double*> mj = unknowns.mj(); const Kokkos::View<const double*> mj = unknowns.mj();
Kokkos::parallel_for(m_mesh.numberOfCells(), KOKKOS_LAMBDA(const int& j){ Kokkos::parallel_for(m_mesh.numberOfCells(), KOKKOS_LAMBDA(const int& j){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment