DOLFIN
DOLFIN C++ interface
MixedNonlinearVariationalProblem.h
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
30namespace dolfin
31{
32
33 // Forward declarations
34 class DirichletBC;
35 class Form;
36 class Function;
37 class FunctionSpace;
38
46
47 class MixedNonlinearVariationalProblem : public Hierarchical<MixedNonlinearVariationalProblem>
48 {
49 public:
52 typedef std::vector<std::vector<std::shared_ptr<const Form>>> form_list_type;
54 std::vector<std::shared_ptr<Function>> u,
55 std::vector<std::shared_ptr<const DirichletBC>> bcs,
56 form_list_type J={{nullptr}});
57
59 void set_bounds(const std::vector<Function>& lb_func,
60 const std::vector<Function>& ub_func);
61
63 void set_bounds(std::vector<std::shared_ptr<const GenericVector>> lb,
64 std::vector<std::shared_ptr<const GenericVector>> ub);
65
68 std::shared_ptr<const Form> residual_form(int i, int j=0) const;
69
72 std::shared_ptr<const Form> jacobian_form(int i, int j=0) const;
73
75 std::vector<std::shared_ptr<Function>> solution();
76 std::shared_ptr<Function> solution(int i);
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
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
87 std::vector<std::shared_ptr<const FunctionSpace>> trial_space() const;
88 std::shared_ptr<const FunctionSpace> trial_space(int i) const;
89
91 std::vector<std::shared_ptr<const FunctionSpace>> test_space() const;
92 std::shared_ptr<const FunctionSpace> test_space(int i) const;
93
95 std::vector<std::shared_ptr<const GenericVector>> lower_bound() const;
96
98 std::vector<std::shared_ptr<const GenericVector>> upper_bound() const;
99
101 bool has_jacobian() const;
102
104 bool has_lower_bound() const;
105
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
Definition: Hierarchical.h:44
Definition: MixedNonlinearVariationalProblem.h:48
bool has_jacobian() const
Check whether Jacobian has been defined.
Definition: MixedNonlinearVariationalProblem.cpp:181
std::vector< std::shared_ptr< const FunctionSpace > > trial_space() const
Return trial space.
Definition: MixedNonlinearVariationalProblem.cpp:126
std::vector< std::shared_ptr< const GenericVector > > lower_bound() const
Return lower bound.
Definition: MixedNonlinearVariationalProblem.cpp:166
std::vector< std::vector< std::shared_ptr< const Form > > > form_list_type
Definition: MixedNonlinearVariationalProblem.h:52
bool has_upper_bound() const
Check whether upper bound have has defined.
Definition: MixedNonlinearVariationalProblem.cpp:191
std::vector< std::shared_ptr< const GenericVector > > upper_bound() const
Return upper bound.
Definition: MixedNonlinearVariationalProblem.cpp:174
std::vector< std::vector< std::shared_ptr< const DirichletBC > > > bcs() const
Return boundary conditions.
Definition: MixedNonlinearVariationalProblem.cpp:114
std::vector< std::shared_ptr< Function > > solution()
Return solution variable.
Definition: MixedNonlinearVariationalProblem.cpp:90
void set_bounds(std::vector< std::shared_ptr< const GenericVector > > lb, std::vector< std::shared_ptr< const GenericVector > > ub)
Set the bounds for bound constrained solver.
bool has_lower_bound() const
Check whether lower bound has been defined.
Definition: MixedNonlinearVariationalProblem.cpp:186
void set_bounds(const std::vector< Function > &lb_func, const std::vector< Function > &ub_func)
Set the bounds for bound constrained solver.
form_list_type jacobian_form() const
Return Jacobian form.
Definition: MixedNonlinearVariationalProblem.cpp:78
form_list_type residual_form() const
Return residual form.
Definition: MixedNonlinearVariationalProblem.cpp:66
std::vector< std::shared_ptr< const FunctionSpace > > test_space() const
Return test space.
Definition: MixedNonlinearVariationalProblem.cpp:138
Definition: adapt.h:30