13 #include "../utility/Vec.h"
27 #include "../utility/numutil.h"
35 "An assumed thickness for PSD. The volume is computed as the"
36 "PSD area passed in to each PSD, times this value."
37 "defaults to 50 nanometres. For reference, membranes are 5 nm.",
46 "Vector of indices of voxels on parent NeuroMesh, from which "
47 "the respective spines emerge.",
53 "Vector of Ids of electrical compartments that map to each "
54 "voxel. This is necessary because the order of the IDs may "
55 "differ from the ordering of the voxels. Note that there "
56 "is always just one voxel per PSD. ",
61 "Vector of Ids of all electrical compartments in this "
62 "PsdMesh. Ordering is as per the tree structure built in "
63 "the NeuroMesh, and may differ from Id order. Ordering "
64 "matches that used for startVoxelInCompt and endVoxelInCompt",
69 "Index of first voxel that maps to each electrical "
70 "compartment. This is a trivial function in the PsdMesh, as"
71 "we have a single voxel per spine. So just a vector of "
77 "Index of end voxel that maps to each electrical "
78 "compartment. Since there is just one voxel per electrical "
79 "compartment in the spine, this is just a vector of index+1",
88 "Specifies the geometry of the spine,"
89 "and the associated parent voxel"
91 "disk params vector with 8 entries per psd, "
92 "vector of Ids of electrical compts mapped to voxels, "
93 "parent voxel index ",
97 vector< unsigned int > >(
105 static Finfo* psdMeshFinfos[] = {
120 sizeof( psdMeshFinfos ) /
sizeof (
Finfo* ),
138 thickness_( 50.0e-9 ),
141 parentDist_( 1, 1e-6 ),
143 surfaceGranularity_( 0.1 ),
148 const double defaultLength = 1e-6;
149 psd_[0].setDia( defaultLength );
151 psd_[0].setNumDivs( 1 );
152 psd_[0].setIsCylinder(
true );
158 surfaceGranularity_( other.surfaceGranularity_ )
186 cout <<
"Warning: PsdMesh::getNeuronVoxel. Currently not working\n";
197 vector< unsigned int > ret(
elecCompt_.size() );
198 for (
unsigned int i = 0; i < ret.size(); ++i )
205 vector< unsigned int > ret(
elecCompt_.size() );
206 for (
unsigned int i = 0; i < ret.size(); ++i )
229 vector< double > diskCoords,
231 vector< Id > elecCompt,
234 vector< unsigned int > parentVoxel )
237 assert( diskCoords.size() == 8 * parentVoxel.size() );
238 psd_.resize( parentVoxel.size() );
239 pa_.resize( parentVoxel.size() );
240 vs_.resize( parentVoxel.size() );
241 area_.resize( parentVoxel.size() );
242 length_.resize( parentVoxel.size() );
249 vector< double >::const_iterator x = diskCoords.begin();
250 for (
unsigned int i = 0; i < parentVoxel.size(); ++i ) {
257 pa_.push_back(
CylBase( p - *x, q - *(x+1), r - *(x+2), 1, 0, 1 ));
259 psd_.back().setDia( *x++ );
260 psd_.back().setIsCylinder(
true );
276 vector< unsigned int > localIndices(
psd_.size() );
277 vector< double > vols(
psd_.size() );
278 for (
unsigned int i = 0; i <
psd_.size(); ++i ) {
282 vector< vector< unsigned int > > outgoingEntries;
283 vector< vector< unsigned int > > incomingEntries;
286 oldVol, 0, localIndices, vols );
298 assert( fid <
psd_.size() );
311 if (
psd_.size() == 0 )
313 assert( fid <
psd_.size() );
320 if (
psd_.size() == 0 )
322 assert( fid <
psd_.size() );
325 double dia = 2.0 * sqrt(
area_[fid] /
PI );
326 psd_[ fid ].setDia( dia );
333 vector< double > ret;
334 ret.push_back(
psd_[fid].getX() );
335 ret.push_back(
psd_[fid].getY() );
336 ret.push_back(
psd_[fid].getZ() );
337 ret.push_back(
psd_[fid].getX() -
pa_[fid].getX() );
338 ret.push_back(
psd_[fid].getY() -
pa_[fid].getY() );
339 ret.push_back(
psd_[fid].getZ() -
pa_[fid].getZ() );
340 ret.push_back(
psd_[fid].getDia() );
347 vector< double > ret;
348 assert( fid <
psd_.size() );
359 return vector< double >( 2, 1.0 );
366 if ( fid <
psd_.size() ) {
382 const SrcFinfo2<
unsigned int, vector< double > >* meshStatsFinfo
390 unsigned int numNodes,
unsigned int numThreads )
399 cout <<
"Error: PsdMesh::parent: Index " << i <<
" out of range: " <<
427 cout <<
"Warning: PsdMesh::innerBuildDefaultMesh: attempt to build a default psd: not permitted\n";
444 vector< VoxelJunction >& ret )
const
461 cout <<
"Warning: PsdMesh::matchMeshEntries: unknown class\n";
465 double& x,
double& y,
double& z )
const
469 x =
psd_[index].getX();
470 y =
psd_[index].getY();
471 z =
psd_[index].getZ();
475 unsigned int& index )
const
479 for(
unsigned int i = 0; i <
psd_.size(); ++i ) {
494 vector< VoxelJunction >& ret )
const
498 for (
unsigned int i = 0; i <
psd_.size(); ++i ) {
510 vector< VoxelJunction >& ret )
const
514 for (
unsigned int i = 0; i <
psd_.size(); ++i ) {
521 vector< VoxelJunction >& ret )
const
523 for(
unsigned int i = 0; i <
psd_.size(); ++i ) {
544 vector< unsigned int > ret(
parent_.size(), -1U );
563 static vector< double > midpoint;
564 midpoint.resize(
psd_.size() * 3 );
565 vector< double >::iterator k = midpoint.begin();
566 for (
unsigned int i = 0; i <
psd_.size(); ++i ) {
567 vector< double > coords =
568 psd_[i].getCoordinates(
pa_[i], 0 );
569 *k = ( coords[0] + coords[3] ) / 2.0;
570 *(k +
psd_.size() ) = ( coords[1] + coords[4] ) / 2.0;
571 *(k + 2 *
psd_.size() ) = ( coords[2] + coords[5] ) / 2.0;
591 for ( vector< double >::const_iterator i =
592 vs_.begin(); i !=
vs_.end(); ++i )
600 double linscale = pow( volscale, 1.0/3.0 );
601 assert(
vs_.size() ==
psd_.size() );
605 for (
unsigned int i = 0; i <
psd_.size(); ++i ) {
606 psd_[i].setLength(
psd_[i].getLength() * linscale );
607 psd_[i].setDia(
psd_[i].getDia() * linscale );
609 area_[i] *= linscale * linscale;
static const Cinfo * initCinfo()
vector< unsigned int > getNeuronVoxel() const
unsigned int getMeshDimensions(unsigned int fid) const
Virtual function to return dimensions of specified entry.
vector< Id > elecCompt_
Parent voxel index.
void innerResetStencil()
virtual func implemented here.
unsigned int parent(unsigned int index) const
double getMeshEntryVolume(unsigned int fid) const
Virtual function to return volume of mesh Entry.
double getMeshEntryVolume(unsigned int fid) const
Virtual function to return volume of mesh Entry.
unsigned int value() const
static const Cinfo * psdMeshCinfo
MeshEntry * lookupEntry(unsigned int index)
double extendedMeshEntryVolume(unsigned int fid) const
Virtual function to return volume of mesh Entry, including.
void matchNeuroMeshEntries(const ChemCompt *other, vector< VoxelJunction > &ret) const
vector< unsigned int > getStartVoxelInCompt() const
Returns index of first voxel mapping to elec compt.
vector< double > getDiffusionScaling(unsigned int fid) const
Virtual function to return scale factor for diffusion. 1 here.
vector< double > getCoordinates(unsigned int fid) const
Virtual function to return coords of mesh Entry.
double thickness_
Thickness of PSD.
void setMeshEntryVolume(unsigned int fid, double volume)
Virtual function to set volume of mesh Entry.
unsigned int innerGetDimensions() const
Returns # of dimensions, always 3 here. Inherited pure virt func.
vector< double > area_
Vol.
double getThickness() const
vector< CylBase > pa_
Specified disk of psd.
vector< double > parentDist_
Specifies direction of psd. Length ignored.
vector< double > getDiffusionArea(unsigned int fid) const
Virtual function to return diffusion X-section area.
void matchCubeMeshEntries(const ChemCompt *other, const CylBase &parent, unsigned int startIndex, double granularity, vector< VoxelJunction > &ret, bool useCylinderCurve, bool useCylinderCap) const
const vector< double > & getVoxelArea() const
double nearest(double x, double y, double z, unsigned int &index) const
void innerSetNumEntries(unsigned int n)
Inherited virtual func.
vector< unsigned int > getEndVoxelInCompt() const
Returns index of end voxel mapping to elec compt, just first+1.
void innerHandleNodeInfo(const Eref &e, unsigned int numNodes, unsigned int numThreads)
double distance(const Vec &other) const
void innerBuildDefaultMesh(const Eref &e, double volume, unsigned int numEntries)
Virtual func to make a mesh with specified Volume and numEntries.
void matchCubeMeshEntries(const ChemCompt *other, vector< VoxelJunction > &ret) const
void matchSpineMeshEntries(const ChemCompt *other, vector< VoxelJunction > &ret) const
double vGetEntireVolume() const
Inherited virtual func.
double extendedMeshEntryVolume(unsigned int fid) const
Vol of all mesh Entries including abutting diff-coupled voxels.
unsigned int innerGetNumEntries() const
void matchMeshEntries(const ChemCompt *other, vector< VoxelJunction > &ret) const
void triggerRemesh(const Eref &e, double oldvol, unsigned int startEntry, const vector< unsigned int > &localIndices, const vector< double > &vols)
static unsigned int numNodes
vector< unsigned int > parent_
Specifies diff distance to PSD.
double surfaceGranularity_
Ids of elec compts mapped to each voxel.
unsigned int getMeshType(unsigned int fid) const
Virtual function to return MeshType of specified entry.
const vector< double > & vGetVoxelMidpoint() const
Virtual func so that derived classes can return voxel midpoint.
vector< unsigned int > getParentVoxel() const
static const Cinfo * initCinfo()
void handlePsdList(const Eref &e, vector< double > params, vector< Id > elecCompts, vector< unsigned int > parentVoxel)
void setStencilSize(unsigned int numRows, unsigned int numCols)
bool vSetVolumeNotRates(double volume)
Inherited virtual func.
const vector< double > & getVoxelLength() const
vector< double > length_
area
void innerHandleRequestMeshStats(const Eref &e, const SrcFinfo2< unsigned int, vector< double > > *meshStatsFinfo)
void indexToSpace(unsigned int index, double &x, double &y, double &z) const
const vector< double > & vGetVoxelVolume() const
Virtual func so that derived classes can pass voxel volume back.
void setThickness(double v)
vector< Id > getElecComptMap() const