openCARP
Doxygen code documentation for the open cardiac electrophysiology simulator openCARP
Public Member Functions | Public Attributes | Protected Attributes | List of all members
limpet::IonIfBase Class Referenceabstract

Represents the ionic model and plug-in (IMP) data structure. More...

#include <ION_IF.h>

Inheritance diagram for limpet::IonIfBase:
Collaboration diagram for limpet::IonIfBase:

Public Member Functions

 IonIfBase (const IonType &type, Target target, int num_node, const std::vector< std::reference_wrapper< IonType >> &plugins)
 Constructor for IonIfBase. More...
 
virtual ~IonIfBase ()
 Virtual destructor declaration. More...
 
const IonTypeget_type () const
 Gets this IMP's model type. More...
 
int get_num_node () const
 Gets the number of nodes handled by this IMP. More...
 
std::size_t get_num_threads () const
 Gets the number of threads used for running this IMP. More...
 
IonIfBaseparent () const
 Gets the parent IMP. More...
 
void set_parent (IonIfBase *parent)
 
std::vector< IonIfBase * > & plugins ()
 Returns a vector containing the plugins of this IMP. More...
 
uint32_t get_reqdat () const
 Gets the data flags for this IMP's required data. More...
 
uint32_t get_moddat () const
 Gets the data flags for this IMP's modified data. More...
 
void set_moddat (uint32_t data)
 Set the data flag for this IMP's modified data. More...
 
cell_geomcgeom ()
 Gets the cell geometry data. More...
 
float get_dt () const
 Gets the basic integration time step. More...
 
void set_dt (float dt)
 Sets the basic integration time step. More...
 
tsget_tstp ()
 Gets the time stepper. More...
 
virtual void * get_sv_address ()=0
 Gets the raw address of the state variables for this IMP. More...
 
virtual std::size_t get_sv_size () const =0
 Gets the size of the structure this IMP uses for state variables. More...
 
std::vector< LUT > & tables ()
 Gets the array of state variables. More...
 
LUTtables_d () const
 Gets an array of LUTs. More...
 
size_t get_n_tables_d () const
 Gets the size of the array returned by IonIf::tables_d. More...
 
Target get_target () const
 
virtual void set_target (Target target)
 
void initialize_params ()
 Initializes user modifiable parameters with default values defined in the respective ionic models. More...
 
virtual void initialize (double dt, GlobalData_t **impdat)
 Initializes lookup table and state variable tables. More...
 
void compute (int start, int end, GlobalData_t **data)
 Perform ionic model computation for 1 time step. More...
 
char * fill_buf (char *buf, int *n, opencarp::Salt_list *l) const
 Appends the state variables to a buffer. More...
 
int restore (opencarp::FILE_SPEC in, int n, const int *pos, IIF_Mask_t *mask, size_t *offset, IMPinfo *impinfo, const int *loc2canon)
 Reads in the state variables for an IMP. More...
 
int dump_luts (bool zipped)
 Dumps array of LUTs to file. More...
 
void destroy_luts ()
 Destroys array of LUTs. More...
 
void tune (const char *im_par, const char *plugs, const char *plug_par)
 Tunes specific IMP parameters from files. More...
 
int read_svs (FILE *file)
 Reads state variable values for one cell from a file. More...
 
int write_svs (FILE *file, int node)
 
virtual void copy_SVs_from (IonIfBase &other, bool alloc)=0
 Copies the state variables of an IMP. More...
 
void copy_plugins_from (IonIfBase &other)
 Copies the plugins of an IMP. More...
 
void for_each (const std::function< void(IonIfBase &)> &consumer)
 Executes the consumer functions on this IMP and each of its plugins. More...
 

Public Attributes

int miifIdx
 imp index within miif More...
 
Target _target
 execution target for this IMP More...
 

Protected Attributes

ts _tstp
 control time stepping More...
 

Detailed Description

Represents the ionic model and plug-in (IMP) data structure.

Definition at line 138 of file ION_IF.h.

Constructor & Destructor Documentation

◆ IonIfBase()

limpet::IonIfBase::IonIfBase ( const IonType type,
Target  target,
int  num_node,
const std::vector< std::reference_wrapper< IonType >> &  plugins 
)

Constructor for IonIfBase.

!< pointer to external variables (Vm, Iion, etc.) that is local to this IMP

Parameters
typeionic model type
targetthis IMP will run on
num_nodenumber of cells handled by this IMP
pluginsarray of plugin types (plugins attached to this IMP)

Definition at line 116 of file ION_IF.cc.

◆ ~IonIfBase()

limpet::IonIfBase::~IonIfBase ( )
virtual

Virtual destructor declaration.

Definition at line 133 of file ION_IF.cc.

Member Function Documentation

◆ cgeom()

cell_geom& limpet::IonIfBase::cgeom ( )
inline

Gets the cell geometry data.

Returns
the cell geometry data

Definition at line 247 of file ION_IF.h.

◆ compute()

void limpet::IonIfBase::compute ( int  start,
int  end,
GlobalData_t **  data 
)

Perform ionic model computation for 1 time step.

Calls the compute functon if this IonIf's type with this IonIf's target.

Note
See limpet::IonType::compute

Definition at line 270 of file ION_IF.cc.

Here is the caller graph for this function:

◆ copy_plugins_from()

void limpet::IonIfBase::copy_plugins_from ( IonIfBase other)

Copies the plugins of an IMP.

A new IonIf object is allocated for each plugin and the state variables are copies with a call to IonIf::copy_SVs_from.

Parameters
otherIMP to copy the plugins from

Definition at line 406 of file ION_IF.cc.

◆ copy_SVs_from()

virtual void limpet::IonIfBase::copy_SVs_from ( IonIfBase other,
bool  alloc 
)
pure virtual

Copies the state variables of an IMP.

Parameters
otherwhere the values are copied from
alloctrue to allocate memory and copy IIF
Postcondition
the copy is only as deep as required for independent functioning of the copy and the original. Static data are shared.

Implemented in limpet::IonIf< T >.

◆ destroy_luts()

void limpet::IonIfBase::destroy_luts ( )

Destroys array of LUTs.

Definition at line 340 of file ION_IF.cc.

◆ dump_luts()

int limpet::IonIfBase::dump_luts ( bool  zipped)

Dumps array of LUTs to file.

Parameters
zippedflag to toggle zipped output
returnnumber of LUTs dumped

Definition at line 321 of file ION_IF.cc.

◆ fill_buf()

char * limpet::IonIfBase::fill_buf ( char *  buf,
int *  n,
opencarp::Salt_list l 
) const

Appends the state variables to a buffer.

Parameters
bufthe buffer
n[inout]current buffer size
llist of local nodes to write
Note
buf is reallocated to hold new data
Returns
pointer to the increased buffer

Definition at line 274 of file ION_IF.cc.

◆ for_each()

void limpet::IonIfBase::for_each ( const std::function< void(IonIfBase &)> &  consumer)

Executes the consumer functions on this IMP and each of its plugins.

Parameters
consumerfunctions to execute on each IMP

Definition at line 417 of file ION_IF.cc.

Here is the caller graph for this function:

◆ get_dt()

float limpet::IonIfBase::get_dt ( ) const

Gets the basic integration time step.

Returns
the basic integration time step

Definition at line 200 of file ION_IF.cc.

◆ get_moddat()

uint32_t limpet::IonIfBase::get_moddat ( ) const

Gets the data flags for this IMP's modified data.

Returns
a bitmap containing the data flags

Definition at line 192 of file ION_IF.cc.

◆ get_n_tables_d()

size_t limpet::IonIfBase::get_n_tables_d ( ) const

Gets the size of the array returned by IonIf::tables_d.

Returns
the number of LUTs stored in the device-side LUT array (this number should be the same as IonIf::tables().size().

Definition at line 216 of file ION_IF.cc.

◆ get_num_node()

int limpet::IonIfBase::get_num_node ( ) const

Gets the number of nodes handled by this IMP.

Returns
the number of nodes

Definition at line 148 of file ION_IF.cc.

Here is the caller graph for this function:

◆ get_num_threads()

std::size_t limpet::IonIfBase::get_num_threads ( ) const

Gets the number of threads used for running this IMP.

Returns
the number of threads running this IMP (dependant on target)

Definition at line 152 of file ION_IF.cc.

◆ get_reqdat()

uint32_t limpet::IonIfBase::get_reqdat ( ) const

Gets the data flags for this IMP's required data.

Returns
a bitmap containing the data flags

Definition at line 188 of file ION_IF.cc.

◆ get_sv_address()

virtual void* limpet::IonIfBase::get_sv_address ( )
pure virtual

Gets the raw address of the state variables for this IMP.

TODO: This is needed for now as many functions (write and read functions) and plugins (using the get_sv_offset function) still use the raw address of the SV table. This can be changed by rewriting the code that calls this function and by writing better tools that get_sv_offset for parent models.

Implemented in limpet::IonIf< T >.

Here is the caller graph for this function:

◆ get_sv_size()

virtual std::size_t limpet::IonIfBase::get_sv_size ( ) const
pure virtual

Gets the size of the structure this IMP uses for state variables.

TODO: This is also needed for calling code to be able to use IonIfBase::get_sv_address as it returns a void pointer.

Implemented in limpet::IonIf< T >.

Here is the caller graph for this function:

◆ get_target()

Target limpet::IonIfBase::get_target ( ) const
inline

Definition at line 338 of file ION_IF.h.

Here is the caller graph for this function:

◆ get_tstp()

ts & limpet::IonIfBase::get_tstp ( )

Gets the time stepper.

Returns
the time stepper.

Definition at line 208 of file ION_IF.cc.

Here is the caller graph for this function:

◆ get_type()

const IonType & limpet::IonIfBase::get_type ( ) const

Gets this IMP's model type.

Returns
a reference to the IMP type (set of generated functions from model code).

Definition at line 144 of file ION_IF.cc.

Here is the caller graph for this function:

◆ initialize()

void limpet::IonIfBase::initialize ( double  dt,
GlobalData_t **  impdat 
)
virtual

Initializes lookup table and state variable tables.

Parameters
dttime step
impdatdata
Precondition
numNode is set
Postcondition
lookup tables are allocated and filled
state variables are set to inital conditions
Todo:
{Further checks are needed: dt: (should be smaller than the max for each model) table range: Vm tables should be of the same size for all IIFs in use}

passing dt is no longer required

Reimplemented in limpet::IonIf< T >.

Definition at line 237 of file ION_IF.cc.

Here is the caller graph for this function:

◆ initialize_params()

void limpet::IonIfBase::initialize_params ( )

Initializes user modifiable parameters with default values defined in the respective ionic models.

Definition at line 229 of file ION_IF.cc.

◆ parent()

IonIfBase * limpet::IonIfBase::parent ( ) const

Gets the parent IMP.

Returns
a pointer to the parent of this IMP

Definition at line 176 of file ION_IF.cc.

Here is the caller graph for this function:

◆ plugins()

std::vector< IonIfBase * > & limpet::IonIfBase::plugins ( )

Returns a vector containing the plugins of this IMP.

Returns
a vector filled with plugins attached to this model

Definition at line 184 of file ION_IF.cc.

Here is the caller graph for this function:

◆ read_svs()

int limpet::IonIfBase::read_svs ( FILE *  file)

Reads state variable values for one cell from a file.

Return values
0good
1temporary table allocated
>1error

Definition at line 395 of file ION_IF.cc.

◆ restore()

int limpet::IonIfBase::restore ( opencarp::FILE_SPEC  in,
int  n,
const int *  pos,
IIF_Mask_t mask,
size_t *  offset,
IMPinfo impinfo,
const int *  loc2canon 
)

Reads in the state variables for an IMP.

The data is verified to make sure it belongs to the expected type of IMP.

Parameters
inoutput file
nnumber of nodes
pospartitioned node numbers
maskglobal region mask ordered canonically
offsetfile offset to SV info canonically ordered
impinfoIMP information
Precondition
the SV tables are allocated
Postcondition
the SV tables have new values

Definition at line 287 of file ION_IF.cc.

◆ set_dt()

void limpet::IonIfBase::set_dt ( float  dt)

Sets the basic integration time step.

Parameters
dtthe basic integration time step

Definition at line 204 of file ION_IF.cc.

◆ set_moddat()

void limpet::IonIfBase::set_moddat ( uint32_t  data)

Set the data flag for this IMP's modified data.

Parameters
databitmap containing the data flags

Definition at line 196 of file ION_IF.cc.

◆ set_parent()

void limpet::IonIfBase::set_parent ( IonIfBase parent)

Definition at line 180 of file ION_IF.cc.

◆ set_target()

void limpet::IonIfBase::set_target ( Target  target)
virtual

Reimplemented in limpet::IonIf< T >.

Definition at line 220 of file ION_IF.cc.

Here is the caller graph for this function:

◆ tables()

std::vector< LUT > & limpet::IonIfBase::tables ( )

Gets the array of state variables.

Returns
a reference to the state variable array structure. Gets the lookup tables.
a reference to the vector of lookup tables (LUT) used by this IMP.

Definition at line 212 of file ION_IF.cc.

Here is the caller graph for this function:

◆ tables_d()

LUT* limpet::IonIfBase::tables_d ( ) const
inline

Gets an array of LUTs.

Returns
an array to LUT structures. Those LUTs are allocated on a device (GPU) and mirror the data in the vector returned by the IonIf::tables getter method.

Definition at line 323 of file ION_IF.h.

◆ tune()

void limpet::IonIfBase::tune ( const char *  im_par,
const char *  plugs,
const char *  plug_par 
)

Tunes specific IMP parameters from files.

For each IMP, a comma separated list of expressions is specified. Each expression is of the form
parameter[+|-|=|/|*][-]###[.[###][e|E[-|+]###][%]
which specifies a float optionally preceded by * or + or - or / or = and optionally followed by a % (float is expressed as a percent of the default value). The meanings of the flags are

=
assign this value to the parameter
*
multiply the default parameter value by this
/
divide the default parameter value by this
+
add this to the default value
-
subtract this from the default value
%
treat the float as this percentage of the default

Plugins and their respective parameters must be specified in the same order

Parameters
im_parcomma separated list of IM specific parameters
plugsplugins specified in colon separated list
plug_parcolon separated list of comma separated lists specifiying parameters for each plugin

Definition at line 348 of file ION_IF.cc.

◆ write_svs()

int limpet::IonIfBase::write_svs ( FILE *  file,
int  node 
)

Definition at line 402 of file ION_IF.cc.

Member Data Documentation

◆ _target

Target limpet::IonIfBase::_target

execution target for this IMP

Definition at line 151 of file ION_IF.h.

◆ _tstp

ts limpet::IonIfBase::_tstp
protected

control time stepping

Definition at line 153 of file ION_IF.h.

◆ miifIdx

int limpet::IonIfBase::miifIdx

imp index within miif

Definition at line 150 of file ION_IF.h.


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