Skip to content
Snippets Groups Projects
Commit 0591b2e2 authored by Dr. Felix Tobias Schindler's avatar Dr. Felix Tobias Schindler
Browse files

[examples.elliptic.discretizations] added hi error to CG

parent 50869b56
No related branches found
No related tags found
No related merge requests found
...@@ -89,16 +89,21 @@ public: ...@@ -89,16 +89,21 @@ public:
{ {
using namespace Dune; using namespace Dune;
using namespace Dune::GDT; using namespace Dune::GDT;
// checks
static_assert(std::is_base_of<Stuff::LocalizableFunction, ReferenceSolutionType>::value, static_assert(std::is_base_of<Stuff::LocalizableFunction, ReferenceSolutionType>::value,
"ReferenceSolutionType has to be derived from Stuff::LocalizableFunction!"); "ReferenceSolutionType has to be derived from Stuff::LocalizableFunction!");
static_assert(std::is_base_of<Stuff::LocalizableFunction, DiscreteSolutionType>::value, static_assert(std::is_base_of<Stuff::LocalizableFunction, DiscreteSolutionType>::value,
"ReferenceSolutionType has to be derived from Stuff::LocalizableFunction!"); "ReferenceSolutionType has to be derived from Stuff::LocalizableFunction!");
// difference
typedef DiscreteFunction::Difference<ReferenceSolutionType, DiscreteSolutionType> DifferenceType; typedef DiscreteFunction::Difference<ReferenceSolutionType, DiscreteSolutionType> DifferenceType;
const DifferenceType difference(referencec_solution, discrete_solution); const DifferenceType difference(referencec_solution, discrete_solution);
// L2 error
ProductOperator::L2<GridPartType> l2_product_operator(grid_part_); ProductOperator::L2<GridPartType> l2_product_operator(grid_part_);
const RangeFieldType l2_error = std::sqrt(l2_product_operator.apply2(difference, difference)); const RangeFieldType l2_error = std::sqrt(l2_product_operator.apply2(difference, difference));
return {l2_error}; // H1 error
ProductOperator::H1<GridPartType> h1_product_operator(grid_part_);
const RangeFieldType h1_error = std::sqrt(h1_product_operator.apply2(difference, difference));
return {l2_error, h1_error};
} }
private: private:
...@@ -135,6 +140,11 @@ public: ...@@ -135,6 +140,11 @@ public:
{ {
} }
const SpaceType& space() const
{
return space_;
}
std::shared_ptr<DiscreteFunctionType> solve() const std::shared_ptr<DiscreteFunctionType> solve() const
{ {
using namespace Dune; using namespace Dune;
...@@ -164,7 +174,7 @@ public: ...@@ -164,7 +174,7 @@ public:
// * dirichlet boundary values // * dirichlet boundary values
DiscreteFunctionType dirichlet_projection(space_, dirichlet_vector, "dirichlet"); DiscreteFunctionType dirichlet_projection(space_, dirichlet_vector, "dirichlet");
typedef Operator::DirichletProjection<FunctionType, DiscreteFunctionType> DirichletProjectionOperatorType; typedef ProjectionOperator::Dirichlet<FunctionType, DiscreteFunctionType> DirichletProjectionOperatorType;
const DirichletProjectionOperatorType dirichlet_projection_operator(BaseType::boundary_info()); const DirichletProjectionOperatorType dirichlet_projection_operator(BaseType::boundary_info());
dirichlet_projection_operator.apply(BaseType::dirichlet(), dirichlet_projection); dirichlet_projection_operator.apply(BaseType::dirichlet(), dirichlet_projection);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment