CppNoddy  0.90
Public Member Functions | List of all members
CppNoddy::Poisson_meridional Class Reference

An object for Poisson problems in the meridional plane of cylindrial polars. More...

#include <Poisson_meridional.h>

Inheritance diagram for CppNoddy::Poisson_meridional:
CppNoddy::Poisson_base CppNoddy::Uncopyable

Public Member Functions

 Poisson_meridional (const double &left, const double &right, const double &bottom, const double &top, const unsigned &Nx, const unsigned &Ny, DenseMatrix< double > *source_ptr)
 A simple Finite Differenced Poisson problem class. More...
 
void solve ()
 Direct solver for the whole 2D domain. More...
 
void assemble_LHS ()
 Assemble the LHS of the linear Poisson matrix problem. More...
 
void set_stokes_streamfn ()
 For a class of Stokes streamfunction problem there is a sign change in the Laplacian-like operator. More...
 
void unset_stokes_streamfn ()
 For a class of Stokes streamfunction problem there is a sign change in the Laplacian-like operator. More...
 
- Public Member Functions inherited from CppNoddy::Poisson_base
 Poisson_base (const double &left, const double &right, const double &bottom, const double &top, const unsigned &Nx, const unsigned &Ny, DenseMatrix< double > *source_ptr)
 A simple Finite Differenced Poisson problem class. More...
 
virtual ~Poisson_base ()
 
virtual void dump ()
 A dump function for data output. More...
 

Additional Inherited Members

- Protected Attributes inherited from CppNoddy::Poisson_base
unsigned NX
 geometry of the domain/meesh More...
 
unsigned NY
 
double DX
 
double DY
 
double LEFT
 
double RIGHT
 
double TOP
 
double BOTTOM
 
DenseMatrix< double > * p_SOURCE
 pointer to the source matrix More...
 
BandedMatrix< double > A
 The containers for the banded matrix problem. More...
 
DenseVector< double > B
 
BandedLinearSystem< double > * p_SYSTEM
 The banded linear system. More...
 

Detailed Description

An object for Poisson problems in the meridional plane of cylindrial polars.

Definition at line 19 of file Poisson_meridional.h.

Constructor & Destructor Documentation

CppNoddy::Poisson_meridional::Poisson_meridional ( const double &  left,
const double &  right,
const double &  bottom,
const double &  top,
const unsigned &  Nx,
const unsigned &  Ny,
DenseMatrix< double > *  source_ptr 
)

A simple Finite Differenced Poisson problem class.

Parameters
leftThe x-position of the left-hand boundary.
rightThe x-position of the right-hand boundary.
bottomThe y-position of the bottom boundary.
topThe y-position of the top boundary.
NxNumber of nodes in x-direction.
NyNumber of nodes in y-direction.
source_ptrA pointer to a DenseMatrix<double> source term.

Definition at line 14 of file Poisson_meridional.cpp.

References CppNoddy::Poisson_base::A, assemble_LHS(), CppNoddy::Poisson_base::B, CppNoddy::Poisson_base::p_SYSTEM, and solve().

20  :
21  Poisson_base( left, right, bottom, top, Nx, Ny, source_ptr )
22  {
23  STOKES_STREAMFN = 1;
24 #ifdef LAPACK
25  p_SYSTEM = new BandedLinearSystem<double>( &A, &B, "lapack" );
26  // since the LHS of the problem is fixed as the Laplacian, we can
27  // LU decompose in the constructor for a zero RHS, then any actual
28  // solve is done as a re_solve using the decomposition. This is
29  // obviously much faster! This requires the LAPACK solver because
30  // the native solver does not explicitly store the LU decomposition.
31  assemble_LHS();
32  p_SYSTEM -> solve();
33 #else
34  p_SYSTEM = new BandedLinearSystem<double>( &A, &B, "native" );
35 #endif
36  }
Poisson_base(const double &left, const double &right, const double &bottom, const double &top, const unsigned &Nx, const unsigned &Ny, DenseMatrix< double > *source_ptr)
A simple Finite Differenced Poisson problem class.
Definition: Poisson_base.h:32
void assemble_LHS()
Assemble the LHS of the linear Poisson matrix problem.
BandedLinearSystem< double > * p_SYSTEM
The banded linear system.
Definition: Poisson_base.h:107
DenseVector< double > B
Definition: Poisson_base.h:105
void solve()
Direct solver for the whole 2D domain.
BandedMatrix< double > A
The containers for the banded matrix problem.
Definition: Poisson_base.h:104

Member Function Documentation

void CppNoddy::Poisson_meridional::assemble_LHS ( )
virtual

Assemble the LHS of the linear Poisson matrix problem.

Reimplemented from CppNoddy::Poisson_base.

Definition at line 81 of file Poisson_meridional.cpp.

References CppNoddy::Poisson_base::A, CppNoddy::Poisson_base::DX, CppNoddy::Poisson_base::DY, CppNoddy::Utility::fill(), CppNoddy::Poisson_base::LEFT, CppNoddy::Poisson_base::NX, and CppNoddy::Poisson_base::NY.

Referenced by Poisson_meridional(), set_stokes_streamfn(), solve(), and unset_stokes_streamfn().

