mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-26 05:50:32 +05:00
occ meshing, lock in block-allocator
This commit is contained in:
parent
cb5c6b477c
commit
69429c6e09
@ -35,30 +35,39 @@ namespace netgen
|
|||||||
|
|
||||||
void * BlockAllocator :: Alloc ()
|
void * BlockAllocator :: Alloc ()
|
||||||
{
|
{
|
||||||
// return new char[size];
|
void * p;
|
||||||
if (!freelist)
|
#pragma omp critical (BlockAllocator)
|
||||||
{
|
{
|
||||||
// cout << "freelist = " << freelist << endl;
|
// return new char[size];
|
||||||
// cout << "BlockAlloc: " << size*blocks << endl;
|
if (!freelist)
|
||||||
char * hcp = new char [size * blocks];
|
{
|
||||||
bablocks.Append (hcp);
|
// cout << "freelist = " << freelist << endl;
|
||||||
bablocks.Last() = hcp;
|
// cout << "BlockAlloc: " << size*blocks << endl;
|
||||||
for (unsigned i = 0; i < blocks-1; i++)
|
char * hcp = new char [size * blocks];
|
||||||
*(void**)&(hcp[i * size]) = &(hcp[ (i+1) * size]);
|
bablocks.Append (hcp);
|
||||||
*(void**)&(hcp[(blocks-1)*size]) = NULL;
|
bablocks.Last() = hcp;
|
||||||
freelist = hcp;
|
for (unsigned i = 0; i < blocks-1; i++)
|
||||||
}
|
*(void**)&(hcp[i * size]) = &(hcp[ (i+1) * size]);
|
||||||
|
*(void**)&(hcp[(blocks-1)*size]) = NULL;
|
||||||
void * p = freelist;
|
freelist = hcp;
|
||||||
freelist = *(void**)freelist;
|
}
|
||||||
|
|
||||||
|
p = freelist;
|
||||||
|
freelist = *(void**)freelist;
|
||||||
|
}
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
void BlockAllocator :: Free (void * p)
|
void BlockAllocator :: Free (void * p)
|
||||||
{
|
{
|
||||||
*(void**)p = freelist;
|
#pragma omp critical (BlockAllocator)
|
||||||
freelist = p;
|
{
|
||||||
|
if (bablocks.Size())
|
||||||
|
{
|
||||||
|
*(void**)p = freelist;
|
||||||
|
freelist = p;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
@ -46,13 +46,15 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
void Free (void * p)
|
void Free (void * p);
|
||||||
|
/*
|
||||||
{
|
{
|
||||||
if (!bablocks.Size()) return;
|
if (!bablocks.Size()) return;
|
||||||
*(void**)p = freelist;
|
*(void**)p = freelist;
|
||||||
freelist = p;
|
freelist = p;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// void Alloc2 ();
|
// void Alloc2 ();
|
||||||
|
@ -101,7 +101,6 @@ namespace netgen
|
|||||||
{
|
{
|
||||||
NgLock lock(mutex);
|
NgLock lock(mutex);
|
||||||
lock.Lock();
|
lock.Lock();
|
||||||
|
|
||||||
points.SetSize(0);
|
points.SetSize(0);
|
||||||
segments.SetSize(0);
|
segments.SetSize(0);
|
||||||
surfelements.SetSize(0);
|
surfelements.SetSize(0);
|
||||||
|
@ -69,7 +69,7 @@ DLL_HEADER void ExportNetgenMeshing()
|
|||||||
return bp::tuple(l);
|
return bp::tuple(l);
|
||||||
}))
|
}))
|
||||||
;
|
;
|
||||||
|
|
||||||
bp::class_<Element>("Element3D")
|
bp::class_<Element>("Element3D")
|
||||||
.add_property("index", &Element::GetIndex, &Element::SetIndex)
|
.add_property("index", &Element::GetIndex, &Element::SetIndex)
|
||||||
.add_property("vertices",
|
.add_property("vertices",
|
||||||
@ -82,17 +82,17 @@ DLL_HEADER void ExportNetgenMeshing()
|
|||||||
}))
|
}))
|
||||||
;
|
;
|
||||||
|
|
||||||
bp::class_<Element2d>("Element2D")
|
bp::class_<Element2d>("Element2D")
|
||||||
.add_property("index", &Element2d::GetIndex, &Element2d::SetIndex)
|
.add_property("index", &Element2d::GetIndex, &Element2d::SetIndex)
|
||||||
.add_property("vertices",
|
.add_property("vertices",
|
||||||
FunctionPointer([](const Element2d & self) -> bp::list
|
FunctionPointer([](const Element2d & self) -> bp::list
|
||||||
{
|
{
|
||||||
bp::list li;
|
bp::list li;
|
||||||
for (int i = 0; i < self.GetNV(); i++)
|
for (int i = 0; i < self.GetNV(); i++)
|
||||||
li.append(self[i]);
|
li.append(self[i]);
|
||||||
return li;
|
return li;
|
||||||
}))
|
}))
|
||||||
;
|
;
|
||||||
ExportArray<Element>();
|
ExportArray<Element>();
|
||||||
ExportArray<Element2d>();
|
ExportArray<Element2d>();
|
||||||
ExportArray<MeshPoint,PointIndex::BASE,PointIndex>();
|
ExportArray<MeshPoint,PointIndex::BASE,PointIndex>();
|
||||||
|
@ -1281,9 +1281,9 @@ namespace netgen
|
|||||||
if (perfstepsstart <= MESHCONST_ANALYSE)
|
if (perfstepsstart <= MESHCONST_ANALYSE)
|
||||||
{
|
{
|
||||||
// delete mesh;
|
// delete mesh;
|
||||||
mesh = make_shared<Mesh>();
|
// mesh = make_shared<Mesh>();
|
||||||
mesh->geomtype = Mesh::GEOM_OCC;
|
mesh->geomtype = Mesh::GEOM_OCC;
|
||||||
|
|
||||||
OCCSetLocalMeshSize(geom,*mesh);
|
OCCSetLocalMeshSize(geom,*mesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user