mirror of
https://github.com/NGSolve/netgen.git
synced 2025-01-30 23:00:35 +05:00
Merge remote-tracking branch 'origin/master' into boundarylayer_fixes_cleanup
This commit is contained in:
commit
565bc2dc6a
@ -2,7 +2,6 @@ target_sources(nglib PRIVATE
|
|||||||
gzstream.cpp
|
gzstream.cpp
|
||||||
hashtabl.cpp
|
hashtabl.cpp
|
||||||
mystring.cpp
|
mystring.cpp
|
||||||
ngarray.cpp
|
|
||||||
ngbitarray.cpp
|
ngbitarray.cpp
|
||||||
optmem.cpp
|
optmem.cpp
|
||||||
parthreads.cpp
|
parthreads.cpp
|
||||||
|
@ -1,75 +0,0 @@
|
|||||||
#ifndef FILE_NGSTD_NgArrayCPP
|
|
||||||
#define FILE_NGSTD_NgArrayCPP
|
|
||||||
// necessary for SGI ????
|
|
||||||
|
|
||||||
/**************************************************************************/
|
|
||||||
/* File: array.cpp */
|
|
||||||
/* Author: Joachim Schoeberl */
|
|
||||||
/* Date: 01. Jun. 95 */
|
|
||||||
/**************************************************************************/
|
|
||||||
|
|
||||||
/*
|
|
||||||
Abstract data type NgArray
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <mystdlib.h>
|
|
||||||
#include <myadt.hpp>
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
|
|
||||||
namespace netgen
|
|
||||||
{
|
|
||||||
//using namespace netgen;
|
|
||||||
|
|
||||||
#ifdef NONE
|
|
||||||
void BASE_Array :: ReSize (int minsize, int elementsize)
|
|
||||||
{
|
|
||||||
cout << "resize, minsize = " << minsize << endl;
|
|
||||||
|
|
||||||
if (inc == -1)
|
|
||||||
throw Exception ("Try to resize fixed size array");
|
|
||||||
|
|
||||||
|
|
||||||
void * p;
|
|
||||||
int nsize = (inc) ? allocsize + inc : 2 * allocsize;
|
|
||||||
if (nsize < minsize) nsize = minsize;
|
|
||||||
|
|
||||||
if (data)
|
|
||||||
{
|
|
||||||
p = new char [nsize * elementsize];
|
|
||||||
|
|
||||||
int mins = (nsize < actsize) ? nsize : actsize;
|
|
||||||
memcpy (p, data, mins * elementsize);
|
|
||||||
|
|
||||||
delete [] static_cast<char*> (data);
|
|
||||||
data = p;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
data = new char[nsize * elementsize];
|
|
||||||
}
|
|
||||||
|
|
||||||
allocsize = nsize;
|
|
||||||
cout << "resize done" << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void BASE_Array :: RangeCheck (int i) const
|
|
||||||
{
|
|
||||||
if (i < 0 || i >= actsize)
|
|
||||||
throw ArrayRangeException ();
|
|
||||||
}
|
|
||||||
|
|
||||||
void BASE_Array :: CheckNonEmpty () const
|
|
||||||
{
|
|
||||||
if (!actsize)
|
|
||||||
{
|
|
||||||
throw Exception ("NgArray should not be empty");
|
|
||||||
// cerr << "NgArray shouldn't be empty";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#endif // FILE_NGSTD_NgArrayCPP
|
|
||||||
|
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace netgen
|
namespace netgen
|
||||||
{
|
{
|
||||||
|
using namespace ngcore;
|
||||||
|
|
||||||
// template <class T, int B1, int B2> class IndirectArray;
|
// template <class T, int B1, int B2> class IndirectArray;
|
||||||
template <class TA1, class TA2> class NgIndirectArray;
|
template <class TA1, class TA2> class NgIndirectArray;
|
||||||
@ -111,11 +112,7 @@ namespace netgen
|
|||||||
/// Access array. BASE-based
|
/// Access array. BASE-based
|
||||||
T & operator[] (TIND i) const
|
T & operator[] (TIND i) const
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
NETGEN_CHECK_RANGE(i,BASE,size+BASE);
|
||||||
if (i-BASE < 0 || i-BASE >= size)
|
|
||||||
cout << "array<" << typeid(T).name() << "> out of range, i = " << i << ", s = " << size << endl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return data[i-BASE];
|
return data[i-BASE];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,13 +127,7 @@ namespace netgen
|
|||||||
/// Access array, one-based (old fashioned)
|
/// Access array, one-based (old fashioned)
|
||||||
T & Elem (int i)
|
T & Elem (int i)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
NETGEN_CHECK_RANGE(i,1,size+1);
|
||||||
if (i < 1 || i > size)
|
|
||||||
cout << "NgArray<" << typeid(T).name()
|
|
||||||
<< ">::Elem out of range, i = " << i
|
|
||||||
<< ", s = " << size << endl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return ((T*)data)[i-1];
|
return ((T*)data)[i-1];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,30 +135,21 @@ namespace netgen
|
|||||||
// [[deprecated("Use operator[] instead")]]
|
// [[deprecated("Use operator[] instead")]]
|
||||||
const T & Get (int i) const
|
const T & Get (int i) const
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
NETGEN_CHECK_RANGE(i,1,size+1);
|
||||||
if (i < 1 || i > size)
|
|
||||||
cout << "NgArray<" << typeid(T).name() << ">::Get out of range, i = " << i
|
|
||||||
<< ", s = " << size << endl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return ((const T*)data)[i-1];
|
return ((const T*)data)[i-1];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Access array, one-based (old fashioned)
|
/// Access array, one-based (old fashioned)
|
||||||
void Set (int i, const T & el)
|
void Set (int i, const T & el)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
NETGEN_CHECK_RANGE(i,1,size+1);
|
||||||
if (i < 1 || i > size)
|
|
||||||
cout << "NgArray<" << typeid(T).name() << ">::Set out of range, i = " << i
|
|
||||||
<< ", s = " << size << endl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
((T*)data)[i-1] = el;
|
((T*)data)[i-1] = el;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// access first element
|
/// access first element
|
||||||
T & First () const
|
T & First () const
|
||||||
{
|
{
|
||||||
|
NETGEN_CHECK_RANGE(0,0,size);
|
||||||
return data[0];
|
return data[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,6 +157,7 @@ namespace netgen
|
|||||||
/// access last element. check by macro CHECK_RANGE
|
/// access last element. check by macro CHECK_RANGE
|
||||||
T & Last () const
|
T & Last () const
|
||||||
{
|
{
|
||||||
|
NETGEN_CHECK_RANGE(size-1,0,size);
|
||||||
return data[size-1];
|
return data[size-1];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -345,10 +328,7 @@ namespace netgen
|
|||||||
/// Delete element i (0-based). Move last element to position i.
|
/// Delete element i (0-based). Move last element to position i.
|
||||||
void Delete (TIND i)
|
void Delete (TIND i)
|
||||||
{
|
{
|
||||||
#ifdef CHECK_Array_RANGE
|
NETGEN_CHECK_RANGE(i,0,size);
|
||||||
RangeCheck (i+1);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
data[i] = std::move(data[size-1]);
|
data[i] = std::move(data[size-1]);
|
||||||
size--;
|
size--;
|
||||||
// DeleteElement (i+1);
|
// DeleteElement (i+1);
|
||||||
@ -358,10 +338,7 @@ namespace netgen
|
|||||||
/// Delete element i (1-based). Move last element to position i.
|
/// Delete element i (1-based). Move last element to position i.
|
||||||
void DeleteElement (TIND i)
|
void DeleteElement (TIND i)
|
||||||
{
|
{
|
||||||
#ifdef CHECK_Array_RANGE
|
NETGEN_CHECK_RANGE(i,1,size+1);
|
||||||
RangeCheck (i);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
data[i-1] = std::move(data[size-1]);
|
data[i-1] = std::move(data[size-1]);
|
||||||
size--;
|
size--;
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@ public:
|
|||||||
|
|
||||||
/// Creates fixed maximal element size table
|
/// Creates fixed maximal element size table
|
||||||
inline TABLE (const NgFlatArray<int,BASE> & entrysizes)
|
inline TABLE (const NgFlatArray<int,BASE> & entrysizes)
|
||||||
: BASE_TABLE (NgFlatArray<int> (entrysizes.Size(), const_cast<int*>(&entrysizes[BASE])),
|
: BASE_TABLE (NgFlatArray<int> (entrysizes.Size(), entrysizes.Size() ? const_cast<int*>(&entrysizes[BASE]) : nullptr),
|
||||||
sizeof(T))
|
sizeof(T))
|
||||||
{ ; }
|
{ ; }
|
||||||
|
|
||||||
|
@ -1245,8 +1245,7 @@ namespace netgen
|
|||||||
|
|
||||||
void NetgenGeometry :: FinalizeMesh(Mesh& mesh) const
|
void NetgenGeometry :: FinalizeMesh(Mesh& mesh) const
|
||||||
{
|
{
|
||||||
if(solids.Size())
|
for (int i = 0; i < std::min(solids.Size(), (size_t)mesh.GetNDomains()); i++)
|
||||||
for (int i = 0; i < mesh.GetNDomains(); i++)
|
|
||||||
if (auto name = solids[i]->properties.name)
|
if (auto name = solids[i]->properties.name)
|
||||||
mesh.SetMaterial (i+1, *name);
|
mesh.SetMaterial (i+1, *name);
|
||||||
|
|
||||||
|
@ -1783,6 +1783,18 @@ project_boundaries : Optional[str] = None
|
|||||||
layer-ending should be projected to that boundary.
|
layer-ending should be projected to that boundary.
|
||||||
|
|
||||||
)delimiter")
|
)delimiter")
|
||||||
|
.def(py::init([]( const py::dict & d ) {
|
||||||
|
try {
|
||||||
|
// Call other constructor with named arguments by unpacking the dictionary
|
||||||
|
py::object cls = py::type::of<BoundaryLayerParameters>();
|
||||||
|
return cls(**d).cast<BoundaryLayerParameters>();
|
||||||
|
}
|
||||||
|
catch (py::error_already_set & e) {
|
||||||
|
cerr << "Error creating BoundaryLayerParameters from dict:" << endl;
|
||||||
|
cerr << e.what() << endl;
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}))
|
||||||
.def_readwrite("boundary", &BoundaryLayerParameters::boundary)
|
.def_readwrite("boundary", &BoundaryLayerParameters::boundary)
|
||||||
.def_readwrite("thickness", &BoundaryLayerParameters::thickness)
|
.def_readwrite("thickness", &BoundaryLayerParameters::thickness)
|
||||||
.def_readwrite("new_material", &BoundaryLayerParameters::new_material)
|
.def_readwrite("new_material", &BoundaryLayerParameters::new_material)
|
||||||
@ -1795,6 +1807,7 @@ project_boundaries : Optional[str] = None
|
|||||||
.def_readwrite("keep_surfaceindex", &BoundaryLayerParameters::keep_surfaceindex)
|
.def_readwrite("keep_surfaceindex", &BoundaryLayerParameters::keep_surfaceindex)
|
||||||
.def_readwrite("limit_safety", &BoundaryLayerParameters::limit_safety)
|
.def_readwrite("limit_safety", &BoundaryLayerParameters::limit_safety)
|
||||||
;
|
;
|
||||||
|
py::implicitly_convertible<py::dict, BoundaryLayerParameters>();
|
||||||
|
|
||||||
#ifdef NG_CGNS
|
#ifdef NG_CGNS
|
||||||
m.def("ReadCGNSFile", &ReadCGNSFile, py::arg("filename"), py::arg("base")=1, "Read mesh and solution vectors from CGNS file");
|
m.def("ReadCGNSFile", &ReadCGNSFile, py::arg("filename"), py::arg("base")=1, "Read mesh and solution vectors from CGNS file");
|
||||||
|
@ -335,8 +335,8 @@ namespace netgen
|
|||||||
{
|
{
|
||||||
static Timer tim("PointFunction - build elementsonpoint table"); RegionTimer reg(tim);
|
static Timer tim("PointFunction - build elementsonpoint table"); RegionTimer reg(tim);
|
||||||
|
|
||||||
Array<bool, PointIndex> bad_point(points.Size());
|
Array<bool, PointIndex> non_tet_points(points.Size());
|
||||||
bad_point = false;
|
non_tet_points = false;
|
||||||
// Don't optimize if point is adjacent to a non-tet element
|
// Don't optimize if point is adjacent to a non-tet element
|
||||||
ParallelForRange(elements.Range(), [&] (auto myrange)
|
ParallelForRange(elements.Range(), [&] (auto myrange)
|
||||||
{
|
{
|
||||||
@ -345,7 +345,7 @@ namespace netgen
|
|||||||
const auto & el = elements[ei];
|
const auto & el = elements[ei];
|
||||||
if(el.NP()!=4)
|
if(el.NP()!=4)
|
||||||
for(auto pi : el.PNums())
|
for(auto pi : el.PNums())
|
||||||
bad_point[pi] = true;
|
non_tet_points[pi] = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -358,7 +358,7 @@ namespace netgen
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
for (PointIndex pi : el.PNums())
|
for (PointIndex pi : el.PNums())
|
||||||
if(!bad_point[pi])
|
if(!non_tet_points[pi])
|
||||||
table.Add (pi, ei);
|
table.Add (pi, ei);
|
||||||
}, points.Size());
|
}, points.Size());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user