Commit 9d2286ac authored by Anne Reinarz's avatar Anne Reinarz

fixed constraints writer

parent caa9793b
Pipeline #171866 passed with stage
......@@ -10,23 +10,25 @@
"architecture": "noarch",
"computational_domain": {
"dimension": 3,
"end_time": 101.0,
"outside_cells_left": 0,
"outside_cells_right": 0,
"end_time": 1001.0,
"offset": [
-15.0,
-15.0,
-15.0
-45.0,
-45.0,
-45.0
],
"width": [
30.0,
30.0,
30.0
90.0,
90.0,
90.0
]
},
"shared_memory": {
"cores": 10,
"cores": 70,
"properties_file": "sharedmemory.properties",
"autotuning_strategy": "dummy",
"background_job_consumers": 9
"background_job_consumers": 69
},
"distributed_memory": {
"timeout": 6000,
......@@ -54,8 +56,8 @@
"type": "Limiting-ADER-DG",
"name": "FOCCZ4Solver",
"order": 3,
"maximum_mesh_size": 2.0,
"maximum_mesh_depth": 0,
"maximum_mesh_size": 15.0,
"maximum_mesh_depth": 2,
"time_stepping": "global",
"aderdg_kernel": {
"language": "C",
......@@ -88,7 +90,7 @@
"source"
],
"scheme": "musclhancock",
"slope_limiter" : "minmod",
"slope_limiter" : "mclim",
"implementation": "generic"
},
......@@ -193,7 +195,7 @@
"type": "user::defined",
"name": "TecplotWriter",
"time": 0.0,
"repeat": 1.0,
"repeat": 10.0,
"output": "./output/tecplot",
"variables": 96
},
......@@ -206,7 +208,7 @@
"output": "./output/adm-integrals"
},
{
"type": "vtk::Legendre::vertices::ascii",
"type": "user::defined",
"name": "ConstraintsWriter",
"variables": 6,
"time": 0.0,
......@@ -217,7 +219,7 @@
"type": "probe::ascii",
"name": "CentralDensity",
"time": 0.0,
"repeat": 0.001,
"repeat": 0.1,
"output": "./output/rho",
"variables": 1,
"select": {
......
......@@ -6,40 +6,68 @@
// www.exahype.eu
// ========================
#include "ConstraintsWriter.h"
#include "PDE.h"
FOCCZ4::ConstraintsWriter::ConstraintsWriter(FOCCZ4::FOCCZ4Solver& solver) {
// @TODO Please insert your code here.
}
#include "kernels/GaussLegendreBasis.h"
#include "kernels/KernelUtils.h"
FOCCZ4::ConstraintsWriter::~ConstraintsWriter() {
}
#include "PDE.h" // ADMConstraints()
#include "kernels/aderdg/generic/c/computeGradients.cpph"
void FOCCZ4::ConstraintsWriter::startPlotting( double time) {
// @TODO Please insert your code here.
}
using namespace kernels;
using namespace exahype::plotters::ascii;
void FOCCZ4::ConstraintsWriter::finishPlotting() {
// @TODO Please insert your code here.
FOCCZ4::ConstraintsWriter::ConstraintsWriter() :
exahype::plotters::ADERDG2UserDefined::ADERDG2UserDefined(),
constraintReductions("output/constraint-", ".asc", exahype::plotters::ascii::parallel::postprocess)
{
constraintReductions.add(0, "hamiltonian");
constraintReductions.add(1, "momentum1");
constraintReductions.add(2, "momentum2");
constraintReductions.add(3, "momentum3");
constraintReductions.add(4, "det1");
constraintReductions.add(5, "traceA");
}
void FOCCZ4::ConstraintsWriter::mapQuantities(
void FOCCZ4::ConstraintsWriter::plotPatch(
const tarch::la::Vector<DIMENSIONS, double>& offsetOfPatch,
const tarch::la::Vector<DIMENSIONS, double>& sizeOfPatch,
const tarch::la::Vector<DIMENSIONS, double>& x,
const tarch::la::Vector<DIMENSIONS, int>& pos,
double* const Q, double* gradQ,
double* const outputQuantities,
double timeStamp
) {
static constexpr int writtenUnknowns = 6;
for(int i=0; i<59; i++) { if(Q[i]!=Q[i]) std::abort(); }
const tarch::la::Vector<DIMENSIONS, double>& dx, // sizeOfPatch
double* u,
double timeStamp) {
double gradQ[basisSize3 * DIMENSIONS * numberOfVariables];
admconstraints_(outputQuantities, Q, gradQ);
kernels::aderdg::generic::c::computeGradQ<FOCCZ4::AbstractFOCCZ4Solver_ADERDG>(gradQ, u, dx);
// volume form for integration
double scaling = tarch::la::volume(dx);
double wx, wy, wz, constraints[6]; // 6 constraints!
idx5 idx_gradQ(basisSize, basisSize, basisSize, DIMENSIONS, numberOfVariables);
idx4 idx_u(basisSize, basisSize, basisSize, numberOfVariables);
for(int i=0; i<6; i++) { if(outputQuantities[i]!=outputQuantities[i]) std::abort(); }
for (int iz = 0; iz < basisSize; iz++) {
for (int iy = 0; iy < basisSize; iy++) {
for (int ix = 0; ix < basisSize; ix++) {
// Gauss-Legendre weights from pos argument
wx = kernels::legendre::weights[FOCCZ4::AbstractFOCCZ4Solver_ADERDG::Order][ix];
wy = kernels::legendre::weights[FOCCZ4::AbstractFOCCZ4Solver_ADERDG::Order][iy];
wz = kernels::legendre::weights[FOCCZ4::AbstractFOCCZ4Solver_ADERDG::Order][iz];
admconstraints_(constraints, &u[idx_u(iz,iy,ix,0)], &gradQ[idx_gradQ(iz,iy,ix,0,0)]);
constraintReductions.addValue(constraints, scaling*wx*wy*wz);
} // x
} // y
} // z
}
void FOCCZ4::ConstraintsWriter::startPlotting( double time) {
constraintReductions.startRow(time);
}
void FOCCZ4::ConstraintsWriter::finishPlotting() {
constraintReductions.finishRow();
}
......@@ -4,34 +4,77 @@
// ========================
// www.exahype.eu
// ========================
#ifndef POSTPROCESSING_ConstraintsWriter_CLASS_HEADER_
#define POSTPROCESSING_ConstraintsWriter_CLASS_HEADER_
#ifndef ConstraintsWriter_CLASS_HEADER_
#define ConstraintsWriter_CLASS_HEADER_
#include "exahype/plotters/Plotter.h"
#include "exahype/plotters/ADERDG2UserDefined.h"
#include "exahype/plotters/ascii/MultipleReductionsWriter.h"
#include "AbstractFOCCZ4Solver_ADERDG.h"
namespace FOCCZ4 {
class FOCCZ4Solver;
class ConstraintsWriter;
}
class FOCCZ4::ConstraintsWriter : public exahype::plotters::Plotter::UserOnTheFlyPostProcessing {
public:
ConstraintsWriter(FOCCZ4::FOCCZ4Solver& solver);
virtual ~ConstraintsWriter();
/**
* The ConstraintsWriter for all primarily ADERDG applications:
* * The LimitingADERDGSolver
* * The ADERDGSolver
**/
class FOCCZ4::ConstraintsWriter : public exahype::plotters::ADERDG2UserDefined {
public:
/** Z4 custom start */
static constexpr int numberOfVariables = FOCCZ4::AbstractFOCCZ4Solver_ADERDG::NumberOfVariables;
static constexpr int order = FOCCZ4::AbstractFOCCZ4Solver_ADERDG::Order;
static constexpr int basisSize = order + 1;
static constexpr int basisSize3 = basisSize*basisSize*basisSize;
exahype::plotters::ascii::MultipleReductionsWriter constraintReductions;
/** Z4 custom end */
/**
* Constructor.
*
* \note ExaHyPE does not increment file counters for
* you if you use user defined plotting. You have
* to declare and manage such member variables yourself.
*/
ConstraintsWriter();
/**
* This method is invoked every time a cell
* is touched by the plotting device.
*
* \note Use the protected variables _order, _variables to
* determine the size of u.
* The array u has the size _variables * (_order+1)^DIMENSIONS.
*
* @param[in] offsetOfPatch the offset of the cell/patch.
* @param[in] sizeOfPatch the offset of the cell/patch.
* @param[in] u the degrees of freedom "living" inside of the patch.
*/
void plotPatch(
const tarch::la::Vector<DIMENSIONS, double>& offsetOfPatch,
const tarch::la::Vector<DIMENSIONS, double>& sizeOfPatch, double* u,
double timeStamp) override;
void startPlotting(double time) override;
/**
* This method is called at the beginning of the plotting.
* You can use it to reset member variables, e.g., those
* used for calculations, or to increment file counters.
*
* @param[in] time a characteristic solver time stamp.
* Usually the global minimum.
*/
void startPlotting( double time) override;
/**
* This method is called at the end of the plotting.
* You can use it to reset member variables, finalise calculations (compute square roots etc.),
* or to increment file counters
*/
void finishPlotting() override;
bool mapWithDerivatives() override {
return true;
}
void mapQuantities(
const tarch::la::Vector<DIMENSIONS, double>& offsetOfPatch,
const tarch::la::Vector<DIMENSIONS, double>& sizeOfPatch,
const tarch::la::Vector<DIMENSIONS, double>& x,
const tarch::la::Vector<DIMENSIONS, int>& pos,
double* const Q, double* gradQ,
double* const outputQuantities,
double timeStamp) override;
};
#endif /* POSTPROCESSING_ConstraintsWriter_CLASS_HEADER_ */
#endif /* ConstraintsWriter_CLASS_HEADER_ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment