Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions test/MHD/OrszagTang/idefix-hll.ini
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ X2-beg periodic
X2-end periodic

[Output]
vtk 0.5
dmp 0.5
log 100
analysis 0.1
vtk 0.5
dmp 0.5
log 100
7 changes: 4 additions & 3 deletions test/MHD/OrszagTang/idefix-hlld-arithmetic.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ X2-beg periodic
X2-end periodic

[Output]
vtk 0.5
dmp 0.5
log 100
analysis 0.1
vtk 0.5
dmp 0.5
log 100
7 changes: 4 additions & 3 deletions test/MHD/OrszagTang/idefix-hlld-hll.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ X2-beg periodic
X2-end periodic

[Output]
vtk 0.5
dmp 0.5
log 100
analysis 0.1
vtk 0.5
dmp 0.5
log 100
7 changes: 4 additions & 3 deletions test/MHD/OrszagTang/idefix-hlld-hlld.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ X2-beg periodic
X2-end periodic

[Output]
vtk 0.5
dmp 0.5
log 100
analysis 0.1
vtk 0.5
dmp 0.5
log 100
7 changes: 4 additions & 3 deletions test/MHD/OrszagTang/idefix-hlld-uct0.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ X2-beg periodic
X2-end periodic

[Output]
vtk 0.5
dmp 0.5
log 100
analysis 0.1
vtk 0.5
dmp 0.5
log 100
7 changes: 4 additions & 3 deletions test/MHD/OrszagTang/idefix-hlld.ini
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ X2-beg periodic
X2-end periodic

[Output]
vtk 0.5
dmp 0.5
log 100
analysis 0.1
vtk 0.5
dmp 0.5
log 100
7 changes: 4 additions & 3 deletions test/MHD/OrszagTang/idefix-tvdlf.ini
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ X2-beg periodic
X2-end periodic

[Output]
vtk 0.5
dmp 0.5
log 100
analysis 0.1
vtk 0.5
dmp 0.5
log 100
7 changes: 4 additions & 3 deletions test/MHD/OrszagTang/idefix.ini
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ X2-beg periodic
X2-end periodic

[Output]
vtk 0.5
dmp 0.5
log 100
analysis 0.1
vtk 0.5
dmp 0.5
log 100
44 changes: 42 additions & 2 deletions test/MHD/OrszagTang/setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,53 @@ generators on different architectures.
**/
/*********************************************/


void CheckConservation(DataBlock &data) {
static real firstCall{true};
static std::array<real,DefaultPhysics::nvar> consArray;
data.hydro->ConvertPrimToCons();
auto Uc = data.hydro->Uc;
auto dV = data.dV;
//idfx::cout << "Analysis: checking conserved quantities..." << std::endl;
#ifdef SINGLE_PRECISION
const real threshold = 1e-4;
#else
const real threshold = 1e-13;
#endif
for(int nv = 0 ; nv < DefaultPhysics::nvar ; nv++) {
real cons = 0;
idefix_reduce("Conserved quantity reduction",
data.beg[KDIR], data.end[KDIR],
data.beg[JDIR], data.end[JDIR],
data.beg[IDIR], data.end[IDIR],
KOKKOS_LAMBDA (int k, int j, int i, real &c) {
c += dV(k,j,i)*Uc(nv,k,j,i);
},
Kokkos::Sum<real>(cons));
#ifdef WITH_MPI
MPI_Allreduce(MPI_IN_PLACE, &cons, 1, realMPI, MPI_SUM, MPI_COMM_WORLD);
#endif
if(firstCall) {
consArray[nv] = cons;
} else {
real err = std::fabs((consArray[nv]-cons));
if(err>threshold) {
std::stringstream str;
str << "Quantity " << data.hydro->VcName[nv] << " is not conserved" << std::endl;
std::cout << "Error on " << data.hydro->VcName[nv] << " is " << err << std::endl;
std::cout << "Original=" << consArray[nv] << " New=" << cons << std::endl;
IDEFIX_ERROR(str);
}
}
}
firstCall=false;
//idfx::cout << "Analysis: done." << std::endl;
}
// Default constructor

// Initialisation routine. Can be used to allocate
// Arrays or variables which are used later on
Setup::Setup(Input &input, Grid &grid, DataBlock &data, Output &output) {

output.EnrollAnalysis(&CheckConservation);
}

// This routine initialize the flow
Expand Down
7 changes: 4 additions & 3 deletions test/MHD/OrszagTang3D/idefix.ini
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ X3-beg periodic
X3-end periodic

[Output]
vtk 0.2
dmp 0.2
log 10
vtk 0.2
dmp 0.2
log 10
analysis 0.1
44 changes: 43 additions & 1 deletion test/MHD/OrszagTang3D/setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,53 @@ generators on different architectures.

Output* myOutput;
int outnum;
// Analysis function

void CheckConservation(DataBlock &data) {
static real firstCall{true};
static std::array<real,DefaultPhysics::nvar> consArray;
data.hydro->ConvertPrimToCons();
auto Uc = data.hydro->Uc;
auto dV = data.dV;
//idfx::cout << "Analysis: checking conserved quantities..." << std::endl;
#ifdef SINGLE_PRECISION
const real threshold = 2e-4;
#else
const real threshold = 1e-13;
#endif
for(int nv = 0 ; nv < DefaultPhysics::nvar ; nv++) {
real cons = 0;
idefix_reduce("Conserved quantity reduction",
data.beg[KDIR], data.end[KDIR],
data.beg[JDIR], data.end[JDIR],
data.beg[IDIR], data.end[IDIR],
KOKKOS_LAMBDA (int k, int j, int i, real &c) {
c += dV(k,j,i)*Uc(nv,k,j,i);
},
Kokkos::Sum<real>(cons));
#ifdef WITH_MPI
MPI_Allreduce(MPI_IN_PLACE, &cons, 1, realMPI, MPI_SUM, MPI_COMM_WORLD);
#endif
if(firstCall) {
consArray[nv] = cons;
} else {
real err = std::fabs((consArray[nv]-cons));
if(err>threshold) {
std::stringstream str;
str << "Quantity " << data.hydro->VcName[nv] << " is not conserved" << std::endl;
std::cout << "Error on " << data.hydro->VcName[nv] << " is " << err << std::endl;
std::cout << "Original=" << consArray[nv] << " New=" << cons << std::endl;
IDEFIX_ERROR(str);
}
}
}
firstCall=false;
//idfx::cout << "Analysis: done." << std::endl;
}

// Initialisation routine. Can be used to allocate
// Arrays or variables which are used later on
Setup::Setup(Input &input, Grid &grid, DataBlock &data, Output &output) {
output.EnrollAnalysis(&CheckConservation);
}

// This routine initialize the flow
Expand Down
Loading