DOLFIN
DOLFIN C++ interface
Loading...
Searching...
No Matches
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
68
70 void update(const Cell& cell,
71 const std::vector<std::vector<double>>& coordinate_dofs0,
72 const std::vector<ufc::cell>& ufc_cells,
73 const std::vector<bool> & enabled_coefficients);
74
76 void update(const Cell& cell0,
77 const std::vector<double>& coordinate_dofs0,
78 const ufc::cell& ufc_cell0,
79 const Cell& cell1,
80 const std::vector<double>& coordinate_dofs1,
81 const ufc::cell& ufc_cell1,
82 const std::vector<bool> & enabled_coefficients);
83
87 void update(const Cell& cell,
88 const std::vector<double>& coordinate_dofs0,
89 const ufc::cell& ufc_cell);
90
94 void update(const Cell& cell0,
95 const std::vector<double>& coordinate_dofs0,
96 const ufc::cell& ufc_cell0,
97 const Cell& cell1,
98 const std::vector<double>& coordinate_dofs1,
99 const ufc::cell& ufc_cell1);
100
102 const double* const * w() const
103 { return w_pointer.data(); }
104
107 double** w()
108 { return w_pointer.data(); }
109
112 const double* const * macro_w() const
113 { return macro_w_pointer.data(); }
114
117 double** macro_w()
118 { return macro_w_pointer.data(); }
119
120 private:
121
122 // Finite elements for coefficients
123 std::vector<FiniteElement> coefficient_elements;
124
125 // Cell integrals (access through get_cell_integral to get proper
126 // fallback to default)
127 std::vector<std::shared_ptr<ufc::cell_integral>>
128 cell_integrals;
129
130 // Exterior facet integrals (access through
131 // get_exterior_facet_integral to get proper fallback to default)
132 std::vector<std::shared_ptr<ufc::exterior_facet_integral>>
133 exterior_facet_integrals;
134
135 // Interior facet integrals (access through
136 // get_interior_facet_integral to get proper fallback to default)
137 std::vector<std::shared_ptr<ufc::interior_facet_integral>>
138 interior_facet_integrals;
139
140 // Point integrals (access through get_vertex_integral to get
141 // proper fallback to default)
142 std::vector<std::shared_ptr<ufc::vertex_integral>>
143 vertex_integrals;
144
145 // Custom integrals (access through get_custom_integral to get
146 // proper fallback to default)
147 std::vector<std::shared_ptr<ufc::custom_integral>> custom_integrals;
148
149 // Cutcell integrals (access through get_cutcell_integral to get
150 // proper fallback to default)
151 std::vector<std::shared_ptr<ufc::cutcell_integral>> cutcell_integrals;
152
153 // Interface integrals (access through get_interface_integral to
154 // get proper fallback to default)
155 std::vector<std::shared_ptr<ufc::interface_integral>> interface_integrals;
156
157 // Overlap integrals (access through get_overlap_integral to get
158 // proper fallback to default)
159 std::vector<std::shared_ptr<ufc::overlap_integral>> overlap_integrals;
160
161 public:
162
163 // Default cell integral
164 std::shared_ptr<ufc::cell_integral>
165 default_cell_integral;
166
167 // Default exterior facet integral
168 std::shared_ptr<ufc::exterior_facet_integral>
169 default_exterior_facet_integral;
170
171 // Default interior facet integral
172 std::shared_ptr<ufc::interior_facet_integral>
173 default_interior_facet_integral;
174
175 // Default point integral
176 std::shared_ptr<ufc::vertex_integral>
177 default_vertex_integral;
178
179 // Default custom integral
180 std::shared_ptr<ufc::custom_integral> default_custom_integral;
181
182 // Default cutcell integral
183 std::shared_ptr<ufc::cutcell_integral> default_cutcell_integral;
184
185 // Default interface integral
186 std::shared_ptr<ufc::interface_integral> default_interface_integral;
187
188 // Default overlap integral
189 std::shared_ptr<ufc::overlap_integral> default_overlap_integral;
190
193 ufc::cell_integral*
194 get_cell_integral(std::size_t domain)
195 {
196 if (domain < form.max_cell_subdomain_id())
197 {
198 ufc::cell_integral * integral
199 = cell_integrals[domain].get();
200 if (integral)
201 return integral;
202 }
203 return default_cell_integral.get();
204 }
205
208 ufc::exterior_facet_integral*
209 get_exterior_facet_integral(std::size_t domain)
210 {
211 if (domain < form.max_exterior_facet_subdomain_id())
212 {
213 ufc::exterior_facet_integral* integral
214 = exterior_facet_integrals[domain].get();
215 if (integral)
216 return integral;
217 }
218 return default_exterior_facet_integral.get();
219 }
220
223 ufc::interior_facet_integral*
224 get_interior_facet_integral(std::size_t domain)
225 {
226 if (domain < form.max_interior_facet_subdomain_id())
227 {
228 ufc::interior_facet_integral* integral
229 = interior_facet_integrals[domain].get();
230 if (integral)
231 return integral;
232 }
233 return default_interior_facet_integral.get();
234 }
235
238 ufc::vertex_integral*
239 get_vertex_integral(std::size_t domain)
240 {
241 if (domain < form.max_vertex_subdomain_id())
242 {
243 ufc::vertex_integral * integral
244 = vertex_integrals[domain].get();
245 if (integral)
246 return integral;
247 }
248 return default_vertex_integral.get();
249 }
250
253 ufc::custom_integral * get_custom_integral(std::size_t domain)
254 {
255 if (domain < form.max_custom_subdomain_id())
256 {
257 ufc::custom_integral * integral = custom_integrals[domain].get();
258 if (integral)
259 return integral;
260 }
261 return default_custom_integral.get();
262 }
263
266 ufc::cutcell_integral * get_cutcell_integral(std::size_t domain)
267 {
268 if (domain < form.max_cutcell_subdomain_id())
269 {
270 ufc::cutcell_integral * integral = cutcell_integrals[domain].get();
271 if (integral)
272 return integral;
273 }
274 return default_cutcell_integral.get();
275 }
276
279 ufc::interface_integral * get_interface_integral(std::size_t domain)
280 {
281 if (domain < form.max_interface_subdomain_id())
282 {
283 ufc::interface_integral * integral = interface_integrals[domain].get();
284 if (integral)
285 return integral;
286 }
287 return default_interface_integral.get();
288 }
289
292 ufc::overlap_integral * get_overlap_integral(std::size_t domain)
293 {
294 if (domain < form.max_overlap_subdomain_id())
295 {
296 ufc::overlap_integral * integral = overlap_integrals[domain].get();
297 if (integral)
298 return integral;
299 }
300 return default_overlap_integral.get();
301 }
302
304 const ufc::form& form;
305
306 // FIXME AL: Check which data is actually used and remove the rest
307
309 std::vector<double> A;
310
312 std::vector<double> A_facet;
313
315 std::vector<double> macro_A;
316
317 private:
318
319 // Coefficients (std::vector<double*> is used to interface with
320 // UFC)
321 std::vector<std::vector<double>> _w;
322 std::vector<double*> w_pointer;
323
324 // Coefficients on macro element (std::vector<double*> is used to
325 // interface with UFC)
326 std::vector<std::vector<double>> _macro_w;
327 std::vector<double*> macro_w_pointer;
328
329 // Coefficient functions
330 const std::vector<std::shared_ptr<const GenericFunction>> coefficients;
331
332 public:
333
336
337 };
338}
339
340#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:312
void init(const Form &form)
Initialise memory.
Definition UFC.cpp:53
ufc::vertex_integral * get_vertex_integral(std::size_t domain)
Definition UFC.h:239
ufc::cutcell_integral * get_cutcell_integral(std::size_t domain)
Definition UFC.h:266
const double *const * macro_w() const
Definition UFC.h:112
ufc::exterior_facet_integral * get_exterior_facet_integral(std::size_t domain)
Definition UFC.h:209
const ufc::form & form
Form.
Definition UFC.h:304
ufc::custom_integral * get_custom_integral(std::size_t domain)
Definition UFC.h:253
std::vector< double > A
Local tensor.
Definition UFC.h:309
std::vector< double > macro_A
Local tensor for macro element.
Definition UFC.h:315
UFC(const Form &form)
Constructor.
Definition UFC.cpp:33
ufc::cell_integral * get_cell_integral(std::size_t domain)
Definition UFC.h:194
const Form & dolfin_form
The form.
Definition UFC.h:335
ufc::interface_integral * get_interface_integral(std::size_t domain)
Definition UFC.h:279
double ** macro_w()
Definition UFC.h:117
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:174
const double *const * w() const
Pointer to coefficient data. Used to support UFC interface.
Definition UFC.h:102
ufc::interior_facet_integral * get_interior_facet_integral(std::size_t domain)
Definition UFC.h:224
~UFC()
Destructor.
Definition UFC.cpp:47
ufc::overlap_integral * get_overlap_integral(std::size_t domain)
Definition UFC.h:292
double ** w()
Definition UFC.h:107
Definition adapt.h:30