~njansson/dolfin/hpc

« back to all changes in this revision

Viewing changes to src/demo/ode/complex/main.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) 2005-2006 Anders Logg.
2
 
// Licensed under the GNU LGPL Version 2.1.
3
 
//
4
 
// First added:  2005-02-03
5
 
// Last changed: 2006-08-21
6
 
//
7
 
// This example demonstrates the solution of a complex-valued ODE:
8
 
// 
9
 
//     z'(t) = j*z(t) on (0,10]
10
 
//     z(0)  = 1
11
 
//
12
 
// where j is the imaginary unit. The exact solution of this system
13
 
// is given by
14
 
//
15
 
//     z(t) = exp(j*t) = (cos(t), sin(t)).
16
 
 
17
 
#include <dolfin.h>
18
 
 
19
 
using namespace dolfin;
20
 
 
21
 
class Exponential : public ComplexODE
22
 
{
23
 
public:
24
 
  
25
 
  Exponential() : ComplexODE(1, 10.0)
26
 
  {
27
 
  }
28
 
  
29
 
  void z0(complex z[])
30
 
  {
31
 
    z[0] = 1.0;
32
 
  }
33
 
 
34
 
  void f(const complex z[], real t, complex y[])
35
 
  {
36
 
    y[0] = j*z[0];
37
 
  }
38
 
 
39
 
};
40
 
 
41
 
int main()
42
 
{
43
 
  Exponential exponential;
44
 
  exponential.solve();
45
 
 
46
 
  return 0;
47
 
}