16 #ifndef __H2D_ERROR_CALCULATOR_H
17 #define __H2D_ERROR_CALCULATOR_H
19 #include "../weakform/weakform.h"
21 #include "error_thread_calculator.h"
33 RelativeErrorToElementNorm,
34 RelativeErrorToGlobalNorm
40 template<
typename Scalar>
41 class HERMES_API ErrorCalculator :
42 public Hermes::Mixins::TimeMeasurable,
43 public Hermes::Mixins::Loggable,
45 public Hermes::Mixins::StateQueryable
55 void calculate_errors(std::vector<MeshFunctionSharedPtr<Scalar> > coarse_solutions, std::vector<MeshFunctionSharedPtr<Scalar> > fine_solutions,
bool sort_and_store =
true);
59 void calculate_errors(MeshFunctionSharedPtr<Scalar> coarse_solution, MeshFunctionSharedPtr<Scalar> fine_solution,
bool sort_and_store =
true);
62 virtual ~ErrorCalculator();
66 void add_error_form(NormFormVol<Scalar>* form);
67 void add_error_form(NormFormSurf<Scalar>* form);
68 void add_error_form(NormFormDG<Scalar>* form);
74 double get_element_error_squared(
int component,
int element_id)
const;
75 double get_element_norm_squared(
int component,
int element_id)
const;
76 double get_error_squared(
int component)
const;
77 double get_norm_squared(
int component)
const;
78 double get_total_error_squared()
const;
79 double get_total_norm_squared()
const;
81 int get_component_count()
const {
return this->component_count; }
87 ElementReference(
int comp,
int element_id,
double*
error,
double* norm) : element_id(element_id), comp(comp), error(error), norm(norm) {};
111 virtual bool isOkay()
const;
112 inline std::string getClassName()
const {
return "ErrorCalculator"; }
115 bool data_prepared_for_querying()
const;
118 void init_data_storage();
122 void postprocess_error();
126 std::vector<MeshFunctionSharedPtr<Scalar> > fine_solutions;
141 double* errors[H2D_MAX_COMPONENTS];
142 double* norms[H2D_MAX_COMPONENTS];
143 double component_errors[H2D_MAX_COMPONENTS];
144 double component_norms[H2D_MAX_COMPONENTS];
145 int element_count[H2D_MAX_COMPONENTS];
146 double errors_squared_sum;
147 double norms_squared_sum;
153 std::vector<NormFormVol<Scalar> *>
mfvol;
155 std::vector<NormFormSurf<Scalar> *>
mfsurf;
157 std::vector<NormFormDG<Scalar> *>
mfDG;
162 static int compareElementReference(
const void * a,
const void * b)
166 if (*((*ref_a).error) > *((*ref_b).error))
172 friend class Adapt < Scalar > ;
176 template<
typename Scalar, NormType normType>
184 template<
typename Scalar, NormType normType>
std::vector< NormFormDG< Scalar > * > mfDG
Holds DG matrix forms.
ElementReference * element_references
A queue of elements which should be processes. The queue had to be filled by the method fill_regular_...
Class utilizes parallel calculation.
A reference to an element.
std::vector< NormFormVol< Scalar > * > mfvol
Holds volumetric matrix forms.
std::vector< NormFormSurf< Scalar > * > mfsurf
Holds surface matrix forms.
CalculatedErrorType errorType
Absolute / Relative error.
int num_act_elems
A total number of active elements across all provided meshes.
bool elements_stored
This is for adaptivity, saying that the errors are the correct ones.
int comp
A component which this element belongs to. Invalid if below 0.
std::vector< MeshFunctionSharedPtr< Scalar > > coarse_solutions
Data.
int component_count
Number of solution components.
CalculatedErrorType
Enum passed to the class ErrorCalculator specifying the calculated errors.
Evaluation of an error between a (coarse) solution and a reference solution.
::xsd::cxx::tree::string< char, simple_type > string
C++ type corresponding to the string XML Schema built-in type.
double * norm
Pointer to the norm.
::xsd::cxx::tree::error< char > error
Error condition.
ElementReference()
Constructor. It creates an invalid element reference.
double * error
Pointer to the final error, respecting the errorType.