MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
testMesh.cpp File Reference
#include "header.h"
#include "SparseMatrix.h"
#include "../shell/Shell.h"
#include "Boundary.h"
#include "MeshEntry.h"
#include "ChemCompt.h"
#include "MeshCompt.h"
#include "CubeMesh.h"
#include "CylBase.h"
#include "NeuroNode.h"
#include "NeuroMesh.h"
#include "../utility/Vec.h"
#include "CylMesh.h"
#include "SpineEntry.h"
#include "SpineMesh.h"
#include "PsdMesh.h"
+ Include dependency graph for testMesh.cpp:

Go to the source code of this file.

Typedefs

typedef pair< unsigned int,
unsigned int > 
PII
 

Functions

void checkAbut (const vector< PII > &intersect, unsigned int ix, unsigned int iy, unsigned int iz, unsigned int nx, unsigned int ny, unsigned int nz, unsigned int meshIndex, vector< VoxelJunction > &ret)
 
Id makeCompt (Id parentCompt, Id parentObj, string name, double len, double dia, double theta)
 
void setIntersectVoxel (vector< PII > &intersect, unsigned int ix, unsigned int iy, unsigned int iz, unsigned int nx, unsigned int ny, unsigned int nz, unsigned int meshIndex)
 
void testCubeMesh ()
 
void testCubeMeshExtendStencil ()
 
void testCubeMeshFillThreeDimSurface ()
 
void testCubeMeshFillTwoDimSurface ()
 
void testCubeMeshJunctionDiffSizeMesh ()
 
void testCubeMeshJunctionThreeDimSurface ()
 
void testCubeMeshJunctionTwoDimSurface ()
 
void testCubeMeshMultiJunctionTwoD ()
 
void testIntersectVoxel ()
 
void testMesh ()
 
void testReMesh ()
 
void testVec ()
 
void testVolScaling ()
 

Variables

static const unsigned int ABUT = ~2
 
static const unsigned int EMPTY = ~0
 
static const unsigned int MULTI = ~3
 
static const unsigned int SURFACE = ~1
 

Typedef Documentation

typedef pair< unsigned int, unsigned int > PII

Definition at line 1304 of file testMesh.cpp.

Function Documentation

void checkAbut ( const vector< PII > &  intersect,
unsigned int  ix,
unsigned int  iy,
unsigned int  iz,
unsigned int  nx,
unsigned int  ny,
unsigned int  nz,
unsigned int  meshIndex,
vector< VoxelJunction > &  ret 
)

checkAbut checks the intersect vector for the current position ix, iy, iz, to determine how many diffusion terms to extract. It then puts each of the extracted terms into the ret vector. There is a minor efficiency for one and two diffusion terms as they are encoded within the intersect vector. Higher-order surface alignments require an in-line scan of neighboring voxels. In all casesl the function inserts a flag indicating surface direction into the diffScale field of the VoxelJunction. 0 = x; 1 = y; 2 = z.

Definition at line 1348 of file CubeMesh.cpp.

References CubeMesh::ABUTX, CubeMesh::ABUTY, CubeMesh::ABUTZ, CubeMesh::EMPTY, CubeMesh::MULTI, and CubeMesh::SURFACE.

Referenced by CubeMesh::matchCubeMeshEntries(), and testIntersectVoxel().

1355 {
1356  unsigned int index = ( iz * ny + iy ) * nx + ix;
1357  unsigned int localFlag = intersect[index].second;
1358 
1359  if ( localFlag == CubeMesh::EMPTY || localFlag == CubeMesh::SURFACE )
1360  return; // Nothing to put into the ret vector
1361  if ( localFlag == CubeMesh::ABUTX ) {
1362  ret.push_back(
1363  VoxelJunction( intersect[index].first, meshIndex, 0 ));
1364  } else if ( localFlag == CubeMesh::ABUTY ) {
1365  ret.push_back(
1366  VoxelJunction( intersect[index].first, meshIndex, 1 ));
1367  } else if ( localFlag == CubeMesh::ABUTZ ) {
1368  ret.push_back(
1369  VoxelJunction( intersect[index].first, meshIndex, 2 ));
1370  } else if ( localFlag == CubeMesh::MULTI ) { // go through all 6 cases.
1371  if ( ix > 0 ) {
1372  index = ( iz * ny + iy ) * nx + ix - 1;
1373  if ( intersect[index].second == CubeMesh::SURFACE )
1374  ret.push_back(
1375  VoxelJunction( intersect[index].first, meshIndex, 0 ));
1376  }
1377  if ( ix + 1 < nx ) {
1378  index = ( iz * ny + iy ) * nx + ix + 1;
1379  if ( intersect[index].second == CubeMesh::SURFACE )
1380  ret.push_back(
1381  VoxelJunction( intersect[index].first, meshIndex, 0 ));
1382  }
1383  if ( iy > 0 ) {
1384  index = ( iz * ny + iy -1 ) * nx + ix;
1385  if ( intersect[index].second == CubeMesh::SURFACE )
1386  ret.push_back(
1387  VoxelJunction( intersect[index].first, meshIndex, 1 ));
1388  }
1389  if ( iy + 1 < ny ) {
1390  index = ( iz * ny + iy + 1 ) * nx + ix;
1391  if ( intersect[index].second == CubeMesh::SURFACE )
1392  ret.push_back(
1393  VoxelJunction( intersect[index].first, meshIndex, 1 ));
1394  }
1395  if ( iz > 0 ) {
1396  index = ( (iz-1) * ny + iy ) * nx + ix;
1397  if ( intersect[index].second == CubeMesh::SURFACE )
1398  ret.push_back(
1399  VoxelJunction( intersect[index].first, meshIndex, 2 ));
1400  }
1401  if ( iz + 1 < nz ) {
1402  index = ( (iz+1) * ny + iy ) * nx + ix;
1403  if ( intersect[index].second == CubeMesh::SURFACE )
1404  ret.push_back(
1405  VoxelJunction( intersect[index].first, meshIndex, 2 ));
1406  }
1407  }
1408 }
static const unsigned int ABUTY
Definition: CubeMesh.h:288
static const unsigned int MULTI
Definition: CubeMesh.h:290
static const unsigned int SURFACE
Definition: CubeMesh.h:286
static const unsigned int EMPTY
Definition: CubeMesh.h:285
static const unsigned int ABUTZ
Definition: CubeMesh.h:289
static const unsigned int ABUTX
Definition: CubeMesh.h:287

+ Here is the caller graph for this function:

Id makeCompt ( Id  parentCompt,
Id  parentObj,
string  name,
double  len,
double  dia,
double  theta 
)

theta in degrees len and dia in metres as usual

Definition at line 855 of file testMesh.cpp.

References Eref::data(), Shell::doAddMsg(), Shell::doCreate(), Id::eref(), Field< A >::get(), PI, and Field< A >::set().

Referenced by testCellDiffn(), and testSmallCellDiffn().

857 {
858  Shell* shell = reinterpret_cast< Shell* >( Id().eref().data() );
859  Id ret = shell->doCreate( "Compartment", parentObj, name, 1 );
860  double pax = 0;
861  double pay = 0;
862  if ( parentCompt != Id() ) {
863  pax = Field< double >::get( parentCompt, "x" );
864  pay = Field< double >::get( parentCompt, "y" );
865  shell->doAddMsg( "Single", parentCompt, "raxial", ret, "axial" );
866  }
867  Field< double >::set( ret, "x0", pax );
868  Field< double >::set( ret, "y0", pay );
869  Field< double >::set( ret, "z0", 0.0 );
870  double x = pax + len * cos( theta * PI / 180.0 );
871  double y = pay + len * sin( theta * PI / 180.0 );
872  Field< double >::set( ret, "x", x );
873  Field< double >::set( ret, "y", y );
874  Field< double >::set( ret, "z", 0.0 );
875  Field< double >::set( ret, "diameter", dia );
876  Field< double >::set( ret, "length", len );
877 
878  return ret;
879 }
char * data() const
Definition: Eref.cpp:41
Eref eref() const
Definition: Id.cpp:125
static bool set(const ObjId &dest, const string &field, A arg)
Definition: SetGet.h:245
Id doCreate(string type, ObjId parent, string name, unsigned int numData, NodePolicy nodePolicy=MooseBlockBalance, unsigned int preferredNode=1)
Definition: Shell.cpp:181
static char name[]
Definition: mfield.cpp:401
ObjId doAddMsg(const string &msgType, ObjId src, const string &srcField, ObjId dest, const string &destField)
Definition: Shell.cpp:269
const double PI
Definition: consts.cpp:12
Definition: Id.h:17
static A get(const ObjId &dest, const string &field)
Definition: SetGet.h:284
Definition: Shell.h:43

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void setIntersectVoxel ( vector< PII > &  intersect,
unsigned int  ix,
unsigned int  iy,
unsigned int  iz,
unsigned int  nx,
unsigned int  ny,
unsigned int  nz,
unsigned int  meshIndex 
)

Definition at line 1304 of file CubeMesh.cpp.

References CubeMesh::ABUTX, CubeMesh::ABUTY, CubeMesh::ABUTZ, setAbut(), and CubeMesh::SURFACE.

Referenced by CubeMesh::assignVoxels(), and testIntersectVoxel().

1309 {
1310  assert( ix < nx && iy < ny && iz < nz );
1311  unsigned int index = ( iz * ny + iy ) * nx + ix;
1312  assert( index < intersect.size() );
1313  intersect[index] = PII( meshIndex, CubeMesh::SURFACE );
1314  if ( ix > 0 )
1315  setAbut( intersect[ (iz*ny + iy) * nx + ix-1 ], meshIndex,
1316  CubeMesh::ABUTX );
1317  if ( ix + 1 < nx )
1318  setAbut( intersect[ (iz*ny + iy) * nx + ix+1 ], meshIndex,
1319  CubeMesh::ABUTX );
1320 
1321  if ( iy > 0 )
1322  setAbut( intersect[ ( iz*ny + iy-1 ) * nx + ix ], meshIndex,
1323  CubeMesh::ABUTY);
1324  if ( iy + 1 < ny )
1325  setAbut( intersect[ ( iz*ny + iy+1 ) * nx + ix ], meshIndex,
1326  CubeMesh::ABUTY);
1327 
1328  if ( iz > 0 )
1329  setAbut( intersect[ ( (iz-1)*ny + iy ) * nx + ix ], meshIndex,
1330  CubeMesh::ABUTZ);
1331  if ( iz + 1 < nz )
1332  setAbut( intersect[ ( (iz+1)*ny + iy ) * nx + ix ], meshIndex,
1333  CubeMesh::ABUTZ);
1334 }
static const unsigned int ABUTY
Definition: CubeMesh.h:288
pair< unsigned int, unsigned int > PII
Definition: CubeMesh.cpp:29
static const unsigned int SURFACE
Definition: CubeMesh.h:286
static const unsigned int ABUTZ
Definition: CubeMesh.h:289
void setAbut(PII &voxel, unsigned int meshIndex, unsigned int axis)
Definition: CubeMesh.cpp:1294
static const unsigned int ABUTX
Definition: CubeMesh.h:287

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void testCubeMesh ( )

Low-level tests for the CubeMesh object: No MOOSE calls involved.

Definition at line 600 of file testMesh.cpp.

References CUBOID, doubleEq(), CubeMesh::getCoords(), ChemCompt::getDimensions(), CubeMesh::getDx(), CubeMesh::getDy(), CubeMesh::getDz(), CubeMesh::getMeshDimensions(), CubeMesh::getMeshType(), MeshCompt::getNeighbors(), CubeMesh::getNx(), CubeMesh::getNy(), CubeMesh::getNz(), CubeMesh::getX0(), CubeMesh::getX1(), CubeMesh::getY0(), CubeMesh::getY1(), CubeMesh::getZ0(), CubeMesh::getZ1(), CubeMesh::innerGetNumEntries(), CubeMesh::innerSetCoords(), CubeMesh::setPreserveNumEntries(), CubeMesh::setX0(), CubeMesh::setX1(), CubeMesh::setY0(), CubeMesh::setY1(), CubeMesh::setZ0(), and CubeMesh::setZ1().

Referenced by testMesh().

601 {
602  CubeMesh cm;
603  cm.setPreserveNumEntries( 0 );
604  assert( cm.getMeshType( 0 ) == CUBOID );
605  assert( cm.getMeshDimensions( 0 ) == 3 );
606  assert( cm.getDimensions() == 3 );
607 
608  vector< double > coords( 9 );
609  coords[0] = 0; // X0
610  coords[1] = 0; // Y0
611  coords[2] = 0; // Z0
612 
613  coords[3] = 2; // X1
614  coords[4] = 4; // Y1
615  coords[5] = 8; // Z1
616 
617  coords[6] = 1; // DX
618  coords[7] = 1; // DY
619  coords[8] = 1; // DZ
620 
621  cm.innerSetCoords( coords );
622 
623  vector< unsigned int > neighbors = cm.getNeighbors( 0 );
624  assert( neighbors.size() == 3 );
625  assert( neighbors[0] = 1 );
626  assert( neighbors[0] = 2 );
627  assert( neighbors[0] = 8 );
628 
629  assert( cm.innerGetNumEntries() == 64 );
630  assert( doubleEq( cm.getX0(), 0 ) );
631  assert( doubleEq( cm.getY0(), 0 ) );
632  assert( doubleEq( cm.getZ0(), 0 ) );
633 
634  assert( doubleEq( cm.getX1(), 2 ) );
635  assert( doubleEq( cm.getY1(), 4 ) );
636  assert( doubleEq( cm.getZ1(), 8 ) );
637 
638  assert( doubleEq( cm.getDx(), 1 ) );
639  assert( doubleEq( cm.getDy(), 1 ) );
640  assert( doubleEq( cm.getDz(), 1 ) );
641 
642  assert( cm.getNx() == 2 );
643  assert( cm.getNy() == 4 );
644  assert( cm.getNz() == 8 );
645 
646  cm.setX0( 1 );
647  cm.setY0( 2 );
648  cm.setZ0( 4 );
649 
650  cm.setX1( 5 );
651  cm.setY1( 6 );
652  cm.setZ1( 8 );
653 
654  vector< double > temp = cm.getCoords( Id().eref() );
655  assert( temp.size() == 9 );
656  assert( doubleEq( temp[0], 1 ) );
657  assert( doubleEq( temp[1], 2 ) );
658  assert( doubleEq( temp[2], 4 ) );
659  assert( doubleEq( temp[3], 5 ) );
660  assert( doubleEq( temp[4], 6 ) );
661  assert( doubleEq( temp[5], 8 ) );
662  assert( doubleEq( temp[6], 1 ) );
663  assert( doubleEq( temp[7], 1 ) );
664  assert( doubleEq( temp[8], 1 ) );
665  assert( cm.innerGetNumEntries() == 64 );
666  assert( cm.getNx() == 4 );
667  assert( cm.getNy() == 4 );
668  assert( cm.getNz() == 4 );
669 
670  neighbors = cm.getNeighbors( 0 );
671  assert( neighbors.size() == 3 );
672  assert( neighbors[0] == 1 );
673  assert( neighbors[1] == 4 );
674  assert( neighbors[2] = 16 );
675 
676  neighbors = cm.getNeighbors( 63 );
677  assert( neighbors.size() == 3 );
678  assert( neighbors[0] == 47 );
679  assert( neighbors[1] == 59 );
680  assert( neighbors[2] == 62 );
681 
682  neighbors = cm.getNeighbors( 2 );
683  assert( neighbors.size() == 4 );
684  assert( neighbors[0] == 1 );
685  assert( neighbors[1] == 3 );
686  assert( neighbors[2] == 6 );
687  assert( neighbors[3] == 18 );
688 
689  neighbors = cm.getNeighbors( 6 );
690  assert( neighbors.size() == 5 );
691  assert( neighbors[0] == 2 );
692  assert( neighbors[1] == 5 );
693  assert( neighbors[2] == 7 );
694  assert( neighbors[3] == 10 );
695  assert( neighbors[4] == 22 );
696 
697  neighbors = cm.getNeighbors( 22 );
698  assert( neighbors.size() == 6 );
699  assert( neighbors[0] == 6 );
700  assert( neighbors[1] == 18 );
701  assert( neighbors[2] == 21 );
702  assert( neighbors[3] == 23 );
703  assert( neighbors[4] == 26 );
704  assert( neighbors[5] == 38 );
705 
706  cm.setPreserveNumEntries( 1 );
707  assert( cm.getNx() == 4 );
708  assert( cm.getNy() == 4 );
709  assert( cm.getNz() == 4 );
710  assert( doubleEq( cm.getDx(), 1.0 ) );
711  assert( doubleEq( cm.getDy(), 1.0 ) );
712  assert( doubleEq( cm.getDz(), 1.0 ) );
713 
714  cm.setX0( 0 );
715  cm.setY0( 0 );
716  cm.setZ0( 0 );
717  // x1 is 5, y1 is 6 and z1 is 8
718 
719  assert( doubleEq( cm.getDx(), 1.25 ) );
720  assert( doubleEq( cm.getDy(), 1.5 ) );
721  assert( doubleEq( cm.getDz(), 2.0 ) );
722 
723  cout << "." << flush;
724 }
unsigned int getNx() const
Definition: CubeMesh.cpp:542
unsigned int getNz() const
Definition: CubeMesh.cpp:565
double getDz() const
Definition: CubeMesh.cpp:531
vector< unsigned int > getNeighbors(unsigned int fid) const
Looks up stencil to return vector of indices of coupled voxels.
Definition: MeshCompt.cpp:69
double getX0() const
Definition: CubeMesh.cpp:441
void setX1(double v)
Definition: CubeMesh.cpp:468
vector< double > getCoords(const Eref &e) const
Definition: CubeMesh.cpp:636
double getX1() const
Definition: CubeMesh.cpp:474
double getDx() const
Definition: CubeMesh.cpp:507
void setY0(double v)
Definition: CubeMesh.cpp:446
void setZ0(double v)
Definition: CubeMesh.cpp:457
double getY1() const
Definition: CubeMesh.cpp:485
void setZ1(double v)
Definition: CubeMesh.cpp:490
unsigned int getNy() const
Definition: CubeMesh.cpp:554
void innerSetCoords(const vector< double > &v)
Definition: CubeMesh.cpp:602
double getZ0() const
Definition: CubeMesh.cpp:463
unsigned int getDimensions() const
Definition: ChemCompt.cpp:340
bool doubleEq(double x, double y)
Definition: doubleEq.cpp:16
double getY0() const
Definition: CubeMesh.cpp:452
unsigned int getMeshType(unsigned int fid) const
Virtual function to return MeshType of specified entry.
Definition: CubeMesh.cpp:772
void setY1(double v)
Definition: CubeMesh.cpp:479
double getZ1() const
Definition: CubeMesh.cpp:496
Definition: Id.h:17
void setPreserveNumEntries(bool v)
Definition: CubeMesh.cpp:581
unsigned int getMeshDimensions(unsigned int fid) const
Virtual function to return dimensions of specified entry.
Definition: CubeMesh.cpp:778
double getDy() const
Definition: CubeMesh.cpp:519
void setX0(double v)
Definition: CubeMesh.cpp:435
unsigned int innerGetNumEntries() const
Definition: CubeMesh.cpp:891

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void testCubeMeshExtendStencil ( )

Definition at line 726 of file testMesh.cpp.

References CUBOID, MeshCompt::extendStencil(), ChemCompt::getDimensions(), CubeMesh::getMeshDimensions(), CubeMesh::getMeshType(), MeshCompt::getStencilRow(), CubeMesh::innerSetCoords(), and CubeMesh::setPreserveNumEntries().

Referenced by testMesh().

727 {
728  CubeMesh cm0;
729  cm0.setPreserveNumEntries( 0 );
730  assert( cm0.getMeshType( 0 ) == CUBOID );
731  assert( cm0.getMeshDimensions( 0 ) == 3 );
732  assert( cm0.getDimensions() == 3 );
733  CubeMesh cm1 = cm0;
734 
735  vector< double > coords( 9 );
736  coords[0] = 0; // X0
737  coords[1] = 0; // Y0
738  coords[2] = 0; // Z0
739 
740  coords[3] = 2; // X1
741  coords[4] = 4; // Y1
742  coords[5] = 8; // Z1
743 
744  coords[6] = 1; // DX
745  coords[7] = 1; // DY
746  coords[8] = 1; // DZ
747 
748  cm0.innerSetCoords( coords );
749  coords[2] = 8; // 2x4 face abuts.
750  coords[5] = 16;
751  cm1.innerSetCoords( coords );
752 
753  const double* entry;
754  const unsigned int* colIndex;
755  unsigned int num = cm0.getStencilRow( 0, &entry, &colIndex );
756  assert( num == 3 );
757  assert( colIndex[0] == 1 );
758  assert( colIndex[1] == 2 );
759  assert( colIndex[2] == 8 );
760 
761  num = cm0.getStencilRow( 56, &entry, &colIndex );
762  assert( num == 3 );
763  assert( colIndex[0] == 48 );
764  assert( colIndex[1] == 57 );
765  assert( colIndex[2] == 58 );
766 
767  vector< VoxelJunction > vj;
768  for ( unsigned int i = 0; i < 8; ++i ) {
769  vj.push_back( VoxelJunction( 56 + i, i ) );
770  }
771  cm0.extendStencil( &cm1, vj );
772 
773  num = cm0.getStencilRow( 56, &entry, &colIndex );
774  assert( num == 4 );
775  assert( colIndex[0] == 48 );
776  assert( colIndex[1] == 57 );
777  assert( colIndex[2] == 58 );
778  assert( colIndex[3] == 64 );
779 
780  for ( unsigned int i = 0; i < 8; ++i ) {
781  num = cm0.getStencilRow( 64 + i, &entry, &colIndex );
782  assert( num == 1 );
783  assert( colIndex[0] == 56 + i );
784  }
785 
786  cout << "." << flush;
787 }
unsigned int getStencilRow(unsigned int meshIndex, const double **entry, const unsigned int **colIndex) const
Definition: MeshCompt.cpp:54
void innerSetCoords(const vector< double > &v)
Definition: CubeMesh.cpp:602
unsigned int getDimensions() const
Definition: ChemCompt.cpp:340
unsigned int getMeshType(unsigned int fid) const
Virtual function to return MeshType of specified entry.
Definition: CubeMesh.cpp:772
void extendStencil(const ChemCompt *other, const vector< VoxelJunction > &vj)
Add boundary voxels to stencil for cross-solver junctions.
Definition: MeshCompt.cpp:121
void setPreserveNumEntries(bool v)
Definition: CubeMesh.cpp:581
unsigned int getMeshDimensions(unsigned int fid) const
Virtual function to return dimensions of specified entry.
Definition: CubeMesh.cpp:778

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void testCubeMeshFillThreeDimSurface ( )

Definition at line 1447 of file testMesh.cpp.

Referenced by testMesh().

1448 {
1449  cout << "." << flush;
1450 }

+ Here is the caller graph for this function:

void testCubeMeshFillTwoDimSurface ( )

Definition at line 1428 of file testMesh.cpp.

References CubeMesh::innerSetCoords(), CubeMesh::numDims(), CubeMesh::setPreserveNumEntries(), and CubeMesh::surface().

Referenced by testMesh().

1429 {
1430  CubeMesh cm;
1431  vector< double > coords( 9, 0.0 );
1432  coords[3] = 5.0;
1433  coords[4] = 3.0;
1434  coords[5] = 1.0;
1435  coords[6] = coords[7] = coords[8] = 1.0;
1436  cm.setPreserveNumEntries( false );
1437  cm.innerSetCoords( coords );
1438  assert( cm.numDims() == 2 );
1439  const vector< unsigned int >& surface = cm.surface();
1440  assert( surface.size() == 15 );
1441  for ( unsigned int i = 0; i < 15; ++i ) {
1442  assert( surface[i] == i );
1443  }
1444  cout << "." << flush;
1445 }
void innerSetCoords(const vector< double > &v)
Definition: CubeMesh.cpp:602
const vector< unsigned int > & surface() const
Utility and test function to read surface.
Definition: CubeMesh.cpp:1111
void setPreserveNumEntries(bool v)
Definition: CubeMesh.cpp:581
unsigned int numDims() const
Utility function for returning # of dimensions in mesh.
Definition: CubeMesh.cpp:1148

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void testCubeMeshJunctionDiffSizeMesh ( )
                    14  15
                    12  13

10 11 12 13 14 10 11 8 9 5 6 7 8 9 6 7 4 5 0 1 2 3 4 2 3 0 1

So, junction should be (4,2)(4,4),(9,6),(9,8),(14,10),(14,12)

Definition at line 1560 of file testMesh.cpp.

References CubeMesh::innerSetCoords(), CubeMesh::matchCubeMeshEntries(), CubeMesh::setPreserveNumEntries(), and CubeMesh::surface().

Referenced by testMesh().

1561 {
1574  CubeMesh cm1;
1575  vector< double > coords( 9, 0.0 );
1576  coords[3] = 5.0;
1577  coords[4] = 3.0;
1578  coords[5] = 1.0;
1579  coords[6] = coords[7] = coords[8] = 1.0;
1580  cm1.setPreserveNumEntries( false );
1581  cm1.innerSetCoords( coords );
1582  vector< unsigned int > surface = cm1.surface();
1583  assert( surface.size() == 15 );
1584 
1585  CubeMesh cm2;
1586  coords[0] = 5.0;
1587  coords[1] = -0.5;
1588  coords[2] = 0.0;
1589  coords[3] = 7.0;
1590  coords[4] = 3.5;
1591  coords[5] = 0.5;
1592  coords[6] = 1.0;
1593  coords[7] = 0.5;
1594  coords[8] = 0.5;
1595  cm2.setPreserveNumEntries( false );
1596  cm2.innerSetCoords( coords );
1597  const vector< unsigned int >& surface2 = cm2.surface();
1598  assert( surface2.size() == 16 );
1599 
1600  vector< VoxelJunction > ret;
1601  cm1.matchCubeMeshEntries( &cm2, ret );
1602  assert( ret.size() == 6 );
1603 
1604  assert( ret[0].first == 4 );
1605  assert( ret[0].second == 2 );
1606  assert( ret[1].first == 4 );
1607  assert( ret[1].second == 4 );
1608  assert( ret[2].first == 9 );
1609  assert( ret[2].second == 6 );
1610  assert( ret[3].first == 9 );
1611  assert( ret[3].second == 8 );
1612  assert( ret[4].first == 14 );
1613  assert( ret[4].second == 10 );
1614  assert( ret[5].first == 14 );
1615  assert( ret[5].second == 12 );
1616 
1617  cout << "." << flush;
1618 }
void matchCubeMeshEntries(const CubeMesh *other, vector< VoxelJunction > &ret) const
Definition: CubeMesh.cpp:1453
void innerSetCoords(const vector< double > &v)
Definition: CubeMesh.cpp:602
const vector< unsigned int > & surface() const
Utility and test function to read surface.
Definition: CubeMesh.cpp:1111
void setPreserveNumEntries(bool v)
Definition: CubeMesh.cpp:581

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void testCubeMeshJunctionThreeDimSurface ( )

Definition at line 1620 of file testMesh.cpp.

Referenced by testMesh().

1621 {
1622  cout << "." << flush;
1623 }

+ Here is the caller graph for this function:

void testCubeMeshJunctionTwoDimSurface ( )
                    8   9

10 11 12 13 14 6 7 5 6 7 8 9 4 5 0 1 2 3 4 2 3 0 1

So, junction should be (4,2),(9,4),(14,6)

That was too easy, since the spatial and meshIndices were identical. Now trim the geometries a bit to look like: 6 7 10 11 12 13 - 4 5 5 6 7 8 9 2 3 0 1 2 3 4 - 1

  • 0

So, junction should be (9,2) only.

Definition at line 1452 of file testMesh.cpp.

References CubeMesh::getMeshToSpace(), CubeMesh::getSpaceToMesh(), CubeMesh::innerSetCoords(), CubeMesh::matchCubeMeshEntries(), CubeMesh::setMeshToSpace(), CubeMesh::setPreserveNumEntries(), CubeMesh::setSpaceToMesh(), CubeMesh::setSurface(), and CubeMesh::surface().

Referenced by testMesh().

1453 {
1463  CubeMesh cm1;
1464  vector< double > coords( 9, 0.0 );
1465  coords[3] = 5.0;
1466  coords[4] = 3.0;
1467  coords[5] = 1.0;
1468  coords[6] = coords[7] = coords[8] = 1.0;
1469  cm1.setPreserveNumEntries( false );
1470  cm1.innerSetCoords( coords );
1471  vector< unsigned int > surface = cm1.surface();
1472  assert( surface.size() == 15 );
1473 
1474  CubeMesh cm2;
1475  coords[0] = 5.0;
1476  coords[1] = -1.0;
1477  coords[2] = 0.0;
1478  coords[3] = 7.0;
1479  coords[4] = 4.0;
1480  coords[5] = 1.0;
1481  coords[6] = coords[7] = coords[8] = 1.0;
1482  cm2.setPreserveNumEntries( false );
1483  cm2.innerSetCoords( coords );
1484  const vector< unsigned int >& surface2 = cm2.surface();
1485  assert( surface2.size() == 10 );
1486 
1487  vector< VoxelJunction > ret;
1488  cm1.matchCubeMeshEntries( &cm2, ret );
1489  assert( ret.size() == 3 );
1490 
1491  assert( ret[0].first == 4 );
1492  assert( ret[0].second == 2 );
1493  assert( ret[1].first == 9 );
1494  assert( ret[1].second == 4 );
1495  assert( ret[2].first == 14 );
1496  assert( ret[2].second == 6 );
1497 
1510  // Trimming cm1. At this point we don't assume automatic updates of
1511  // the m2s, s2m and surface vectors when any of them is changed.
1512  vector< unsigned int > m2s = cm1.getMeshToSpace();
1513  assert( m2s.size() == 15 );
1514  m2s.resize( 14 );
1515  cm1.setMeshToSpace( m2s );
1516  vector< unsigned int > s2m = cm1.getSpaceToMesh();
1517  assert( s2m.size() == 15 );
1518  s2m[14] = ~0;
1519  cm1.setSpaceToMesh( s2m );
1520  surface.resize( 4 );
1521  // As a shortcut, just assign the places near the junction
1522  // Note that the indices are spaceIndices.
1523  surface[0] = 3;
1524  surface[1] = 4;
1525  surface[2] = 9;
1526  surface[3] = 13;
1527  cm1.setSurface( surface );
1528 
1529  // Trimming cm2.
1530  m2s = cm2.getMeshToSpace();
1531  assert( m2s.size() == 10 );
1532  m2s.resize( 8 );
1533  m2s[0] = 1;
1534  for ( unsigned int i = 1; i < 8; ++i )
1535  m2s[i] = i + 2;
1536  cm2.setMeshToSpace( m2s );
1537  s2m.clear();
1538  s2m.resize( 10, ~0 );
1539  for ( unsigned int i = 0; i < 8; ++i )
1540  s2m[ m2s[i] ] = i;
1541  cm2.setSpaceToMesh( s2m );
1542  // As a shortcut, just assign the places near the junction
1543  // Note that the indices are spaceIndices.
1544  surface[0] = 3;
1545  surface[1] = 4;
1546  surface[2] = 6;
1547  surface[3] = 8;
1548  cm2.setSurface( surface );
1549 
1550  // Now test it out.
1551  ret.resize( 0 );
1552  cm1.matchCubeMeshEntries( &cm2, ret );
1553  assert( ret.size() == 1 );
1554  assert( ret[0].first == 9 );
1555  assert( ret[0].second == 2 );
1556 
1557  cout << "." << flush;
1558 }
void matchCubeMeshEntries(const CubeMesh *other, vector< VoxelJunction > &ret) const
Definition: CubeMesh.cpp:1453
void innerSetCoords(const vector< double > &v)
Definition: CubeMesh.cpp:602
const vector< unsigned int > & surface() const
Utility and test function to read surface.
Definition: CubeMesh.cpp:1111
void setSpaceToMesh(vector< unsigned int > v)
Definition: CubeMesh.cpp:666
vector< unsigned int > getMeshToSpace() const
Definition: CubeMesh.cpp:661
void setMeshToSpace(vector< unsigned int > v)
Definition: CubeMesh.cpp:655
vector< unsigned int > getSpaceToMesh() const
Definition: CubeMesh.cpp:672
void setPreserveNumEntries(bool v)
Definition: CubeMesh.cpp:581
void setSurface(vector< unsigned int > v)
Definition: CubeMesh.cpp:677

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void testCubeMeshMultiJunctionTwoD ( )

The simulated geometry is: D D BBBA CCCCC Here, A is at (0,0,0) to (10,10,10) microns. B is then (-30,0,0) to (0,10,10) microns C is (-30,-10,0) to (20,0,10) microns D is (0,10,0) to (10,30,10) microns.

Definition at line 1636 of file testMesh.cpp.

References CubeMesh::innerSetCoords(), CubeMesh::setPreserveNumEntries(), and CubeMesh::surface().

Referenced by testMesh().

1637 {
1638  CubeMesh A;
1639  vector< double > coords( 9, 0.0 );
1640  coords[3] = 10e-6;
1641  coords[4] = 10e-6;
1642  coords[5] = 10e-6;
1643  coords[6] = coords[7] = coords[8] = 10e-6;
1644  A.setPreserveNumEntries( false );
1645  A.innerSetCoords( coords );
1646  vector< unsigned int > surface = A.surface();
1647  assert( surface.size() == 1 );
1648  assert( surface[0] == 0 );
1649 
1650  CubeMesh B;
1651  coords[0] = -30e-6; coords[1] = 0; coords[2] = 0;
1652  coords[3] = 0; coords[4] = 10e-6; coords[5] = 10e-6;
1653  coords[6] = coords[7] = coords[8] = 10e-6;
1654  B.setPreserveNumEntries( false );
1655  B.innerSetCoords( coords );
1656  surface = B.surface();
1657  assert( surface.size() == 3 );
1658  assert( surface[0] == 0 );
1659  assert( surface[1] == 1 );
1660  assert( surface[2] == 2 );
1661 
1662  CubeMesh D;
1663  coords[0] = 0; coords[1] = 10e-6; coords[2] = 0;
1664  coords[3] = 10e-6; coords[4] = 30e-6; coords[5] = 10e-6;
1665  coords[6] = coords[7] = coords[8] = 10e-6;
1666  D.setPreserveNumEntries( false );
1667  D.innerSetCoords( coords );
1668  surface = D.surface();
1669  assert( surface.size() == 2 );
1670  assert( surface[0] == 0 );
1671  assert( surface[1] == 1 );
1672 
1673  CubeMesh C;
1674  coords[0] = -30e-6; coords[1] = -10e-6; coords[2] = 0;
1675  coords[3] = 20e-6; coords[4] = 0; coords[5] = 10e-6;
1676  coords[6] = coords[7] = coords[8] = 10e-6;
1677  C.setPreserveNumEntries( false );
1678  C.innerSetCoords( coords );
1679  surface = C.surface();
1680  assert( surface.size() == 5 );
1681  assert( surface[0] == 0 );
1682  assert( surface[1] == 1 );
1683  assert( surface[2] == 2 );
1684  assert( surface[3] == 3 );
1685  assert( surface[4] == 4 );
1686 
1687 
1688  cout << "." << flush;
1689 }
void innerSetCoords(const vector< double > &v)
Definition: CubeMesh.cpp:602
const vector< unsigned int > & surface() const
Utility and test function to read surface.
Definition: CubeMesh.cpp:1111
void setPreserveNumEntries(bool v)
Definition: CubeMesh.cpp:581

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void testIntersectVoxel ( )

Here is the geometry of the surface. * is surface, - is empty.

    -***-
    -*---
    -***-


    x***x
    x*32-
    x***x

x is ABUTX
y is ABUTY
z is ABUTZ
2 is 2 points
3 is MULTI

Definition at line 1318 of file testMesh.cpp.

References CubeMesh::ABUTX, checkAbut(), CubeMesh::EMPTY, CubeMesh::MULTI, setIntersectVoxel(), and CubeMesh::SURFACE.

1319 {
1341  unsigned int nx = 5;
1342  unsigned int ny = 3;
1343  unsigned int nz = 1;
1344  vector< PII > intersect( nx * ny * nz, PII(
1346  unsigned int meshIndex = 0;
1347  setIntersectVoxel( intersect, 1, 0, 0, nx, ny, nz, meshIndex++ );
1348  setIntersectVoxel( intersect, 2, 0, 0, nx, ny, nz, meshIndex++ );
1349  setIntersectVoxel( intersect, 3, 0, 0, nx, ny, nz, meshIndex++ );
1350  setIntersectVoxel( intersect, 1, 1, 0, nx, ny, nz, meshIndex++ );
1351  setIntersectVoxel( intersect, 1, 2, 0, nx, ny, nz, meshIndex++ );
1352  setIntersectVoxel( intersect, 2, 2, 0, nx, ny, nz, meshIndex++ );
1353  setIntersectVoxel( intersect, 3, 2, 0, nx, ny, nz, meshIndex++ );
1354 
1355  assert( intersect[0].first == 0 &&
1356  intersect[0].second == CubeMesh::ABUTX );
1357  assert( intersect[1].first == 0 &&
1358  intersect[1].second == CubeMesh::SURFACE );
1359  assert( intersect[2].first == 1 &&
1360  intersect[2].second == CubeMesh::SURFACE );
1361  assert( intersect[3].first == 2 &&
1362  intersect[3].second == CubeMesh::SURFACE );
1363  assert( intersect[4].first == 2 &&
1364  intersect[4].second == CubeMesh::ABUTX );
1365 
1366  assert( intersect[5].first == 3 &&
1367  intersect[5].second == CubeMesh::ABUTX );
1368  assert( intersect[6].first == 3 &&
1369  intersect[6].second == CubeMesh::SURFACE );
1370  assert( intersect[7].first == 1 &&
1371  intersect[7].second == CubeMesh::MULTI );
1372  assert( intersect[8].first == 2 &&
1373  intersect[8].second == CubeMesh::MULTI );
1374  assert( intersect[9].first == EMPTY &&
1375  intersect[9].second == CubeMesh::EMPTY );
1376 
1377  assert( intersect[10].first == 4 &&
1378  intersect[10].second == CubeMesh::ABUTX );
1379  assert( intersect[11].first == 4 &&
1380  intersect[11].second == CubeMesh::SURFACE );
1381  assert( intersect[12].first == 5 &&
1382  intersect[12].second == CubeMesh::SURFACE );
1383  assert( intersect[13].first == 6 &&
1384  intersect[13].second == CubeMesh::SURFACE );
1385  assert( intersect[14].first == 6 &&
1386  intersect[14].second == CubeMesh::ABUTX );
1387 
1388  // Next: test out checkAbut.
1389  vector< VoxelJunction > ret;
1390  checkAbut( intersect, 0, 0, 0, nx, ny, nz, 1234, ret );
1391  assert( ret.size() == 1 );
1392  assert( ret[0].first == 0 && ret[0].second == 1234 );
1393  ret.clear();
1394  // The ones below are either SURFACE or EMPTY and should not add points
1395  checkAbut( intersect, 1, 0, 0, nx, ny, nz, 1234, ret );
1396  checkAbut( intersect, 2, 0, 0, nx, ny, nz, 1234, ret );
1397  checkAbut( intersect, 3, 0, 0, nx, ny, nz, 1234, ret );
1398  checkAbut( intersect, 1, 1, 0, nx, ny, nz, 1234, ret );
1399  checkAbut( intersect, 4, 1, 0, nx, ny, nz, 1234, ret );
1400  checkAbut( intersect, 1, 2, 0, nx, ny, nz, 1234, ret );
1401  checkAbut( intersect, 2, 2, 0, nx, ny, nz, 1234, ret );
1402  checkAbut( intersect, 3, 2, 0, nx, ny, nz, 1234, ret );
1403  assert( ret.size() == 0 );
1404  checkAbut( intersect, 2, 1, 0, nx, ny, nz, 9999, ret );
1405  assert( ret.size() == 3 );
1406  assert( ret[0].first == 3 && ret[0].second == 9999 );
1407  assert( ret[1].first == 1 && ret[1].second == 9999 );
1408  assert( ret[2].first == 5 && ret[1].second == 9999 );
1409  ret.clear();
1410  checkAbut( intersect, 3, 1, 0, nx, ny, nz, 8888, ret );
1411  assert( ret.size() == 2 );
1412  assert( ret[0].first == 2 && ret[0].second == 8888 );
1413  assert( ret[1].first == 6 && ret[1].second == 8888 );
1414  ret.clear();
1415  checkAbut( intersect, 4, 0, 0, nx, ny, nz, 7777, ret );
1416  checkAbut( intersect, 0, 1, 0, nx, ny, nz, 6666, ret );
1417  checkAbut( intersect, 0, 2, 0, nx, ny, nz, 5555, ret );
1418  checkAbut( intersect, 4, 2, 0, nx, ny, nz, 4444, ret );
1419  assert( ret.size() == 4 );
1420  assert( ret[0].first == 2 && ret[0].second == 7777 );
1421  assert( ret[1].first == 3 && ret[1].second == 6666 );
1422  assert( ret[2].first == 4 && ret[2].second == 5555 );
1423  assert( ret[3].first == 6 && ret[3].second == 4444 );
1424 
1425  cout << "." << flush;
1426 }
pair< unsigned int, unsigned int > PII
Definition: testMesh.cpp:1304
void setIntersectVoxel(vector< PII > &intersect, unsigned int ix, unsigned int iy, unsigned int iz, unsigned int nx, unsigned int ny, unsigned int nz, unsigned int meshIndex)
Definition: CubeMesh.cpp:1304
static const unsigned int EMPTY
Definition: testMesh.cpp:1300
static const unsigned int MULTI
Definition: CubeMesh.h:290
static const unsigned int SURFACE
Definition: CubeMesh.h:286
void checkAbut(const vector< PII > &intersect, unsigned int ix, unsigned int iy, unsigned int iz, unsigned int nx, unsigned int ny, unsigned int nz, unsigned int meshIndex, vector< VoxelJunction > &ret)
Definition: CubeMesh.cpp:1348
static const unsigned int EMPTY
Definition: CubeMesh.h:285
static const unsigned int ABUTX
Definition: CubeMesh.h:287

+ Here is the call graph for this function:

void testMesh ( )

Definition at line 2138 of file testMesh.cpp.

References testCubeMesh(), testCubeMeshExtendStencil(), testCubeMeshFillThreeDimSurface(), testCubeMeshFillTwoDimSurface(), testCubeMeshJunctionDiffSizeMesh(), testCubeMeshJunctionThreeDimSurface(), testCubeMeshJunctionTwoDimSurface(), testCubeMeshMultiJunctionTwoD(), testVec(), and testVolScaling().

Referenced by nonMpiTests().

2139 {
2140  testVec();
2141  testVolScaling();
2142  // testCylBase();
2143  // testNeuroNode();
2144  // testNeuroNodeTree();
2145  // testCylMesh();
2146  // testMidLevelCylMesh();
2147  testCubeMesh();
2149  // testReMesh(); // Waiting to have pool subdivision propagate.
2150  // testNeuroMeshLinear();
2151  // testNeuroMeshBranching();
2152  // testIntersectVoxel();
2159  // testSpineEntry();
2160  // testSpineAndPsdMesh();
2161  // testCellPortion();
2162 }
void testVolScaling()
Definition: testMesh.cpp:34
void testCubeMeshFillThreeDimSurface()
Definition: testMesh.cpp:1447
void testCubeMeshJunctionTwoDimSurface()
Definition: testMesh.cpp:1452
void testCubeMeshJunctionThreeDimSurface()
Definition: testMesh.cpp:1620
void testVec()
Definition: testMesh.cpp:1691
void testCubeMeshFillTwoDimSurface()
Definition: testMesh.cpp:1428
void testCubeMeshJunctionDiffSizeMesh()
Definition: testMesh.cpp:1560
void testCubeMeshMultiJunctionTwoD()
Definition: testMesh.cpp:1636
void testCubeMeshExtendStencil()
Definition: testMesh.cpp:726
void testCubeMesh()
Definition: testMesh.cpp:600

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void testReMesh ( )

Tests scaling of volume and # of entries upon mesh resize

Definition at line 792 of file testMesh.cpp.

References Eref::data(), Shell::doCreate(), Shell::doDelete(), doubleEq(), Id::eref(), Field< A >::get(), NA, Field< A >::set(), and SetGet2< A1, A2 >::set().

793 {
794  Shell* s = reinterpret_cast< Shell* >( Id().eref().data() );
795  Id base = s->doCreate( "Neutral", Id(), "base", 1 );
796 
797  Id cube = s->doCreate( "CubeMesh", base, "cube", 1 );
799  cube, "buildDefaultMesh", 1.0, 1 );
800  assert( ret );
801  unsigned int vol = Field< double >::get( cube, "volume" );
802  assert( doubleEq( vol, 1.0 ) );
803  Id pool = s->doCreate( "Pool", cube, "pool", 1 );
804  Id mesh( "/base/cube/mesh" );
805  assert( mesh != Id() );
806 
808  // 1 millimolar in 1 m^3 is 1 mole per liter.
809  double linsize = Field< double >::get( pool, "volume" );
810  assert( doubleEq( linsize, 1.0 ) );
811 
812  ret = Field< double >::set( pool, "conc", 1 );
813  assert( ret );
814  double n = Field< double >::get( pool, "n" );
815  assert( doubleEq( n, NA ) );
816 
818  cube, "buildDefaultMesh", 1.0e-3, 1 );
819  Field< double >::set( pool, "conc", 1 );
820  n = Field< double >::get( pool, "n" );
821  assert( doubleEq( n, NA / 1000.0 ) );
822 
824  // Next we do the remeshing.
825  double x = 1.234;
826  Field< double >::set( pool, "concInit", x );
828  cube, "buildDefaultMesh", 1, 8 );
829  // This is nasty, needs the change to propagate through messages.
830  linsize = Field< double >::get( pool, "volume" );
831  assert( doubleEq( linsize, 0.125 ) );
832 
833  n = Field< double >::get( ObjId( pool, 0 ), "concInit" );
834  assert( doubleEq( n, x ) );
835  n = Field< double >::get( ObjId( pool, 7 ), "concInit" );
836  assert( doubleEq( n, x ) );
837  n = Field< double >::get( ObjId( pool, 0 ), "nInit" );
838  assert( doubleEq( n, x * NA / 8.0 ) );
839  n = Field< double >::get( ObjId( pool, 7 ), "nInit" );
840  assert( doubleEq( n, x * NA / 8.0 ) );
841  n = Field< double >::get( ObjId( pool, 0 ), "conc" );
842  assert( doubleEq( n, x ) );
843  n = Field< double >::get( ObjId( pool, 7 ), "conc" );
844  assert( doubleEq( n, x ) );
845 
847  s->doDelete( base );
848  cout << "." << flush;
849 }
char * data() const
Definition: Eref.cpp:41
const double NA
Definition: consts.cpp:15
Definition: ObjId.h:20
Eref eref() const
Definition: Id.cpp:125
static bool set(const ObjId &dest, const string &field, A arg)
Definition: SetGet.h:245
Id doCreate(string type, ObjId parent, string name, unsigned int numData, NodePolicy nodePolicy=MooseBlockBalance, unsigned int preferredNode=1)
Definition: Shell.cpp:181
bool doubleEq(double x, double y)
Definition: doubleEq.cpp:16
bool doDelete(ObjId oid)
Definition: Shell.cpp:259
Definition: Id.h:17
static A get(const ObjId &dest, const string &field)
Definition: SetGet.h:284
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:

void testVec ( )

Definition at line 1691 of file testMesh.cpp.

References Vec::crossProduct(), Vec::dotProduct(), doubleEq(), and Vec::orthogonalAxes().

Referenced by testMesh().

1692 {
1693  Vec i( 1, 0, 0 );
1694  Vec j( 0, 1, 0 );
1695  Vec k( 0, 0, 1 );
1696 
1697  assert( doubleEq( i.dotProduct( j ), 0.0 ) );
1698  assert( doubleEq( j.dotProduct( k ), 0.0 ) );
1699  assert( doubleEq( j.dotProduct( j ), 1.0 ) );
1700 
1701  assert( i.crossProduct( j ) == k );
1702 
1703  Vec u, v;
1704  i.orthogonalAxes( u, v );
1705  assert( u == j );
1706  assert( v == k );
1707 
1708  cout << "." << flush;
1709 }
bool doubleEq(double x, double y)
Definition: doubleEq.cpp:16
Definition: Vec.h:13
void orthogonalAxes(Vec &u, Vec &v) const
Generates vectors u and v to form a mutually orthogonal system.
Definition: Vec.cpp:41

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void testVolScaling ( )

This tests how volume changes in a mesh propagate to all child pools, reacs, and enzymes.

Definition at line 34 of file testMesh.cpp.

References Eref::data(), Shell::doCreate(), Shell::doDelete(), doubleEq(), Id::eref(), Field< A >::get(), makeReacTest(), and Field< A >::set().

Referenced by testMesh().

35 {
36  extern Id makeReacTest();
37  Shell* s = reinterpret_cast< Shell* >( Id().eref().data() );
38 
39  Id kin = makeReacTest();
40  Id subCompt = s->doCreate( "CubeMesh", kin, "subCompt", 1 );
41  Field< double >::set( subCompt, "volume", 1e-16 );
42  Id SP = s->doCreate( "Pool", subCompt, "SP", 1 );
43  Field< double >::set( SP, "concInit", 2 );
44 
45  vector< double > n;
46  n.push_back( Field< double >::get( ObjId( "/kinetics/A" ), "nInit" ) );
47  n.push_back( Field< double >::get( ObjId( "/kinetics/e1Pool" ), "nInit" ) );
48  n.push_back( Field< double >::get( ObjId( "/kinetics/r1" ), "numKf" ));
49  n.push_back( Field< double >::get( ObjId( "/kinetics/r1" ), "numKb" ));
50  n.push_back( Field< double >::get( ObjId( "/kinetics/r2" ), "numKf" ));
51  n.push_back( Field< double >::get( ObjId( "/kinetics/r2" ), "numKb" ));
52  n.push_back( Field< double >::get( ObjId( "/kinetics/e1Pool/e1" ), "k1" ) );
53  n.push_back( Field< double >::get( ObjId( "/kinetics/e1Pool/e1" ), "k2" ) );
54  n.push_back( Field< double >::get( ObjId( "/kinetics/e1Pool/e1" ), "k3" ) );
55  n.push_back( Field< double >::get( ObjId( "/kinetics/e2Pool/e2" ), "Km" ) );
56  n.push_back( Field< double >::get( ObjId( "/kinetics/e2Pool/e2" ), "kcat" ) );
57  n.push_back( Field< double >::get( SP, "nInit" ) );
58 
59  double vol = Field< double >::get( kin, "volume" );
60 
61  vol *= 10;
62  Field< double >::set( kin, "volume", vol );
63 
64  vector< double > m;
65  m.push_back( Field< double >::get( ObjId( "/kinetics/A" ), "nInit" ) );
66  m.push_back( Field< double >::get( ObjId( "/kinetics/e1Pool" ), "nInit" ) );
67  m.push_back( Field< double >::get( ObjId( "/kinetics/r1" ), "numKf" ));
68  m.push_back( Field< double >::get( ObjId( "/kinetics/r1" ), "numKb" ));
69  m.push_back( Field< double >::get( ObjId( "/kinetics/r2" ), "numKf" ));
70  m.push_back( Field< double >::get( ObjId( "/kinetics/r2" ), "numKb" ));
71  m.push_back( Field< double >::get( ObjId( "/kinetics/e1Pool/e1" ), "k1" ) );
72  m.push_back( Field< double >::get( ObjId( "/kinetics/e1Pool/e1" ), "k2" ) );
73  m.push_back( Field< double >::get( ObjId( "/kinetics/e1Pool/e1" ), "k3" ) );
74  m.push_back( Field< double >::get( ObjId( "/kinetics/e2Pool/e2" ), "Km" ) );
75  m.push_back( Field< double >::get( ObjId( "/kinetics/e2Pool/e2" ), "kcat" ) );
76  m.push_back( Field< double >::get( SP, "nInit" ) );
77 
78  assert( doubleEq( n[0] * 10, m[0] ) ); // A nInit
79  assert( doubleEq( n[1] * 10, m[1] ) ); // e1Pool
80  assert( doubleEq( n[2] / 10, m[2] ) ); // r1 numKf
81  assert( doubleEq( n[3], m[3] ) ); // r1 numKb
82  assert( doubleEq( n[4] / 10, m[4] ) ); // r2 numKf
83  assert( doubleEq( n[5], m[5] ) ); // r2 numKb
84  assert( doubleEq( n[6] / 10, m[6] ) ); // e1 k1
85  assert( doubleEq( n[7], m[7] ) ); // e1 k2
86  assert( doubleEq( n[8], m[8] ) ); // e1 k3
87  assert( doubleEq( n[9], m[9] ) ); // e2 Km
88  assert( doubleEq( n[10], m[10] ) ); // e2 kcat
89  assert( doubleEq( n[11], m[11] ) ); // SP nInit
90 
91  s->doDelete( kin );
92  cout << "." << flush;
93 }
char * data() const
Definition: Eref.cpp:41
Definition: SetGet.h:236
Id makeReacTest()
Definition: testKsolve.cpp:34
Definition: ObjId.h:20
Eref eref() const
Definition: Id.cpp:125
static bool set(const ObjId &dest, const string &field, A arg)
Definition: SetGet.h:245
Id doCreate(string type, ObjId parent, string name, unsigned int numData, NodePolicy nodePolicy=MooseBlockBalance, unsigned int preferredNode=1)
Definition: Shell.cpp:181
bool doubleEq(double x, double y)
Definition: doubleEq.cpp:16
bool doDelete(ObjId oid)
Definition: Shell.cpp:259
Definition: Id.h:17
static A get(const ObjId &dest, const string &field)
Definition: SetGet.h:284
Definition: Shell.h:43

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

const unsigned int ABUT = ~2
static

Definition at line 1302 of file testMesh.cpp.

const unsigned int EMPTY = ~0
static

Definition at line 1300 of file testMesh.cpp.

const unsigned int MULTI = ~3
static

Definition at line 1303 of file testMesh.cpp.

const unsigned int SURFACE = ~1
static

Definition at line 1301 of file testMesh.cpp.