Commit 6a181a76 authored by Kirill Terekhov's avatar Kirill Terekhov

Some fixes and updates for eclipse grid reader

parent 62a1d80a
......@@ -1225,7 +1225,7 @@ void draw_faces_nc(std::vector<face2gl> & set, int highlight = -1)
{
if( drawedges == 2 || drawedges == 3 ) return;
glEnable(GL_POLYGON_OFFSET_FILL);
//glPolygonOffset(1.0, 1.0);
glPolygonOffset(1.0, 1.0);
glColor4f(0,1,0,0.1);
glBegin(GL_TRIANGLES);
......@@ -1245,7 +1245,7 @@ void draw_faces(std::vector<face2gl> & set, int highlight = -1)
{
if( drawedges == 2 || drawedges == 3) return;
glEnable(GL_POLYGON_OFFSET_FILL);
//glPolygonOffset(1.0, 1.0);
glPolygonOffset(1.0, 1.0);
if( visualization_tag.isValid() ) CommonColorBar->BindTexture();
......@@ -1271,7 +1271,7 @@ void draw_faces_alpha(std::vector<face2gl> & set, double alpha)
if( visualization_tag.isValid() ) CommonColorBar->BindTexture();
glEnable(GL_POLYGON_OFFSET_FILL);
//glPolygonOffset(1.0, 1.0);
glPolygonOffset(1.0, 1.0);
glBegin(GL_TRIANGLES);
for(INMOST_DATA_ENUM_TYPE q = 0; q < set.size() ; q++) set[q].draw_colour_alpha(alpha);
......@@ -1304,7 +1304,7 @@ void draw_faces_interactive_nc(std::vector<face2gl> & set)
glColor4f(0,1,0,0.1);
glEnable(GL_POLYGON_OFFSET_FILL);
//glPolygonOffset(1.0, 1.0);
glPolygonOffset(1.0, 1.0);
glBegin(GL_TRIANGLES);
......@@ -1320,7 +1320,7 @@ void draw_faces_interactive(std::vector<face2gl> & set)
if( visualization_tag.isValid() ) CommonColorBar->BindTexture();
glEnable(GL_POLYGON_OFFSET_FILL);
//glPolygonOffset(1.0, 1.0);
glPolygonOffset(1.0, 1.0);
glBegin(GL_TRIANGLES);
......@@ -1337,7 +1337,7 @@ void draw_faces_interactive_alpha(std::vector<face2gl> & set, double alpha)
if( visualization_tag.isValid() ) CommonColorBar->BindTexture();
glEnable(GL_POLYGON_OFFSET_FILL);
//glPolygonOffset(1.0, 1.0);
glPolygonOffset(1.0, 1.0);
glBegin(GL_TRIANGLES);
......@@ -2369,7 +2369,7 @@ public:
{
if( visualization_tag.isValid() ) CommonColorBar->BindTexture();
glEnable(GL_POLYGON_OFFSET_FILL);
//glPolygonOffset(1.0, 1.0);
glPolygonOffset(1.0, 1.0);
glBegin(GL_TRIANGLES);
for(INMOST_DATA_ENUM_TYPE k = 0; k < cells.size(); k+=pace) if( cells[k]->GetMarker(marker))
......@@ -2654,7 +2654,7 @@ public:
ElementArray<Node> nodes = Face(mm,faces[k])->getNodes();
glEnable(GL_POLYGON_OFFSET_FILL);
//glPolygonOffset(1.0, 1.0);
glPolygonOffset(1.0, 1.0);
glBegin(GL_POLYGON);
......
......@@ -295,7 +295,7 @@ namespace INMOST
bool need_sparse[6] = {false,false,false,false,false,false};
#endif
for(tag_array_type::size_type i = 0; i < tags.size(); i++)
{
{
if( tags[i].GetTagName() == name )
{
assert( tags[i].GetDataType() == dtype && (size == ENUMUNDEF || size == tags[i].GetSize()) );
......@@ -306,16 +306,16 @@ namespace INMOST
new_tag = tags[i];
break;
}
}
}
if( !new_tag.isValid() )
{
new_tag = Tag(m,name,dtype,size);
#if defined(USE_OMP)
#pragma omp critical
#endif
{
tags.push_back(new_tag);
}
{
tags.push_back(new_tag);
}
}
for(ElementType mask = NODE; mask <= MESH; mask = mask << 1)
{
......@@ -331,20 +331,20 @@ namespace INMOST
}
else
{
INMOST_DATA_ENUM_TYPE new_pos = ENUMUNDEF;
INMOST_DATA_ENUM_TYPE new_pos = ENUMUNDEF;
#if defined(USE_OMP)
#pragma omp critical
#endif
{
new_pos = static_cast<INMOST_DATA_ENUM_TYPE>(dense_data.size());
if( !empty_dense_data.empty() )
{
new_pos = empty_dense_data.back();
empty_dense_data.pop_back();
dense_data[new_pos] = dense_sub_type(new_tag.GetRecordSize());
}
else dense_data.push_back(dense_sub_type(new_tag.GetRecordSize()));
}
{
new_pos = static_cast<INMOST_DATA_ENUM_TYPE>(dense_data.size());
if( !empty_dense_data.empty() )
{
new_pos = empty_dense_data.back();
empty_dense_data.pop_back();
dense_data[new_pos] = dense_sub_type(new_tag.GetRecordSize());
}
else dense_data.push_back(dense_sub_type(new_tag.GetRecordSize()));
}
new_tag.SetPosition(new_pos,mask);
INMOST_DATA_ENUM_TYPE new_size = dynamic_cast<Mesh *>(this)->GetArrayCapacity(ElementNum(mask));
if( new_size < 1024 && mask != MESH ) new_size = 1024;
......@@ -363,9 +363,9 @@ namespace INMOST
#if defined(USE_OMP)
#pragma omp critical
#endif
{
sparse_data[j].resize(new_size);
}
{
sparse_data[j].resize(new_size);
}
}
#endif
return new_tag;
......
......@@ -41,7 +41,7 @@
// a very expensive check for debug purposes,
// when you release marker checks all the elements
// that no element is marked by released marker
//#define CHECKS_MARKERS
//#define CHECKS_MARKERS
// use additional sets to store elements for parallel
// exchanges, otherwise it will recompute those elements
......
......@@ -1219,6 +1219,9 @@ namespace INMOST
class Mesh : public TagManager, public Storage //implemented in mesh.cpp
{
public:
#if defined(CHECKS_MARKERS)
bool check_shared_mrk, check_private_mrk;
#endif
enum MeshState {Serial, Parallel};
typedef chunk_array<integer,chunk_bits_empty>
empty_container;
......@@ -1314,7 +1317,7 @@ namespace INMOST
/// @param n Byte position and byte bit mask.
/// @param cleanup Elements on which marker should be removed.
void ReleaseMarker (MarkerType n, ElementType cleanup = NONE);
void ReleasePrivateMarker(MarkerType n);
void ReleasePrivateMarker(MarkerType n, ElementType cleanup = NONE);
/// Set tolerance for coordinates comparison. This tolerance is used in comparators
/// when two meshes are merged during loading, in ResolveShared to check that nodes on different processors match
/// and in UnpackElementsData
......
This diff is collapsed.
......@@ -147,7 +147,7 @@ namespace INMOST
for(typename ElementArray<T>::size_type j = 1; j < data.size(); j++)
{
n1 = data[j]->getNodes();
assert(nodes.back() == n1[0] || nodes.back() == n1[1]);
assert((nodes.back() == n1[0] || nodes.back() == n1[1]));
if( nodes.back() == n1[0] )
nodes.push_back(n1[1]);
else
......@@ -434,10 +434,19 @@ namespace INMOST
//isInputForwardIterators<T,InputIterator>();
if( !head_column.empty() )
{
MarkerType hide_marker = mesh->CreateMarker();
MarkerType hide_marker = mesh->CreatePrivateMarker();
visits.resize(head_column.size());
visits0.resize(head_column.size());
/*
for(typename dynarray<HandleType, 256>::size_type it = 0; it < head_column.size(); ++it)
{
Element::adj_type const & sub = mesh->LowConn(head_column[it]);
for(Element::adj_type::size_type jt = 0; jt < sub.size(); ++jt)
if( mesh->GetPrivateMarker(sub[jt],hide_marker) )
printf("element %s:%d already have marker %d\n",ElementTypeName(GetHandleElementType(sub[jt])),GetHandleID(sub[jt]),hide_marker);
}
*/
for(typename dynarray<HandleType, 256>::size_type it = 0; it < head_column.size(); ++it)
{
visits[it] = it < num_inner ? 2 : 1;
......@@ -445,21 +454,21 @@ namespace INMOST
Element::adj_type const & sub = mesh->LowConn(head_column[it]);
for(Element::adj_type::size_type jt = 0; jt < sub.size(); ++jt)
{
if( !mesh->GetMarker(sub[jt],hide_marker) )
if( !mesh->GetPrivateMarker(sub[jt],hide_marker) )
{
head_row.push_back(sub[jt]);
mesh->SetMarker(sub[jt],hide_marker);
mesh->SetPrivateMarker(sub[jt],hide_marker);
}
}
}
tiny_map<HandleType,int,256> mat_num;
for(dynarray<HandleType,256>::size_type it = 0; it < head_row.size(); ++it)
{
mesh->RemMarker(head_row[it],hide_marker);
mesh->RemPrivateMarker(head_row[it],hide_marker);
mat_num[head_row[it]] = static_cast<int>(it);
}
mesh->ReleaseMarker(hide_marker);
mesh->ReleasePrivateMarker(hide_marker);
matrix.resize(head_row.size()*head_column.size(),0);
......@@ -538,19 +547,19 @@ namespace INMOST
{
std::vector<int> add_remember;
add_remember.reserve(min_loop.size());
MarkerType hide_marker = mesh->CreateMarker();
for(typename ElementArray<T>::size_type k = 0; k < ret.size(); k++) mesh->SetMarker(ret.at(k),hide_marker);
MarkerType hide_marker = mesh->CreatePrivateMarker();
for(typename ElementArray<T>::size_type k = 0; k < ret.size(); k++) mesh->SetPrivateMarker(ret.at(k),hide_marker);
if( print ) std::cout << "return loop [" << ret.size() << "]:";
for(dynarray<HandleType,256>::size_type k = 0; k < head_column.size(); k++)
if( mesh->GetMarker(head_column[k],hide_marker) )
if( mesh->GetPrivateMarker(head_column[k],hide_marker) )
{
visits[k]--;
add_remember.push_back((int)k);
if( print ) std::cout << k << " ";
}
if( print ) std::cout << std::endl;
for(typename ElementArray<T>::size_type k = 0; k < ret.size(); k++) mesh->RemMarker(ret.at(k),hide_marker);
mesh->ReleaseMarker(hide_marker);
for(typename ElementArray<T>::size_type k = 0; k < ret.size(); k++) mesh->RemPrivateMarker(ret.at(k),hide_marker);
mesh->ReleasePrivateMarker(hide_marker);
remember.push_back(std::make_pair(add_remember,min_loop_measure));
return true;
}
......
......@@ -92,8 +92,11 @@ namespace INMOST
return "UNKNOWN";
}
void Mesh::Init(std::string name)
{
void Mesh::Init(std::string name)
{
#if defined(CHECKS_MARKERS)
check_shared_mrk = check_private_mrk = false;
#endif
m_link = this;
integer selfid = 1;
selfid = TieElement(5);
......@@ -147,16 +150,16 @@ namespace INMOST
Mesh::Mesh()
:TagManager(), Storage(NULL,ComposeHandle(MESH,0))
{
std::stringstream tmp;
tmp << "Mesh" << allocated_meshes.size();
name = tmp.str();
Init(name);
std::stringstream tmp;
tmp << "Mesh" << allocated_meshes.size();
name = tmp.str();
Init(name);
}
Mesh::Mesh(std::string name)
Mesh::Mesh(std::string name)
:TagManager(), Storage(NULL,ComposeHandle(MESH,0))
{
Init(name);
Init(name);
}
bool Mesh::GetPrivateMarker(HandleType h, MarkerType n) const
......@@ -284,11 +287,15 @@ namespace INMOST
Mesh::Mesh(const Mesh & other)
:TagManager(other),Storage(NULL,ComposeHandle(MESH,0))
{
{
std::stringstream tmp;
tmp << other.name << "_copy";
name = tmp.str();
}
{
std::stringstream tmp;
tmp << other.name << "_copy";
name = tmp.str();
}
#if defined(CHECKS_MARKERS)
check_shared_mrk = other.check_shared_mrk;
check_private_mrk = other.check_private_mrk;
#endif
m_link = this;
integer selfid = 1;
selfid = TieElement(5);
......@@ -361,11 +368,15 @@ namespace INMOST
Mesh & Mesh::operator =(Mesh const & other)
{
if( this == &other ) return *this; //don't do anything
{
std::stringstream tmp;
tmp << other.name << "_copy";
name = tmp.str();
}
{
std::stringstream tmp;
tmp << other.name << "_copy";
name = tmp.str();
}
#if defined(CHECKS_MARKERS)
check_shared_mrk = other.check_shared_mrk;
check_private_mrk = other.check_private_mrk;
#endif
//first delete everything
//delete parallel vars
#if defined(USE_MPI)
......@@ -1888,30 +1899,50 @@ namespace INMOST
}
#if defined(CHECKS_MARKERS)
#ifndef NDEBUG
for(int etypenum = 0; etypenum < ElementNum(MESH); ++etypenum)
if( check_shared_mrk )
{
integer end = LastLocalIDNum(etypenum);
for(integer id = 0; id < end; ++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");
for(int etypenum = 0; etypenum < ElementNum(MESH); ++etypenum)
{
integer end = LastLocalIDNum(etypenum);
for(integer id = 0; id < end; ++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
#endif
Storage::RemMarker(n);
}
void Mesh::ReleasePrivateMarker(MarkerType n)
void Mesh::ReleasePrivateMarker(MarkerType n, ElementType cleanup)
{
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) )
RemPrivateMarker(ComposeHandle(etype,id),n);
}
}
#if defined(CHECKS_MARKERS)
#ifndef NDEBUG
int thread = GetLocalProcessorRank();
for(int etypenum = 0; etypenum < ElementNum(MESH); ++etypenum)
if( check_private_mrk )
{
integer end = LastLocalIDNum(etypenum);
for(integer id = 0; id < end; ++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");
int thread = GetLocalProcessorRank();
MarkerType pn = n & ~MarkerPrivateBit;
for(int etypenum = 0; etypenum < ElementNum(MESH); ++etypenum)
{
integer end = LastLocalIDNum(etypenum);
for(integer id = 0; id < end; ++id)
if( isValidElementNum(etypenum,id) )
assert((static_cast<const bulk *>(MGetDenseLink(etypenum,id,tag_private_markers[thread]))[pn >> MarkerShift] & static_cast<bulk>(pn & MarkerMask)) == 0 && "marker was not properly cleared from elements");
}
}
#endif
#endif
......
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