82  {
83  const double inv_dx2 = 1 / ( DX * DX );
84  const double inv_dy2 = 1 / ( DY * DY );
85  // clear the matrix
86  Utility::fill( A, 0.0 );
87  // top & bottom
88  for ( unsigned i = 0; i < NX; ++i )
89  {
90  A( i, i ) = 1.0;
91  A( ( NY - 1 ) * NX + i, ( NY - 1 ) * NX + i ) = 1.0;
92  }
93 
94  // left & right
95  for ( unsigned j = 0; j < NY; ++j )
96  {
97  A( j * NX, j * NX ) = 1.0;
98  A( j * NX + NX - 1, j * NX + NX - 1 ) = 1.0;
99  }
100 
101  // interior points
102  for ( unsigned j = 1; j < NY - 1; ++j )
103  {
104  for ( unsigned i = 1; i < NX - 1; ++i )
105  {
106  const double r = LEFT + i * DX;
107  A( j * NX + i, j * NX + i ) = -2 * ( inv_dx2 + inv_dy2 );
108  A( j * NX + i, j * NX + i - 1 ) = inv_dx2 - STOKES_STREAMFN / ( 2 * DX * r );
109  A( j * NX + i, j * NX + i + 1 ) = inv_dx2 + STOKES_STREAMFN / ( 2 * DX * r );
110  A( j * NX + i, j * NX + i - NX ) = inv_dy2;
111  A( j * NX + i, j * NX + i + NX ) = inv_dy2;
112  }
113  }
114  }
unsigned NX
geometry of the domain/meesh
Definition: Poisson_base.h:98
BandedMatrix< double > A
The containers for the banded matrix problem.
Definition: Poisson_base.h:104
void fill(BandedMatrix< _Type > &A, const _Type &value)
Set all elements of a specified BANDED matrix.
Definition: Utility.h:89
void CppNoddy::Poisson_meridional::set_stokes_streamfn ( )
inline

For a class of Stokes streamfunction problem there is a sign change in the Laplacian-like operator.

This sets the sign change.

Definition at line 49 of file Poisson_meridional.h.

References assemble_LHS(), CppNoddy::Poisson_base::p_SYSTEM, and solve().

Referenced by main().

50  {
51  STOKES_STREAMFN = -1;
52  // since the operator on the LHS is different we need to re-factorise it
53 #ifdef LAPACK
54  assemble_LHS();
55  p_SYSTEM -> solve();
56 #endif
57  }
void assemble_LHS()
Assemble the LHS of the linear Poisson matrix problem.
BandedLinearSystem< double > * p_SYSTEM
The banded linear system.
Definition: Poisson_base.h:107
void solve()
Direct solver for the whole 2D domain.
void CppNoddy::Poisson_meridional::solve ( )
virtual

Direct solver for the whole 2D domain.

Reimplemented from CppNoddy::Poisson_base.

Definition at line 38 of file Poisson_meridional.cpp.

References assemble_LHS(), CppNoddy::Poisson_base::B, CppNoddy::Poisson_base::NX, CppNoddy::Poisson_base::NY, CppNoddy::Poisson_base::p_SOURCE, and CppNoddy::Poisson_base::p_SYSTEM.

Referenced by main(), Poisson_meridional(), set_stokes_streamfn(), and unset_stokes_streamfn().

39  {
40  // top & bottom
41  for ( unsigned i = 0; i < NX; ++i )
42  {
43  B[ i ] = p_SOURCE -> get( i, 0 );
44  B[ ( NY - 1 ) * NX + i ] = p_SOURCE -> get( i, NY - 1 );
45  }
46 
47  // left & right
48  for ( unsigned j = 0; j < NY; ++j )
49  {
50  B[ j * NX ] = p_SOURCE -> get( 0, j );
51  B[ j * NX + NX - 1 ] = p_SOURCE -> get( NX - 1, j );
52  }
53 
54  // interior points
55  for ( unsigned j = 1; j < NY - 1; ++j )
56  {
57  for ( unsigned i = 1; i < NX - 1; ++i )
58  {
59  B[ j * NX + i ] = p_SOURCE -> get( i, j );
60  }
61  }
62 
63 #ifdef LAPACK
64  // use the existing LU decomposition
65  p_SYSTEM -> re_solve_lapack();
66 #else
67  // otherwise start from scratch with the native solver
68  assemble_LHS();
69  p_SYSTEM -> solve();
70 #endif
71 
72  for ( unsigned j = 0; j < NY; ++j )
73  {
74  for ( unsigned i = 0; i < NX; ++i )
75  {
76  p_SOURCE -> set( i, j ) = B[ j * NX + i ];
77  }
78  }
79  }
unsigned NX
geometry of the domain/meesh
Definition: Poisson_base.h:98
void assemble_LHS()
Assemble the LHS of the linear Poisson matrix problem.
BandedLinearSystem< double > * p_SYSTEM
The banded linear system.
Definition: Poisson_base.h:107
DenseVector< double > B
Definition: Poisson_base.h:105
void solve()
Direct solver for the whole 2D domain.
DenseMatrix< double > * p_SOURCE
pointer to the source matrix
Definition: Poisson_base.h:102
void CppNoddy::Poisson_meridional::unset_stokes_streamfn ( )
inline

For a class of Stokes streamfunction problem there is a sign change in the Laplacian-like operator.

This unsets the sign change, to give the standard Laplacian.

Definition at line 62 of file Poisson_meridional.h.

References assemble_LHS(), CppNoddy::Poisson_base::p_SYSTEM, and solve().

63  {
64  STOKES_STREAMFN = 1;
65  // since the operator on the LHS is different we need to re-factorise it
66 #ifdef LAPACK
67  assemble_LHS();
68  p_SYSTEM -> solve();
69 #endif
70  }
void assemble_LHS()
Assemble the LHS of the linear Poisson matrix problem.
BandedLinearSystem< double > * p_SYSTEM
The banded linear system.
Definition: Poisson_base.h:107
void solve()
Direct solver for the whole 2D domain.

The documentation for this class was generated from the following files:

© 2012

R.E. Hewitt