tuning mesh(un)pickling

This commit is contained in:
Joachim Schoeberl 2021-06-26 12:14:17 +02:00
parent e84d4e90c8
commit 54db7941d0
2 changed files with 21 additions and 4 deletions

View File

@ -207,7 +207,7 @@ namespace ngcore
Do(&v[0], size); Do(&v[0], size);
return (*this); return (*this);
} }
// archive implementation for enums // archive implementation for enums
template<typename T> template<typename T>
auto operator & (T& val) -> std::enable_if_t<std::is_enum<T>::value, Archive&> auto operator & (T& val) -> std::enable_if_t<std::is_enum<T>::value, Archive&>
@ -809,6 +809,8 @@ namespace ngcore
return *this; return *this;
} }
Archive & Do (std::byte * d, size_t n) override
{ stream->read(reinterpret_cast<char*>(d), n*sizeof(std::byte)); return *this; } // NOLINT
Archive & Do (double * d, size_t n) override Archive & Do (double * d, size_t n) override
{ stream->read(reinterpret_cast<char*>(d), n*sizeof(double)); return *this; } // NOLINT { stream->read(reinterpret_cast<char*>(d), n*sizeof(double)); return *this; } // NOLINT
Archive & Do (int * i, size_t n) override Archive & Do (int * i, size_t n) override

View File

@ -840,6 +840,7 @@ namespace netgen
void DoArchive (Archive & ar) void DoArchive (Archive & ar)
{ {
/*
short _np, _typ; short _np, _typ;
bool _curved; bool _curved;
if (ar.Output()) if (ar.Output())
@ -847,10 +848,24 @@ namespace netgen
ar & _np & _typ & index & _curved; ar & _np & _typ & index & _curved;
if (ar.Input()) if (ar.Input())
{ np = _np; typ = ELEMENT_TYPE(_typ); is_curved = _curved; } { np = _np; typ = ELEMENT_TYPE(_typ); is_curved = _curved; }
/*
for (size_t i = 0; i < np; i++)
ar & pnum[i];
*/ */
if (ar.Output())
{
short _np, _typ;
bool _curved;
_np = np; _typ = typ; _curved = is_curved;
ar & _np & _typ & index & _curved;
}
else
{
alignas (4) std::byte tmp[9];
ar.Do (&tmp[0], 9);
np = *(short*)(void*)&tmp[0];
typ = ELEMENT_TYPE(*(short*)(void*)&tmp[2]);
index = *(int*)(void*)&tmp[4];
is_curved = *(bool*)(void*)&tmp[8];
}
static_assert(sizeof(int) == sizeof (PointIndex)); static_assert(sizeof(int) == sizeof (PointIndex));
ar.Do( (int*)&pnum[0], np); ar.Do( (int*)&pnum[0], np);
} }