MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ReadKkit.cpp File Reference
#include <iomanip>
#include <fstream>
#include "header.h"
#include "../utility/utility.h"
#include "PoolBase.h"
#include "Pool.h"
#include "BufPool.h"
#include "ReacBase.h"
#include "EnzBase.h"
#include "lookupVolumeFromMesh.h"
#include "../shell/Shell.h"
#include "../shell/Wildcard.h"
#include "ReadKkit.h"
+ Include dependency graph for ReadKkit.cpp:

Go to the source code of this file.

Enumerations

enum  GenesisTableModes {
  TAB_IO, TAB_LOOP, TAB_ONCE, TAB_BUF,
  TAB_SPIKE, TAB_FIELDS, TAB_DELAY
}
 

Functions

void assignArgs (map< string, int > &argConv, const vector< string > &args)
 
unsigned int chopLine (const string &line, vector< string > &ret)
 
Id findMeshOfEnz (Id enz)
 
Id findParentComptOfReac (Id reac)
 
vector< unsigned int > findVolOrder (const vector< double > &vols)
 
string lower (const string &input)
 
void makeSolverOnCompt (Shell *s, const vector< ObjId > &compts, bool isGsolve)
 
Id makeStandardElements (Id pa, const string &modelname)
 
static void positionCompt (ObjId compt, double side, bool shiftUp)
 
void setMethod (Shell *s, Id mgr, double simdt, double plotdt, const string &method)
 
bool volCompare (const pair< unsigned int, double > &A, const pair< unsigned int, double > &B)
 

Variables

static const double KKIT_NA = 6.0e23
 

Enumeration Type Documentation

Enumerator
TAB_IO 
TAB_LOOP 
TAB_ONCE 
TAB_BUF 
TAB_SPIKE 
TAB_FIELDS 
TAB_DELAY 

Definition at line 1242 of file ReadKkit.cpp.

Function Documentation

void assignArgs ( map< string, int > &  argConv,
const vector< string > &  args 
)

Definition at line 562 of file ReadKkit.cpp.

Referenced by ReadKkit::objdump().

563 {
564  for ( unsigned int i = 2; i != args.size(); ++i )
565  argConv[ args[i] ] = i + 2;
566 }

+ Here is the caller graph for this function:

unsigned int chopLine ( const string &  line,
vector< string > &  ret 
)

Definition at line 31 of file ReadKkit.cpp.

References moose::trim().

Referenced by ReadKkit::readData(), and ReadKkit::readInit().

32 {
33  ret.resize( 0 );
34  stringstream ss( line );
35  string arg;
36  while ( ss >> arg ) {
37  ret.push_back( moose::trim(arg, "\"") );
38  }
39  return ret.size();
40 }
std::string trim(const std::string myString, const string &delimiters)
Definition: strutil.cpp:53

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Id findMeshOfEnz ( Id  enz)

Return the MeshEntry into which the enzyme should be placed. This is simple: Just identify the compartment holding the enzyme molecule.

Definition at line 828 of file ReadKkit.cpp.

References Id::element(), Cinfo::findFinfo(), getCompt(), Element::getNeighbors(), and EnzBase::initCinfo().

829 {
830  static const Finfo* enzFinfo =
831  EnzBase::initCinfo()->findFinfo( "enzOut" );
832  assert( enzFinfo );
833 
834  vector< Id > enzVec;
835  enz.element()->getNeighbors( enzVec, enzFinfo );
836  assert( enzVec.size() == 1 );
837  vector< Id > meshEntries;
838  return getCompt( enzVec[0] );
839 }
Element * element() const
Synonym for Id::operator()()
Definition: Id.cpp:113
ObjId getCompt(Id id)
unsigned int getNeighbors(vector< Id > &ret, const Finfo *finfo) const
Definition: Element.cpp:949
static const Cinfo * initCinfo()
Definition: EnzBase.cpp:33
const Finfo * findFinfo(const string &name) const
Definition: Cinfo.cpp:224
Definition: Finfo.h:12

+ Here is the call graph for this function:

Id findParentComptOfReac ( Id  reac)

Definition at line 789 of file ReadKkit.cpp.

References Id::element(), Cinfo::findFinfo(), getCompt(), Element::getNeighbors(), and ReacBase::initCinfo().

Referenced by ReadKkit::assignReacCompartments().

790 {
791  static const Finfo* subFinfo =
792  ReacBase::initCinfo()->findFinfo( "subOut" );
793  assert( subFinfo );
794 
795  vector< Id > subVec;
796  reac.element()->getNeighbors( subVec, subFinfo );
797  if ( subVec.size() == 0 ) // Dangling reaction
798  return Id();
799  // For now just put the reac in the compt belonging to the
800  // first substrate
801  return getCompt( subVec[0] );
802 }
Element * element() const
Synonym for Id::operator()()
Definition: Id.cpp:113
static const Cinfo * initCinfo()
Definition: ReacBase.cpp:33
ObjId getCompt(Id id)
Definition: Id.h:17
unsigned int getNeighbors(vector< Id > &ret, const Finfo *finfo) const
Definition: Element.cpp:949
const Finfo * findFinfo(const string &name) const
Definition: Cinfo.cpp:224
Definition: Finfo.h:12

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

vector< unsigned int > findVolOrder ( const vector< double > &  vols)

Definition at line 723 of file ReadKkit.cpp.

References volCompare().

Referenced by ReadKkit::assignPoolCompartments(), and testVolSort().

724 {
725  vector< pair< unsigned int, double > > p( vols.size() );
726  for ( unsigned int i = 0; i < vols.size(); ++i ) {
727  p[i].first = i;
728  p[i].second = vols[i];
729  }
730  sort( p.begin(), p.end(), volCompare );
731  vector< unsigned int > ret( vols.size() );
732  for ( unsigned int i = 0; i < vols.size(); ++i ) {
733  ret[ vols.size() -i -1 ] = p[i].first;
734  }
735  return ret;
736 }
bool volCompare(const pair< unsigned int, double > &A, const pair< unsigned int, double > &B)
Definition: ReadKkit.cpp:715

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

string lower ( const string &  input)

Definition at line 42 of file ReadKkit.cpp.

Referenced by setMethod().

43 {
44  string ret = input;
45  for ( unsigned int i = 0; i < input.length(); ++i )
46  ret[i] = tolower( ret[i] );
47  return ret;
48 }

+ Here is the caller graph for this function:

void makeSolverOnCompt ( Shell s,
const vector< ObjId > &  compts,
bool  isGsolve 
)

Definition at line 166 of file ReadKkit.cpp.

168 {
169 
170  if ( compts.size() > 3 ) {
171  cout << "Warning: ReadKkit::makeSolverOnCompt: Cannot handle " <<
172  compts.size() << " chemical compartments\n";
173  return;
174  }
175  vector< Id > stoichVec;
176  /*
177  if ( compts.size() == 2 ) {
178  double side = Field< double >::get( compts[1], "dy" );
179  positionCompt( compts[0], side, true );
180  }
181  if ( compts.size() == 3 ) {
182  double side = Field< double >::get( compts[1], "dy" );
183  positionCompt( compts[0], side, true );
184  positionCompt( compts[2], side, false );
185  }
186  */
187  /*
188  for ( vector< ObjId >::const_iterator
189  i = compts.begin(); i != compts.end(); ++i ) {
190  string simpath = i->path() + "/##";
191  Id ksolve;
192  if ( isGsolve )
193  ksolve = s->doCreate( "Gsolve", *i, "gsolve", 1 );
194  else
195  ksolve = s->doCreate( "Ksolve", *i, "ksolve", 1 );
196  dsolve = s->doCreate("Dsolve,")
197  Id stoich = s->doCreate( "Stoich", *i, "stoich", 1 );
198  stoichVec.push_back( stoich );
199  Field< Id >::set( stoich, "compartment", *i );
200  Field< Id >::set( stoich, "ksolve", ksolve );
201  Field< string >::set( stoich, "path", simpath );
202  }
203  */
204  /* Not needed now that we use xfer pools to cross compartments.
205  if ( stoichVec.size() == 2 ) {
206  SetGet1< Id >::set( stoichVec[1], "buildXreacs", stoichVec[0] );
207  }
208  if ( stoichVec.size() == 3 ) {
209  SetGet1< Id >::set( stoichVec[1], "buildXreacs", stoichVec[0] );
210  SetGet1< Id >::set( stoichVec[1], "buildXreacs", stoichVec[2] );
211  }
212  for ( vector< Id >::iterator
213  i = stoichVec.begin(); i != stoichVec.end(); ++i ) {
214  SetGet0::set( *i, "filterXreacs" );
215  }
216  */
217 }
Id makeStandardElements ( Id  pa,
const string &  modelname 
)

Definition at line 123 of file ReadKkit.cpp.

References Eref::data(), Shell::doCreate(), Id::eref(), MooseGlobal, Id::path(), and SetGet2< A1, A2 >::set().

Referenced by ReadKkit::read(), and ReadCspace::readModelString().

124 {
125  Shell* shell = reinterpret_cast< Shell* >( Id().eref().data() );
126  string modelPath = pa.path() + "/" + modelname;
127  if ( pa == Id() )
128  modelPath = "/" + modelname;
129  Id mgr( modelPath );
130  if ( mgr == Id() )
131  mgr = shell->doCreate( "Neutral", pa, modelname, 1, MooseGlobal );
132  Id kinetics( modelPath + "/kinetics" );
133  if ( kinetics == Id() ) {
134  kinetics =
135  shell->doCreate( "CubeMesh", mgr, "kinetics", 1, MooseGlobal );
136  SetGet2< double, unsigned int >::set( kinetics, "buildDefaultMesh", 1e-15, 1 );
137  }
138  assert( kinetics != Id() );
139 
140  Id graphs = shell->doCreate( "Neutral", mgr, "graphs", 1, MooseGlobal);
141  assert( graphs != Id() );
142  Id moregraphs = shell->doCreate( "Neutral", mgr, "moregraphs", 1, MooseGlobal );
143 
144  Id geometry = shell->doCreate( "Neutral", mgr, "geometry", 1, MooseGlobal );
145  assert( geometry != Id() );
146 
147  Id groups =
148  shell->doCreate( "Neutral", mgr, "groups", 1, MooseGlobal );
149  assert( groups != Id() );
150  return mgr;
151 }
char * data() const
Definition: Eref.cpp:41
std::string path(const std::string &separator="/") const
Definition: Id.cpp:76
Eref eref() const
Definition: Id.cpp:125
Id doCreate(string type, ObjId parent, string name, unsigned int numData, NodePolicy nodePolicy=MooseBlockBalance, unsigned int preferredNode=1)
Definition: Shell.cpp:181
Definition: Id.h:17
Definition: Shell.h:43
static bool set(const ObjId &dest, const string &field, A1 arg1, A2 arg2)
Definition: SetGet.h:365

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void positionCompt ( ObjId  compt,
double  side,
bool  shiftUp 
)
static

Definition at line 153 of file ReadKkit.cpp.

References Field< A >::get(), and Field< A >::set().

154 {
155  double y0 = Field< double >::get( compt, "y0" );
156  double y1 = Field< double >::get( compt, "y1" );
157  if ( shiftUp ) {
158  Field< double >::set( compt, "y0", y0 + side );
159  Field< double >::set( compt, "y1", y1 + side );
160  } else {
161  Field< double >::set( compt, "y0", y0 - y1 );
162  Field< double >::set( compt, "y1", 0 );
163  }
164 }
static bool set(const ObjId &dest, const string &field, A arg)
Definition: SetGet.h:245
static A get(const ObjId &dest, const string &field)
Definition: SetGet.h:284

+ Here is the call graph for this function:

void setMethod ( Shell s,
Id  mgr,
double  simdt,
double  plotdt,
const string &  method 
)

Definition at line 219 of file ReadKkit.cpp.

References Shell::doSetClock(), Shell::doUseClock(), lower(), Id::path(), and simpleWildcardFind().

Referenced by ReadKkit::read().

221 {
222  vector< ObjId > ret;
223  simpleWildcardFind( mgr.path() + "/#[ISA=ChemCompt]", ret );
224  assert( ret.size() > 0 );
225 
226  Id compt( mgr.path() + "/kinetics" );
227  assert( compt != Id() );
228  string simpath2 = mgr.path() + "/##[ISA=StimulusTable]," +
229  mgr.path() + "/##[ISA=PulseGen]";
230  string m = lower( method );
231  /*
232  if ( m == "ksolve" || m =="gsl" || m == "gssa" || m == "gsolve" ||
233  m == "gillespie" || m == "stochastic" )
234  {
235  cout << " Warning: Default solver set is Exponential Euler. To set \'gsl\' or \'gssa\' solver use function mooseaddChemSolver(modelpath,\'solverType\')"<<"\n";
236  }
237 
238 
239  if ( m == "rk4" ) {
240  cout << "Warning, not yet implemented. Using rk5 instead\n";
241  m = "rk5";
242  }
243  if ( m == "ksolve" || m == "gsl" ||
244  m == "rk5" || m == "rkf" || m == "rk" ) {
245  makeSolverOnCompt( s, mgr, ret, false );
246  } else if ( m == "gssa" || m == "gsolve" ||
247  m == "gillespie" || m == "stochastic" ) {
248  makeSolverOnCompt( s, mgr,ret, true );
249  } else if ( m == "ee" || m == "neutral" ) {
250  // s->doUseClock( simpath, "process", 4 );
251  // s->doSetClock( 4, simdt );
252  } else {
253  cout << "ReadKkit::setMethod: option " << method <<
254  " not known, using Exponential Euler (ee)\n";
255  // s->doUseClock( simpath, "process", 4 );
256  // s->doSetClock( 4, simdt );
257  }
258  */
259  s->doUseClock( simpath2, "proc", 11 );
260  s->doSetClock( 10, simdt );
261  s->doSetClock( 11, simdt );
262  s->doSetClock( 12, simdt );
263  s->doSetClock( 13, simdt );
264  s->doSetClock( 14, simdt );
265  s->doSetClock( 15, plotdt ); // Gsolve and Ksolve
266  s->doSetClock( 16, plotdt ); // Gsolve and Ksolve
267  s->doSetClock( 17, plotdt ); // Stats objects
268  s->doSetClock( 18, plotdt ); // Table2 objects.
269 }
void doSetClock(unsigned int tickNum, double dt)
Definition: Shell.cpp:377
std::string path(const std::string &separator="/") const
Definition: Id.cpp:76
int simpleWildcardFind(const string &path, vector< ObjId > &ret)
Definition: Wildcard.cpp:137
string lower(const string &input)
Definition: ReadKkit.cpp:42
Definition: Id.h:17
void doUseClock(string path, string field, unsigned int tick)
Definition: Shell.cpp:382

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool volCompare ( const pair< unsigned int, double > &  A,
const pair< unsigned int, double > &  B 
)

Definition at line 715 of file ReadKkit.cpp.

Referenced by findVolOrder().

718 {
719  return A.second < B.second;
720 }

+ Here is the caller graph for this function:

Variable Documentation