Dear all,
I want to compute the L2-norm for a large number of scalar history-variables. The solution vectors for all of them are stored in the following container: "std::vector<Vector<double>>(num_of_history_variables)".
So far I called integrate_difference "
num_of_history_variables" times, which is quite time consuming. Thus, I´d like to compute the L2-norm by myself to get a second time measurement and may save in the first call some time reducing information which integrate_differnce doesn´t provide for subsequent calls.
In order to do so, I compared for a arbitrary history variable the vector of cell errors, calculated from integrate_differnce, with those cell errors of my own implementation. Unfortunately I don´t come up with the same cell error(s).
In the following is a snippet of my code, some remarks for a better understanding:
(I access my history variables via a CellDataStorage object. The Variable "comp_0" is the value at the QP of my current mesh, the variable "comp_0_ref" is the corresponding value of the reference solution on the same QP).
------------------------------------------------------------------------------------------------
Functions::FEFieldFunction<dim> fe_field(dof_handler_scalar_ar, reference_solution_n[0]);
cell=dof_handler_scalar.begin_active();
for(; cell!=endc; cell++)
{
fe_values.reinit(cell);
std::vector<std::shared_ptr<PointHistory<dim>>> lqph = quadrature_point_history.get_data(cell);
double error_cell=0;
for(unsigned int q=0; q<qf_cell.size(); q++)
{
const double JxW = fe_values.JxW(q);
Vector<double> projection_variables = lqph[q]->create_vector_for_projection();
double comp_0 = projection_variables(0);
error_cell += ((comp_0 - comp_0_ref)*(comp_0 - comp_0_ref)*JxW);
}
std::cout<<"Local cell error: "<<std::sqrt(error_cell)<<" , ";
}
------------------------------------------------------------------------------------------
I had a look in the implementation of the integrate_difference function with case == L2 as well.
However I could not identify any differences to my own implementation.
My question is if there is a mistake in my code snippet, i.e in the way how I calculate the integrals for the cell errors?
On each cell, I basically multiply the squared abs-value of the difference with the JxW-Value, sum those values up and finally take the square root.
Thanks in advance for helping!
Best
Simon