~njansson/dolfin/hpc

« back to all changes in this revision

Viewing changes to src/kernel/mf/MatrixFactory.cpp

  • Committer: Johannes Ring
  • Date: 2008-03-05 22:43:06 UTC
  • Revision ID: johannr@simula.no-20080305224306-2npsdyhfdpl2esji
The BIG commit!

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Copyright (C) 2006 Anders Logg.
2
 
// Licensed under the GNU LGPL Version 2.1.
3
 
//
4
 
// First added:  2006-08-21
5
 
// Last changed: 2006-10-26
6
 
 
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>
13
 
 
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"
22
 
 
23
 
using namespace dolfin;
24
 
 
25
 
//-----------------------------------------------------------------------------
26
 
void MatrixFactory::computeMassMatrix(GenericMatrix& A, Mesh& mesh)
27
 
{
28
 
  warning("Using default dof map in MatrixFactory");
29
 
  if (mesh.type().cellType() == CellType::triangle)
30
 
  {
31
 
    MassMatrix2DBilinearForm a;
32
 
    assemble(A, a, mesh);
33
 
  }
34
 
  else if (mesh.type().cellType() == CellType::tetrahedron)
35
 
  {
36
 
    MassMatrix3DBilinearForm a;
37
 
    assemble(A, a, mesh);
38
 
  }
39
 
  else
40
 
  {
41
 
    error("Unknown mesh type.");
42
 
  }
43
 
}
44
 
//-----------------------------------------------------------------------------
45
 
void MatrixFactory::computeStiffnessMatrix(GenericMatrix& A, Mesh& mesh, real c)
46
 
{
47
 
  Function f(mesh, c);
48
 
 
49
 
  warning("Using default dof map in MatrixFactory");
50
 
  if (mesh.type().cellType() == CellType::triangle)
51
 
  {
52
 
    StiffnessMatrix2DBilinearForm a(f);
53
 
    assemble(A, a, mesh);
54
 
  }
55
 
  else if (mesh.type().cellType() == CellType::tetrahedron)
56
 
  {
57
 
    StiffnessMatrix3DBilinearForm a(f);
58
 
    assemble(A, a, mesh);
59
 
  }
60
 
  else
61
 
  {
62
 
    error("Unknown mesh type.");
63
 
  } 
64
 
}
65
 
//-----------------------------------------------------------------------------
66
 
void MatrixFactory::computeConvectionMatrix(GenericMatrix& A, Mesh& mesh,
67
 
                                            real cx, real cy, real cz)
68
 
{
69
 
  Function fx(mesh, cx);
70
 
  Function fy(mesh, cy);
71
 
  Function fz(mesh, cz);
72
 
 
73
 
  warning("Using default dof map in MatrixFactory");
74
 
  if (mesh.type().cellType() == CellType::triangle)
75
 
  {
76
 
    ConvectionMatrix2DBilinearForm a(fx, fy);
77
 
    assemble(A, a, mesh);
78
 
  }
79
 
  else if (mesh.type().cellType() == CellType::tetrahedron)
80
 
  {
81
 
    ConvectionMatrix3DBilinearForm a(fx, fy, fz);
82
 
    assemble(A, a, mesh);
83
 
  }
84
 
  else
85
 
  {
86
 
    error("Unknown mesh type.");
87
 
  }
88
 
}
89
 
//-----------------------------------------------------------------------------
90
 
void MatrixFactory::computeLoadVector(GenericVector& x, Mesh& mesh, real c)
91
 
{
92
 
  Function f(mesh, c);
93
 
 
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)
97
 
  {
98
 
    LoadVector2DLinearForm b(f);
99
 
    assemble(x, b, mesh);
100
 
  }
101
 
  else if (mesh.type().cellType() == CellType::tetrahedron)
102
 
  {
103
 
    LoadVector3DLinearForm b(f);
104
 
    assemble(x, b, mesh);
105
 
  }
106
 
  else
107
 
  {
108
 
    error("Unknown mesh type.");
109
 
  } 
110
 
}
111
 
//-----------------------------------------------------------------------------