Loading...
Searching...
No Matches
ErrorControl.h
// Copyright (C) 2010 Marie E. Rognes
//
// This file is part of DOLFIN.
//
// DOLFIN is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// DOLFIN is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
//
// First added: 2010-08-19
// Last changed: 2012-09-03
#ifndef __ERROR_CONTROL_H
#define __ERROR_CONTROL_H
#include <vector>
#include <memory>
#include <dolfin/common/Hierarchical.h>
#include <dolfin/common/Variable.h>
#include <dolfin/fem/LinearVariationalSolver.h>
#include "adapt.h"
namespace dolfin
{
class DirichletBC;
class Form;
class Function;
class FunctionSpace;
class SpecialFacetFunction;
class Vector;
template <typename T> class MeshFunction;
class ErrorControl : public Hierarchical<ErrorControl>, public Variable
{
public:
ErrorControl(std::shared_ptr<Form> a_star,
std::shared_ptr<Form> L_star,
std::shared_ptr<Form> residual,
std::shared_ptr<Form> a_R_T,
std::shared_ptr<Form> L_R_T,
std::shared_ptr<Form> a_R_dT,
std::shared_ptr<Form> L_R_dT,
std::shared_ptr<Form> eta_T,
bool is_linear);
~ErrorControl() {}
static Parameters default_parameters()
{
Parameters p("error_control");
// Set parameters for dual solver
Parameters p_dual(LinearVariationalSolver::default_parameters());
p_dual.rename("dual_variational_solver");
p.add(p_dual);
return p;
}
double estimate_error(const Function& u,
const std::vector<std::shared_ptr<const DirichletBC> > bcs);
void compute_indicators(MeshFunction<double>& indicators,
const Function& u);
void residual_representation(Function& R_T,
SpecialFacetFunction& R_dT,
const Function& u);
void compute_cell_residual(Function& R_T, const Function& u);
void compute_facet_residual(SpecialFacetFunction& R_dT,
const Function& u,
const Function& R_T);
void compute_dual(Function& z,
const std::vector<std::shared_ptr<const DirichletBC> > bcs);
void compute_extrapolation(const Function& z,
const std::vector<std::shared_ptr<const DirichletBC> > bcs);
friend std::shared_ptr<ErrorControl>
adapt(const ErrorControl& ec,
std::shared_ptr<const Mesh> adapted_mesh,
bool adapt_coefficients);
private:
void apply_bcs_to_extrapolation(const std::vector<std::shared_ptr<const DirichletBC> > bcs);
// Bilinear and linear form for dual problem
std::shared_ptr<Form> _a_star;
std::shared_ptr<Form> _L_star;
// Functional for evaluating residual (error estimate)
std::shared_ptr<Form> _residual;
// Bilinear and linear form for computing cell residual R_T
std::shared_ptr<Form> _a_R_T;
std::shared_ptr<Form> _L_R_T;
// Bilinear and linear form for computing facet residual R_dT
std::shared_ptr<Form> _a_R_dT;
std::shared_ptr<Form> _L_R_dT;
// Linear form for computing error indicators
std::shared_ptr<Form> _eta_T;
// Computed extrapolation
std::shared_ptr<Function> _Ez_h;
bool _is_linear;
// Function spaces for extrapolation, cell bubble and cell cone:
std::shared_ptr<const FunctionSpace> _extrapolation_space;
std::shared_ptr<const FunctionSpace> _bubble_space;
std::shared_ptr<const FunctionSpace> _cone_space;
// Functions for cell bubble, cell cone, computed cell residual,
// computed facet residual, and interpolated extrapolated(!) dual:
std::shared_ptr<Function> _cell_bubble;
std::shared_ptr<Function> _cell_cone;
std::shared_ptr<Function> _R_T;
std::shared_ptr<SpecialFacetFunction> _R_dT;
std::shared_ptr<Function> _Pi_E_z_h;
};
}
#endif
dolfin::DirichletBC
Interface for setting (strong) Dirichlet boundary conditions.
Definition DirichletBC.h:125
dolfin::ErrorControl::estimate_error
double estimate_error(const Function &u, const std::vector< std::shared_ptr< const DirichletBC > > bcs)
Definition ErrorControl.cpp:96
dolfin::ErrorControl::compute_facet_residual
void compute_facet_residual(SpecialFacetFunction &R_dT, const Function &u, const Function &R_T)
Definition ErrorControl.cpp:336
dolfin::ErrorControl::compute_cell_residual
void compute_cell_residual(Function &R_T, const Function &u)
Definition ErrorControl.cpp:260
dolfin::ErrorControl::default_parameters
static Parameters default_parameters()
Default parameter values.
Definition ErrorControl.h:88
dolfin::ErrorControl::compute_extrapolation
void compute_extrapolation(const Function &z, const std::vector< std::shared_ptr< const DirichletBC > > bcs)
Definition ErrorControl.cpp:161
dolfin::ErrorControl::residual_representation
void residual_representation(Function &R_T, SpecialFacetFunction &R_dT, const Function &u)
Definition ErrorControl.cpp:243
dolfin::ErrorControl::adapt
friend std::shared_ptr< ErrorControl > adapt(const ErrorControl &ec, std::shared_ptr< const Mesh > adapted_mesh, bool adapt_coefficients)
dolfin::ErrorControl::~ErrorControl
~ErrorControl()
Destructor.
Definition ErrorControl.h:85
dolfin::ErrorControl::compute_indicators
void compute_indicators(MeshFunction< double > &indicators, const Function &u)
Definition ErrorControl.cpp:176
dolfin::ErrorControl::compute_dual
void compute_dual(Function &z, const std::vector< std::shared_ptr< const DirichletBC > > bcs)
Definition ErrorControl.cpp:130
dolfin::ErrorControl::ErrorControl
ErrorControl(std::shared_ptr< Form > a_star, std::shared_ptr< Form > L_star, std::shared_ptr< Form > residual, std::shared_ptr< Form > a_R_T, std::shared_ptr< Form > L_R_T, std::shared_ptr< Form > a_R_dT, std::shared_ptr< Form > L_R_dT, std::shared_ptr< Form > eta_T, bool is_linear)
Definition ErrorControl.cpp:55
dolfin::Form
Base class for UFC code generated by FFC for DOLFIN with option -l.
Definition Form.h:86
dolfin::FunctionSpace
Definition FunctionSpace.h:54
dolfin::Function
Definition Function.h:66
dolfin::Hierarchical< ErrorControl >::Hierarchical
Hierarchical(ErrorControl &self)
Definition Hierarchical.h:48
dolfin::LinearVariationalSolver::default_parameters
static Parameters default_parameters()
Default parameter values.
Definition LinearVariationalSolver.h:49
dolfin::MeshFunction
Definition MeshFunction.h:58
dolfin::Parameters
Definition Parameters.h:95
dolfin::Parameters::add
void add(std::string key)
Definition Parameters.h:128
dolfin::Parameters::rename
void rename(std::string key)
Rename parameter set.
Definition Parameters.cpp:55
dolfin::SpecialFacetFunction
Definition SpecialFacetFunction.h:42
dolfin::Variable::Variable
Variable()
Create unnamed variable.
Definition Variable.cpp:31
dolfin::Vector
Definition Vector.h:37
dolfin
Definition adapt.h:30
dolfin::residual
double residual(const GenericLinearOperator &A, const GenericVector &x, const GenericVector &b)
Compute residual ||Ax - b||.
Definition solve.cpp:163