mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-24 21:10:33 +05:00
clear solutiondata object on python-exit
This commit is contained in:
parent
a0f70b4d73
commit
33626c6669
@ -11,6 +11,7 @@
|
||||
#include "archive.hpp"
|
||||
#include "flags.hpp"
|
||||
#include "ngcore_api.hpp"
|
||||
#include "profiler.hpp"
|
||||
namespace py = pybind11;
|
||||
|
||||
namespace ngcore
|
||||
@ -297,18 +298,25 @@ namespace ngcore
|
||||
{
|
||||
PyArchive<T_ARCHIVE_OUT> ar;
|
||||
ar & self;
|
||||
static Timer t("ngspickle 2");
|
||||
t.Start();
|
||||
auto output = pybind11::make_tuple(ar.WriteOut());
|
||||
t.Stop();
|
||||
/*
|
||||
GetLogger("Archive")->trace("Pickling output for object of type {} = {}",
|
||||
Demangle(typeid(T).name()),
|
||||
std::string(pybind11::str(output)));
|
||||
*/
|
||||
return output;
|
||||
},
|
||||
[](const pybind11::tuple & state)
|
||||
{
|
||||
T* val = nullptr;
|
||||
/*
|
||||
GetLogger("Archive")->trace("State for unpickling of object of type {} = {}",
|
||||
Demangle(typeid(T).name()),
|
||||
std::string(pybind11::str(state[0])));
|
||||
*/
|
||||
PyArchive<T_ARCHIVE_IN> ar(state[0]);
|
||||
ar & val;
|
||||
return val;
|
||||
|
@ -96,8 +96,8 @@ void ParallelFor( int first, int next, const TFunc & f )
|
||||
|
||||
|
||||
|
||||
typedef void (*TaskManager)(std::function<void(int,int)>);
|
||||
typedef void (*Tracer)(string, bool); // false .. start, true .. stop
|
||||
typedef void (*NgTaskManager)(std::function<void(int,int)>);
|
||||
typedef void (*NgTracer)(string, bool); // false .. start, true .. stop
|
||||
|
||||
inline void DummyTaskManager (std::function<void(int,int)> func)
|
||||
{
|
||||
@ -108,7 +108,7 @@ void ParallelFor( int first, int next, const TFunc & f )
|
||||
inline void DummyTracer (string, bool) { ; }
|
||||
|
||||
template <typename FUNC>
|
||||
inline void ParallelFor (TaskManager tm, size_t n, FUNC func)
|
||||
inline void ParallelFor (NgTaskManager tm, size_t n, FUNC func)
|
||||
{
|
||||
(*tm) ([n,func] (size_t nr, size_t nums)
|
||||
{
|
||||
@ -121,7 +121,7 @@ void ParallelFor( int first, int next, const TFunc & f )
|
||||
}
|
||||
|
||||
template <typename FUNC>
|
||||
inline void ParallelForRange (TaskManager tm, size_t n, FUNC func)
|
||||
inline void ParallelForRange (NgTaskManager tm, size_t n, FUNC func)
|
||||
{
|
||||
(*tm) ([n,func] (size_t nr, size_t nums)
|
||||
{
|
||||
|
@ -1157,7 +1157,7 @@ namespace netgen
|
||||
|
||||
void Ngx_Mesh :: Refine (NG_REFINEMENT_TYPE reftype,
|
||||
void (*task_manager)(function<void(int,int)>),
|
||||
Tracer tracer)
|
||||
NgTracer tracer)
|
||||
{
|
||||
NgLock meshlock (mesh->MajorMutex(), 1);
|
||||
|
||||
|
@ -1681,7 +1681,7 @@ namespace netgen
|
||||
|
||||
int MarkHangingTets (T_MTETS & mtets,
|
||||
const INDEX_2_CLOSED_HASHTABLE<PointIndex> & cutedges,
|
||||
TaskManager tm)
|
||||
NgTaskManager tm)
|
||||
{
|
||||
static int timer = NgProfiler::CreateTimer ("MarkHangingTets");
|
||||
NgProfiler::RegionTimer reg (timer);
|
||||
@ -1759,7 +1759,7 @@ namespace netgen
|
||||
|
||||
bool MarkHangingTris (T_MTRIS & mtris,
|
||||
const INDEX_2_CLOSED_HASHTABLE<PointIndex> & cutedges,
|
||||
TaskManager tm)
|
||||
NgTaskManager tm)
|
||||
{
|
||||
bool hanging = false;
|
||||
// for (int i = 1; i <= mtris.Size(); i++)
|
||||
|
@ -12,8 +12,8 @@ public:
|
||||
int usemarkedelements;
|
||||
bool refine_hp;
|
||||
bool refine_p;
|
||||
TaskManager task_manager = &DummyTaskManager;
|
||||
Tracer tracer = &DummyTracer;
|
||||
NgTaskManager task_manager = &DummyTaskManager;
|
||||
NgTracer tracer = &DummyTracer;
|
||||
DLL_HEADER BisectionOptions ();
|
||||
};
|
||||
|
||||
|
@ -16,7 +16,7 @@ namespace netgen
|
||||
;
|
||||
}
|
||||
|
||||
void AnisotropicClusters :: Update(TaskManager tm, Tracer tracer)
|
||||
void AnisotropicClusters :: Update(NgTaskManager tm, NgTracer tracer)
|
||||
{
|
||||
static int timer = NgProfiler::CreateTimer ("clusters");
|
||||
// static int timer1 = NgProfiler::CreateTimer ("clusters1");
|
||||
|
@ -27,7 +27,7 @@ public:
|
||||
AnisotropicClusters (const Mesh & amesh);
|
||||
~AnisotropicClusters();
|
||||
|
||||
void Update(TaskManager tm = &DummyTaskManager, Tracer trace = &DummyTracer);
|
||||
void Update(NgTaskManager tm = &DummyTaskManager, NgTracer trace = &DummyTracer);
|
||||
|
||||
int GetVertexRepresentant (int vnr) const
|
||||
{ return cluster_reps.Get(vnr); }
|
||||
|
@ -1280,10 +1280,14 @@ namespace netgen
|
||||
|
||||
void Mesh :: DoArchive (Archive & archive)
|
||||
{
|
||||
static Timer t("Mesh::Archive"); RegionTimer r(t);
|
||||
static Timer tvol("Mesh::Archive vol elements");
|
||||
archive & dimension;
|
||||
archive & points;
|
||||
archive & surfelements;
|
||||
tvol.Start();
|
||||
archive & volelements;
|
||||
tvol.Stop();
|
||||
archive & segments;
|
||||
archive & facedecoding;
|
||||
archive & materials & bcnames & cd2names & cd3names;
|
||||
@ -6417,8 +6421,8 @@ namespace netgen
|
||||
return 1;
|
||||
}
|
||||
|
||||
void Mesh :: UpdateTopology (TaskManager tm,
|
||||
Tracer tracer)
|
||||
void Mesh :: UpdateTopology (NgTaskManager tm,
|
||||
NgTracer tracer)
|
||||
{
|
||||
static Timer t("Update Topology"); RegionTimer reg(t);
|
||||
topology.Update(tm, tracer);
|
||||
|
@ -777,8 +777,8 @@ namespace netgen
|
||||
const MeshTopology & GetTopology () const
|
||||
{ return topology; }
|
||||
|
||||
DLL_HEADER void UpdateTopology (TaskManager tm = &DummyTaskManager,
|
||||
Tracer tracer = &DummyTracer);
|
||||
DLL_HEADER void UpdateTopology (NgTaskManager tm = &DummyTaskManager,
|
||||
NgTracer tracer = &DummyTracer);
|
||||
|
||||
class CurvedElements & GetCurvedElements () const
|
||||
{ return *curvedelems; }
|
||||
|
@ -11,6 +11,15 @@
|
||||
// #include <csg.hpp>
|
||||
// #include <geometry2d.hpp>
|
||||
#include <../interface/writeuser.hpp>
|
||||
#include <../include/nginterface.h>
|
||||
|
||||
|
||||
class ClearSolutionClass
|
||||
{
|
||||
public:
|
||||
ClearSolutionClass() { }
|
||||
~ClearSolutionClass() { Ng_ClearSolutionData(); }
|
||||
};
|
||||
|
||||
|
||||
#ifdef NG_MPI4PY
|
||||
@ -1238,6 +1247,10 @@ grow_edges : bool = False
|
||||
}, py::arg("quads")=true, py::arg("nx")=10, py::arg("ny")=10, py::arg("flip_triangles")=false, py::arg("bbbpts")=py::list(), py::arg("bbbnames")=py::list())
|
||||
;
|
||||
;
|
||||
|
||||
py::class_<ClearSolutionClass> (m, "ClearSolutionClass")
|
||||
.def(py::init<>())
|
||||
;
|
||||
}
|
||||
|
||||
PYBIND11_MODULE(libmesh, m) {
|
||||
|
@ -3,7 +3,8 @@
|
||||
|
||||
namespace netgen
|
||||
{
|
||||
|
||||
using ngcore::ParallelForRange;
|
||||
|
||||
|
||||
template <class T>
|
||||
void QuickSortRec (NgFlatArray<T> data,
|
||||
@ -332,10 +333,10 @@ namespace netgen
|
||||
}
|
||||
|
||||
|
||||
void MeshTopology :: Update (TaskManager tm, Tracer tracer)
|
||||
void MeshTopology :: Update (NgTaskManager tm_unused, NgTracer tracer)
|
||||
{
|
||||
static int timer = NgProfiler::CreateTimer ("topology");
|
||||
NgProfiler::RegionTimer reg (timer);
|
||||
static Timer timer("Topology::Update");
|
||||
RegionTimer reg (timer);
|
||||
|
||||
#ifdef PARALLEL
|
||||
// ParallelMeshTopology & paralleltop = mesh.GetParallelTopology();
|
||||
@ -382,10 +383,9 @@ namespace netgen
|
||||
}
|
||||
*/
|
||||
ParallelForRange
|
||||
(tm, ne,
|
||||
[&] (size_t begin, size_t end)
|
||||
(ne, [&] (IntRange r)
|
||||
{
|
||||
for (ElementIndex ei = begin; ei < end; ei++)
|
||||
for (ElementIndex ei : r)
|
||||
{
|
||||
const Element & el = (*mesh)[ei];
|
||||
for (int j = 0; j < el.GetNV(); j++)
|
||||
@ -426,10 +426,10 @@ namespace netgen
|
||||
}
|
||||
*/
|
||||
ParallelForRange
|
||||
(tm, nse,
|
||||
[&] (size_t begin, size_t end)
|
||||
(nse,
|
||||
[&] (IntRange r)
|
||||
{
|
||||
for (SurfaceElementIndex ei = begin; ei < end; ei++)
|
||||
for (SurfaceElementIndex ei : r)
|
||||
{
|
||||
const Element2d & el = (*mesh)[ei];
|
||||
for (int j = 0; j < el.GetNV(); j++)
|
||||
@ -553,9 +553,11 @@ namespace netgen
|
||||
cnt = 0;
|
||||
|
||||
ParallelForRange
|
||||
(tm, mesh->GetNV(), // Points().Size(),
|
||||
[&] (size_t begin, size_t end)
|
||||
(mesh->GetNV(), // Points().Size(),
|
||||
[&] (IntRange r)
|
||||
{
|
||||
auto begin = r.First();
|
||||
auto end = r.Next();
|
||||
INDEX_CLOSED_HASHTABLE<int> v2eht(2*max_edge_on_vertex+10);
|
||||
for (PointIndex v = begin+PointIndex::BASE;
|
||||
v < end+PointIndex::BASE; v++)
|
||||
@ -607,9 +609,11 @@ namespace netgen
|
||||
// for (PointIndex v = PointIndex::BASE; v < nv+PointIndex::BASE; v++)
|
||||
|
||||
ParallelForRange
|
||||
(tm, mesh->GetNV(), // Points().Size(),
|
||||
[&] (size_t begin, size_t end)
|
||||
(mesh->GetNV(), // Points().Size(),
|
||||
[&] (IntRange r)
|
||||
{
|
||||
auto begin = r.First();
|
||||
auto end = r.Next();
|
||||
INDEX_CLOSED_HASHTABLE<int> v2eht(2*max_edge_on_vertex+10);
|
||||
NgArray<int> vertex2;
|
||||
for (PointIndex v = begin+PointIndex::BASE;
|
||||
@ -731,9 +735,11 @@ namespace netgen
|
||||
// for (auto v : mesh.Points().Range())
|
||||
// NgProfiler::StartTimer (timer2b1);
|
||||
ParallelForRange
|
||||
(tm, mesh->GetNV(), // Points().Size(),
|
||||
[&] (size_t begin, size_t end)
|
||||
(mesh->GetNV(), // Points().Size(),
|
||||
[&] (IntRange r)
|
||||
{
|
||||
auto begin = r.First();
|
||||
auto end = r.Next();
|
||||
INDEX_3_CLOSED_HASHTABLE<int> vert2face(2*max_face_on_vertex+10);
|
||||
for (PointIndex v = begin+PointIndex::BASE;
|
||||
v < end+PointIndex::BASE; v++)
|
||||
@ -779,9 +785,11 @@ namespace netgen
|
||||
// for (auto v : mesh.Points().Range())
|
||||
|
||||
ParallelForRange
|
||||
(tm, mesh->GetNV(), // Points().Size(),
|
||||
[&] (size_t begin, size_t end)
|
||||
(mesh->GetNV(), // Points().Size(),
|
||||
[&] (IntRange r)
|
||||
{
|
||||
auto begin = r.First();
|
||||
auto end = r.Next();
|
||||
INDEX_3_CLOSED_HASHTABLE<int> vert2face(2*max_face_on_vertex+10);
|
||||
for (PointIndex v = begin+PointIndex::BASE;
|
||||
v < end+PointIndex::BASE; v++)
|
||||
@ -1164,11 +1172,11 @@ namespace netgen
|
||||
}
|
||||
*/
|
||||
ParallelForRange
|
||||
(tm, ne,
|
||||
[&] (size_t begin, size_t end)
|
||||
(ne,
|
||||
[&] (IntRange r)
|
||||
{
|
||||
NgArray<int> hfaces;
|
||||
for (ElementIndex ei = begin; ei < end; ei++)
|
||||
for (ElementIndex ei : r)
|
||||
{
|
||||
GetElementFaces (ei+1, hfaces);
|
||||
for (auto f : hfaces)
|
||||
|
@ -81,7 +81,7 @@ public:
|
||||
bool HasFaces () const
|
||||
{ return buildfaces; }
|
||||
|
||||
void Update(TaskManager tm = &DummyTaskManager, Tracer tracer = &DummyTracer);
|
||||
void Update(NgTaskManager tm = &DummyTaskManager, NgTracer tracer = &DummyTracer);
|
||||
bool NeedsUpdate() const;
|
||||
|
||||
|
||||
|
@ -22,3 +22,5 @@ def Redraw(*args, **kwargs):
|
||||
cnt += 1
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
|
@ -59,3 +59,6 @@ class _MeshsizeObject:
|
||||
optsteps3d=5)
|
||||
|
||||
meshsize = _MeshsizeObject()
|
||||
|
||||
|
||||
clearsol = ClearSolutionClass()
|
||||
|
Loading…
Reference in New Issue
Block a user