Debian Codegraph @

dolfin/fem/MixedNonlinearVariationalProblem.h

raw
1 // Copyright (C) 2011 Anders Logg
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 Cecile Daversin-Catty, 2018.
19 //
20 // First added: 2018-10-03
21 // Last changed: 2018-10-03
22
23 #ifndef __MIXED_NONLINEAR_VARIATIONAL_PROBLEM_H
24 #define __MIXED_NONLINEAR_VARIATIONAL_PROBLEM_H
25
26 #include <memory>
27 #include <vector>
28 #include <dolfin/common/Hierarchical.h>
29
30 namespace dolfin
31 {
32
33 // Forward declarations
34 class DirichletBC;
35 class Form;
36 class Function;
37 class FunctionSpace;
38
39 /// This class represents a mixed nonlinear variational problem:
40 ///
41 /// Find u = (u_1, ..., u_n) in V = V1 x ... x Vn such that
42 ///
43 /// F(u; v) = 0 for all v in V^,
44 ///
45 /// where V is the trial space and V^ is the test space.
46
47 class MixedNonlinearVariationalProblem : public Hierarchical<MixedNonlinearVariationalProblem>
48 {
49 public:
50 /// Create mixed nonlinear variational problem
51 /// with a list of boundary conditions
52 typedef std::vector<std::vector<std::shared_ptr<const Form>>> form_list_type;
53 MixedNonlinearVariationalProblem(form_list_type F,
54 std::vector<std::shared_ptr<Function>> u,
55 std::vector<std::shared_ptr<const DirichletBC>> bcs,
56 form_list_type J={{nullptr}});
57
58 /// Set the bounds for bound constrained solver
59 void set_bounds(const std::vector<Function>& lb_func,
60 const std::vector<Function>& ub_func);
61
62 /// Set the bounds for bound constrained solver
63 void set_bounds(std::vector<std::shared_ptr<const GenericVector>> lb,
64 std::vector<std::shared_ptr<const GenericVector>> ub);
65
66 /// Return residual form
67 form_list_type residual_form() const;
68 std::shared_ptr<const Form> residual_form(int i, int j=0) const;
69
70 /// Return Jacobian form
71 form_list_type jacobian_form() const;
72 std::shared_ptr<const Form> jacobian_form(int i, int j=0) const;
73
74 /// Return solution variable
75 std::vector<std::shared_ptr<Function>> solution();
76 std::shared_ptr<Function> solution(int i);
77 /// Return solution variable - const version
78 //std::vector<std::shared_ptr<const Function>> solution() const;
79 const std::vector<std::shared_ptr<Function>> solution() const;
80 std::shared_ptr<const Function> solution(int i) const;
81
82 /// Return boundary conditions
83 std::vector<std::vector<std::shared_ptr<const DirichletBC>>> bcs() const;
84 std::vector<std::shared_ptr<const DirichletBC>> bcs(int i) const;
85
86 /// Return trial space
87 std::vector<std::shared_ptr<const FunctionSpace>> trial_space() const;
88 std::shared_ptr<const FunctionSpace> trial_space(int i) const;
89
90 /// Return test space
91 std::vector<std::shared_ptr<const FunctionSpace>> test_space() const;
92 std::shared_ptr<const FunctionSpace> test_space(int i) const;
93
94 /// Return lower bound
95 std::vector<std::shared_ptr<const GenericVector>> lower_bound() const;
96
97 /// Return upper bound
98 std::vector<std::shared_ptr<const GenericVector>> upper_bound() const;
99
100 /// Check whether Jacobian has been defined
101 bool has_jacobian() const;
102
103 /// Check whether lower bound has been defined
104 bool has_lower_bound() const;
105
106 /// Check whether upper bound have has defined
107 bool has_upper_bound() const;
108
109 private:
110
111 // Check forms
112 void check_forms() const;
113
114 // Build the necessary mappings between submeshes
115 void build_mappings();
116
117 // The residual form
118 form_list_type _residual;
119
120 // The Jacobian form (pointer may be null if not provided)
121 form_list_type _jacobian;
122
123 // The solution
124 std::vector<std::shared_ptr<Function>> _u;
125
126 // The boundary conditions
127 std::vector<std::vector<std::shared_ptr<const DirichletBC>>> _bcs;
128
129 // The lower and upper bounds (pointers may be null if not
130 // provided)
131 std::vector<std::shared_ptr<const GenericVector>> _lb;
132 std::vector<std::shared_ptr<const GenericVector>> _ub;
133 };
134
135 }
136
137 #endif