~njansson/dolfin/hpc

« back to all changes in this revision

Viewing changes to sandbox/eval/main.cpp

  • Committer: Anders Logg
  • Date: 2008-03-17 14:59:36 UTC
  • mfrom: (2402.1.1 trunk)
  • Revision ID: logg@simula.no-20080317145936-buwlwbwp3tx74frg
merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
// Testing evaluation at arbitrary points
8
8
 
9
9
#include <dolfin.h>
 
10
#include "Projection.h"
10
11
 
11
12
using namespace dolfin;
12
13
 
18
19
 
19
20
  void eval(real* values, const real* x) const
20
21
  {
21
 
    values[0] = sin(3.0*x[0])*sin(3.0*x[1]);
 
22
    values[0] = sin(3.0*x[0])*sin(3.0*x[1])*sin(3.0*x[2]);
22
23
  }
23
24
  
24
25
};
25
26
 
26
27
int main()
27
28
{
28
 
  UnitSquare mesh(10, 10);
29
 
  real x[2] = {0.3, 0.3};
 
29
  UnitCube mesh(8, 8, 8);
 
30
  real x[3] = {0.3, 0.3, 0.3};
30
31
  real v[1] = {0.0};
31
32
 
32
33
  // A user-defined function
33
34
  F f(mesh);
34
35
 
 
36
  // Project to a discrete function
 
37
  ProjectionBilinearForm a;
 
38
  ProjectionLinearForm L(f);
 
39
  LinearPDE pde(a, L, mesh);
 
40
  Function g;
 
41
  pde.solve(g);
 
42
 
 
43
  // Evaluate user-defined function
35
44
  f.eval(v, x);
36
45
  message("f(x) = %g", v[0]);
 
46
 
 
47
  // Evaluate discrete function
 
48
  g.eval(v, x);
 
49
  message("g(x) = %g", v[0]);
37
50
}