Commit 665ff828 authored by Kirill Terekhov's avatar Kirill Terekhov
Browse files

Added few features

Resolved call ambiguity with isValidElement.

Added service for putting markers on true boundary faces in parallel.

Added service to clean up markers from elements on marker release.
parent f5e27e26
This diff is collapsed.
......@@ -1487,5 +1487,71 @@ namespace INMOST
*/
}
}
void UnpackBoundary(const Tag & tag, const Element & element, const INMOST_DATA_BULK_TYPE * data, INMOST_DATA_ENUM_TYPE size)
{
if( size )
{
bool flag = true;
const Storage::integer * recv = static_cast<const Storage::integer *>(static_cast<const void *>(data));
Storage::integer_array arr = element->IntegerArray(tag);
for(Storage::integer_array::iterator it = arr.begin(); it != arr.end(); it++)
if( *it == recv[0] )
{
flag = false;
break;
}
if( flag )
arr.push_back(recv[0]);
}
}
void Mesh::MarkBoundaryFaces(MarkerType boundary_marker)
{
if( GetProcessorsNumber() > 1 )
{
Tag tag_bnd = CreateTag("CALC_BOUNDARY",DATA_INTEGER,FACE,NONE);
//we need shared unique numbers on cells
if( !(have_global_id & CELL) ) AssignGlobalID(CELL);
#if defined(USE_OMP)
#pragma omp parallel for
#endif
for(integer it = 0; it < FaceLastLocalID(); ++it) if( isValidFace(it) )
{
Face face = FaceByLocalID(it);
integer_array arr = face->IntegerArray(tag_bnd);
ElementArray<Cell> adj = face->getCells();
for(ElementArray<Cell>::iterator jt = adj.begin(); jt != adj.end(); jt++)
arr.push_back(jt->GlobalID());
}
ReduceData(tag_bnd,FACE,0,UnpackBoundary);
ExchangeData(tag_bnd,FACE,0);
#if defined(USE_OMP)
#pragma omp parallel for
#endif
for(integer it = 0; it < FaceLastLocalID(); ++it) if( isValidFace(it) )
{
Face face = FaceByLocalID(it);
if( face->IntegerArray(tag_bnd).size() == 1 )
face->SetMarker(boundary_marker);
}
DeleteTag(tag_bnd);
}
else //nothing to worry about
{
#if defined(USE_OMP)
#pragma omp parallel for
#endif
for(integer it = 0; it < FaceLastLocalID(); ++it)
{
Face face = FaceByLocalID(it);
if( face->Boundary() ) face->SetMarker(boundary_marker);
}
}
}
}
#endif
......@@ -1626,7 +1626,7 @@ namespace INMOST
std::pair<ElementSet,bool> Mesh::CreateSet(std::string name)
{
for(integer it = 0; it < EsetLastLocalID(); ++it) if( isValidElement(ElementNum(ESET),it) )
for(integer it = 0; it < EsetLastLocalID(); ++it) if( isValidElement(ESET,it) )
{
ElementSet e = EsetByLocalID(it);
if( e->GetName() == name )
......@@ -1646,7 +1646,7 @@ namespace INMOST
{
array<Storage::real> temp(dims*NumberOfNodes());
Storage::integer j = 0;
for(Storage::integer k = 0; k < NodeLastLocalID(); ++k) if( isValidElement(0,k) )
for(Storage::integer k = 0; k < NodeLastLocalID(); ++k) if( isValidElementNum(0,k) )
{
memcpy(temp.data()+j,MGetDenseLink(ComposeHandleNum(0,k),CoordsTag()),sizeof(Storage::real)*dims);
j+=dims;
......@@ -1655,7 +1655,7 @@ namespace INMOST
DeleteTag(tag_coords);
tag_coords = CreateTag("COORD",DATA_REAL,NODE,NONE,dims);
j = 0;
for(Storage::integer k = 0; k < NodeLastLocalID(); ++k) if( isValidElement(0,k) )
for(Storage::integer k = 0; k < NodeLastLocalID(); ++k) if( isValidElementNum(0,k) )
{
memcpy(MGetDenseLink(ComposeHandleNum(0,k),CoordsTag()),temp.data()+j,sizeof(Storage::real)*dims);
j+=dims;
......@@ -1834,16 +1834,29 @@ namespace INMOST
return InvalidMarker();
}
void Mesh::ReleaseMarker(MarkerType n)
void Mesh::ReleaseMarker(MarkerType n, ElementType cleanup)
{
assert(!isPrivate(n));
assert(!isPrivate(n));
if( cleanup )
{
for(ElementType etype = NODE; etype < MESH; etype = NextElementType(etype)) if( cleanup & etype )
{
integer end = LastLocalID(etype);
#if defined(USE_OMP)
#pragma omp parallel for
#endif
for(integer id = 0; id < end; ++id)
if( isValidElement(etype,id) )
RemMarker(ComposeHandle(etype,id),n);
}
}
#if defined(CHECKS_MARKERS)
#ifndef NDEBUG
for(int etypenum = 0; etypenum < ElementNum(MESH); ++etypenum)
{
integer end = LastLocalIDNum(etypenum);
for(integer id = 0; id < end; ++id)
if( isValidElement(etypenum,id) )
if( isValidElementNum(etypenum,id) )
assert((static_cast<const bulk *>(MGetDenseLink(etypenum,id,MarkersTag()))[n >> MarkerShift] & static_cast<bulk>(n & MarkerMask)) == 0 && "marker was not properly cleared from elements");
}
#endif
......@@ -1861,7 +1874,7 @@ namespace INMOST
{
integer end = LastLocalIDNum(etypenum);
for(integer id = 0; id < end; ++id)
if( isValidElement(etypenum,id) )
if( isValidElementNum(etypenum,id) )
assert((static_cast<const bulk *>(MGetDenseLink(etypenum,id,tag_private_marker[thread]))[n >> MarkerShift] & static_cast<bulk>(n & MarkerMask)) == 0 && "marker was not properly cleared from elements");
}
#endif
......@@ -2298,7 +2311,7 @@ namespace INMOST
ElementSet Mesh::GetSet(std::string name)
{
for(integer it = 0; it < EsetLastLocalID(); ++it) if( isValidElement(ElementNum(ESET),it) )
for(integer it = 0; it < EsetLastLocalID(); ++it) if( isValidElement(ESET,it) )
{
ElementSet e = EsetByLocalID(it);
if( e->GetName() == name )
......@@ -2310,7 +2323,7 @@ namespace INMOST
ElementArray<ElementSet> Mesh::GetSetsByPrefix(std::string name)
{
ElementArray<ElementSet> ret(this);
for(integer it = 0; it < EsetLastLocalID(); ++it) if( isValidElement(ElementNum(ESET),it) )
for(integer it = 0; it < EsetLastLocalID(); ++it) if( isValidElement(ESET,it) )
{
ElementSet e = EsetByLocalID(it);
if( e->GetName().substr(0,name.size()) == name )
......
......@@ -2215,16 +2215,16 @@ namespace INMOST
for(unsigned j = 0; j < count; j++)
{
eit = elements[i].begin() + array_size_recv[k++];
//REPORT_STR("element type " << ElementTypeName(GetHandleElementType(*eit)) << " global id " << Integer(*eit,GlobalIDTag()));
//REPORT_STR("element type " << ElementTypeName(GetHandleElementType(*eit)) << " global id " << Integer(*eit,GlobalIDTag()));
assert( !select || GetMarker(*eit,select) ); //if fires then very likely that marker was not synchronized
//REPORT_VAL("size",array_size_recv[k]);
//for(int qq = 0; qq < array_size_recv[k]; ++qq)
//{
// REPORT_VAL("value " << qq, (*(Storage::integer *)&array_data_recv[pos+qq*tag.GetBytesSize()]));
//}
//REPORT_VAL("size",array_size_recv[k]);
//for(int qq = 0; qq < array_size_recv[k]; ++qq)
//{
// REPORT_VAL("value " << qq, (*(Storage::integer *)&array_data_recv[pos+qq*tag.GetBytesSize()]));
//}
op(tag,Element(this,*eit),&array_data_recv[pos],array_size_recv[k]);
pos += GetDataCapacity(&array_data_recv[pos],array_size_recv[k],tag);
//pos += array_size_recv[k]*tag.GetBytesSize();
//pos += array_size_recv[k]*tag.GetBytesSize();
++k;
++total_unpacked;
}
......@@ -2237,7 +2237,7 @@ namespace INMOST
assert( !select || GetMarker(*eit,select) ); //if fires then very likely that marker was not synchronized
op(tag,Element(this,*eit),&array_data_recv[pos],size);
pos += GetDataCapacity(&array_data_recv[pos],size,tag);
//pos += size*tag.GetBytesSize();
//pos += size*tag.GetBytesSize();
++total_unpacked;
}
}
......@@ -2250,7 +2250,7 @@ namespace INMOST
{
op(tag,Element(this,*eit),&array_data_recv[pos],array_size_recv[k]);
pos += GetDataCapacity(&array_data_recv[pos],array_size_recv[k],tag);
//pos += array_size_recv[k]*tag.GetBytesSize();
//pos += array_size_recv[k]*tag.GetBytesSize();
++k;
++total_unpacked;
}
......@@ -2261,7 +2261,7 @@ namespace INMOST
{
op(tag,Element(this,*eit),&array_data_recv[pos],size);
pos += GetDataCapacity(&array_data_recv[pos],size,tag);
//pos += size*tag.GetBytesSize();
//pos += size*tag.GetBytesSize();
++total_unpacked;
}
}
......
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