Memosa-FVM  0.2
OneDConduction< T > Class Template Reference

#include <OneDConduction.h>

Collaboration diagram for OneDConduction< T >:

Public Member Functions

 OneDConduction (const int nCells, const T &kConst)
 
void solve ()
 
boost::shared_ptr< Array< T > > getSolution ()
 

Private Attributes

const int _nCells
 
_kConst
 
_xL
 
_xR
 
boost::shared_ptr< Array< T > > _x
 

Detailed Description

template<class T>
class OneDConduction< T >

Definition at line 26 of file OneDConduction.h.

Constructor & Destructor Documentation

template<class T>
OneDConduction< T >::OneDConduction ( const int  nCells,
const T &  kConst 
)
inline

Definition at line 29 of file OneDConduction.h.

29  :
30  _nCells(nCells),
31  _kConst(kConst),
32  _xL(0),
33  _xR(1),
34  _x(new Array<T>(_nCells))
35  {}
const int _nCells
boost::shared_ptr< Array< T > > _x
Definition: Array.h:14

Member Function Documentation

template<class T>
boost::shared_ptr<Array<T> > OneDConduction< T >::getSolution ( )
inline

Definition at line 85 of file OneDConduction.h.

References OneDConduction< T >::_x.

Referenced by main().

85 {return _x;}
boost::shared_ptr< Array< T > > _x
template<class T>
void OneDConduction< T >::solve ( )
inline

Definition at line 37 of file OneDConduction.h.

References OneDConduction< T >::_kConst, OneDConduction< T >::_nCells, OneDConduction< T >::_x, OneDConduction< T >::_xL, OneDConduction< T >::_xR, and TDMA().

Referenced by main().

38  {
39  Array<T> ae(_nCells);
40  Array<T> aw(_nCells);
41  Array<T> ap(_nCells);
42  Array<T> b(_nCells);
43 
44  ae = T(0.);
45  aw = T(0.);
46  ap = T(0.);
47  b = T(0.);
48 
49  const T dx = T(1.0)/_nCells;
50 
51  for(int nf=0; nf<=_nCells; nf++)
52  {
53  int c0 = nf-1;
54  int c1 = nf;
55 
56  const T xf = dx*nf;
57  const T kf = 1.0 + _kConst*xf;
58  T coeff = kf/dx;
59  if (nf==0)
60  {
61  coeff *= 2.;
62  c0 = 0;
63  b[c0] += coeff*_xL;
64  ap[c0] -= coeff;
65  }
66  else if (nf==_nCells)
67  {
68  coeff *=2;
69  b[c0] += coeff*_xR;
70  ap[c0] -= coeff;
71  }
72  else
73  {
74  ae[c0] = coeff;
75  aw[c1] = coeff;
76  ap[c0] -= coeff;
77  ap[c1] -= coeff;
78  }
79  }
80 
81  cout << " ae[0] " << ae[0] << endl;
82  TDMA(ap,ae,aw,b,*_x);
83  }
const int _nCells
boost::shared_ptr< Array< T > > _x
void TDMA(Array< T > &ap, Array< T > &ae, Array< T > &aw, Array< T > &b, Array< T > &x)
Definition: Array.h:14

Member Data Documentation

template<class T>
T OneDConduction< T >::_kConst
private

Definition at line 89 of file OneDConduction.h.

Referenced by OneDConduction< T >::solve().

template<class T>
const int OneDConduction< T >::_nCells
private

Definition at line 88 of file OneDConduction.h.

Referenced by OneDConduction< T >::solve().

template<class T>
boost::shared_ptr<Array<T> > OneDConduction< T >::_x
private
template<class T>
T OneDConduction< T >::_xL
private

Definition at line 90 of file OneDConduction.h.

Referenced by OneDConduction< T >::solve().

template<class T>
T OneDConduction< T >::_xR
private

Definition at line 91 of file OneDConduction.h.

Referenced by OneDConduction< T >::solve().


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