Files
@ 854077b2d7cc
Branch filter:
Location: EI/VirtualLeaf/src/cellbase.h - annotation
854077b2d7cc
10.7 KiB
text/x-chdr
Added first tissue growth protocol: The expanding cell.
--
user: Michael Guravage <michael.guravage@cwi.nl>
branch 'default'
added src/protocols/MyGrowthModel/Makefile
added src/protocols/MyGrowthModel/mygrowthmodel.cpp
added src/protocols/MyGrowthModel/mygrowthmodel.h
added src/protocols/MyGrowthModel/mygrowthmodel.pro
changed src/protocols/Makefile
--
user: Michael Guravage <michael.guravage@cwi.nl>
branch 'default'
added src/protocols/MyGrowthModel/Makefile
added src/protocols/MyGrowthModel/mygrowthmodel.cpp
added src/protocols/MyGrowthModel/mygrowthmodel.h
added src/protocols/MyGrowthModel/mygrowthmodel.pro
changed src/protocols/Makefile
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 | 79f94eaa3b9e 79f94eaa3b9e 79f94eaa3b9e 79f94eaa3b9e 79f94eaa3b9e 79f94eaa3b9e 15d600891648 79f94eaa3b9e 79f94eaa3b9e 79f94eaa3b9e 79f94eaa3b9e 15d600891648 79f94eaa3b9e 79f94eaa3b9e 79f94eaa3b9e 79f94eaa3b9e 79f94eaa3b9e 79f94eaa3b9e 79f94eaa3b9e 79f94eaa3b9e 79f94eaa3b9e 79f94eaa3b9e 79f94eaa3b9e 79f94eaa3b9e 79f94eaa3b9e 79f94eaa3b9e 79f94eaa3b9e 79f94eaa3b9e 79f94eaa3b9e 79f94eaa3b9e 79f94eaa3b9e 79f94eaa3b9e 096de6bb6fab 096de6bb6fab 79f94eaa3b9e 79f94eaa3b9e 79f94eaa3b9e 79f94eaa3b9e 096de6bb6fab 79f94eaa3b9e 79f94eaa3b9e 79f94eaa3b9e 79f94eaa3b9e 79f94eaa3b9e 79f94eaa3b9e 79f94eaa3b9e 79f94eaa3b9e 79f94eaa3b9e 79f94eaa3b9e 782330072e62 782330072e62 782330072e62 782330072e62 79f94eaa3b9e 79f94eaa3b9e 79f94eaa3b9e 79f94eaa3b9e 15d600891648 79f94eaa3b9e 79f94eaa3b9e 79f94eaa3b9e 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 79f94eaa3b9e 79f94eaa3b9e 79f94eaa3b9e 79f94eaa3b9e 79f94eaa3b9e 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 79f94eaa3b9e 79f94eaa3b9e 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 79f94eaa3b9e 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 79f94eaa3b9e 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 096de6bb6fab 782330072e62 096de6bb6fab 782330072e62 782330072e62 782330072e62 782330072e62 79f94eaa3b9e 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 79f94eaa3b9e 782330072e62 782330072e62 782330072e62 782330072e62 79f94eaa3b9e 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 79f94eaa3b9e 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 8aaffb5565a2 782330072e62 782330072e62 782330072e62 782330072e62 79f94eaa3b9e 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 79f94eaa3b9e 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 79f94eaa3b9e 782330072e62 79f94eaa3b9e 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 79f94eaa3b9e 8aaffb5565a2 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 79f94eaa3b9e 79f94eaa3b9e 782330072e62 782330072e62 79f94eaa3b9e 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 79f94eaa3b9e 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 79f94eaa3b9e 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 79f94eaa3b9e 782330072e62 782330072e62 79f94eaa3b9e 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 79f94eaa3b9e 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 79f94eaa3b9e 782330072e62 782330072e62 782330072e62 782330072e62 79f94eaa3b9e 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 79f94eaa3b9e 79f94eaa3b9e 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 79f94eaa3b9e 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 79f94eaa3b9e 782330072e62 782330072e62 79f94eaa3b9e 782330072e62 79f94eaa3b9e 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 79f94eaa3b9e 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 79f94eaa3b9e 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 782330072e62 79f94eaa3b9e 79f94eaa3b9e 79f94eaa3b9e 79f94eaa3b9e 782330072e62 782330072e62 782330072e62 79f94eaa3b9e 79f94eaa3b9e 79f94eaa3b9e 79f94eaa3b9e 782330072e62 | /*
*
* $Id$
*
* This file is part of the Virtual Leaf.
*
* VirtualLeaf is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VirtualLeaf is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the Virtual Leaf. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2010 Roeland Merks.
*
*/
// CellBase derives from Vector, where Vector is simply used as a Vertex
#ifndef _CELLBASE_H_
#define _CELLBASE_H_
#include <list>
#include <vector>
#include <iostream>
#include <QString>
#include <QDebug>
#include "vector.h"
#include "parameter.h"
#include "wall.h"
#include "warning.h"
#include "assert.h"
extern Parameter par;
using namespace std;
class Mesh;
class Node;
class CellBase;
class NodeSet;
struct ParentInfo {
Vector polarization;
double PINmembrane;
double PINendosome;
};
// We need a little trick here, to make sure the plugin and the main application will see the same static datamembers
// otherwise each have their own instantation.
// My solution is as follows. I collect all original statics in a class. The main application instantiates it and
// has a static pointer to it. After loading the plugin I set a static pointer to the same class
class CellsStaticDatamembers {
public:
CellsStaticDatamembers(void) {
ncells = 0;
nchem = 0;
base_area = 0.;
}
~CellsStaticDatamembers() {
#ifdef QDEBUG
qDebug() << "Oops! Desctructor of CellsStaticDatamembers called" << endl;
#endif
}
int ncells;
int nchem;
double base_area;
};
class CellBase : public QObject, public Vector
{
Q_OBJECT
friend class Mesh;
friend class CellInfo;
friend class Node;
friend class WallBase;
friend class SimPluginInterface;
public:
CellBase(QObject *parent=0);
CellBase(double x,double y,double z=0); // constructor
virtual ~CellBase() {
delete[] chem;
delete[] new_chem;
if (division_axis) delete division_axis;
//cerr << "CellBase " << index << " is dying. " << endl;
}
CellBase(const CellBase &src); // copy constructor
virtual bool BoundaryPolP(void) const { return false; }
CellBase operator=(const CellBase &src); // assignment operator
CellBase operator=(const Vector &src);
void SetChemical(int chem, double conc);
inline void SetNewChem(int chem, double conc)
{
new_chem[chem] = conc;
}
void SetSource(int chem, double conc)
{
source=true;
source_chem = chem;
source_conc = conc;
}
// set chem 1 to conc in all membranes of this cell
void SetTransporters(int chem, double conc);
void UnfixNodes(void);
void FixNodes(void);
void UnsetSource(void) {
source = false;
}
inline bool Source(void) { return source; }
enum boundary_type {None, Noflux, SourceSink, SAM};
static const char * boundary_type_names[4];
inline const char *BoundaryStr(void) { return boundary_type_names[boundary]; }
ostream &print(ostream &os) const;
inline double Chemical(int c) const { // returns the value of chemical c
#ifdef _undefined_
qDebug() << endl << "Entering cellbase::chemical(" << c << "), and nchem is: " << NChem() << "." << endl;
#endif
int nchem = NChem();
#ifdef _undefined_
if ((c<0) || (c>=nchem))
MyWarning::warning("CellBase::Chemical says: index c is: %d, but nchem is: %d. Merely return zero", c, nchem);
#endif
return ((c<0) || (c>=nchem)) ? 0 : chem[c];
}
//void print_nblist(void) const;
boundary_type SetBoundary(boundary_type bound)
{
if (bound!=None) {
}
return boundary=bound;
}
boundary_type ResetBoundary(void) { return boundary=None; }
boundary_type Boundary(void) const { return boundary; }
static int &NChem(void) { return static_data_members->nchem; }
double CalcArea(void) const;
double RecalcArea(void) { return area = CalcArea(); }
Vector Centroid(void) const;
void SetIntegrals(void) const;
double Length(Vector *long_axis = 0, double *width = 0) const;
double CalcLength(Vector *long_axis = 0, double *width = 0) const;
double ExactCircumference(void) const;
inline int Index(void) const { return index; }
void SetTargetArea(double tar_ar) { target_area=tar_ar; }
inline void SetTargetLength(double tar_l) { target_length=tar_l; }
inline void SetLambdaLength(double lambda_length) { lambda_celllength = lambda_length; }
inline double TargetArea(void) { return target_area; }
inline void SetStiffness(double stiff) { stiffness = stiff; }
inline double Stiffness(void) { return stiffness; }
inline double EnlargeTargetArea(double da) { return target_area+=da; }
inline double Area(void) const { return area; }
inline void Divide(void) { flag_for_divide = true; }
inline void DivideOverAxis(const Vector &v)
{
division_axis = new Vector(v);
flag_for_divide = true;
}
inline double WallCircumference(void) const {
double sum=0.;
for (list<Wall *>::const_iterator w=walls.begin();
w!=walls.end();
w++) {
sum += (*w)->Length();
}
return sum;
}
QList<WallBase *> getWalls(void) {
QList<WallBase *> wall_list;
for (list<Wall *>::iterator i=walls.begin();
i!=walls.end();
i++) {
wall_list << *i;
}
return wall_list;
}
void Dump(ostream &os) const;
QString printednodelist(void);
inline bool DeadP(void) { return dead; }
inline void MarkDead(void) { dead = true; }
static double &BaseArea(void)
{
return static_data_members->base_area;
}
void CheckForDivision(void);
// write flux from neighboring cells into "flux"
void Flux(double *flux, double *D);
inline bool FixedP(void) { return fixed; }
inline bool Fix(void) { FixNodes(); return (fixed=true); }
inline bool Unfix(void) { UnfixNodes(); return (fixed=false);}
inline void setCellVec(Vector cv) { cellvec = cv; }
bool AtBoundaryP(void) const;
static inline int &NCells(void)
{
return static_data_members->ncells;
}
inline void Mark(void)
{
marked=true;
}
inline void Unmark(void)
{
marked=false;
}
inline bool Marked(void) const {
return marked;
}
//! Returns the sum of chemical "chem" of this CellBase's neighbors
double SumChemicalsOfNeighbors(int chem)
{
double sum=0.;
for (list<Wall *>::const_iterator w=walls.begin();
w!=walls.end();
w++) {
sum += (*w)->Length() * ( (*w)->c1!=this ? (*w)->c1->Chemical(chem) : (*w)->c2->Chemical(chem) );
}
return sum;
}
//! Generalization of the previous member function
template<class P, class Op> P ReduceNeighbors(Op f) {
P sum=0;
for (list<Wall *>::const_iterator w=walls.begin();
w!=walls.end();
w++) {
sum += (*w)->c1 != this ? f( *((*w)->c1) ) : f ( *((*w)->c2) );
}
return sum;
}
//! The same, but now for the walls
template<class P, class Op> P ReduceWalls(Op f, P sum) {
for (list<Wall *>::const_iterator w=walls.begin();
w!=walls.end();
w++) {
sum += f( **w );
}
return sum;
}
//! The same, but now for the walls AND neighbors
template<class P, class Op> P ReduceCellAndWalls(Op f)
{
P sum = 0;
for (list<Wall *>::const_iterator w=walls.begin();
w!=walls.end();
w++) {
sum += ((*w)->c1 == this) ?
f( ((*w)->c1), ((*w)->c2), *w ) :
f( ((*w)->c2), ((*w)->c1), *w );
}
return sum;
}
//! Sum transporters at this CellBase's side of the walls
double SumTransporters(int ch)
{
double sum=0.;
for (list<Wall *>::const_iterator w=walls.begin();
w!=walls.end();
w++) {
sum += (*w)->getTransporter(this, ch);
}
return sum;
}
inline int NumberOfDivisions(void) { return div_counter; }
//! Sum transporters at this CellBase's side of the walls
double SumLengthTransporters(int ch)
{
double sum=0.;
for (list<Wall *>::const_iterator w=walls.begin();
w!=walls.end();
w++) {
sum += (*w)->getTransporter(this, ch) * (*w)->Length();
}
return sum;
}
double SumLengthTransportersChemical(int trch, int ch)
{
double sum=0.;
for (list<Wall *>::const_iterator w=walls.begin();
w!=walls.end();
w++) {
sum += (*w)->getTransporter(this, trch) * ( (*w)->c1!=this ? (*w)->c1->Chemical(ch) : (*w)->c2->Chemical(ch) );
}
return sum;
}
inline int CellType(void) const { return cell_type; }
inline void SetCellType(int ct) { cell_type = ct; }
static void SetNChem(int new_nchem)
{
if (NCells()) {
MyWarning::error("CellBase::SetNChem says: not permitted, call SetNChem after deleting all cells.");
} else {
NChem() = new_nchem;
}
}
inline double TargetLength() const { return target_length; }
static inline CellsStaticDatamembers *GetStaticDataMemberPointer(void) { return static_data_members; }
protected:
// (define a list of Node* iterators)
typedef list < list<Node *>::iterator > ItList;
int index;
inline void SetChemToNewchem(void)
{
for (int c=0;c<CellBase::NChem();c++) {
chem[c]=new_chem[c];
}
}
inline void SetNewChemToChem(void)
{
for (int c=0;c<CellBase::NChem();c++) {
new_chem[c]=chem[c];
}
}
inline double NewChem(int c) const { return new_chem[c]; }
protected:
list<Node *> nodes;
void ConstructNeighborList(void);
long wall_list_index (Wall *elem) const;
// DATA MEMBERS
// list of nodes, in clockwise order
// a (non-ordered) list of neighboring cells (actually I think the
// introduction of ConstructWalls() has made these
// lists ordered (clockwise), but I am not yet 100% sure...).
list<CellBase *> neighbors;
list<Wall *> walls;
double *chem;
double *new_chem;
boundary_type boundary;
mutable double area;
double target_area;
double target_length;
double lambda_celllength;
double stiffness; // stiffness like in Hogeweg (2000)
bool fixed;
bool pin_fixed;
bool at_boundary;
bool dead;
bool flag_for_divide;
Vector *division_axis;
int cell_type;
// for length constraint
mutable double intgrl_xx, intgrl_xy, intgrl_yy, intgrl_x, intgrl_y;
bool source;
Vector cellvec;
// STATIC DATAMEMBERS MOVED TO CLASS
static CellsStaticDatamembers *static_data_members;
double source_conc;
int source_chem;
// PRIVATE MEMBER FUNCTIONS
inline static void ClearNCells(void)
{
NCells()=0;
}
bool marked;
int div_counter;
};
ostream &operator<<(ostream &os, const CellBase &v);
inline Vector PINdir(CellBase *here, CellBase *nb, Wall *w)
{
return w->getTransporter( here, 1) * w->getInfluxVector(here);
}
#endif
/* finis*/
|