Skip to content
Snippets Groups Projects
Commit 11eec7ce authored by Reichelt, Michael's avatar Reichelt, Michael
Browse files

Bug found, L2 error calculation working

The problem was an temporary r-value, for which the memory got "stolen" by mfem. So the reference was reset which hindered the mfem VectorFunctionCoefficiente Evaluation process..
parent 17981641
No related branches found
No related tags found
No related merge requests found
......@@ -119,6 +119,25 @@ TEST_CASE("Time Dependent Gridfunction", "[time_dependent_gridfunction]") {
double const eoc = std::log2(error/error2);
REQUIRE_THAT(eoc, Catch::Matchers::WithinAbs(order+1., 0.1));
}
SECTION("Second Order"){
int order = 2;
mfem::H1_FECollection fec_x(order, mesh_x.Dimension());
mfem::H1_FECollection fec_t(order, mesh_t.Dimension());
mfem::FiniteElementSpace X(&mesh_x, &fec_x, vdim);
mfem::FiniteElementSpace T(&mesh_t, &fec_t);
vtint::time_dependent_gridfunction_t u_gf1(T, X, u_analytical_vectorial);
double const error = u_gf1.l2_error(u_analytical_vectorial);
//write to file to see if it is reasonable
//u_gf1.save_as_vtk("first_order_vectorial", 0.05);
mesh_t.UniformRefinement();
mesh_x.UniformRefinement();
mfem::FiniteElementSpace X2(&mesh_x, &fec_x, vdim);
mfem::FiniteElementSpace T2(&mesh_t, &fec_t);
vtint::time_dependent_gridfunction_t u_gf2(T2, X2, u_analytical_vectorial);
double const error2 = u_gf2.l2_error(u_analytical_vectorial);
double const eoc = std::log2(error/error2);
REQUIRE_THAT(eoc, Catch::Matchers::WithinAbs(order+1., 0.1));
}
}
}SECTION("H1-L2 seminorm error (i.e. in H^1(0,T;L^2(\\Omega))") {
SECTION("First order") {
......
......@@ -250,7 +250,8 @@ namespace vtint {
mfem::GridFunction spatial_gridfunction = this->spatial_gridfunction_for_time(t);
auto u_analytical_for_time = [u_analytical, t, vdim](const mfem::Vector &x, mfem::Vector & res){
res.SetSize(vdim);
res = u_analytical(t, x);
mfem::Vector const u_tmp = u_analytical(t, x); //we have to do that, otherwise it will be a "stealing copy" from an r-value, which leads to mfem problems...
res = u_tmp;
std::cout << "t: " << t << "\n";
std::cout << "x: " << "\n";
x.Print(std::cout);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment