Commit b214f48f authored by Kirill Terekhov's avatar Kirill Terekhov
Browse files

some updates

Replacing dereference of zero'th element by data();
Fixed issues in GridGen that prevented compilation by microsoft visual
studio compiler;
Fixed small bug introduced by previous commit.
parent 97ea10c7
...@@ -20,7 +20,7 @@ Mesh * ParallelCubeGenerator(INMOST_MPI_Comm comm, int nx, int ny, int nz) ...@@ -20,7 +20,7 @@ Mesh * ParallelCubeGenerator(INMOST_MPI_Comm comm, int nx, int ny, int nz)
m->SetCommunicator(comm); // Set the MPI communicator, usually MPI_COMM_WORLD m->SetCommunicator(comm); // Set the MPI communicator, usually MPI_COMM_WORLD
#if defined(USE_MPI) #if defined(USE_MPI)
MPI::COMM_WORLD.Set_errhandler(MPI::ERRORS_THROW_EXCEPTIONS); //MPI::COMM_WORLD.Set_errhandler(MPI::ERRORS_THROW_EXCEPTIONS);
#endif #endif
rank = m->GetProcessorRank(); // Get the rank of the current process rank = m->GetProcessorRank(); // Get the rank of the current process
...@@ -56,9 +56,9 @@ Mesh * ParallelCubeGenerator(INMOST_MPI_Comm comm, int nx, int ny, int nz) ...@@ -56,9 +56,9 @@ Mesh * ParallelCubeGenerator(INMOST_MPI_Comm comm, int nx, int ny, int nz)
int localsize[3], localstart[3], localend[3]; int localsize[3], localstart[3], localend[3];
int avgsize[3] = int avgsize[3] =
{ {
(int)ceil(sizes[0]/procs_per_axis[0]), (int)ceil((double)sizes[0]/procs_per_axis[0]),
(int)ceil(sizes[1]/procs_per_axis[1]), (int)ceil((double)sizes[1]/procs_per_axis[1]),
(int)ceil(sizes[2]/procs_per_axis[2]) (int)ceil((double)sizes[2]/procs_per_axis[2])
}; };
for(int j = 0; j < 3; j++) for(int j = 0; j < 3; j++)
...@@ -125,7 +125,7 @@ Mesh * ParallelCubePrismGenerator(INMOST_MPI_Comm comm, int nx, int ny, int nz) ...@@ -125,7 +125,7 @@ Mesh * ParallelCubePrismGenerator(INMOST_MPI_Comm comm, int nx, int ny, int nz)
m->SetCommunicator(comm); // Set the MPI communicator, usually MPI_COMM_WORLD m->SetCommunicator(comm); // Set the MPI communicator, usually MPI_COMM_WORLD
#if defined(USE_MPI) #if defined(USE_MPI)
MPI::COMM_WORLD.Set_errhandler(MPI::ERRORS_THROW_EXCEPTIONS); //MPI::COMM_WORLD.Set_errhandler(MPI::ERRORS_THROW_EXCEPTIONS);
#endif #endif
rank = m->GetProcessorRank(); // Get the rank of the current process rank = m->GetProcessorRank(); // Get the rank of the current process
...@@ -160,9 +160,9 @@ Mesh * ParallelCubePrismGenerator(INMOST_MPI_Comm comm, int nx, int ny, int nz) ...@@ -160,9 +160,9 @@ Mesh * ParallelCubePrismGenerator(INMOST_MPI_Comm comm, int nx, int ny, int nz)
int localsize[3], localstart[3], localend[3]; int localsize[3], localstart[3], localend[3];
int avgsize[3] = int avgsize[3] =
{ {
(int)ceil(sizes[0]/procs_per_axis[0]), (int)ceil((double)sizes[0]/procs_per_axis[0]),
(int)ceil(sizes[1]/procs_per_axis[1]), (int)ceil((double)sizes[1]/procs_per_axis[1]),
(int)ceil(sizes[2]/procs_per_axis[2]) (int)ceil((double)sizes[2]/procs_per_axis[2])
}; };
for(int j = 0; j < 3; j++) for(int j = 0; j < 3; j++)
......
...@@ -104,7 +104,7 @@ namespace INMOST ...@@ -104,7 +104,7 @@ namespace INMOST
d = 0.0; d = 0.0;
adjacent<Node> nodes = f->getNodes(); adjacent<Node> nodes = f->getNodes();
for (unsigned int i=1; i<nodes.size()-1; i++) for (unsigned int i=1; i<nodes.size()-1; i++)
d += c = det4v(point, &nodes[0].Coords()[0], &nodes[i].Coords()[0], &nodes[i+1].Coords()[0]); d += c = det4v(point, nodes[0].Coords().data(), nodes[i].Coords().data(), nodes[i+1].Coords().data());
if (f->getAsFace()->FaceOrientedOutside(this) == 0) c = -1.0; else c = 1.0; if (f->getAsFace()->FaceOrientedOutside(this) == 0) c = -1.0; else c = 1.0;
if (c*d > eps) vp++; else if (c*d < eps) vm++; else vz++; if (c*d > eps) vp++; else if (c*d < eps) vm++; else vz++;
} }
...@@ -530,7 +530,7 @@ namespace INMOST ...@@ -530,7 +530,7 @@ namespace INMOST
{ {
adjacent<Node> nodes = e->getNodes(); adjacent<Node> nodes = e->getNodes();
Storage::real c[3]; Storage::real c[3];
vec_diff(&nodes[0].Coords()[0],&nodes[1].Coords()[0],c,mdim); vec_diff(nodes[0].Coords().data(),nodes[1].Coords().data(),c,mdim);
*ret = vec_len(c,mdim); *ret = vec_len(c,mdim);
//~ if( isnan(*ret) || fabs(*ret) < 1e-15 ) throw -1; //~ if( isnan(*ret) || fabs(*ret) < 1e-15 ) throw -1;
break; break;
...@@ -707,7 +707,7 @@ namespace INMOST ...@@ -707,7 +707,7 @@ namespace INMOST
break; break;
case CENTROID: case CENTROID:
if(etype == NODE ) if(etype == NODE )
memcpy(ret,&e->getAsNode()->Coords()[0],sizeof(real)*mdim); memcpy(ret,e->getAsNode()->Coords().data(),sizeof(real)*mdim);
else if(HaveGeometricData(CENTROID,etype)) else if(HaveGeometricData(CENTROID,etype))
{ {
memcpy(ret,&e->RealDF(centroid_tag),sizeof(real)*mdim); memcpy(ret,&e->RealDF(centroid_tag),sizeof(real)*mdim);
...@@ -728,7 +728,7 @@ namespace INMOST ...@@ -728,7 +728,7 @@ namespace INMOST
break; break;
case BARYCENTER: case BARYCENTER:
if( etype == NODE ) if( etype == NODE )
memcpy(ret,&e->getAsNode()->Coords()[0],sizeof(real)*mdim); memcpy(ret,e->getAsNode()->Coords().data(),sizeof(real)*mdim);
else if(HaveGeometricData(BARYCENTER,etype)) else if(HaveGeometricData(BARYCENTER,etype))
memcpy(ret,&e->RealDF(barycenter_tag),sizeof(real)*mdim); memcpy(ret,&e->RealDF(barycenter_tag),sizeof(real)*mdim);
else else
...@@ -797,7 +797,7 @@ namespace INMOST ...@@ -797,7 +797,7 @@ namespace INMOST
{ {
Storage::real_array v1 = nodes[j].Coords(); Storage::real_array v1 = nodes[j].Coords();
Storage::real_array v2 = nodes[j+1].Coords(); Storage::real_array v2 = nodes[j+1].Coords();
c = det3v(&v0[0],&v1[0],&v2[0]); c = det3v(v0.data(),v1.data(),v2.data());
d += c; d += c;
y[0] += c * (v0[0] + v1[0] + v2[0]); y[0] += c * (v0[0] + v1[0] + v2[0]);
y[1] += c * (v0[1] + v1[1] + v2[1]); y[1] += c * (v0[1] + v1[1] + v2[1]);
...@@ -817,7 +817,7 @@ namespace INMOST ...@@ -817,7 +817,7 @@ namespace INMOST
break; break;
case NORMAL: case NORMAL:
if( HaveGeometricData(NORMAL,etype) ) if( HaveGeometricData(NORMAL,etype) )
memcpy(ret,&e->RealArray(normal_tag)[0],sizeof(real)*GetDimensions()); memcpy(ret,&e->RealDF(normal_tag),sizeof(real)*GetDimensions());
else else
{ {
memset(ret,0,sizeof(real)*mdim); memset(ret,0,sizeof(real)*mdim);
...@@ -885,12 +885,12 @@ namespace INMOST ...@@ -885,12 +885,12 @@ namespace INMOST
if( p.size() <= 3 ) return true; if( p.size() <= 3 ) return true;
unsigned int i, s = p.size(); unsigned int i, s = p.size();
Storage::real v[2][3] = {{0,0,0},{0,0,0}}; Storage::real v[2][3] = {{0,0,0},{0,0,0}};
vec_diff(&p[1].Coords()[0],&p[0].Coords()[0],v[0],3); vec_diff(p[1].Coords().data(),p[0].Coords().data(),v[0],3);
vec_diff(&p[2].Coords()[0],&p[0].Coords()[0],v[1],3); vec_diff(p[2].Coords().data(),p[0].Coords().data(),v[1],3);
vec_cross_product(v[0],v[1],v[1]); vec_cross_product(v[0],v[1],v[1]);
for(i = 3; i < s; i++) for(i = 3; i < s; i++)
{ {
vec_diff(&p[i].Coords()[0],&p[0].Coords()[0],v[0],3); vec_diff(p[i].Coords().data(),p[0].Coords().data(),v[0],3);
if( fabs(vec_dot_product(v[0],v[1],3)) > m->GetEpsilon() ) return false; if( fabs(vec_dot_product(v[0],v[1],3)) > m->GetEpsilon() ) return false;
} }
return true; return true;
...@@ -1081,11 +1081,11 @@ namespace INMOST ...@@ -1081,11 +1081,11 @@ namespace INMOST
if( it == nodes.end() ) break; if( it == nodes.end() ) break;
Storage::real_array av1 = jt->getAsNode()->Coords(); Storage::real_array av1 = jt->getAsNode()->Coords();
Storage::real_array av2 = it->getAsNode()->Coords(); Storage::real_array av2 = it->getAsNode()->Coords();
tval = meantri(&av0[0],&av1[0],&av2[0],m->GetDimensions(),func,time); tval = meantri(av0.data(),av1.data(),av2.data(),m->GetDimensions(),func,time);
vec_diff(&av1[0],&av0[0],&v1[0],dim); vec_diff(av1.data(),av0.data(),v1,dim);
vec_diff(&av2[0],&av0[0],&v2[0],dim); vec_diff(av2.data(),av0.data(),v2,dim);
if( dim == 2 ) v1[2] = v2[2] = 0; if( dim == 2 ) v1[2] = v2[2] = 0;
vec_cross_product(&v1[0],&v2[0],product); vec_cross_product(v1,v2,product);
tvol = vec_dot_product(product,normal,dim)*0.5; tvol = vec_dot_product(product,normal,dim)*0.5;
val += tval*tvol; val += tval*tvol;
vol += tvol; vol += tvol;
...@@ -1165,7 +1165,7 @@ namespace INMOST ...@@ -1165,7 +1165,7 @@ namespace INMOST
Storage::real middle[3]; Storage::real middle[3];
for (unsigned int i = 0 ; i < dim ; i++) middle[i] = (x1[i]+x2[i])*0.5; for (unsigned int i = 0 ; i < dim ; i++) middle[i] = (x1[i]+x2[i])*0.5;
//Simpson formula //Simpson formula
return (func(&x1[0],time) + 4*func(middle,time) + func(&x2[0],time))/6e0; return (func(x1.data(),time) + 4*func(middle,time) + func(x2.data(),time))/6e0;
} }
return 0; return 0;
} }
...@@ -1265,10 +1265,10 @@ namespace INMOST ...@@ -1265,10 +1265,10 @@ namespace INMOST
Storage::real tri[3][3]; Storage::real tri[3][3];
Centroid(tri[2]); Centroid(tri[2]);
adjacent<Node> nodes = getNodes(); adjacent<Node> nodes = getNodes();
memcpy(tri[0],&nodes[nodes.size()-1].Coords()[0],sizeof(Storage::real)*dim); memcpy(tri[0],nodes[nodes.size()-1].Coords().data(),sizeof(Storage::real)*dim);
for(unsigned q = 0; q < nodes.size(); q++) for(unsigned q = 0; q < nodes.size(); q++)
{ {
memcpy(tri[1],&nodes[q].Coords()[0],sizeof(Storage::real)*dim); memcpy(tri[1],nodes[q].Coords().data(),sizeof(Storage::real)*dim);
Storage::real a[3],b[3],c[3],n[3], d, k, m; Storage::real a[3],b[3],c[3],n[3], d, k, m;
Storage::real dot00,dot01,dot02,dot11,dot12,invdenom, uq,vq; Storage::real dot00,dot01,dot02,dot11,dot12,invdenom, uq,vq;
a[0] = tri[0][0] - tri[2][0]; a[0] = tri[0][0] - tri[2][0];
......
...@@ -858,7 +858,7 @@ namespace INMOST ...@@ -858,7 +858,7 @@ namespace INMOST
typedef chunk_array<Face *,15> faces_container; typedef chunk_array<Face *,15> faces_container;
typedef chunk_array<Cell *,15> cells_container; typedef chunk_array<Cell *,15> cells_container;
typedef chunk_array<ElementSet *,7> sets_container; typedef chunk_array<ElementSet *,7> sets_container;
typedef std::vector<INMOST_DATA_ENUM_TYPE> empty_container; typedef chunk_array<INMOST_DATA_ENUM_TYPE,7> empty_container;
//typedef std::vector<Node *> nodes_container; //typedef std::vector<Node *> nodes_container;
//typedef std::vector<Edge *> edges_container; //typedef std::vector<Edge *> edges_container;
...@@ -956,6 +956,7 @@ namespace INMOST ...@@ -956,6 +956,7 @@ namespace INMOST
ElementSet * CreateOrderedSet(); ElementSet * CreateOrderedSet();
Element * FindSharedAdjacency(Element * const * arr, unsigned num) ; Element * FindSharedAdjacency(Element * const * arr, unsigned num) ;
void ReorderEmpty(ElementType reordertypes); void ReorderEmpty(ElementType reordertypes);
//Bug inside: sort would not work on chunk_array, because it is not contiguous in memory
void ReorderApply(Tag index, ElementType mask); void ReorderApply(Tag index, ElementType mask);
bool isOriginal(Element * e); //don't know now what this function was for, should detect the copy-constructed element, but copy-construction is prohibited bool isOriginal(Element * e); //don't know now what this function was for, should detect the copy-constructed element, but copy-construction is prohibited
INMOST_DATA_ENUM_TYPE GetArrayCapacity(ElementType etype); //This function is needed by TagManager, may be made private in future INMOST_DATA_ENUM_TYPE GetArrayCapacity(ElementType etype); //This function is needed by TagManager, may be made private in future
......
...@@ -395,13 +395,15 @@ namespace INMOST ...@@ -395,13 +395,15 @@ namespace INMOST
if( !HideMarker() ) if( !HideMarker() )
{ {
/* /*
dynarray<Element *, 64> inter(arr[0]->HighConn().begin(),arr[0]->HighConn().end()); Element::adj_type const & hc = arr[0]->HighConn();
dynarray<Element *, 64> inter(hc.data(),hc.data()+hc.size());
MarkerType mrk = CreateMarker(); MarkerType mrk = CreateMarker();
for(unsigned i = 1; i < s; i++) for(unsigned i = 1; i < s; i++)
{ {
for(Element::adj_iterator jt = arr[i]->HighConn().begin(); jt != arr[i]->HighConn().end(); ++jt) (*jt)->SetMarker(mrk); Element::adj_type const & ihc = arr[i]->HighConn();
for(Element::adj_type::enumerator jt = 0; jt < ihc.size(); ++jt) ihc[jt]->SetMarker(mrk);
{ {
size_t m = 0, n = 0; int m = 0, n = 0;
while( m < inter.size() ) while( m < inter.size() )
{ {
if( inter[m]->GetMarker(mrk) ) if( inter[m]->GetMarker(mrk) )
...@@ -410,7 +412,7 @@ namespace INMOST ...@@ -410,7 +412,7 @@ namespace INMOST
} }
inter.resize(n); inter.resize(n);
} }
for(Element::adj_iterator jt = arr[i]->HighConn().begin(); jt != arr[i]->HighConn().end(); ++jt) (*jt)->RemMarker(mrk); for(Element::adj_type::enumerator jt = 0; jt < ihc.size(); ++jt) ihc[jt]->RemMarker(mrk);
if( inter.empty() ) if( inter.empty() )
{ {
ReleaseMarker(mrk); ReleaseMarker(mrk);
......
...@@ -93,9 +93,9 @@ namespace INMOST ...@@ -93,9 +93,9 @@ namespace INMOST
//std::cout << "swap " << t->GetTagName() << " from " << local_id << " to " << new_local_id << " record size: " << record_size << " bytes: " << bytes << " data size: " << data_size << std::endl; //std::cout << "swap " << t->GetTagName() << " from " << local_id << " to " << new_local_id << " record size: " << record_size << " bytes: " << bytes << " data size: " << data_size << std::endl;
temp.resize(record_size); temp.resize(record_size);
memcpy(&temp[0],&arr[to],record_size); memcpy(temp.data(),&arr[to],record_size);
memcpy(&arr[to],&arr[from],record_size); memcpy(&arr[to],&arr[from],record_size);
memcpy(&arr[from],&temp[0],record_size); memcpy(&arr[from],temp.data(),record_size);
} }
} }
Storage::Storage(Mesh * m, ElementType _etype) Storage::Storage(Mesh * m, ElementType _etype)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment