1
// Automatically generated by FFC, the FEniCS Form Compiler, version 0.2.5.
2
// For further information, go to http://www/fenics.org/ffc/.
3
// Licensed under the GNU GPL Version 2.
5
#ifndef __STIFFNESSMATRIX2D_H
6
#define __STIFFNESSMATRIX2D_H
8
#include <dolfin/Mesh.h>
9
#include <dolfin/Cell.h>
10
#include <dolfin/Point.h>
11
#include <dolfin/Vector.h>
12
#include <dolfin/AffineMap.h>
13
#include <dolfin/FiniteElement.h>
14
#include <dolfin/FiniteElementSpec.h>
15
#include <dolfin/LinearForm.h>
16
#include <dolfin/BilinearForm.h>
18
namespace dolfin { namespace StiffnessMatrix2D {
20
/// This class contains the form to be evaluated, including
21
/// contributions from the interior and boundary of the domain.
23
class BilinearForm : public dolfin::BilinearForm
27
class TestElement : public dolfin::FiniteElement
31
TestElement() : dolfin::FiniteElement(), tensordims(0), subelements(0)
33
// Element is scalar, don't need to initialize tensordims
35
// Element is simple, don't need to initialize subelements
40
if ( tensordims ) delete [] tensordims;
43
for (unsigned int i = 0; i < elementdim(); i++)
44
delete subelements[i];
45
delete [] subelements;
49
inline unsigned int spacedim() const
54
inline unsigned int shapedim() const
59
inline unsigned int tensordim(unsigned int i) const
61
dolfin_error("Element is scalar.");
65
inline unsigned int elementdim() const
70
inline unsigned int rank() const
75
void nodemap(int nodes[], const Cell& cell, const Mesh& mesh) const
77
nodes[0] = cell.vertexID(0);
78
nodes[1] = cell.vertexID(1);
79
nodes[2] = cell.vertexID(2);
82
void pointmap(Point points[], unsigned int components[], const AffineMap& map) const
84
points[0] = map(0.000000000000000e+00, 0.000000000000000e+00);
85
points[1] = map(1.000000000000000e+00, 0.000000000000000e+00);
86
points[2] = map(0.000000000000000e+00, 1.000000000000000e+00);
92
void vertexeval(real values[], unsigned int vertex, const real x[], const Mesh& mesh) const
94
// FIXME: Temporary fix for Lagrange elements
95
values[0] = x[vertex];
98
const FiniteElement& operator[] (unsigned int i) const
103
FiniteElement& operator[] (unsigned int i)
108
FiniteElementSpec spec() const
110
FiniteElementSpec s("Lagrange", "triangle", 1);
116
unsigned int* tensordims;
117
FiniteElement** subelements;
121
class TrialElement : public dolfin::FiniteElement
125
TrialElement() : dolfin::FiniteElement(), tensordims(0), subelements(0)
127
// Element is scalar, don't need to initialize tensordims
129
// Element is simple, don't need to initialize subelements
134
if ( tensordims ) delete [] tensordims;
137
for (unsigned int i = 0; i < elementdim(); i++)
138
delete subelements[i];
139
delete [] subelements;
143
inline unsigned int spacedim() const
148
inline unsigned int shapedim() const
153
inline unsigned int tensordim(unsigned int i) const
155
dolfin_error("Element is scalar.");
159
inline unsigned int elementdim() const
164
inline unsigned int rank() const
169
void nodemap(int nodes[], const Cell& cell, const Mesh& mesh) const
171
nodes[0] = cell.vertexID(0);
172
nodes[1] = cell.vertexID(1);
173
nodes[2] = cell.vertexID(2);
176
void pointmap(Point points[], unsigned int components[], const AffineMap& map) const
178
points[0] = map(0.000000000000000e+00, 0.000000000000000e+00);
179
points[1] = map(1.000000000000000e+00, 0.000000000000000e+00);
180
points[2] = map(0.000000000000000e+00, 1.000000000000000e+00);
186
void vertexeval(real values[], unsigned int vertex, const real x[], const Mesh& mesh) const
188
// FIXME: Temporary fix for Lagrange elements
189
values[0] = x[vertex];
192
const FiniteElement& operator[] (unsigned int i) const
197
FiniteElement& operator[] (unsigned int i)
202
FiniteElementSpec spec() const
204
FiniteElementSpec s("Lagrange", "triangle", 1);
210
unsigned int* tensordims;
211
FiniteElement** subelements;
215
BilinearForm(const real& c0) : dolfin::BilinearForm(0), c0(c0)
217
// Create finite element for test space
218
_test = new TestElement();
220
// Create finite element for trial space
221
_trial = new TrialElement();
224
void eval(real block[], const AffineMap& map) const
226
// Compute geometry tensors
227
const real G0_0_0 = map.det*c0*(map.g00*map.g00 + map.g01*map.g01);
228
const real G0_0_1 = map.det*c0*(map.g00*map.g10 + map.g01*map.g11);
229
const real G0_1_0 = map.det*c0*(map.g10*map.g00 + map.g11*map.g01);
230
const real G0_1_1 = map.det*c0*(map.g10*map.g10 + map.g11*map.g11);
232
// Compute element tensor
233
block[0] = 4.999999999999998e-01*G0_0_0 + 4.999999999999997e-01*G0_0_1 + 4.999999999999997e-01*G0_1_0 + 4.999999999999996e-01*G0_1_1;
234
block[1] = -4.999999999999998e-01*G0_0_0 - 4.999999999999997e-01*G0_1_0;
235
block[2] = -4.999999999999997e-01*G0_0_1 - 4.999999999999996e-01*G0_1_1;
236
block[3] = -4.999999999999998e-01*G0_0_0 - 4.999999999999997e-01*G0_0_1;
237
block[4] = 4.999999999999998e-01*G0_0_0;
238
block[5] = 4.999999999999997e-01*G0_0_1;
239
block[6] = -4.999999999999997e-01*G0_1_0 - 4.999999999999996e-01*G0_1_1;
240
block[7] = 4.999999999999997e-01*G0_1_0;
241
block[8] = 4.999999999999996e-01*G0_1_1;