Peano
Loading...
Searching...
No Matches
ErrorMeasurement.py
Go to the documentation of this file.
1# This file is part of the Peano project. For conditions of distribution and
2# use, please see the copyright notice at www.peano-framework.org
5 create_finish_time_step_implementation_for_error_measurement,
6)
7
8from exahype2.solvers.PDETerms import PDETerms
9
10from exahype2.solvers.fv.actionsets import VolumeWisePostprocessSolution
11
12
15 self,
16 solver,
17 error_measurement_implementation=PDETerms.User_Defined_Implementation,
18 delta_between_database_flushes=0,
19 output_file_name="FVErrorMeasurement",
20 data_delta_between_snapshots="1e+16",
21 time_delta_between_snapshots=0.0,
22 clear_database_after_flush=True,
23 ):
24 super(ErrorMeasurement, self).__init__(
25 solver=solver,
26 error_measurement_implementation=error_measurement_implementation,
27 delta_between_database_flushes=delta_between_database_flushes,
28 output_file_name=output_file_name,
29 data_delta_between_snapshots=data_delta_between_snapshots,
30 time_delta_between_snapshots=time_delta_between_snapshots,
31 clear_database_after_flush=clear_database_after_flush,
32 )
33
34 solver._finish_time_step_implementation += create_finish_time_step_implementation_for_error_measurement(
35 guard="_solverState == SolverState::GridInitialisation or (_solverState == SolverState::TimeStep and isLastGridSweepOfTimeStep())"
36 )
37
38 solver._action_set_postprocess_solution = VolumeWisePostprocessSolution(solver)
39 solver._action_set_postprocess_solution.guard = """
40 (repositories::{{SOLVER_INSTANCE}}.getSolverState() == {{SOLVER_NAME}}::SolverState::GridInitialisation or
41 repositories::{{SOLVER_INSTANCE}}.isLastGridSweepOfTimeStep())"""
42 solver._action_set_postprocess_solution.add_postprocessing_kernel(
43 create_postprocessing_kernel_for_error_measurement()
44 )
45
46
48 return """
49 double errors[3] = {0.0, 0.0, 0.0};
50 double solution[{{NUMBER_OF_UNKNOWNS}}];
51
52 #if Dimensions==2
53 const double cellVolume = volumeH[0] * volumeH[1];
54 #else
55 const double cellVolume = volumeH[0] * volumeH[1] * volumeH[2];
56 #endif
57
58 repositories::{{SOLVER_INSTANCE}}.analyticalSolution(
59 volumeX,
60 timeStamp,
61 timeStepSize,
62 value,
63 solution
64 );
65
66 for (int unknown = 0; unknown < {{NUMBER_OF_UNKNOWNS}}; unknown++) {
67 double error = std::abs(value[unknown] - solution[unknown]);
68 errors[0] += cellVolume * error; // L1 norm
69 errors[1] += cellVolume * error * error; // L2 norm
70 errors[2] = std::max(errors[2], error); // L_inf norm
71 }
72
73 repositories::{{SOLVER_INSTANCE}}.setError(errors);
74"""
Error measurement tool for ExaHyPE 2 solvers, this is the base class that must be specialised for dif...
__init__(self, solver, error_measurement_implementation, delta_between_database_flushes, output_file_name, data_delta_between_snapshots, time_delta_between_snapshots, clear_database_after_flush)