CppNoddy  0.85
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Groups Pages
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.
void solve ()
 Direct solver for the whole 2D domain.
void assemble_LHS ()
 Assemble the LHS of the linear Poisson matrix problem.
void set_stokes_streamfn ()
 For a class of Stokes streamfunction problem there is a sign change in the Laplacian-like operator.
void unset_stokes_streamfn ()
 For a class of Stokes streamfunction problem there is a sign change in the Laplacian-like operator.
- 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.
virtual ~Poisson_base ()
virtual void dump ()
 A dump function for data output.

Additional Inherited Members

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

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().

:
Poisson_base( left, right, bottom, top, Nx, Ny, source_ptr )
{
STOKES_STREAMFN = 1;
#ifdef LAPACK
p_SYSTEM = new BandedLinearSystem<double>( &A, &B, "lapack" );
// since the LHS of the problem is fixed as the Laplacian, we can
// LU decompose in the constructor for a zero RHS, then any actual
// solve is done as a re_solve using the decomposition. This is
// obviously much faster! This requires the LAPACK solver because
// the native solver does not explicitly store the LU decomposition.
#else
p_SYSTEM = new BandedLinearSystem<double>( &A, &B, "native" );
#endif
}

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().

{
const double inv_dx2 = 1 / ( DX * DX );
const double inv_dy2 = 1 / ( DY * DY );
// clear the matrix
Utility::fill( A, 0.0 );
// top & bottom
for ( unsigned i = 0; i < NX; ++i )
{
A( i, i ) = 1.0;
A( ( NY - 1 ) * NX + i, ( NY - 1 ) * NX + i ) = 1.0;
}
// left & right
for ( unsigned j = 0; j < NY; ++j )
{
A( j * NX, j * NX ) = 1.0;
A( j * NX + NX - 1, j * NX + NX - 1 ) = 1.0;
}
// interior points
for ( unsigned j = 1; j < NY - 1; ++j )
{
for ( unsigned i = 1; i < NX - 1; ++i )
{
const double r = LEFT + i * DX;
A( j * NX + i, j * NX + i ) = -2 * ( inv_dx2 + inv_dy2 );
A( j * NX + i, j * NX + i - 1 ) = inv_dx2 - STOKES_STREAMFN / ( 2 * DX * r );
A( j * NX + i, j * NX + i + 1 ) = inv_dx2 + STOKES_STREAMFN / ( 2 * DX * r );
A( j * NX + i, j * NX + i - NX ) = inv_dy2;
A( j * NX + i, j * NX + i + NX ) = inv_dy2;
}
}
}
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().

{
STOKES_STREAMFN = -1;
// since the operator on the LHS is different we need to re-factorise it
#ifdef LAPACK
#endif
}
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().

{
// top & bottom
for ( unsigned i = 0; i < NX; ++i )
{
B[ i ] = p_SOURCE -> get( i, 0 );
B[ ( NY - 1 ) * NX + i ] = p_SOURCE -> get( i, NY - 1 );
}
// left & right
for ( unsigned j = 0; j < NY; ++j )
{
B[ j * NX ] = p_SOURCE -> get( 0, j );
B[ j * NX + NX - 1 ] = p_SOURCE -> get( NX - 1, j );
}
// interior points
for ( unsigned j = 1; j < NY - 1; ++j )
{
for ( unsigned i = 1; i < NX - 1; ++i )
{
B[ j * NX + i ] = p_SOURCE -> get( i, j );
}
}
#ifdef LAPACK
// use the existing LU decomposition
p_SYSTEM -> re_solve_lapack();
#else
// otherwise start from scratch with the native solver
#endif
for ( unsigned j = 0; j < NY; ++j )
{
for ( unsigned i = 0; i < NX; ++i )
{
p_SOURCE -> set( i, j ) = B[ j * NX + i ];
}
}
}
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().

{
STOKES_STREAMFN = 1;
// since the operator on the LHS is different we need to re-factorise it
#ifdef LAPACK
#endif
}

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

© 2012

R.E. Hewitt