DOLFIN
DOLFIN C++ interface
UFC.h
1// Copyright (C) 2007-2015 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 Garth N. Wells 2009
19//
20// First added: 2007-01-17
21// Last changed: 2015-10-23
22
23#ifndef __UFC_DATA_H
24#define __UFC_DATA_H
25
26#include <vector>
27#include <memory>
28#include <ufc.h>
29
30namespace dolfin
31{
32
33 class Cell;
34 class FiniteElement;
35 class Form;
36 class FunctionSpace;
37 class GenericFunction;
38 class Mesh;
39
45
46 class UFC
47 {
48 public:
49
51 UFC(const Form& form);
52
54 UFC(const UFC& ufc);
55
57 ~UFC();
58
60 void init(const Form& form);
61
63 void update(const Cell& cell,
64 const std::vector<double>& coordinate_dofs0,
65 const ufc::cell& ufc_cell,
66 const std::vector<bool> & enabled_coefficients);
67
69 void update(const Cell& cell0,
70 const std::vector<double>& coordinate_dofs0,
71 const ufc::cell& ufc_cell0,
72 const Cell& cell1,
73 const std::vector<double>& coordinate_dofs1,
74 const ufc::cell& ufc_cell1,
75 const std::vector<bool> & enabled_coefficients);
76
80 void update(const Cell& cell,
81 const std::vector<double>& coordinate_dofs0,
82 const ufc::cell& ufc_cell);
83
87 void update(const Cell& cell0,
88 const std::vector<double>& coordinate_dofs0,
89 const ufc::cell& ufc_cell0,
90 const Cell& cell1,
91 const std::vector<double>& coordinate_dofs1,
92 const ufc::cell& ufc_cell1);
93
95 const double* const * w() const
96 { return w_pointer.data(); }
97
100 double** w()
101 { return w_pointer.data(); }
102
105 const double* const * macro_w() const
106 { return macro_w_pointer.data(); }
107
110 double** macro_w()
111 { return macro_w_pointer.data(); }
112
113 private:
114
115 // Finite elements for coefficients
116 std::vector<FiniteElement> coefficient_elements;
117
118 // Cell integrals (access through get_cell_integral to get proper
119 // fallback to default)
120 std::vector<std::shared_ptr<ufc::cell_integral>>
121 cell_integrals;
122
123 // Exterior facet integrals (access through
124 // get_exterior_facet_integral to get proper fallback to default)
125 std::vector<std::shared_ptr<ufc::exterior_facet_integral>>
126 exterior_facet_integrals;
127
128 // Interior facet integrals (access through
129 // get_interior_facet_integral to get proper fallback to default)
130 std::vector<std::shared_ptr<ufc::interior_facet_integral>>
131 interior_facet_integrals;
132
133 // Point integrals (access through get_vertex_integral to get
134 // proper fallback to default)
135 std::vector<std::shared_ptr<ufc::vertex_integral>>
136 vertex_integrals;
137
138 // Custom integrals (access through get_custom_integral to get
139 // proper fallback to default)
140 std::vector<std::shared_ptr<ufc::custom_integral>> custom_integrals;
141
142 // Cutcell integrals (access through get_cutcell_integral to get
143 // proper fallback to default)
144 std::vector<std::shared_ptr<ufc::cutcell_integral>> cutcell_integrals;
145
146 // Interface integrals (access through get_interface_integral to
147 // get proper fallback to default)
148 std::vector<std::shared_ptr<ufc::interface_integral>> interface_integrals;
149
150 // Overlap integrals (access through get_overlap_integral to get
151 // proper fallback to default)
152 std::vector<std::shared_ptr<ufc::overlap_integral>> overlap_integrals;
153
154 public:
155
156 // Default cell integral
157 std::shared_ptr<ufc::cell_integral>
158 default_cell_integral;
159
160 // Default exterior facet integral
161 std::shared_ptr<ufc::exterior_facet_integral>
162 default_exterior_facet_integral;
163
164 // Default interior facet integral
165 std::shared_ptr<ufc::interior_facet_integral>
166 default_interior_facet_integral;
167
168 // Default point integral
169 std::shared_ptr<ufc::vertex_integral>
170 default_vertex_integral;
171
172 // Default custom integral
173 std::shared_ptr<ufc::custom_integral> default_custom_integral;
174
175 // Default cutcell integral
176 std::shared_ptr<ufc::cutcell_integral> default_cutcell_integral;
177
178 // Default interface integral
179 std::shared_ptr<ufc::interface_integral> default_interface_integral;
180
181 // Default overlap integral
182 std::shared_ptr<ufc::overlap_integral> default_overlap_integral;
183
186 ufc::cell_integral*
187 get_cell_integral(std::size_t domain)
188 {
189 if (domain < form.max_cell_subdomain_id())
190 {
191 ufc::cell_integral * integral
192 = cell_integrals[domain].get();
193 if (integral)
194 return integral;
195 }
196 return default_cell_integral.get();
197 }
198
201 ufc::exterior_facet_integral*
202 get_exterior_facet_integral(std::size_t domain)
203 {
204 if (domain < form.max_exterior_facet_subdomain_id())
205 {
206 ufc::exterior_facet_integral* integral
207 = exterior_facet_integrals[domain].get();
208 if (integral)
209 return integral;
210 }
211 return default_exterior_facet_integral.get();
212 }
213
216 ufc::interior_facet_integral*
217 get_interior_facet_integral(std::size_t domain)
218 {
219 if (domain < form.max_interior_facet_subdomain_id())
220 {
221 ufc::interior_facet_integral* integral
222 = interior_facet_integrals[domain].get();
223 if (integral)
224 return integral;
225 }
226 return default_interior_facet_integral.get();
227 }
228
231 ufc::vertex_integral*
232 get_vertex_integral(std::size_t domain)
233 {
234 if (domain < form.max_vertex_subdomain_id())
235 {
236 ufc::vertex_integral * integral
237 = vertex_integrals[domain].get();
238 if (integral)
239 return integral;
240 }
241 return default_vertex_integral.get();
242 }
243
246 ufc::custom_integral * get_custom_integral(std::size_t domain)
247 {
248 if (domain < form.max_custom_subdomain_id())
249 {
250 ufc::custom_integral * integral = custom_integrals[domain].get();
251 if (integral)
252 return integral;
253 }
254 return default_custom_integral.get();
255 }
256
259 ufc::cutcell_integral * get_cutcell_integral(std::size_t domain)
260 {
261 if (domain < form.max_cutcell_subdomain_id())
262 {
263 ufc::cutcell_integral * integral = cutcell_integrals[domain].get();
264 if (integral)
265 return integral;
266 }
267 return default_cutcell_integral.get();
268 }
269
272 ufc::interface_integral * get_interface_integral(std::size_t domain)
273 {
274 if (domain < form.max_interface_subdomain_id())
275 {
276 ufc::interface_integral * integral = interface_integrals[domain].get();
277 if (integral)
278 return integral;
279 }
280 return default_interface_integral.get();
281 }
282
285 ufc::overlap_integral * get_overlap_integral(std::size_t domain)
286 {
287 if (domain < form.max_overlap_subdomain_id())
288 {
289 ufc::overlap_integral * integral = overlap_integrals[domain].get();
290 if (integral)
291 return integral;
292 }
293 return default_overlap_integral.get();
294 }
295
297 const ufc::form& form;
298
299 // FIXME AL: Check which data is actually used and remove the rest
300
302 std::vector<double> A;
303
305 std::vector<double> A_facet;
306
308 std::vector<double> macro_A;
309
310 private:
311
312 // Coefficients (std::vector<double*> is used to interface with
313 // UFC)
314 std::vector<std::vector<double>> _w;
315 std::vector<double*> w_pointer;
316
317 // Coefficients on macro element (std::vector<double*> is used to
318 // interface with UFC)
319 std::vector<std::vector<double>> _macro_w;
320 std::vector<double*> macro_w_pointer;
321
322 // Coefficient functions
323 const std::vector<std::shared_ptr<const GenericFunction>> coefficients;
324
325 public:
326
329
330 };
331}
332
333#endif
A Cell is a MeshEntity of topological codimension 0.
Definition: Cell.h:43
Base class for UFC code generated by FFC for DOLFIN with option -l.
Definition: Form.h:86
Definition: UFC.h:47
std::vector< double > A_facet
Local tensor.
Definition: UFC.h:305
void init(const Form &form)
Initialise memory.
Definition: UFC.cpp:53
ufc::vertex_integral * get_vertex_integral(std::size_t domain)
Definition: UFC.h:232
ufc::cutcell_integral * get_cutcell_integral(std::size_t domain)
Definition: UFC.h:259
const double *const * macro_w() const
Definition: UFC.h:105
ufc::exterior_facet_integral * get_exterior_facet_integral(std::size_t domain)
Definition: UFC.h:202
const ufc::form & form
Form.
Definition: UFC.h:297
ufc::custom_integral * get_custom_integral(std::size_t domain)
Definition: UFC.h:246
std::vector< double > A
Local tensor.
Definition: UFC.h:302
std::vector< double > macro_A
Local tensor for macro element.
Definition: UFC.h:308
UFC(const Form &form)
Constructor.
Definition: UFC.cpp:33
ufc::cell_integral * get_cell_integral(std::size_t domain)
Definition: UFC.h:187
const Form & dolfin_form
The form.
Definition: UFC.h:328
ufc::interface_integral * get_interface_integral(std::size_t domain)
Definition: UFC.h:272
double ** macro_w()
Definition: UFC.h:110
void update(const Cell &cell, const std::vector< double > &coordinate_dofs0, const ufc::cell &ufc_cell, const std::vector< bool > &enabled_coefficients)
Update current cell.
Definition: UFC.cpp:158
const double *const * w() const
Pointer to coefficient data. Used to support UFC interface.
Definition: UFC.h:95
ufc::interior_facet_integral * get_interior_facet_integral(std::size_t domain)
Definition: UFC.h:217
~UFC()
Destructor.
Definition: UFC.cpp:47
ufc::overlap_integral * get_overlap_integral(std::size_t domain)
Definition: UFC.h:285
double ** w()
Definition: UFC.h:100
Definition: adapt.h:30