occ meshing, lock in block-allocator

This commit is contained in:
Joachim Schoeberl 2015-01-20 17:41:16 +00:00
parent cb5c6b477c
commit 69429c6e09
5 changed files with 47 additions and 37 deletions

View File

@ -35,30 +35,39 @@ namespace netgen
void * BlockAllocator :: Alloc ()
{
// return new char[size];
if (!freelist)
{
// cout << "freelist = " << freelist << endl;
// cout << "BlockAlloc: " << size*blocks << endl;
char * hcp = new char [size * blocks];
bablocks.Append (hcp);
bablocks.Last() = hcp;
for (unsigned i = 0; i < blocks-1; i++)
*(void**)&(hcp[i * size]) = &(hcp[ (i+1) * size]);
*(void**)&(hcp[(blocks-1)*size]) = NULL;
freelist = hcp;
}
void * p = freelist;
freelist = *(void**)freelist;
void * p;
#pragma omp critical (BlockAllocator)
{
// return new char[size];
if (!freelist)
{
// cout << "freelist = " << freelist << endl;
// cout << "BlockAlloc: " << size*blocks << endl;
char * hcp = new char [size * blocks];
bablocks.Append (hcp);
bablocks.Last() = hcp;
for (unsigned i = 0; i < blocks-1; i++)
*(void**)&(hcp[i * size]) = &(hcp[ (i+1) * size]);
*(void**)&(hcp[(blocks-1)*size]) = NULL;
freelist = hcp;
}
p = freelist;
freelist = *(void**)freelist;
}
return p;
}
/*
void BlockAllocator :: Free (void * p)
{
*(void**)p = freelist;
freelist = p;
#pragma omp critical (BlockAllocator)
{
if (bablocks.Size())
{
*(void**)p = freelist;
freelist = p;
}
}
}
*/
}

View File

@ -46,13 +46,15 @@ public:
///
void Free (void * p)
void Free (void * p);
/*
{
if (!bablocks.Size()) return;
*(void**)p = freelist;
freelist = p;
}
*/
private:
// void Alloc2 ();

View File

@ -101,7 +101,6 @@ namespace netgen
{
NgLock lock(mutex);
lock.Lock();
points.SetSize(0);
segments.SetSize(0);
surfelements.SetSize(0);

View File

@ -69,7 +69,7 @@ DLL_HEADER void ExportNetgenMeshing()
return bp::tuple(l);
}))
;
bp::class_<Element>("Element3D")
.add_property("index", &Element::GetIndex, &Element::SetIndex)
.add_property("vertices",
@ -82,17 +82,17 @@ DLL_HEADER void ExportNetgenMeshing()
}))
;
bp::class_<Element2d>("Element2D")
.add_property("index", &Element2d::GetIndex, &Element2d::SetIndex)
.add_property("vertices",
FunctionPointer([](const Element2d & self) -> bp::list
{
bp::list li;
for (int i = 0; i < self.GetNV(); i++)
li.append(self[i]);
return li;
}))
;
bp::class_<Element2d>("Element2D")
.add_property("index", &Element2d::GetIndex, &Element2d::SetIndex)
.add_property("vertices",
FunctionPointer([](const Element2d & self) -> bp::list
{
bp::list li;
for (int i = 0; i < self.GetNV(); i++)
li.append(self[i]);
return li;
}))
;
ExportArray<Element>();
ExportArray<Element2d>();
ExportArray<MeshPoint,PointIndex::BASE,PointIndex>();

View File

@ -1281,9 +1281,9 @@ namespace netgen
if (perfstepsstart <= MESHCONST_ANALYSE)
{
// delete mesh;
mesh = make_shared<Mesh>();
// mesh = make_shared<Mesh>();
mesh->geomtype = Mesh::GEOM_OCC;
OCCSetLocalMeshSize(geom,*mesh);
}