Loading...
Searching...
No Matches
GenericAdaptiveVariationalSolver.h
// Copyright (C) 2010--2012 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/>.
//
// Modified by Anders Logg, 2010-2011.
//
// First added: 2010-08-19
// Last changed: 2012-11-14
#ifndef __GENERIC_ADAPTIVE_VARIATIONAL_SOLVER_H
#define __GENERIC_ADAPTIVE_VARIATIONAL_SOLVER_H
#include <vector>
#include <memory>
#include <dolfin/common/Variable.h>
#include <dolfin/adaptivity/ErrorControl.h>
namespace dolfin
{
// Forward declarations
class DirichletBC;
class Form;
class Function;
class FunctionSpace;
class GoalFunctional;
class Mesh;
class Parameters;
class GenericAdaptiveVariationalSolver : public Variable
{
public:
virtual ~GenericAdaptiveVariationalSolver();
void solve(const double tol);
virtual std::shared_ptr<const Function> solve_primal() = 0;
virtual std::vector<std::shared_ptr<const DirichletBC> >
extract_bcs() const = 0;
virtual double evaluate_goal(Form& M,
std::shared_ptr<const Function> u) const = 0;
virtual void adapt_problem(std::shared_ptr<const Mesh> mesh) = 0;
std::vector<std::shared_ptr<Parameters> > adaptive_data() const;
static Parameters default_parameters()
{
Parameters p("adaptive_solver");
// Set default generic adaptive parameters
p.add("max_iterations", 50);
p.add("max_dimension", 0);
p.add("save_data", false);
p.add("data_label", "default/adaptivity");
p.add("reference", 0.0);
p.add("marking_strategy", "dorfler");
p.add("marking_fraction", 0.5, 0.0, 1.0);
// Set parameters for dual solver
Parameters ec_params(ErrorControl::default_parameters());
p.add(ec_params);
return p;
}
void summary();
protected:
std::shared_ptr<Form> goal;
std::shared_ptr<ErrorControl> control;
// A list of adaptive data
std::vector<std::shared_ptr<Parameters> > _adaptive_data;
virtual std::size_t num_dofs_primal() = 0;
};
}
#endif
dolfin::DirichletBC
Interface for setting (strong) Dirichlet boundary conditions.
Definition DirichletBC.h:125
dolfin::ErrorControl::default_parameters
static Parameters default_parameters()
Default parameter values.
Definition ErrorControl.h:88
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::GenericAdaptiveVariationalSolver
Definition GenericAdaptiveVariationalSolver.h:46
dolfin::GenericAdaptiveVariationalSolver::evaluate_goal
virtual double evaluate_goal(Form &M, std::shared_ptr< const Function > u) const =0
dolfin::GenericAdaptiveVariationalSolver::goal
std::shared_ptr< Form > goal
The goal functional.
Definition GenericAdaptiveVariationalSolver.h:139
dolfin::GenericAdaptiveVariationalSolver::adaptive_data
std::vector< std::shared_ptr< Parameters > > adaptive_data() const
Definition GenericAdaptiveVariationalSolver.cpp:198
dolfin::GenericAdaptiveVariationalSolver::summary
void summary()
Present summary of all adaptive data and parameters.
Definition GenericAdaptiveVariationalSolver.cpp:203
dolfin::GenericAdaptiveVariationalSolver::num_dofs_primal
virtual std::size_t num_dofs_primal()=0
dolfin::GenericAdaptiveVariationalSolver::extract_bcs
virtual std::vector< std::shared_ptr< const DirichletBC > > extract_bcs() const =0
dolfin::GenericAdaptiveVariationalSolver::solve
void solve(const double tol)
Definition GenericAdaptiveVariationalSolver.cpp:52
dolfin::GenericAdaptiveVariationalSolver::default_parameters
static Parameters default_parameters()
Definition GenericAdaptiveVariationalSolver.h:113
dolfin::GenericAdaptiveVariationalSolver::control
std::shared_ptr< ErrorControl > control
Error control object.
Definition GenericAdaptiveVariationalSolver.h:142
dolfin::GenericAdaptiveVariationalSolver::adapt_problem
virtual void adapt_problem(std::shared_ptr< const Mesh > mesh)=0
dolfin::GenericAdaptiveVariationalSolver::solve_primal
virtual std::shared_ptr< const Function > solve_primal()=0
dolfin::GoalFunctional
Definition GoalFunctional.h:35
dolfin::Mesh
Definition Mesh.h:84
dolfin::Parameters
Definition Parameters.h:95
dolfin::Parameters::add
void add(std::string key)
Definition Parameters.h:128
dolfin::Variable::Variable
Variable()
Create unnamed variable.
Definition Variable.cpp:31
dolfin
Definition adapt.h:30