1
// Automatically generated by FFC, the FEniCS Form Compiler, version 0.3.5.
2
// For further information, go to http://www/fenics.org/ffc/.
3
// Licensed under the GNU GPL Version 2.
8
#include <dolfin/Mesh.h>
9
#include <dolfin/Cell.h>
10
#include <dolfin/Point.h>
11
#include <dolfin/AffineMap.h>
12
#include <dolfin/FiniteElement.h>
13
#include <dolfin/FiniteElementSpec.h>
14
#include <dolfin/BilinearForm.h>
15
#include <dolfin/LinearForm.h>
16
#include <dolfin/Functional.h>
17
#include <dolfin/FEM.h>
19
namespace dolfin { namespace L2Norm {
21
/// This class contains the form to be evaluated, including
22
/// contributions from the interior and boundary of the domain.
24
class LinearForm : public dolfin::LinearForm
30
class FunctionElement_0;
32
class FunctionElement_1;
34
LinearForm(Function& w0, Function& w1);
37
bool interior_contribution() const;
39
void eval(real block[], const AffineMap& map, real det) const;
41
bool boundary_contribution() const;
43
void eval(real block[], const AffineMap& map, real det, unsigned int facet) const;
45
bool interior_boundary_contribution() const;
47
void eval(real block[], const AffineMap& map0, const AffineMap& map1, real det, unsigned int facet0, unsigned int facet1, unsigned int alignment) const;
51
class LinearForm::TestElement : public dolfin::FiniteElement
55
TestElement() : dolfin::FiniteElement(), tensordims(0), subelements(0)
57
// Element is scalar, don't need to initialize tensordims
59
// Element is simple, don't need to initialize subelements
64
if ( tensordims ) delete [] tensordims;
67
for (unsigned int i = 0; i < elementdim(); i++)
68
delete subelements[i];
69
delete [] subelements;
73
inline unsigned int spacedim() const
78
inline unsigned int shapedim() const
83
inline unsigned int tensordim(unsigned int i) const
85
dolfin_error("Element is scalar.");
89
inline unsigned int elementdim() const
94
inline unsigned int rank() const
99
void nodemap(int nodes[], const Cell& cell, const Mesh& mesh) const
101
nodes[0] = cell.index();
104
void pointmap(Point points[], unsigned int components[], const AffineMap& map) const
106
points[0] = map(3.333333333333334e-01, 3.333333333333334e-01);
110
void vertexeval(uint vertex_nodes[], unsigned int vertex, const Mesh& mesh) const
112
// FIXME: Temporary fix for Lagrange elements
113
vertex_nodes[0] = vertex;
116
const FiniteElement& operator[] (unsigned int i) const
121
FiniteElement& operator[] (unsigned int i)
126
FiniteElementSpec spec() const
128
FiniteElementSpec s("Discontinuous Lagrange", "triangle", 0);
134
unsigned int* tensordims;
135
FiniteElement** subelements;
139
class LinearForm::FunctionElement_0 : public dolfin::FiniteElement
143
FunctionElement_0() : dolfin::FiniteElement(), tensordims(0), subelements(0)
145
// Element is scalar, don't need to initialize tensordims
147
// Element is simple, don't need to initialize subelements
152
if ( tensordims ) delete [] tensordims;
155
for (unsigned int i = 0; i < elementdim(); i++)
156
delete subelements[i];
157
delete [] subelements;
161
inline unsigned int spacedim() const
166
inline unsigned int shapedim() const
171
inline unsigned int tensordim(unsigned int i) const
173
dolfin_error("Element is scalar.");
177
inline unsigned int elementdim() const
182
inline unsigned int rank() const
187
void nodemap(int nodes[], const Cell& cell, const Mesh& mesh) const
189
nodes[0] = cell.entities(0)[0];
190
nodes[1] = cell.entities(0)[1];
191
nodes[2] = cell.entities(0)[2];
194
void pointmap(Point points[], unsigned int components[], const AffineMap& map) const
196
points[0] = map(0.000000000000000e+00, 0.000000000000000e+00);
197
points[1] = map(1.000000000000000e+00, 0.000000000000000e+00);
198
points[2] = map(0.000000000000000e+00, 1.000000000000000e+00);
204
void vertexeval(uint vertex_nodes[], unsigned int vertex, const Mesh& mesh) const
206
// FIXME: Temporary fix for Lagrange elements
207
vertex_nodes[0] = vertex;
210
const FiniteElement& operator[] (unsigned int i) const
215
FiniteElement& operator[] (unsigned int i)
220
FiniteElementSpec spec() const
222
FiniteElementSpec s("Lagrange", "triangle", 1);
228
unsigned int* tensordims;
229
FiniteElement** subelements;
233
class LinearForm::FunctionElement_1 : public dolfin::FiniteElement
237
FunctionElement_1() : dolfin::FiniteElement(), tensordims(0), subelements(0)
239
// Element is scalar, don't need to initialize tensordims
241
// Element is simple, don't need to initialize subelements
246
if ( tensordims ) delete [] tensordims;
249
for (unsigned int i = 0; i < elementdim(); i++)
250
delete subelements[i];
251
delete [] subelements;
255
inline unsigned int spacedim() const
260
inline unsigned int shapedim() const
265
inline unsigned int tensordim(unsigned int i) const
267
dolfin_error("Element is scalar.");
271
inline unsigned int elementdim() const
276
inline unsigned int rank() const
281
void nodemap(int nodes[], const Cell& cell, const Mesh& mesh) const
283
nodes[0] = cell.entities(0)[0];
284
nodes[1] = cell.entities(0)[1];
285
nodes[2] = cell.entities(0)[2];
288
void pointmap(Point points[], unsigned int components[], const AffineMap& map) const
290
points[0] = map(0.000000000000000e+00, 0.000000000000000e+00);
291
points[1] = map(1.000000000000000e+00, 0.000000000000000e+00);
292
points[2] = map(0.000000000000000e+00, 1.000000000000000e+00);
298
void vertexeval(uint vertex_nodes[], unsigned int vertex, const Mesh& mesh) const
300
// FIXME: Temporary fix for Lagrange elements
301
vertex_nodes[0] = vertex;
304
const FiniteElement& operator[] (unsigned int i) const
309
FiniteElement& operator[] (unsigned int i)
314
FiniteElementSpec spec() const
316
FiniteElementSpec s("Lagrange", "triangle", 1);
322
unsigned int* tensordims;
323
FiniteElement** subelements;
327
LinearForm::LinearForm(Function& w0, Function& w1) : dolfin::LinearForm(2)
329
// Create finite element for test space
330
_test = new TestElement();
333
initFunction(0, w0, new FunctionElement_0());
334
initFunction(1, w1, new FunctionElement_1());
337
// Contribution from the interior
338
bool LinearForm::interior_contribution() const { return true; }
340
void LinearForm::eval(real block[], const AffineMap& map, real det) const
342
// Compute coefficients
343
const real c0_0 = c[0][0];
344
const real c0_1 = c[0][1];
345
const real c0_2 = c[0][2];
346
const real c1_0 = c[1][0];
347
const real c1_1 = c[1][1];
348
const real c1_2 = c[1][2];
350
// Compute geometry tensors
351
const real G0_0_0 = det*c0_0*c0_0 + det*c1_0*c1_0;
352
const real G0_0_1 = det*c0_0*c0_1 + det*c1_0*c1_1;
353
const real G0_0_2 = det*c0_0*c0_2 + det*c1_0*c1_2;
354
const real G0_1_0 = det*c0_1*c0_0 + det*c1_1*c1_0;
355
const real G0_1_1 = det*c0_1*c0_1 + det*c1_1*c1_1;
356
const real G0_1_2 = det*c0_1*c0_2 + det*c1_1*c1_2;
357
const real G0_2_0 = det*c0_2*c0_0 + det*c1_2*c1_0;
358
const real G0_2_1 = det*c0_2*c0_1 + det*c1_2*c1_1;
359
const real G0_2_2 = det*c0_2*c0_2 + det*c1_2*c1_2;
360
const real G1_0_0 = det*c0_0*c1_0 + det*c1_0*c0_0;
361
const real G1_0_1 = det*c0_0*c1_1 + det*c1_0*c0_1;
362
const real G1_0_2 = det*c0_0*c1_2 + det*c1_0*c0_2;
363
const real G1_1_0 = det*c0_1*c1_0 + det*c1_1*c0_0;
364
const real G1_1_1 = det*c0_1*c1_1 + det*c1_1*c0_1;
365
const real G1_1_2 = det*c0_1*c1_2 + det*c1_1*c0_2;
366
const real G1_2_0 = det*c0_2*c1_0 + det*c1_2*c0_0;
367
const real G1_2_1 = det*c0_2*c1_1 + det*c1_2*c0_1;
368
const real G1_2_2 = det*c0_2*c1_2 + det*c1_2*c0_2;
370
// Compute element tensor
371
block[0] = 8.333333333333318e-02*G0_0_0 + 4.166666666666659e-02*G0_0_1 + 4.166666666666658e-02*G0_0_2 + 4.166666666666659e-02*G0_1_0 + 8.333333333333318e-02*G0_1_1 + 4.166666666666659e-02*G0_1_2 + 4.166666666666658e-02*G0_2_0 + 4.166666666666659e-02*G0_2_1 + 8.333333333333316e-02*G0_2_2 - 8.333333333333318e-02*G1_0_0 - 4.166666666666659e-02*G1_0_1 - 4.166666666666658e-02*G1_0_2 - 4.166666666666659e-02*G1_1_0 - 8.333333333333318e-02*G1_1_1 - 4.166666666666659e-02*G1_1_2 - 4.166666666666658e-02*G1_2_0 - 4.166666666666659e-02*G1_2_1 - 8.333333333333316e-02*G1_2_2;
374
// No contribution from the boundary
375
bool LinearForm::boundary_contribution() const { return false; }
377
void LinearForm::eval(real block[], const AffineMap& map, real det, unsigned int facet) const {}
379
// No contribution from interior boundaries
380
bool LinearForm::interior_boundary_contribution() const { return false; }
382
void LinearForm::eval(real block[], const AffineMap& map0, const AffineMap& map1, real det, unsigned int facet0, unsigned int facet1, unsigned int alignment) const {}