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