1
// Copyright (C) 2006 Anders Logg.
2
// Licensed under the GNU LGPL Version 2.1.
4
// First added: 2006-08-21
5
// Last changed: 2006-10-26
7
#include <dolfin/assemble.h>
8
#include <dolfin/DofMapSet.h>
9
#include <dolfin/GenericMatrix.h>
10
#include <dolfin/GenericVector.h>
11
#include <dolfin/Mesh.h>
12
#include <dolfin/MatrixFactory.h>
14
#include "ffc-forms/MassMatrix2D.h"
15
#include "ffc-forms/MassMatrix3D.h"
16
#include "ffc-forms/StiffnessMatrix2D.h"
17
#include "ffc-forms/StiffnessMatrix3D.h"
18
#include "ffc-forms/ConvectionMatrix2D.h"
19
#include "ffc-forms/ConvectionMatrix3D.h"
20
#include "ffc-forms/LoadVector2D.h"
21
#include "ffc-forms/LoadVector3D.h"
23
using namespace dolfin;
25
//-----------------------------------------------------------------------------
26
void MatrixFactory::computeMassMatrix(GenericMatrix& A, Mesh& mesh)
28
warning("Using default dof map in MatrixFactory");
29
if (mesh.type().cellType() == CellType::triangle)
31
MassMatrix2DBilinearForm a;
34
else if (mesh.type().cellType() == CellType::tetrahedron)
36
MassMatrix3DBilinearForm a;
41
error("Unknown mesh type.");
44
//-----------------------------------------------------------------------------
45
void MatrixFactory::computeStiffnessMatrix(GenericMatrix& A, Mesh& mesh, real c)
49
warning("Using default dof map in MatrixFactory");
50
if (mesh.type().cellType() == CellType::triangle)
52
StiffnessMatrix2DBilinearForm a(f);
55
else if (mesh.type().cellType() == CellType::tetrahedron)
57
StiffnessMatrix3DBilinearForm a(f);
62
error("Unknown mesh type.");
65
//-----------------------------------------------------------------------------
66
void MatrixFactory::computeConvectionMatrix(GenericMatrix& A, Mesh& mesh,
67
real cx, real cy, real cz)
69
Function fx(mesh, cx);
70
Function fy(mesh, cy);
71
Function fz(mesh, cz);
73
warning("Using default dof map in MatrixFactory");
74
if (mesh.type().cellType() == CellType::triangle)
76
ConvectionMatrix2DBilinearForm a(fx, fy);
79
else if (mesh.type().cellType() == CellType::tetrahedron)
81
ConvectionMatrix3DBilinearForm a(fx, fy, fz);
86
error("Unknown mesh type.");
89
//-----------------------------------------------------------------------------
90
void MatrixFactory::computeLoadVector(GenericVector& x, Mesh& mesh, real c)
94
error("MF forms need to be updated to new mesh format.");
95
warning("Using default dof map in MatrixFactory");
96
if (mesh.type().cellType() == CellType::triangle)
98
LoadVector2DLinearForm b(f);
101
else if (mesh.type().cellType() == CellType::tetrahedron)
103
LoadVector3DLinearForm b(f);
104
assemble(x, b, mesh);
108
error("Unknown mesh type.");
111
//-----------------------------------------------------------------------------