Commit 2cadb032 authored by Kirill Terekhov's avatar Kirill Terekhov

fix MarkNormalOrientation; fix crash on windows in UpackTagData with zero size

parent 91b7243e
...@@ -1359,7 +1359,6 @@ namespace INMOST ...@@ -1359,7 +1359,6 @@ namespace INMOST
void Init (std::string name); void Init (std::string name);
public: public:
Tag tag_sendto; Tag tag_sendto;
TagInteger tag_an_id;
Tag tag_processors; Tag tag_processors;
/// Go through all elements and detect presence of prescribed element in /// Go through all elements and detect presence of prescribed element in
/// any reference data tag. /// any reference data tag.
......
...@@ -264,7 +264,10 @@ namespace INMOST ...@@ -264,7 +264,10 @@ namespace INMOST
n &= ~MarkerPrivateBit; n &= ~MarkerPrivateBit;
int thread = GetLocalProcessorRank(); int thread = GetLocalProcessorRank();
const bulk * mem = static_cast<const bulk *>(MGetDenseLink(h,tag_private_markers[thread])); const bulk * mem = static_cast<const bulk *>(MGetDenseLink(h,tag_private_markers[thread]));
return (mem[n >> MarkerShift] & static_cast<bulk>(n & MarkerMask)) != 0; MarkerType pos = n >> MarkerShift;
bulk mask = static_cast<bulk>(n & MarkerMask);
bulk mark = mem[pos];
return (mark & mask) != 0;
} }
void Mesh::SetPrivateMarker(HandleType h,MarkerType n) void Mesh::SetPrivateMarker(HandleType h,MarkerType n)
...@@ -2041,6 +2044,7 @@ namespace INMOST ...@@ -2041,6 +2044,7 @@ namespace INMOST
ret = (k << MarkerShift) | mask; ret = (k << MarkerShift) | mask;
marker_space[k] |= mask; marker_space[k] |= mask;
ret |= MarkerPrivateBit; ret |= MarkerPrivateBit;
//std::cout << __FILE__ << ":" << __LINE__ << " " << __FUNCTION__ << " ret " << ret << " k " << k << std::endl;
return ret; return ret;
} }
} }
...@@ -2113,6 +2117,7 @@ namespace INMOST ...@@ -2113,6 +2117,7 @@ namespace INMOST
} }
#endif #endif
#endif #endif
//std::cout << __FILE__ << ":" << __LINE__ << " " << __FUNCTION__ << " ret " << n << std::endl;
Storage::RemPrivateMarker(n); Storage::RemPrivateMarker(n);
} }
......
...@@ -1249,8 +1249,7 @@ namespace INMOST ...@@ -1249,8 +1249,7 @@ namespace INMOST
tag_layers = CreateTag("LAYERS",DATA_INTEGER,MESH,NONE,1); tag_layers = CreateTag("LAYERS",DATA_INTEGER,MESH,NONE,1);
tag_bridge = CreateTag("BRIDGE",DATA_INTEGER,MESH,NONE,1); tag_bridge = CreateTag("BRIDGE",DATA_INTEGER,MESH,NONE,1);
tag_sendto = CreateTag("PROTECTED_SENDTO",DATA_INTEGER, ESET | CELL | FACE | EDGE | NODE, ESET | CELL | FACE | EDGE | NODE); tag_sendto = CreateTag("PROTECTED_SENDTO",DATA_INTEGER, ESET | CELL | FACE | EDGE | NODE, ESET | CELL | FACE | EDGE | NODE);
tag_an_id = CreateTag("PROTECTED_ID",DATA_INTEGER, CELL | FACE | EDGE | NODE, CELL | FACE | EDGE | NODE);
#if defined(USE_MPI) #if defined(USE_MPI)
randomizer = Random(); randomizer = Random();
...@@ -3210,16 +3209,17 @@ namespace INMOST ...@@ -3210,16 +3209,17 @@ namespace INMOST
// std::cout << " no marker" << std::endl; // std::cout << " no marker" << std::endl;
//} //}
assert( !select || GetMarker(*eit,select) ); //if fires then very likely that marker was not synchronized assert( !select || GetMarker(*eit,select) ); //if fires then very likely that marker was not synchronized
if( tag.GetDataType() == DATA_REFERENCE ) if( tag.GetDataType() == DATA_REFERENCE ) //change received content with actual reference to element
{ {
for (INMOST_DATA_ENUM_TYPE i = 0; i < array_size_recv[k]; i++) for (INMOST_DATA_ENUM_TYPE i = 0; i < array_size_recv[k]; i++)
{ {
HandleType * data = (HandleType*)(&array_data_recv[pos + (size_t)i*tag.GetBytesSize()]); INMOST_DATA_ENUM_TYPE spos = pos + i * tag.GetBytesSize();
int pos = -1; INMOST_DATA_ENUM_TYPE dpos = ENUMUNDEF;
HandleType * data = (HandleType*)(&array_data_recv[spos]);
if( *data != InvalidHandle() ) if( *data != InvalidHandle() )
{ {
pos = GetHandleID(*data); dpos = GetHandleID(*data);
*data = unpack_elements[GetHandleElementNum(*data)][pos]; *data = unpack_elements[GetHandleElementNum(*data)][dpos];
} }
//REPORT_STR("element " << ElementTypeName(GetHandleElementType(*eit)) << " " << GetHandleID(*eit) ); //REPORT_STR("element " << ElementTypeName(GetHandleElementType(*eit)) << " " << GetHandleID(*eit) );
//REPORT_VAL("unpack type ",ElementTypeName(GetHandleElementType(*data))); //REPORT_VAL("unpack type ",ElementTypeName(GetHandleElementType(*data)));
...@@ -3228,11 +3228,14 @@ namespace INMOST ...@@ -3228,11 +3228,14 @@ namespace INMOST
//if( GetHandleElementType(*data) == ESET ) REPORT_VAL("unpack name ", ElementSet(this,*data).GetName()); //if( GetHandleElementType(*data) == ESET ) REPORT_VAL("unpack name ", ElementSet(this,*data).GetName());
} }
} }
assert( k < array_size_recv.size() ); assert(k < array_size_recv.size());
INMOST_DATA_ENUM_TYPE data_size = GetDataCapacity(&array_data_recv[pos],array_size_recv[k],tag); if (array_size_recv[k])
assert(pos + data_size <= array_data_recv.size()); {
op(tag,Element(this,*eit),&array_data_recv[pos],array_size_recv[k]); INMOST_DATA_ENUM_TYPE data_size = GetDataCapacity(&array_data_recv[pos], array_size_recv[k], tag);
pos += data_size; assert(pos + data_size <= array_data_recv.size());
op(tag, Element(this, *eit), &array_data_recv[pos], array_size_recv[k]);
pos += data_size;
}
++k; ++k;
++total_unpacked; ++total_unpacked;
} }
...@@ -3257,16 +3260,17 @@ namespace INMOST ...@@ -3257,16 +3260,17 @@ namespace INMOST
std::cout << " no marker" << std::endl; std::cout << " no marker" << std::endl;
} }
assert( !select || GetMarker(*eit,select) ); //if fires then very likely that marker was not synchronized assert( !select || GetMarker(*eit,select) ); //if fires then very likely that marker was not synchronized
if( tag.GetDataType() == DATA_REFERENCE ) if( tag.GetDataType() == DATA_REFERENCE ) //change received content with actual reference to element
{ {
for (INMOST_DATA_ENUM_TYPE i = 0; i < size; i++) for (INMOST_DATA_ENUM_TYPE i = 0; i < size; i++)
{ {
HandleType * data = (HandleType*)(&array_data_recv[pos + (size_t)i*tag.GetBytesSize()]); INMOST_DATA_ENUM_TYPE spos = pos + i * tag.GetBytesSize();
int pos = -1; INMOST_DATA_ENUM_TYPE dpos = ENUMUNDEF;
HandleType * data = (HandleType*)(&array_data_recv[spos]);
if( *data != InvalidHandle() ) if( *data != InvalidHandle() )
{ {
pos = GetHandleID(*data); dpos = GetHandleID(*data);
*data = unpack_elements[GetHandleElementNum(*data)][pos]; *data = unpack_elements[GetHandleElementNum(*data)][dpos];
} }
//REPORT_STR("element " << ElementTypeName(GetHandleElementType(*eit)) << " " << GetHandleID(*eit) ); //REPORT_STR("element " << ElementTypeName(GetHandleElementType(*eit)) << " " << GetHandleID(*eit) );
//REPORT_VAL("unpack type ",ElementTypeName(GetHandleElementType(*data))); //REPORT_VAL("unpack type ",ElementTypeName(GetHandleElementType(*data)));
...@@ -3275,9 +3279,9 @@ namespace INMOST ...@@ -3275,9 +3279,9 @@ namespace INMOST
//if( GetHandleElementType(*data) == ESET ) REPORT_VAL("unpack name ", ElementSet(this,*data).GetName()); //if( GetHandleElementType(*data) == ESET ) REPORT_VAL("unpack name ", ElementSet(this,*data).GetName());
} }
} }
INMOST_DATA_ENUM_TYPE data_size = GetDataCapacity(&array_data_recv[pos],size,tag); INMOST_DATA_ENUM_TYPE data_size = GetDataCapacity(&array_data_recv[pos], size, tag);
assert(pos + data_size <= array_data_recv.size()); assert(pos + data_size <= array_data_recv.size());
op(tag,Element(this,*eit),&array_data_recv[pos],size); op(tag, Element(this, *eit), &array_data_recv[pos], size);
pos += data_size; pos += data_size;
++total_unpacked; ++total_unpacked;
} }
...@@ -3297,12 +3301,13 @@ namespace INMOST ...@@ -3297,12 +3301,13 @@ namespace INMOST
{ {
for (INMOST_DATA_ENUM_TYPE i = 0; i < array_size_recv[k]; i++) for (INMOST_DATA_ENUM_TYPE i = 0; i < array_size_recv[k]; i++)
{ {
HandleType * data = (HandleType*)(&array_data_recv[pos + (size_t)i*tag.GetBytesSize()]); INMOST_DATA_ENUM_TYPE spos = pos + i * tag.GetBytesSize();
int pos = -1; INMOST_DATA_ENUM_TYPE dpos = ENUMUNDEF;
HandleType * data = (HandleType*)(&array_data_recv[spos]);
if( *data != InvalidHandle() ) if( *data != InvalidHandle() )
{ {
pos = GetHandleID(*data); dpos = GetHandleID(*data);
*data = unpack_elements[GetHandleElementNum(*data)][pos]; *data = unpack_elements[GetHandleElementNum(*data)][dpos];
} }
//REPORT_STR("element " << ElementTypeName(GetHandleElementType(*eit)) << " " << GetHandleID(*eit) ); //REPORT_STR("element " << ElementTypeName(GetHandleElementType(*eit)) << " " << GetHandleID(*eit) );
//REPORT_VAL("unpack type ",ElementTypeName(GetHandleElementType(*data))); //REPORT_VAL("unpack type ",ElementTypeName(GetHandleElementType(*data)));
...@@ -3312,10 +3317,13 @@ namespace INMOST ...@@ -3312,10 +3317,13 @@ namespace INMOST
} }
} }
assert(k < array_size_recv.size()); assert(k < array_size_recv.size());
INMOST_DATA_ENUM_TYPE data_size = GetDataCapacity(&array_data_recv[pos],array_size_recv[k],tag); if (array_size_recv[k])
assert(pos + data_size <= array_data_recv.size()); {
op(tag,Element(this,*eit),&array_data_recv[pos],array_size_recv[k]); INMOST_DATA_ENUM_TYPE data_size = GetDataCapacity(&array_data_recv[pos], array_size_recv[k], tag);
pos += data_size; assert(pos + data_size <= array_data_recv.size());
op(tag, Element(this, *eit), &array_data_recv[pos], array_size_recv[k]);
pos += data_size;
}
++k; ++k;
++total_unpacked; ++total_unpacked;
} }
...@@ -3329,16 +3337,17 @@ namespace INMOST ...@@ -3329,16 +3337,17 @@ namespace INMOST
{ {
if( !select || GetMarker(*eit,select) ) if( !select || GetMarker(*eit,select) )
{ {
if( tag.GetDataType() == DATA_REFERENCE ) if( tag.GetDataType() == DATA_REFERENCE ) //change received content with actual reference to element
{ {
for (INMOST_DATA_ENUM_TYPE i = 0; i < size; i++) for (INMOST_DATA_ENUM_TYPE i = 0; i < size; i++)
{ {
HandleType * data = (HandleType*)(&array_data_recv[pos + (size_t)i*tag.GetBytesSize()]); INMOST_DATA_ENUM_TYPE spos = pos + i * tag.GetBytesSize();
int pos = -1; INMOST_DATA_ENUM_TYPE dpos = ENUMUNDEF;
HandleType * data = (HandleType*)(&array_data_recv[spos]);
if( *data != InvalidHandle() ) if( *data != InvalidHandle() )
{ {
pos = GetHandleID(*data); dpos = GetHandleID(*data);
*data = unpack_elements[GetHandleElementNum(*data)][pos]; *data = unpack_elements[GetHandleElementNum(*data)][dpos];
} }
//REPORT_STR("element " << ElementTypeName(GetHandleElementType(*eit)) << " " << GetHandleID(*eit) ); //REPORT_STR("element " << ElementTypeName(GetHandleElementType(*eit)) << " " << GetHandleID(*eit) );
//REPORT_VAL("unpack type ",ElementTypeName(GetHandleElementType(*data))); //REPORT_VAL("unpack type ",ElementTypeName(GetHandleElementType(*data)));
...@@ -3347,15 +3356,15 @@ namespace INMOST ...@@ -3347,15 +3356,15 @@ namespace INMOST
//if( GetHandleElementType(*data) == ESET ) REPORT_VAL("unpack name ", ElementSet(this,*data).GetName()); //if( GetHandleElementType(*data) == ESET ) REPORT_VAL("unpack name ", ElementSet(this,*data).GetName());
} }
} }
INMOST_DATA_ENUM_TYPE data_size = GetDataCapacity(&array_data_recv[pos],size,tag); INMOST_DATA_ENUM_TYPE data_size = GetDataCapacity(&array_data_recv[pos], size, tag);
if( (size_t)pos + data_size > array_data_recv.size() ) if ((size_t)pos + data_size > array_data_recv.size())
{ {
std::cout << "element " << ElementTypeName(GetHandleElementType(*eit)) << " id " << GetHandleID(*eit); std::cout << "element " << ElementTypeName(GetHandleElementType(*eit)) << " id " << GetHandleID(*eit);
std::cout << " data type " << DataTypeName(tag.GetDataType()) << " size " << size << " bytes " << tag.GetBytesSize() ; std::cout << " data type " << DataTypeName(tag.GetDataType()) << " size " << size << " bytes " << tag.GetBytesSize();
std::cout << " pos " << pos << " data_size " << data_size << " recv " << array_data_recv.size() << std::endl; std::cout << " pos " << pos << " data_size " << data_size << " recv " << array_data_recv.size() << std::endl;
} }
assert(pos+data_size <= array_data_recv.size()); assert(pos + data_size <= array_data_recv.size());
op(tag,Element(this,*eit),&array_data_recv[pos],size); op(tag, Element(this, *eit), &array_data_recv[pos], size);
pos += data_size; pos += data_size;
++total_unpacked; ++total_unpacked;
} }
...@@ -7195,6 +7204,7 @@ namespace INMOST ...@@ -7195,6 +7204,7 @@ namespace INMOST
GatherParallelStorage(ghost_elements,shared_elements,FACE); GatherParallelStorage(ghost_elements,shared_elements,FACE);
#endif //USE_PARALLEL_STORAGE #endif //USE_PARALLEL_STORAGE
TagRealArray tag_nrm = CreateTag("TEMPORARY_NORMAL",DATA_REAL,FACE,NONE,3); TagRealArray tag_nrm = CreateTag("TEMPORARY_NORMAL",DATA_REAL,FACE,NONE,3);
for (iteratorFace it = BeginFace(); it != EndFace(); ++it) it->RemMarker(mrk);
for(iteratorFace it = BeginFace(); it != EndFace(); ++it) for(iteratorFace it = BeginFace(); it != EndFace(); ++it)
if( it->GetStatus() & (Element::Ghost | Element::Shared) ) if( it->GetStatus() & (Element::Ghost | Element::Shared) )
it->UnitNormal(tag_nrm[it->self()].data()); it->UnitNormal(tag_nrm[it->self()].data());
......
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