MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
LookupTable Class Reference

#include <RateLookup.h>

+ Collaboration diagram for LookupTable:

Public Member Functions

void addColumns (int species, const vector< double > &C1, const vector< double > &C2)
 Adds the columns for a given species. Columns supplied are C1 and C2. More...
 
void column (unsigned int species, LookupColumn &column)
 
void lookup (const LookupColumn &column, const LookupRow &row, double &C1, double &C2)
 Actually performs the lookup and the linear interpolation. More...
 
 LookupTable ()
 
 LookupTable (double min, double max, unsigned int nDivs, unsigned int nSpecies)
 number of species (no. of columns / 2) More...
 
void row (double x, LookupRow &row)
 

Private Attributes

double dx_
 
double max_
 max of the voltage / caConc range More...
 
double min_
 min of the voltage / caConc range More...
 
unsigned int nColumns_
 (# columns) = 2 * (# species) More...
 
unsigned int nPts_
 
vector< double > table_
 Flattened table. More...
 

Detailed Description

Definition at line 27 of file RateLookup.h.

Constructor & Destructor Documentation

LookupTable::LookupTable ( )
inline

Definition at line 30 of file RateLookup.h.

30 { ; }
LookupTable::LookupTable ( double  min,
double  max,
unsigned int  nDivs,
unsigned int  nSpecies 
)

number of species (no. of columns / 2)

Parameters
minmin of range
maxmax of range
nDivsnumber of divisions (~ no. of rows)

Definition at line 15 of file RateLookup.cpp.

17 {
18  min_ = min;
19  max_ = max;
20  // Number of points is 1 more than number of divisions.
21  // Then add one more since we may interpolate at the last point in the table.
22  nPts_ = nDivs + 1 + 1;
23  dx_ = ( max - min ) / nDivs;
24  // Every row has 2 entries for each type of gate
25  nColumns_ = 2 * nSpecies;
26 
27  //~ interpolate_.resize( nSpecies );
28  table_.resize( nPts_ * nColumns_ );
29 }
unsigned int nColumns_
(# columns) = 2 * (# species)
Definition: RateLookup.h:75
double dx_
Definition: RateLookup.h:73
double max_
max of the voltage / caConc range
Definition: RateLookup.h:69
unsigned int nPts_
Definition: RateLookup.h:70
vector< double > table_
Flattened table.
Definition: RateLookup.h:67
double min_
min of the voltage / caConc range
Definition: RateLookup.h:68

Member Function Documentation

void LookupTable::addColumns ( int  species,
const vector< double > &  C1,
const vector< double > &  C2 
)

Adds the columns for a given species. Columns supplied are C1 and C2.

Definition at line 31 of file RateLookup.cpp.

Referenced by HSolveActive::createLookupTables().

37 {
38  vector< double >::const_iterator ic1 = C1.begin();
39  vector< double >::const_iterator ic2 = C2.begin();
40  vector< double >::iterator iTable = table_.begin() + 2 * species;
41  // Loop until last but one point
42  for ( unsigned int igrid = 0; igrid < nPts_ - 1 ; ++igrid ) {
43  *( iTable ) = *ic1;
44  *( iTable + 1 ) = *ic2;
45 
46  iTable += nColumns_;
47  ++ic1, ++ic2;
48  }
49  // Then duplicate the last point
50  *( iTable ) = C1.back();
51  *( iTable + 1 ) = C2.back();
52 
53  //~ interpolate_[ species ] = interpolate;
54 }
unsigned int nColumns_
(# columns) = 2 * (# species)
Definition: RateLookup.h:75
unsigned int nPts_
Definition: RateLookup.h:70
vector< double > table_
Flattened table.
Definition: RateLookup.h:67

+ Here is the caller graph for this function:

void LookupTable::column ( unsigned int  species,
LookupColumn column 
)

Definition at line 56 of file RateLookup.cpp.

References LookupColumn::column.

Referenced by HSolveActive::createLookupTables().

57 {
58  column.column = 2 * species;
59  //~ column.interpolate = interpolate_[ species ];
60 }
unsigned int column
Definition: RateLookup.h:23

+ Here is the caller graph for this function:

void LookupTable::lookup ( const LookupColumn column,
const LookupRow row,
double &  C1,
double &  C2 
)

Actually performs the lookup and the linear interpolation.

Definition at line 76 of file RateLookup.cpp.

References LookupColumn::column, LookupRow::fraction, and LookupRow::row.

Referenced by HSolveActive::reinitChannels().

81 {
82  double a, b;
83  double *ap, *bp;
84 
85  ap = row.row + column.column;
86 
87  //~ if ( ! column.interpolate ) {
88  //~ C1 = *ap;
89  //~ C2 = *( ap + 1 );
90  //~
91  //~ return;
92  //~ }
93 
94  bp = ap + nColumns_;
95 
96  a = *ap;
97  b = *bp;
98  C1 = a + ( b - a ) * row.fraction;
99 
100  a = *( ap + 1 );
101  b = *( bp + 1 );
102  C2 = a + ( b - a ) * row.fraction;
103 }
unsigned int nColumns_
(# columns) = 2 * (# species)
Definition: RateLookup.h:75
double fraction
Definition: RateLookup.h:16
unsigned int column
Definition: RateLookup.h:23
double * row
Pointer to the first column on a row.
Definition: RateLookup.h:15

+ Here is the caller graph for this function:

void LookupTable::row ( double  x,
LookupRow row 
)

Returns the row corresponding to x in the "row" parameter. i.e., returns the leftover fraction and the row's start address.

Definition at line 62 of file RateLookup.cpp.

References LookupRow::fraction, and LookupRow::row.

Referenced by HSolveActive::reinitChannels().

63 {
64  if ( x < min_ )
65  x = min_;
66  else if ( x > max_ )
67  x = max_;
68 
69  double div = ( x - min_ ) / dx_;
70  unsigned int integer = ( unsigned int )( div );
71 
72  row.fraction = div - integer;
73  row.row = &( table_.front() ) + integer * nColumns_;
74 }
unsigned int nColumns_
(# columns) = 2 * (# species)
Definition: RateLookup.h:75
double fraction
Definition: RateLookup.h:16
double dx_
Definition: RateLookup.h:73
double max_
max of the voltage / caConc range
Definition: RateLookup.h:69
vector< double > table_
Flattened table.
Definition: RateLookup.h:67
double min_
min of the voltage / caConc range
Definition: RateLookup.h:68
double * row
Pointer to the first column on a row.
Definition: RateLookup.h:15

+ Here is the caller graph for this function:

Member Data Documentation

double LookupTable::dx_
private

This is the smallest difference: (max - min) / nDivs

Definition at line 73 of file RateLookup.h.

double LookupTable::max_
private

max of the voltage / caConc range

Definition at line 69 of file RateLookup.h.

double LookupTable::min_
private

min of the voltage / caConc range

Definition at line 68 of file RateLookup.h.

unsigned int LookupTable::nColumns_
private

(# columns) = 2 * (# species)

Definition at line 75 of file RateLookup.h.

unsigned int LookupTable::nPts_
private

Number of rows in the table. Equal to nDivs + 2, so that interpol. is safe at either end.

Definition at line 70 of file RateLookup.h.

vector< double > LookupTable::table_
private

Flattened table.

Definition at line 67 of file RateLookup.h.


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