DOLFIN
DOLFIN C++ interface
Loading...
Searching...
No Matches
GenericAdaptiveVariationalSolver.h
1// Copyright (C) 2010--2012 Marie E. Rognes
2//
3// This file is part of DOLFIN.
4//
5// DOLFIN is free software: you can redistribute it and/or modify
6// it under the terms of the GNU Lesser General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// DOLFIN is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU Lesser General Public License for more details.
14//
15// You should have received a copy of the GNU Lesser General Public License
16// along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
17//
18// Modified by Anders Logg, 2010-2011.
19//
20// First added: 2010-08-19
21// Last changed: 2012-11-14
22
23#ifndef __GENERIC_ADAPTIVE_VARIATIONAL_SOLVER_H
24#define __GENERIC_ADAPTIVE_VARIATIONAL_SOLVER_H
25
26#include <vector>
27#include <memory>
28#include <dolfin/common/Variable.h>
29#include <dolfin/adaptivity/ErrorControl.h>
30
31namespace dolfin
32{
33 // Forward declarations
34 class DirichletBC;
35 class Form;
36 class Function;
37 class FunctionSpace;
38 class GoalFunctional;
39 class Mesh;
40 class Parameters;
41
46 {
47 public:
48
50
58 void solve(const double tol);
59
65 virtual std::shared_ptr<const Function> solve_primal() = 0;
66
73 virtual std::vector<std::shared_ptr<const DirichletBC> >
74 extract_bcs() const = 0;
75
87 virtual double evaluate_goal(Form& M,
88 std::shared_ptr<const Function> u) const = 0;
89
95 virtual void adapt_problem(std::shared_ptr<const Mesh> mesh) = 0;
96
102 std::vector<std::shared_ptr<Parameters> > adaptive_data() const;
103
114 {
115 Parameters p("adaptive_solver");
116
117 // Set default generic adaptive parameters
118 p.add("max_iterations", 50);
119 p.add("max_dimension", 0);
120 p.add("save_data", false);
121 p.add("data_label", "default/adaptivity");
122 p.add("reference", 0.0);
123 p.add("marking_strategy", "dorfler");
124 p.add("marking_fraction", 0.5, 0.0, 1.0);
125
126 // Set parameters for dual solver
128 p.add(ec_params);
129
130 return p;
131 }
132
134 void summary();
135
136 protected:
137
139 std::shared_ptr<Form> goal;
140
142 std::shared_ptr<ErrorControl> control;
143
144 // A list of adaptive data
145 std::vector<std::shared_ptr<Parameters> > _adaptive_data;
146
152 virtual std::size_t num_dofs_primal() = 0;
153
154 };
155}
156
157
158
159#endif
static Parameters default_parameters()
Default parameter values.
Definition ErrorControl.h:88
Base class for UFC code generated by FFC for DOLFIN with option -l.
Definition Form.h:86
Definition GenericAdaptiveVariationalSolver.h:46
virtual double evaluate_goal(Form &M, std::shared_ptr< const Function > u) const =0
std::shared_ptr< Form > goal
The goal functional.
Definition GenericAdaptiveVariationalSolver.h:139
std::vector< std::shared_ptr< Parameters > > adaptive_data() const
Definition GenericAdaptiveVariationalSolver.cpp:198
void summary()
Present summary of all adaptive data and parameters.
Definition GenericAdaptiveVariationalSolver.cpp:203
virtual std::size_t num_dofs_primal()=0
virtual std::vector< std::shared_ptr< const DirichletBC > > extract_bcs() const =0
void solve(const double tol)
Definition GenericAdaptiveVariationalSolver.cpp:52
static Parameters default_parameters()
Definition GenericAdaptiveVariationalSolver.h:113
std::shared_ptr< ErrorControl > control
Error control object.
Definition GenericAdaptiveVariationalSolver.h:142
virtual void adapt_problem(std::shared_ptr< const Mesh > mesh)=0
virtual std::shared_ptr< const Function > solve_primal()=0
Definition Parameters.h:95
void add(std::string key)
Definition Parameters.h:128
Common base class for DOLFIN variables.
Definition Variable.h:36
Definition adapt.h:30