Merge remote-tracking branch 'origin/master' into boundarylayer_fixes

This commit is contained in:
Matthias Hochsteger 2024-02-19 09:23:33 +01:00
commit 86d47b5614
32 changed files with 258 additions and 182 deletions

View File

@ -41,39 +41,39 @@ namespace ngcore
/// N integers /// N integers
template <int N, typename T = int> template <int N, typename T = int>
class INT class IVec
{ {
/// data /// data
T i[(N>0)?N:1]; T i[(N>0)?N:1];
public: public:
/// ///
NETGEN_INLINE INT () { } NETGEN_INLINE IVec () { }
/// init all /// init all
NETGEN_INLINE INT (T ai1) NETGEN_INLINE IVec (T ai1)
{ {
for (int j = 0; j < N; j++) { i[j] = ai1; } for (int j = 0; j < N; j++) { i[j] = ai1; }
} }
/// init i[0], i[1] /// init i[0], i[1]
constexpr NETGEN_INLINE INT (T ai1, T ai2) constexpr NETGEN_INLINE IVec (T ai1, T ai2)
: i{ai1, ai2} { ; } : i{ai1, ai2} { ; }
/// init i[0], i[1], i[2] /// init i[0], i[1], i[2]
constexpr NETGEN_INLINE INT (T ai1, T ai2, T ai3) constexpr NETGEN_INLINE IVec (T ai1, T ai2, T ai3)
: i{ai1, ai2, ai3} { ; } : i{ai1, ai2, ai3} { ; }
/// init i[0], i[1], i[2] /// init i[0], i[1], i[2]
constexpr NETGEN_INLINE INT (T ai1, T ai2, T ai3, T ai4) constexpr NETGEN_INLINE IVec (T ai1, T ai2, T ai3, T ai4)
: i{ai1, ai2, ai3, ai4} { ; } : i{ai1, ai2, ai3, ai4} { ; }
/// init i[0], i[1], i[2] /// init i[0], i[1], i[2]
constexpr NETGEN_INLINE INT (T ai1, T ai2, T ai3, T ai4, T ai5) constexpr NETGEN_INLINE IVec (T ai1, T ai2, T ai3, T ai4, T ai5)
: i{ai1, ai2, ai3, ai4, ai5} { ; } : i{ai1, ai2, ai3, ai4, ai5} { ; }
/// init i[0], i[1], i[2] /// init i[0], i[1], i[2]
NETGEN_INLINE INT (T ai1, T ai2, T ai3, T ai4, T ai5, T ai6, T ai7, T ai8, T ai9) NETGEN_INLINE IVec (T ai1, T ai2, T ai3, T ai4, T ai5, T ai6, T ai7, T ai8, T ai9)
: i{ai1, ai2, ai3, ai4, ai5, ai6, ai7, ai8, ai9 } { ; } : i{ai1, ai2, ai3, ai4, ai5, ai6, ai7, ai8, ai9 } { ; }
template <typename ARCHIVE> template <typename ARCHIVE>
@ -83,7 +83,7 @@ namespace ngcore
} }
template <int N2, typename T2> template <int N2, typename T2>
NETGEN_INLINE INT (const INT<N2,T2> & in2) NETGEN_INLINE IVec (const IVec<N2,T2> & in2)
{ {
if (N2 <= N) if (N2 <= N)
{ {
@ -100,7 +100,7 @@ namespace ngcore
} }
template <typename T2> template <typename T2>
NETGEN_INLINE INT (const BaseArrayObject<T2> & ao) NETGEN_INLINE IVec (const BaseArrayObject<T2> & ao)
{ {
for (int j = 0; j < N; j++) for (int j = 0; j < N; j++)
i[j] = ao.Spec()[j]; i[j] = ao.Spec()[j];
@ -108,7 +108,7 @@ namespace ngcore
NETGEN_INLINE size_t Size() const { return N; } NETGEN_INLINE size_t Size() const { return N; }
/// all ints equal ? /// all ints equal ?
NETGEN_INLINE bool operator== (const INT & in2) const NETGEN_INLINE bool operator== (const IVec & in2) const
{ {
for (int j = 0; j < N; j++) for (int j = 0; j < N; j++)
if (i[j] != in2.i[j]) return 0; if (i[j] != in2.i[j]) return 0;
@ -116,7 +116,7 @@ namespace ngcore
} }
/// any ints unequal ? /// any ints unequal ?
NETGEN_INLINE bool operator!= (const INT & in2) const NETGEN_INLINE bool operator!= (const IVec & in2) const
{ {
for (int j = 0; j < N; j++) for (int j = 0; j < N; j++)
if (i[j] != in2.i[j]) return 1; if (i[j] != in2.i[j]) return 1;
@ -124,7 +124,7 @@ namespace ngcore
} }
/// sort integers /// sort integers
NETGEN_INLINE INT & Sort () & NETGEN_INLINE IVec & Sort () &
{ {
for (int k = 0; k < N; k++) for (int k = 0; k < N; k++)
for (int l = k+1; l < N; l++) for (int l = k+1; l < N; l++)
@ -133,7 +133,7 @@ namespace ngcore
return *this; return *this;
} }
NETGEN_INLINE INT Sort () && NETGEN_INLINE IVec Sort () &&
{ {
for (int k = 0; k < N; k++) for (int k = 0; k < N; k++)
for (int l = k+1; l < N; l++) for (int l = k+1; l < N; l++)
@ -155,7 +155,7 @@ namespace ngcore
operator FlatArray<T> () { return FlatArray<T> (N, &i[0]); } operator FlatArray<T> () { return FlatArray<T> (N, &i[0]); }
NETGEN_INLINE INT<N,T> & operator= (T value) NETGEN_INLINE IVec<N,T> & operator= (T value)
{ {
for (int j = 0; j < N; j++) for (int j = 0; j < N; j++)
i[j] = value; i[j] = value;
@ -163,7 +163,7 @@ namespace ngcore
} }
template <typename T2> template <typename T2>
NETGEN_INLINE INT<N,T> & operator= (INT<N,T2> v2) NETGEN_INLINE IVec<N,T> & operator= (IVec<N,T2> v2)
{ {
for (int j = 0; j < N; j++) for (int j = 0; j < N; j++)
i[j] = v2[j]; i[j] = v2[j];
@ -186,14 +186,14 @@ namespace ngcore
/// sort 2 integers /// sort 2 integers
template <> template <>
NETGEN_INLINE INT<2> & INT<2>::Sort () & NETGEN_INLINE IVec<2> & IVec<2>::Sort () &
{ {
if (i[0] > i[1]) Swap (i[0], i[1]); if (i[0] > i[1]) Swap (i[0], i[1]);
return *this; return *this;
} }
template <> template <>
NETGEN_INLINE INT<2> INT<2>::Sort () && NETGEN_INLINE IVec<2> IVec<2>::Sort () &&
{ {
if (i[0] > i[1]) Swap (i[0], i[1]); if (i[0] > i[1]) Swap (i[0], i[1]);
return *this; return *this;
@ -201,7 +201,7 @@ namespace ngcore
/// sort 3 integers /// sort 3 integers
template <> template <>
NETGEN_INLINE INT<3> INT<3>::Sort () && NETGEN_INLINE IVec<3> IVec<3>::Sort () &&
{ {
if (i[0] > i[1]) Swap (i[0], i[1]); if (i[0] > i[1]) Swap (i[0], i[1]);
if (i[1] > i[2]) Swap (i[1], i[2]); if (i[1] > i[2]) Swap (i[1], i[2]);
@ -211,7 +211,7 @@ namespace ngcore
/// Print integers /// Print integers
template <int N, typename T> template <int N, typename T>
inline ostream & operator<<(ostream & s, const INT<N,T> & i2) inline ostream & operator<<(ostream & s, const IVec<N,T> & i2)
{ {
for (int j = 0; j < N; j++) for (int j = 0; j < N; j++)
s << (int) i2[j] << " "; s << (int) i2[j] << " ";
@ -219,15 +219,15 @@ namespace ngcore
} }
template <int N, typename T> template <int N, typename T>
auto begin(const INT<N,T> & ind) auto begin(const IVec<N,T> & ind)
{ {
return AOWrapperIterator<INT<N,T>> (ind, 0); return AOWrapperIterator<IVec<N,T>> (ind, 0);
} }
template <int N, typename T> template <int N, typename T>
auto end(const INT<N,T> & ind) auto end(const IVec<N,T> & ind)
{ {
return AOWrapperIterator<INT<N,T>> (ind, N); return AOWrapperIterator<IVec<N,T>> (ind, N);
} }
@ -236,9 +236,9 @@ namespace ngcore
template <int N, typename TI> template <int N, typename TI>
NETGEN_INLINE size_t HashValue (const INT<N,TI> & ind, size_t size) NETGEN_INLINE size_t HashValue (const IVec<N,TI> & ind, size_t size)
{ {
INT<N,size_t> lind = ind; IVec<N,size_t> lind = ind;
size_t sum = 0; size_t sum = 0;
for (int i = 0; i < N; i++) for (int i = 0; i < N; i++)
sum += lind[i]; sum += lind[i];
@ -247,24 +247,24 @@ namespace ngcore
/// hash value of 1 int /// hash value of 1 int
template <typename TI> template <typename TI>
NETGEN_INLINE size_t HashValue (const INT<1,TI> & ind, size_t size) NETGEN_INLINE size_t HashValue (const IVec<1,TI> & ind, size_t size)
{ {
return ind[0] % size; return ind[0] % size;
} }
/// hash value of 2 int /// hash value of 2 int
template <typename TI> template <typename TI>
NETGEN_INLINE size_t HashValue (const INT<2,TI> & ind, size_t size) NETGEN_INLINE size_t HashValue (const IVec<2,TI> & ind, size_t size)
{ {
INT<2,size_t> lind = ind; IVec<2,size_t> lind = ind;
return (113*lind[0]+lind[1]) % size; return (113*lind[0]+lind[1]) % size;
} }
/// hash value of 3 int /// hash value of 3 int
template <typename TI> template <typename TI>
NETGEN_INLINE size_t HashValue (const INT<3,TI> & ind, size_t size) NETGEN_INLINE size_t HashValue (const IVec<3,TI> & ind, size_t size)
{ {
INT<3,size_t> lind = ind; IVec<3,size_t> lind = ind;
return (113*lind[0]+59*lind[1]+lind[2]) % size; return (113*lind[0]+59*lind[1]+lind[2]) % size;
} }
@ -284,9 +284,9 @@ namespace ngcore
template <int N, typename TI> template <int N, typename TI>
NETGEN_INLINE size_t HashValue2 (const INT<N,TI> & ind, size_t mask) NETGEN_INLINE size_t HashValue2 (const IVec<N,TI> & ind, size_t mask)
{ {
INT<N,size_t> lind = ind; IVec<N,size_t> lind = ind;
size_t sum = 0; size_t sum = 0;
for (int i = 0; i < N; i++) for (int i = 0; i < N; i++)
sum += lind[i]; sum += lind[i];
@ -295,24 +295,24 @@ namespace ngcore
/// hash value of 1 int /// hash value of 1 int
template <typename TI> template <typename TI>
NETGEN_INLINE size_t HashValue2 (const INT<1,TI> & ind, size_t mask) NETGEN_INLINE size_t HashValue2 (const IVec<1,TI> & ind, size_t mask)
{ {
return ind[0] & mask; return ind[0] & mask;
} }
/// hash value of 2 int /// hash value of 2 int
template <typename TI> template <typename TI>
NETGEN_INLINE size_t HashValue2 (const INT<2,TI> & ind, size_t mask) NETGEN_INLINE size_t HashValue2 (const IVec<2,TI> & ind, size_t mask)
{ {
INT<2,size_t> lind = ind; IVec<2,size_t> lind = ind;
return (113*lind[0]+lind[1]) & mask; return (113*lind[0]+lind[1]) & mask;
} }
/// hash value of 3 int /// hash value of 3 int
template <typename TI> template <typename TI>
NETGEN_INLINE size_t HashValue2 (const INT<3,TI> & ind, size_t mask) NETGEN_INLINE size_t HashValue2 (const IVec<3,TI> & ind, size_t mask)
{ {
INT<3,size_t> lind = ind; IVec<3,size_t> lind = ind;
return (113*lind[0]+59*lind[1]+lind[2]) & mask; return (113*lind[0]+59*lind[1]+lind[2]) & mask;
} }
@ -332,7 +332,7 @@ namespace ngcore
// using ngstd::max; // using ngstd::max;
template <int D, typename T> template <int D, typename T>
NETGEN_INLINE T Max (const INT<D,T> & i) NETGEN_INLINE T Max (const IVec<D,T> & i)
{ {
if (D == 0) return 0; if (D == 0) return 0;
T m = i[0]; T m = i[0];
@ -342,7 +342,7 @@ namespace ngcore
} }
template <int D, typename T> template <int D, typename T>
NETGEN_INLINE T Min (const INT<D,T> & i) NETGEN_INLINE T Min (const IVec<D,T> & i)
{ {
if (D == 0) return 0; if (D == 0) return 0;
T m = i[0]; T m = i[0];
@ -352,18 +352,18 @@ namespace ngcore
} }
template <int D, typename T> template <int D, typename T>
NETGEN_INLINE INT<D,T> Max (INT<D,T> i1, INT<D,T> i2) NETGEN_INLINE IVec<D,T> Max (IVec<D,T> i1, IVec<D,T> i2)
{ {
INT<D,T> tmp; IVec<D,T> tmp;
for (int i = 0; i < D; i++) for (int i = 0; i < D; i++)
tmp[i] = std::max(i1[i], i2[i]); tmp[i] = std::max(i1[i], i2[i]);
return tmp; return tmp;
} }
template <int D, typename T> template <int D, typename T>
NETGEN_INLINE INT<D,T> operator+ (INT<D,T> i1, INT<D,T> i2) NETGEN_INLINE IVec<D,T> operator+ (IVec<D,T> i1, IVec<D,T> i2)
{ {
INT<D,T> tmp; IVec<D,T> tmp;
for (int i = 0; i < D; i++) for (int i = 0; i < D; i++)
tmp[i] = i1[i]+i2[i]; tmp[i] = i1[i]+i2[i];
return tmp; return tmp;
@ -828,21 +828,21 @@ namespace ngcore
} }
template <typename TI> template <typename TI>
NETGEN_INLINE size_t HashValue (const INT<3,TI> ind) NETGEN_INLINE size_t HashValue (const IVec<3,TI> ind)
{ {
INT<3,size_t> lind = ind; IVec<3,size_t> lind = ind;
return 113*lind[0]+59*lind[1]+lind[2]; return 113*lind[0]+59*lind[1]+lind[2];
} }
template <typename TI> template <typename TI>
NETGEN_INLINE size_t HashValue (const INT<2,TI> ind) NETGEN_INLINE size_t HashValue (const IVec<2,TI> ind)
{ {
INT<2,size_t> lind = ind; IVec<2,size_t> lind = ind;
return 113*lind[0]+lind[1]; return 113*lind[0]+lind[1];
} }
template <typename TI> template <typename TI>
NETGEN_INLINE size_t HashValue (const INT<1,TI> ind) NETGEN_INLINE size_t HashValue (const IVec<1,TI> ind)
{ {
return ind[0]; return ind[0];
} }
@ -1075,7 +1075,7 @@ namespace ngcore
#ifdef PARALLEL #ifdef PARALLEL
namespace ngcore { namespace ngcore {
template<int S, typename T> template<int S, typename T>
class MPI_typetrait<ngcore::INT<S, T> > class MPI_typetrait<ngcore::IVec<S, T> >
{ {
public: public:
/// gets the MPI datatype /// gets the MPI datatype
@ -1099,7 +1099,7 @@ namespace ngcore
template<typename T> struct MPI_typetrait; template<typename T> struct MPI_typetrait;
template<int S, typename T> template<int S, typename T>
struct MPI_typetrait<INT<S, T> > { struct MPI_typetrait<IVec<S, T> > {
static auto MPIType () { static auto MPIType () {
return MPI_typetrait<std::array<T,S>>::MPIType(); return MPI_typetrait<std::array<T,S>>::MPIType();
} }
@ -1112,8 +1112,8 @@ namespace std
{ {
// structured binding support // structured binding support
template <auto N, typename T> template <auto N, typename T>
struct tuple_size<ngcore::INT<N,T>> : std::integral_constant<std::size_t, N> {}; struct tuple_size<ngcore::IVec<N,T>> : std::integral_constant<std::size_t, N> {};
template<size_t N, auto M, typename T> struct tuple_element<N,ngcore::INT<M,T>> { using type = T; }; template<size_t N, auto M, typename T> struct tuple_element<N,ngcore::IVec<M,T>> { using type = T; };
} }
#endif #endif

View File

@ -44,7 +44,7 @@ namespace GZSTREAM_NAMESPACE {
// class gzstreambuf: // class gzstreambuf:
// -------------------------------------- // --------------------------------------
gzstreambuf* gzstreambuf::open( const filesystem::path & name, int open_mode) { gzstreambuf* gzstreambuf::open( const std::filesystem::path & name, int open_mode) {
if ( is_open()) if ( is_open())
return (gzstreambuf*)0; return (gzstreambuf*)0;
mode = open_mode; mode = open_mode;
@ -143,7 +143,7 @@ int gzstreambuf::sync() {
// class gzstreambase: // class gzstreambase:
// -------------------------------------- // --------------------------------------
gzstreambase::gzstreambase( const filesystem::path & name, int mode) { gzstreambase::gzstreambase( const std::filesystem::path & name, int mode) {
init( &buf); init( &buf);
open( name.c_str(), mode); open( name.c_str(), mode);
} }
@ -152,7 +152,7 @@ gzstreambase::~gzstreambase() {
buf.close(); buf.close();
} }
void gzstreambase::open( const filesystem::path & name, int open_mode) { void gzstreambase::open( const std::filesystem::path & name, int open_mode) {
if ( ! buf.open( name.c_str(), open_mode)) if ( ! buf.open( name.c_str(), open_mode))
clear( rdstate() | std::ios::badbit); clear( rdstate() | std::ios::badbit);
} }

View File

@ -62,7 +62,7 @@ public:
// ASSERT: both input & output capabilities will not be used together // ASSERT: both input & output capabilities will not be used together
} }
int is_open() { return opened; } int is_open() { return opened; }
gzstreambuf* open( const filesystem::path & name, int open_mode); gzstreambuf* open( const std::filesystem::path & name, int open_mode);
gzstreambuf* close(); gzstreambuf* close();
~gzstreambuf() { close(); } ~gzstreambuf() { close(); }
@ -76,9 +76,9 @@ protected:
gzstreambuf buf; gzstreambuf buf;
public: public:
gzstreambase() { init(&buf); } gzstreambase() { init(&buf); }
gzstreambase( const filesystem::path & name, int open_mode); gzstreambase( const std::filesystem::path & name, int open_mode);
~gzstreambase(); ~gzstreambase();
void open( const filesystem::path & name, int open_mode); void open( const std::filesystem::path & name, int open_mode);
void close(); void close();
gzstreambuf* rdbuf() { return &buf; } gzstreambuf* rdbuf() { return &buf; }
}; };
@ -92,10 +92,10 @@ public:
class DLL_HEADER igzstream : public gzstreambase, public std::istream { class DLL_HEADER igzstream : public gzstreambase, public std::istream {
public: public:
igzstream() : std::istream( &buf) {} igzstream() : std::istream( &buf) {}
igzstream( const filesystem::path & name, int open_mode = std::ios::in) igzstream( const std::filesystem::path & name, int open_mode = std::ios::in)
: gzstreambase( name, open_mode), std::istream( &buf) {} : gzstreambase( name, open_mode), std::istream( &buf) {}
gzstreambuf* rdbuf() { return gzstreambase::rdbuf(); } gzstreambuf* rdbuf() { return gzstreambase::rdbuf(); }
void open( const filesystem::path & name, int open_mode = std::ios::in) { void open( const std::filesystem::path & name, int open_mode = std::ios::in) {
gzstreambase::open( name, open_mode); gzstreambase::open( name, open_mode);
} }
}; };
@ -103,10 +103,10 @@ public:
class DLL_HEADER ogzstream : public gzstreambase, public std::ostream { class DLL_HEADER ogzstream : public gzstreambase, public std::ostream {
public: public:
ogzstream() : std::ostream( &buf) {} ogzstream() : std::ostream( &buf) {}
ogzstream( const filesystem::path & name, int mode = std::ios::out) ogzstream( const std::filesystem::path & name, int mode = std::ios::out)
: gzstreambase( name, mode), std::ostream( &buf) {} : gzstreambase( name, mode), std::ostream( &buf) {}
gzstreambuf* rdbuf() { return gzstreambase::rdbuf(); } gzstreambuf* rdbuf() { return gzstreambase::rdbuf(); }
void open( const filesystem::path & name, int open_mode = std::ios::out) { void open( const std::filesystem::path & name, int open_mode = std::ios::out) {
gzstreambase::open( name, open_mode); gzstreambase::open( name, open_mode);
} }
}; };

View File

@ -45,5 +45,4 @@ namespace netgen
// #include "mpi_interface.hpp" // #include "mpi_interface.hpp"
#include "netgenout.hpp" #include "netgenout.hpp"
#endif #endif

View File

@ -8,7 +8,7 @@
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
using namespace ngcore; // using namespace ngcore;
template <typename T> template <typename T>
py::array MoveToNumpy(std::vector<T>& vec) py::array MoveToNumpy(std::vector<T>& vec)

View File

@ -77,8 +77,8 @@ public:
template<typename TFunc> template<typename TFunc>
void ParallelFor( int first, int next, const TFunc & f ) void ParallelFor( int first, int next, const TFunc & f )
{ {
int nthreads = thread::hardware_concurrency(); int nthreads = std::thread::hardware_concurrency();
thread * threads = new thread[nthreads]; std::thread * threads = new std::thread[nthreads];
for (int i=0; i<nthreads; i++) for (int i=0; i<nthreads; i++)
{ {
int myfirst = first + (next-first)*i/nthreads; int myfirst = first + (next-first)*i/nthreads;
@ -97,7 +97,7 @@ void ParallelFor( int first, int next, const TFunc & f )
typedef void (*NgTaskManager)(std::function<void(int,int)>); typedef void (*NgTaskManager)(std::function<void(int,int)>);
typedef void (*NgTracer)(string, bool); // false .. start, true .. stop typedef void (*NgTracer)(std::string, bool); // false .. start, true .. stop
inline void DummyTaskManager (std::function<void(int,int)> func) inline void DummyTaskManager (std::function<void(int,int)> func)
{ {
@ -105,7 +105,7 @@ void ParallelFor( int first, int next, const TFunc & f )
func(1,2); func(1,2);
} }
inline void DummyTracer (string, bool) { ; } inline void DummyTracer (std::string, bool) { ; }
template <typename FUNC> template <typename FUNC>
inline void ParallelFor (NgTaskManager tm, size_t n, FUNC func) inline void ParallelFor (NgTaskManager tm, size_t n, FUNC func)

View File

@ -16,7 +16,7 @@ namespace netgen
templates, global types, defines and variables templates, global types, defines and variables
*/ */
DLL_HEADER extern const string netgen_version; DLL_HEADER extern const std::string netgen_version;
/// The following value may be adapted to the hardware ! /// The following value may be adapted to the hardware !
#ifndef CLOCKS_PER_SEC #ifndef CLOCKS_PER_SEC

View File

@ -12,8 +12,6 @@
namespace netgen namespace netgen
{ {
using ngcore::INT;
constexpr static double EPSILON=0.000000001; constexpr static double EPSILON=0.000000001;
void ComputeWeight( Spline & s, Point<2> p ) void ComputeWeight( Spline & s, Point<2> p )
@ -2037,13 +2035,13 @@ shared_ptr<netgen::SplineGeometry2d> CSG2d :: GenerateSplineGeometry()
} }
netgen::BoxTree <2> solid_tree(box); netgen::BoxTree <2> solid_tree(box);
Array<INT<2>> loop_list; Array<IVec<2>> loop_list;
for(auto i : Range(solids)) for(auto i : Range(solids))
for(auto li : Range(solids[i].polys)) for(auto li : Range(solids[i].polys))
{ {
solid_tree.Insert(solids[i].polys[li].GetBoundingBox(), loop_list.Size()); solid_tree.Insert(solids[i].polys[li].GetBoundingBox(), loop_list.Size());
loop_list.Append(INT<2>(i, li)); loop_list.Append(IVec<2>(i, li));
} }
for(auto i1 : Range(solids)) for(auto i1 : Range(solids))

View File

@ -5,6 +5,11 @@
#include <mystdlib.h> #include <mystdlib.h>
#include <mydefs.hpp> #include <mydefs.hpp>
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
# ifdef __APPLE__ # ifdef __APPLE__
#define GL_SILENCE_DEPRECATION #define GL_SILENCE_DEPRECATION
#define GL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED #define GL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED

View File

@ -1,3 +1,8 @@
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
#include <tcl.h> #include <tcl.h>
#include <tk.h> #include <tk.h>

View File

@ -49,28 +49,29 @@ namespace metis { extern "C" {
#define M_PI 3.14159265358979323846 #define M_PI 3.14159265358979323846
#endif #endif
/*** Windows headers ***/ /*** Windows headers ***/
#ifdef _MSC_VER #ifdef _MSC_VER
# define WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN
# ifndef NO_PARALLEL_THREADS # ifndef NO_PARALLEL_THREADS
# ifdef MSVC_EXPRESS # ifdef MSVC_EXPRESS
# else # else
# include <afxwin.h> // # include <afxwin.h>
# include <afxmt.h> // # include <afxmt.h>
# endif // MSVC_EXPRESS # endif // MSVC_EXPRESS
# endif # endif
# include <windows.h> // # include <windows.h>
# undef WIN32_LEAN_AND_MEAN # undef WIN32_LEAN_AND_MEAN
# include <winnt.h> // # include <winnt.h>
#else // Not using MC VC++ #else // Not using MC VC++
#endif
// using namespace std;
namespace netgen
{
using namespace std;
}
#endif #endif
using namespace std;
#endif

View File

@ -8,7 +8,7 @@
namespace netgen::cg namespace netgen::cg
{ {
typedef ngcore::ClosedHashTable<ngcore::INT<3,size_t>, size_t> PointTable; typedef ngcore::ClosedHashTable<ngcore::IVec<3,size_t>, size_t> PointTable;
int getDim(ElementType_t type) int getDim(ElementType_t type)
{ {
@ -416,7 +416,7 @@ namespace netgen::cg
for(auto i : Range(nv)) for(auto i : Range(nv))
{ {
ngcore::INT<3,size_t> hash = {*reinterpret_cast<size_t*>(&x[i]), *reinterpret_cast<size_t*>(&y[i]), *reinterpret_cast<size_t*>(&z[i])}; ngcore::IVec<3,size_t> hash = {*reinterpret_cast<size_t*>(&x[i]), *reinterpret_cast<size_t*>(&y[i]), *reinterpret_cast<size_t*>(&z[i])};
size_t pi_ng; size_t pi_ng;
size_t pos; size_t pos;
// check if this point is new // check if this point is new

View File

@ -1147,7 +1147,8 @@ struct GrowthVectorLimiter {
// result in pushed through elements, since we do not (yet) // result in pushed through elements, since we do not (yet)
// curvature through layers. // curvature through layers.
// Therefore we disable curving for these surfaces. // Therefore we disable curving for these surfaces.
mesh.GetFaceDescriptor(i).SetSurfNr(-1); if(!params.keep_surfaceindex)
mesh.GetFaceDescriptor(i).SetSurfNr(-1);
} }
} }
@ -1413,14 +1414,12 @@ struct GrowthVectorLimiter {
// return true; // return true;
// return false; // return false;
auto segs = topo.GetVertexSegments(pi); auto segs = topo.GetVertexSegments(pi);
// cout << "segs of " << pi << ", " << segs.Size() << endl; if(segs.Size() == 1)
return true;
auto first_edgenr = mesh[segs[0]].edgenr; auto first_edgenr = mesh[segs[0]].edgenr;
for(auto segi : segs) for(auto segi : segs)
if(mesh[segi].edgenr != first_edgenr) { if(mesh[segi].edgenr != first_edgenr)
// cout << "found corner point " << pi << endl; return true;
return true;
}
// cout << "no corner point " << pi << endl;
return false; return false;
}; };

View File

@ -27,6 +27,7 @@ public:
bool limit_growth_vectors = true; bool limit_growth_vectors = true;
double limit_safety = 0.3; // alloow only 30% of the growth vector length double limit_safety = 0.3; // alloow only 30% of the growth vector length
bool sides_keep_surfaceindex = false; bool sides_keep_surfaceindex = false;
bool keep_surfaceindex = false;
Array<size_t> project_boundaries; Array<size_t> project_boundaries;
}; };

View File

@ -840,12 +840,12 @@ namespace netgen
tets_with_3_bnd_points.SetSize(cnt); tets_with_3_bnd_points.SetSize(cnt);
static Timer t1("Build face table"); t1.Start(); static Timer t1("Build face table"); t1.Start();
ngcore::ClosedHashTable< ngcore::INT<3>, int > face_table( 4*cnt + 3 ); ngcore::ClosedHashTable< ngcore::IVec<3>, int > face_table( 4*cnt + 3 );
for(auto ei : tets_with_3_bnd_points) for(auto ei : tets_with_3_bnd_points)
for(auto j : Range(4)) for(auto j : Range(4))
{ {
auto i3_ = tempels[ei].GetFace (j); auto i3_ = tempels[ei].GetFace (j);
ngcore::INT<3> i3 = {i3_[0], i3_[1], i3_[2]}; ngcore::IVec<3> i3 = {i3_[0], i3_[1], i3_[2]};
if(bnd_points[i3[0]] && bnd_points[i3[1]] && bnd_points[i3[2]]) if(bnd_points[i3[0]] && bnd_points[i3[1]] && bnd_points[i3[2]])
{ {
i3.Sort(); i3.Sort();
@ -860,7 +860,7 @@ namespace netgen
for (int i = 1; i <= mesh.GetNOpenElements(); i++) for (int i = 1; i <= mesh.GetNOpenElements(); i++)
{ {
const Element2d & tri = mesh.OpenElement(i); const Element2d & tri = mesh.OpenElement(i);
ngcore::INT<3> i3(tri[0], tri[1], tri[2]); ngcore::IVec<3> i3(tri[0], tri[1], tri[2]);
i3.Sort(); i3.Sort();
if(!face_table.Used(i3)) if(!face_table.Used(i3))
openels.Append(i); openels.Append(i);

View File

@ -38,7 +38,7 @@ namespace netgen
if(p1<p0) if(p1<p0)
Swap(p0,p1); Swap(p0,p1);
INT<2> hash = {p0,p1}; IVec<2> hash = {p0,p1};
auto pos = edge_to_trig.Position(hash); auto pos = edge_to_trig.Position(hash);
if (pos == -1) return -1; if (pos == -1) return -1;
@ -53,7 +53,7 @@ namespace netgen
if(p1<p0) if(p1<p0)
Swap(p0,p1); Swap(p0,p1);
INT<2> hash = {p0,p1}; IVec<2> hash = {p0,p1};
auto pos = edge_to_trig.Position(hash); auto pos = edge_to_trig.Position(hash);
if (pos == -1) if (pos == -1)
edge_to_trig[hash] = {eli, -1}; edge_to_trig[hash] = {eli, -1};
@ -80,7 +80,7 @@ namespace netgen
if(p1<p0) if(p1<p0)
Swap(p0,p1); Swap(p0,p1);
INT<2> hash = {p0,p1}; IVec<2> hash = {p0,p1};
auto pos = edge_to_trig.Position(hash); auto pos = edge_to_trig.Position(hash);
auto i2 = edge_to_trig.GetData(pos); auto i2 = edge_to_trig.GetData(pos);
@ -256,7 +256,7 @@ namespace netgen
{ {
int p1 = trig[k]; int p1 = trig[k];
int p2 = trig[(k+1)%3]; int p2 = trig[(k+1)%3];
INT<2> edge{p1,p2}; IVec<2> edge{p1,p2};
edge.Sort(); edge.Sort();
bool found = false; bool found = false;
for (int l = 0; l < edges.Size(); l++) for (int l = 0; l < edges.Size(); l++)
@ -801,13 +801,13 @@ namespace netgen
// Mark edges and trigs as inside or outside, starting with boundary edges // Mark edges and trigs as inside or outside, starting with boundary edges
enum POSITION { UNKNOWN, BOUNDARY, INSIDE, OUTSIDE }; enum POSITION { UNKNOWN, BOUNDARY, INSIDE, OUTSIDE };
Array<POSITION, SurfaceElementIndex> trig_pos(tempmesh.SurfaceElements().Size()); Array<POSITION, SurfaceElementIndex> trig_pos(tempmesh.SurfaceElements().Size());
ngcore::ClosedHashTable<INT<2>, POSITION> edge_pos(3*tempmesh.SurfaceElements().Size()); ngcore::ClosedHashTable<IVec<2>, POSITION> edge_pos(3*tempmesh.SurfaceElements().Size());
trig_pos = UNKNOWN; trig_pos = UNKNOWN;
for (auto & seg : tempmesh.LineSegments()) for (auto & seg : tempmesh.LineSegments())
{ {
ArrayMem<SurfaceElementIndex, 2> els; ArrayMem<SurfaceElementIndex, 2> els;
INT<2> edge{seg[0], seg[1]}; IVec<2> edge{seg[0], seg[1]};
edge.Sort(); edge.Sort();
edge_pos[edge] = BOUNDARY; edge_pos[edge] = BOUNDARY;
@ -828,8 +828,8 @@ namespace netgen
else else
pos = OUTSIDE; pos = OUTSIDE;
INT<2> e1{seg[0], pi2}; IVec<2> e1{seg[0], pi2};
INT<2> e2{seg[1], pi2}; IVec<2> e2{seg[1], pi2};
e1.Sort(); e1.Sort();
e2.Sort(); e2.Sort();
if(!edge_pos.Used(e1)) if(!edge_pos.Used(e1))
@ -857,7 +857,7 @@ namespace netgen
// any edge of unknown trig already marked? // any edge of unknown trig already marked?
for(auto i : IntRange(3)) for(auto i : IntRange(3))
{ {
INT<2> edge{el[(i+1)%3], el[(i+2)%3]}; IVec<2> edge{el[(i+1)%3], el[(i+2)%3]};
edge.Sort(); edge.Sort();
if(edge_pos.Used(edge) && edge_pos[edge]!=BOUNDARY) if(edge_pos.Used(edge) && edge_pos[edge]!=BOUNDARY)
{ {
@ -871,7 +871,7 @@ namespace netgen
if(trig_pos[sei] != UNKNOWN) if(trig_pos[sei] != UNKNOWN)
for(auto i : IntRange(3)) for(auto i : IntRange(3))
{ {
INT<2> edge{el[(i+1)%3], el[(i+2)%3]}; IVec<2> edge{el[(i+1)%3], el[(i+2)%3]};
edge.Sort(); edge.Sort();
if(!edge_pos.Used(edge) || edge_pos[edge]==BOUNDARY) if(!edge_pos.Used(edge) || edge_pos[edge]==BOUNDARY)
edge_pos[edge] = trig_pos[sei]; edge_pos[edge] = trig_pos[sei];

View File

@ -2,7 +2,6 @@
namespace netgen namespace netgen
{ {
using ngcore::INT;
static inline Point<2> P2( Point<3> p ) static inline Point<2> P2( Point<3> p )
{ {
@ -44,14 +43,14 @@ namespace netgen
class DelaunayMesh class DelaunayMesh
{ {
ngcore::ClosedHashTable<INT<2>, INT<2>> edge_to_trig; ngcore::ClosedHashTable<IVec<2>, IVec<2>> edge_to_trig;
Array<DelaunayTrig> trigs; Array<DelaunayTrig> trigs;
unique_ptr<DelaunayTree<2>> tree; unique_ptr<DelaunayTree<2>> tree;
Array<Point<2>, PointIndex> & points; Array<Point<2>, PointIndex> & points;
Array<int> closeels; Array<int> closeels;
Array<int> intersecting; Array<int> intersecting;
Array<INT<2>> edges; Array<IVec<2>> edges;
int GetNeighbour( int eli, int edge ); int GetNeighbour( int eli, int edge );

View File

@ -6359,6 +6359,8 @@ namespace netgen
for(auto si : Range(segments)) for(auto si : Range(segments))
{ {
auto& seg = segments[si]; auto& seg = segments[si];
// Copy segment, as reference above might get invalidated in AddSegment()
auto reference_seg = seg;
auto p1 = seg[0]; auto p1 = seg[0];
auto p2 = seg[1]; auto p2 = seg[1];
@ -6378,7 +6380,7 @@ namespace netgen
seg[1] = ipts[1]; seg[1] = ipts[1];
for(auto i : Range(size_t(1), ipts.Size()-1)) for(auto i : Range(size_t(1), ipts.Size()-1))
{ {
Segment snew = seg; Segment snew = reference_seg;
if(c2) if(c2)
{ {
snew[0] = ipts[ipts.Size()-1-i]; snew[0] = ipts[ipts.Size()-1-i];
@ -7152,6 +7154,53 @@ namespace netgen
SetNextMajorTimeStamp(); SetNextMajorTimeStamp();
} }
void Mesh :: SplitFacesByAdjacentDomains ()
{
UpdateTopology();
std::map<std::tuple<int, int, int>, int> face_doms_2_new_face;
int nfaces = FaceDescriptors().Size();
Array<bool> first_visit(nfaces);
first_visit = true;
for (auto sei : Range(SurfaceElements()))
{
int eli0, eli1;
GetTopology().GetSurface2VolumeElement(sei+1, eli0, eli1);
auto & sel = (*this)[sei];
int face = sel.GetIndex();
int domin = VolumeElement(eli0).GetIndex();
int domout = eli1 ? VolumeElement(eli1).GetIndex() : 0;
if(domin < domout)
swap(domin, domout);
auto key = std::make_tuple(face, domin, domout);
if(face_doms_2_new_face.find(key) == face_doms_2_new_face.end())
{
if(!first_visit[face-1]) {
nfaces++;
FaceDescriptor new_fd = FaceDescriptors()[face-1];
new_fd.bcprop = nfaces;
new_fd.domin = domin;
new_fd.domout = domout;
AddFaceDescriptor(new_fd);
SetBCName(nfaces-1, new_fd.GetBCName());
face_doms_2_new_face[key] = nfaces;
}
else {
face_doms_2_new_face[key] = face;
auto & fd = FaceDescriptors()[face-1];
fd.domin = domin;
fd.domout = domout;
}
first_visit[face-1] = false;
}
sel.SetIndex(face_doms_2_new_face[key]);
}
SetNextMajorTimeStamp();
RebuildSurfaceElementLists ();
CalcSurfacesOfNode();
UpdateTopology();
}
void Mesh :: SetMaterial (int domnr, const string & mat) void Mesh :: SetMaterial (int domnr, const string & mat)
{ {
if (domnr > materials.Size()) if (domnr > materials.Size())

View File

@ -699,6 +699,8 @@ namespace netgen
auto & GetCommunicator() const { return this->comm; } auto & GetCommunicator() const { return this->comm; }
void SetCommunicator(NgMPI_Comm acomm); void SetCommunicator(NgMPI_Comm acomm);
DLL_HEADER void SplitFacesByAdjacentDomains();
/// ///
DLL_HEADER void SetMaterial (int domnr, const string & mat); DLL_HEADER void SetMaterial (int domnr, const string & mat);
/// ///

View File

@ -9,7 +9,6 @@
#include "../include/opti.hpp" #include "../include/opti.hpp"
namespace netgen namespace netgen
{ {
// extern int printmessage_importance; // extern int printmessage_importance;
@ -62,4 +61,6 @@ namespace netgen
#include "paralleltop.hpp" #include "paralleltop.hpp"
#endif #endif

View File

@ -1250,6 +1250,7 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
.def ("GetCD3Name", &Mesh::GetCD3Name) .def ("GetCD3Name", &Mesh::GetCD3Name)
.def ("SetCD3Name", &Mesh::SetCD3Name) .def ("SetCD3Name", &Mesh::SetCD3Name)
.def ("SplitFacesByAdjacentDomains", &Mesh::SplitFacesByAdjacentDomains)
.def("GetIdentifications", [](Mesh & self) -> py::list .def("GetIdentifications", [](Mesh & self) -> py::list
{ {
py::list points; py::list points;
@ -1463,7 +1464,8 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
variant<string, int> domain, bool outside, variant<string, int> domain, bool outside,
optional<string> project_boundaries, optional<string> project_boundaries,
bool grow_edges, bool limit_growth_vectors, bool grow_edges, bool limit_growth_vectors,
bool sides_keep_surfaceindex) bool sides_keep_surfaceindex,
bool keep_surfaceindex)
{ {
BoundaryLayerParameters blp; BoundaryLayerParameters blp;
BitArray boundaries(self.GetNFD()+1); BitArray boundaries(self.GetNFD()+1);
@ -1549,12 +1551,14 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
blp.grow_edges = grow_edges; blp.grow_edges = grow_edges;
blp.limit_growth_vectors = limit_growth_vectors; blp.limit_growth_vectors = limit_growth_vectors;
blp.sides_keep_surfaceindex = sides_keep_surfaceindex; blp.sides_keep_surfaceindex = sides_keep_surfaceindex;
blp.keep_surfaceindex = keep_surfaceindex;
GenerateBoundaryLayer (self, blp); GenerateBoundaryLayer (self, blp);
self.UpdateTopology(); self.UpdateTopology();
}, py::arg("boundary"), py::arg("thickness"), py::arg("material"), }, py::arg("boundary"), py::arg("thickness"), py::arg("material"),
py::arg("domains") = ".*", py::arg("outside") = false, py::arg("domains") = ".*", py::arg("outside") = false,
py::arg("project_boundaries")=nullopt, py::arg("grow_edges")=true, py::arg("limit_growth_vectors") = true, py::arg("sides_keep_surfaceindex")=false, py::arg("project_boundaries")=nullopt, py::arg("grow_edges")=true, py::arg("limit_growth_vectors") = true, py::arg("sides_keep_surfaceindex")=false,
py::arg("keep_surfaceindex")=false,
R"delimiter( R"delimiter(
Add boundary layer to mesh. Add boundary layer to mesh.

View File

@ -5,7 +5,6 @@ namespace netgen
{ {
using ngcore::ParallelForRange; using ngcore::ParallelForRange;
using ngcore::ParallelFor; using ngcore::ParallelFor;
using ngcore::INT;
using ngcore::TasksPerThread; using ngcore::TasksPerThread;
/* /*
@ -699,20 +698,20 @@ namespace netgen
// edge is splitting edge in middle of triangle: // edge is splitting edge in middle of triangle:
for (int j = 1; j <= 2; j++) for (int j = 1; j <= 2; j++)
{ {
INT<2> paedge1, paedge2, paedge3; IVec<2> paedge1, paedge2, paedge3;
int orient_inner = 0; int orient_inner = 0;
if (j == 1) if (j == 1)
{ {
paedge1 = INT<2> (pa0[0], verts[1]); paedge1 = IVec<2> (pa0[0], verts[1]);
paedge2 = INT<2> (pa0[1], verts[1]); paedge2 = IVec<2> (pa0[1], verts[1]);
paedge3 = INT<2> (pa0[0], pa0[1]); paedge3 = IVec<2> (pa0[0], pa0[1]);
orient_inner = 0; orient_inner = 0;
} }
else else
{ {
paedge1 = INT<2> (pa1[0], verts[0]); paedge1 = IVec<2> (pa1[0], verts[0]);
paedge2 = INT<2> (pa1[1], verts[0]); paedge2 = IVec<2> (pa1[1], verts[0]);
paedge3 = INT<2> (pa1[0], pa1[1]); paedge3 = IVec<2> (pa1[0], pa1[1]);
orient_inner = 1; orient_inner = 1;
} }
if (paedge1[0] > paedge1[1]) if (paedge1[0] > paedge1[1])
@ -752,21 +751,21 @@ namespace netgen
if (!bisect_edge) // not a bisect edge (then a red edge) if (!bisect_edge) // not a bisect edge (then a red edge)
{ {
INT<2> paedge1, paedge2, paedge3; IVec<2> paedge1, paedge2, paedge3;
int orient1 = 0, orient2 = 0, orient3=0; int orient1 = 0, orient2 = 0, orient3=0;
// int orient_inner = 0; // int orient_inner = 0;
paedge1 = INT<2> (pa0[0], pa0[1]); paedge1 = IVec<2> (pa0[0], pa0[1]);
paedge2 = INT<2> (pa1[0], pa1[1]); paedge2 = IVec<2> (pa1[0], pa1[1]);
// find common vertex and the third pa edge // find common vertex and the third pa edge
if (pa0[0]==pa1[0]){// 00 if (pa0[0]==pa1[0]){// 00
//orient1 = 0; //orient1 = 0;
orient2 = 1; orient2 = 1;
if (pa0[1]<pa1[1]){ if (pa0[1]<pa1[1]){
orient3 = 1; orient3 = 1;
paedge3 = INT<2> (pa0[1], pa1[1]); paedge3 = IVec<2> (pa0[1], pa1[1]);
}else{ }else{
//orient3 = 0; //orient3 = 0;
paedge3 = INT<2> (pa1[1], pa0[1]); paedge3 = IVec<2> (pa1[1], pa0[1]);
} }
} }
else if (pa0[0]==pa1[1]){//01 else if (pa0[0]==pa1[1]){//01
@ -774,10 +773,10 @@ namespace netgen
//orient2 = 0; //orient2 = 0;
if (pa0[1]<pa1[0]){ if (pa0[1]<pa1[0]){
orient3 = 1; orient3 = 1;
paedge3 = INT<2> (pa0[1], pa1[0]); paedge3 = IVec<2> (pa0[1], pa1[0]);
}else{ }else{
//orient3 = 0; //orient3 = 0;
paedge3 = INT<2> (pa1[0], pa0[1]); paedge3 = IVec<2> (pa1[0], pa0[1]);
} }
} }
else if (pa0[1]==pa1[0]){//10 else if (pa0[1]==pa1[0]){//10
@ -785,10 +784,10 @@ namespace netgen
orient2 = 1; orient2 = 1;
if (pa0[0]<pa1[1]){ if (pa0[0]<pa1[1]){
orient3 = 1; orient3 = 1;
paedge3 = INT<2> (pa0[0], pa1[1]); paedge3 = IVec<2> (pa0[0], pa1[1]);
}else{ }else{
//orient3 = 0; //orient3 = 0;
paedge3 = INT<2> (pa1[1], pa0[0]); paedge3 = IVec<2> (pa1[1], pa0[0]);
} }
} }
else if (pa0[1]==pa1[1]){//11 else if (pa0[1]==pa1[1]){//11
@ -796,10 +795,10 @@ namespace netgen
//orient2 = 0; //orient2 = 0;
if (pa0[0]<pa1[0]){ if (pa0[0]<pa1[0]){
orient3 = 1; orient3 = 1;
paedge3 = INT<2> (pa0[0], pa1[0]); paedge3 = IVec<2> (pa0[0], pa1[0]);
}else{ }else{
//orient3 = 0; //orient3 = 0;
paedge3 = INT<2> (pa1[0], pa0[0]); paedge3 = IVec<2> (pa1[0], pa0[0]);
} }
} }
@ -832,16 +831,16 @@ namespace netgen
pa1[1] != pa2[1]) pa1[1] != pa2[1])
for (int j = 1; j <= 2; j++) for (int j = 1; j <= 2; j++)
{ {
INT<2> paedge1, paedge2; IVec<2> paedge1, paedge2;
if (j == 1) if (j == 1)
{ {
paedge1 = INT<2> (pa1[0], pa2[0]); paedge1 = IVec<2> (pa1[0], pa2[0]);
paedge2 = INT<2> (pa1[1], pa2[1]); paedge2 = IVec<2> (pa1[1], pa2[1]);
} }
else else
{ {
paedge1 = INT<2> (pa1[0], pa2[1]); paedge1 = IVec<2> (pa1[0], pa2[1]);
paedge2 = INT<2> (pa1[1], pa2[0]); paedge2 = IVec<2> (pa1[1], pa2[0]);
} }
int paedgenr1 = 0, paedgenr2 = 0; int paedgenr1 = 0, paedgenr2 = 0;
@ -877,7 +876,7 @@ namespace netgen
for (int j = 0; j < 2; j++) for (int j = 0; j < 2; j++)
for (int k = 0; k < 2; k++) for (int k = 0; k < 2; k++)
{ {
INT<2> paedge (pa1[1-j], pa2[1-k]); IVec<2> paedge (pa1[1-j], pa2[1-k]);
int orientpa = 1; int orientpa = 1;
if (paedge[0] > paedge[1]) if (paedge[0] > paedge[1])
{ {
@ -909,12 +908,12 @@ namespace netgen
// edge hashtable:: needed for getting parent faces // edge hashtable:: needed for getting parent faces
ngcore::ClosedHashTable<INT<2>, int> v2e(nv); ngcore::ClosedHashTable<IVec<2>, int> v2e(nv);
if (build_parent_faces) if (build_parent_faces)
for (auto i : Range(edge2vert)) for (auto i : Range(edge2vert))
{ {
auto edge = edge2vert[i]; auto edge = edge2vert[i];
INT<2> e2(edge[0], edge[1]); IVec<2> e2(edge[0], edge[1]);
e2.Sort(); e2.Sort();
v2e[e2] = i; v2e[e2] = i;
} }
@ -947,7 +946,7 @@ namespace netgen
vert2oldface.AddSave (face2vert[i][0], i); vert2oldface.AddSave (face2vert[i][0], i);
// find all potential intermediate faces // find all potential intermediate faces
Array<INT<3>> intermediate_faces; Array<IVec<3>> intermediate_faces;
if (build_parent_faces) if (build_parent_faces)
{ {
for (ElementIndex ei = 0; ei < ne; ei++) for (ElementIndex ei = 0; ei < ne; ei++)
@ -957,7 +956,7 @@ namespace netgen
// cout << "element: " << (*mesh)[ei].PNums() << endl; // cout << "element: " << (*mesh)[ei].PNums() << endl;
(*mesh)[ei].GetFace(i+1, face); (*mesh)[ei].GetFace(i+1, face);
// cout << "face " << face.PNums() << endl; // cout << "face " << face.PNums() << endl;
INT<3,PointIndex> f3 = { face[0], face[1], face[2] }; IVec<3,PointIndex> f3 = { face[0], face[1], face[2] };
for (int j = 0; j < 3; j++) for (int j = 0; j < 3; j++)
{ {
PointIndex v = f3[j]; PointIndex v = f3[j];
@ -973,10 +972,10 @@ namespace netgen
PointIndex v2 = f3[0]+f3[1]+f3[2] - v - v0; PointIndex v2 = f3[0]+f3[1]+f3[2] - v - v0;
// if there is an edge connecting v1 and v2, accept // if there is an edge connecting v1 and v2, accept
// the new face // the new face
INT<2> parentedge(v1, v2); IVec<2> parentedge(v1, v2);
parentedge.Sort(); parentedge.Sort();
if (v2e.Used(parentedge)){ if (v2e.Used(parentedge)){
INT<3> cf3 = { v0, v1, v2 }; IVec<3> cf3 = { v0, v1, v2 };
cf3.Sort(); cf3.Sort();
// cout << "intermediate: " << cf3 << " of " << f3 << endl; // cout << "intermediate: " << cf3 << " of " << f3 << endl;
intermediate_faces.Append (cf3); intermediate_faces.Append (cf3);
@ -988,7 +987,7 @@ namespace netgen
for (SurfaceElementIndex sei = 0; sei < nse; sei++) for (SurfaceElementIndex sei = 0; sei < nse; sei++)
{ {
const Element2d & sel = (*mesh)[sei]; const Element2d & sel = (*mesh)[sei];
INT<3,PointIndex> f3 = { sel[0], sel[1], sel[2] }; IVec<3,PointIndex> f3 = { sel[0], sel[1], sel[2] };
for (int j = 0; j < 3; j++) for (int j = 0; j < 3; j++)
{ {
PointIndex v = f3[j]; PointIndex v = f3[j];
@ -1004,10 +1003,10 @@ namespace netgen
PointIndex v2 = f3[0]+f3[1]+f3[2] - v - v0; PointIndex v2 = f3[0]+f3[1]+f3[2] - v - v0;
// if there is an edge connecting v1 and v2, accept // if there is an edge connecting v1 and v2, accept
// the new face // the new face
INT<2> parentedge(v1, v2); IVec<2> parentedge(v1, v2);
parentedge.Sort(); parentedge.Sort();
if (v2e.Used(parentedge)){ if (v2e.Used(parentedge)){
INT<3> cf3 = { v0, v1, v2 }; IVec<3> cf3 = { v0, v1, v2 };
cf3.Sort(); cf3.Sort();
// cout << "intermediate: " << cf3 << " of " << f3 << endl; // cout << "intermediate: " << cf3 << " of " << f3 << endl;
intermediate_faces.Append (cf3); intermediate_faces.Append (cf3);
@ -1377,11 +1376,11 @@ namespace netgen
// cout << "f2v = " << face2vert << endl; // cout << "f2v = " << face2vert << endl;
ngcore::ClosedHashTable<INT<3>, int> v2f(nv); ngcore::ClosedHashTable<IVec<3>, int> v2f(nv);
for (auto i : Range(face2vert)) for (auto i : Range(face2vert))
{ {
auto face = face2vert[i]; auto face = face2vert[i];
INT<3> f3(face[0], face[1], face[2]); IVec<3> f3(face[0], face[1], face[2]);
f3.Sort(); f3.Sort();
v2f[f3] = i; v2f[f3] = i;
} }
@ -1393,7 +1392,7 @@ namespace netgen
for (auto i : Range(nfa)) for (auto i : Range(nfa))
{ {
INT<3,PointIndex> f3(face2vert[i][0], face2vert[i][1], face2vert[i][2]); IVec<3,PointIndex> f3(face2vert[i][0], face2vert[i][1], face2vert[i][2]);
// face on coarses level ? // face on coarses level ?
@ -1433,10 +1432,10 @@ namespace netgen
// if there is an edge connecting v1 and v2, accept // if there is an edge connecting v1 and v2, accept
// the new face // the new face
INT<2> parentedge(v1, v2); IVec<2> parentedge(v1, v2);
parentedge.Sort(); parentedge.Sort();
if (v2e.Used(parentedge)){ if (v2e.Used(parentedge)){
INT<3> parentverts(v0, v1, v2); IVec<3> parentverts(v0, v1, v2);
parentverts.Sort(); parentverts.Sort();
int classnr = 0; int classnr = 0;
@ -1476,13 +1475,13 @@ namespace netgen
PointIndex v1 = parents[1]; PointIndex v1 = parents[1];
PointIndex v2 = f3[(k+1)%3]; PointIndex v2 = f3[(k+1)%3];
PointIndex v3 = f3[(k+2)%3]; PointIndex v3 = f3[(k+2)%3];
INT<3> parentedge1(v0, v2); IVec<3> parentedge1(v0, v2);
parentedge1.Sort(); parentedge1.Sort();
INT<3> parentedge2(v0, v3); IVec<3> parentedge2(v0, v3);
parentedge2.Sort(); parentedge2.Sort();
INT<3> parentedge3(v1, v2); IVec<3> parentedge3(v1, v2);
parentedge3.Sort(); parentedge3.Sort();
INT<3> parentedge4(v1, v3); IVec<3> parentedge4(v1, v3);
parentedge4.Sort(); parentedge4.Sort();
// if edges [v0,v2], [v0, v3], [v1,v2], [v1,v3] exists // if edges [v0,v2], [v0, v3], [v1,v2], [v1,v3] exists
// then vb is the bisecting edge // then vb is the bisecting edge
@ -1507,13 +1506,13 @@ namespace netgen
// by default v0 < v1 < vb < v2 < v3 // by default v0 < v1 < vb < v2 < v3
classnr=9; classnr=9;
} }
INT<3> parentverts1(v0, v2, v3); IVec<3> parentverts1(v0, v2, v3);
parentverts1.Sort(); parentverts1.Sort();
INT<3> parentverts2(v1, v2, v3); IVec<3> parentverts2(v1, v2, v3);
parentverts2.Sort(); parentverts2.Sort();
INT<3> parentverts3(v0, v1, v2); IVec<3> parentverts3(v0, v1, v2);
parentverts3.Sort(); parentverts3.Sort();
INT<3> parentverts4(v0, v1, v3); IVec<3> parentverts4(v0, v1, v3);
parentverts4.Sort(); parentverts4.Sort();
int pafacenr1=-1, pafacenr2=-1, pafacenr3=-1, pafacenr4=-1; int pafacenr1=-1, pafacenr2=-1, pafacenr3=-1, pafacenr4=-1;
if (v2f.Used(parentverts1)) if (v2f.Used(parentverts1))
@ -1561,13 +1560,13 @@ namespace netgen
PointIndex v1 = parents[1]; PointIndex v1 = parents[1];
PointIndex v2 = f3[(k+1)%3]; PointIndex v2 = f3[(k+1)%3];
PointIndex v3 = f3[(k+2)%3]; PointIndex v3 = f3[(k+2)%3];
INT<2> parentedge1(v0, v2); IVec<2> parentedge1(v0, v2);
parentedge1.Sort(); parentedge1.Sort();
INT<2> parentedge2(v0, v3); IVec<2> parentedge2(v0, v3);
parentedge2.Sort(); parentedge2.Sort();
INT<2> parentedge3(v1, v2); IVec<2> parentedge3(v1, v2);
parentedge3.Sort(); parentedge3.Sort();
INT<2> parentedge4(v1, v3); IVec<2> parentedge4(v1, v3);
parentedge4.Sort(); parentedge4.Sort();
// if edges [v0,v2], [v0, v3], [v1,v2], [v1,v3] exists // if edges [v0,v2], [v0, v3], [v1,v2], [v1,v3] exists
@ -1595,13 +1594,13 @@ namespace netgen
} }
// cout << "classnr = " << classnr << endl; // cout << "classnr = " << classnr << endl;
INT<3> parentverts1(v1, v2, v3); IVec<3> parentverts1(v1, v2, v3);
parentverts1.Sort(); parentverts1.Sort();
INT<3> parentverts2(v0, v2, v3); IVec<3> parentverts2(v0, v2, v3);
parentverts2.Sort(); parentverts2.Sort();
INT<3> parentverts3(v0, v1, v3); IVec<3> parentverts3(v0, v1, v3);
parentverts3.Sort(); parentverts3.Sort();
INT<3> parentverts4(v0, v1, v2); IVec<3> parentverts4(v0, v1, v2);
parentverts4.Sort(); parentverts4.Sort();
if (!v2f.Used(parentverts1) || !v2f.Used(parentverts2) || if (!v2f.Used(parentverts1) || !v2f.Used(parentverts2) ||
@ -1634,17 +1633,17 @@ namespace netgen
// v0 is a coarse vertex ==> f3 is a boundary face // v0 is a coarse vertex ==> f3 is a boundary face
if (v0==pa1[0] || v0==pa1[1]){ if (v0==pa1[0] || v0==pa1[1]){
if (pa1[0]==v0){// type 0: bottom left corner if (pa1[0]==v0){// type 0: bottom left corner
INT<3> parentverts(v0, pa1[1], pa2[1]); IVec<3> parentverts(v0, pa1[1], pa2[1]);
int pafacenr = v2f[parentverts]; int pafacenr = v2f[parentverts];
parent_faces[i] = { 16, { pafacenr, -1, -1, -1} }; parent_faces[i] = { 16, { pafacenr, -1, -1, -1} };
//cout << "f "<<i<<":pf "<< pafacenr<< "A" <<endl; //cout << "f "<<i<<":pf "<< pafacenr<< "A" <<endl;
}else if (pa2[0]==v0) {// type 1: bottom right corner }else if (pa2[0]==v0) {// type 1: bottom right corner
INT<3> parentverts(pa1[0], v0, pa2[1]); IVec<3> parentverts(pa1[0], v0, pa2[1]);
int pafacenr = v2f[parentverts]; int pafacenr = v2f[parentverts];
parent_faces[i] = { 17, { pafacenr, -1, -1, -1} }; parent_faces[i] = { 17, { pafacenr, -1, -1, -1} };
//cout << "f "<<i<<":pf "<< pafacenr<< "B" <<endl; //cout << "f "<<i<<":pf "<< pafacenr<< "B" <<endl;
}else if (pa1[1]==v0){// type 2: top left corner }else if (pa1[1]==v0){// type 2: top left corner
INT<3> parentverts(pa1[0], pa2[0], v0); IVec<3> parentverts(pa1[0], pa2[0], v0);
int pafacenr = v2f[parentverts]; int pafacenr = v2f[parentverts];
parent_faces[i] = { 18, { pafacenr, -1, -1, -1} }; parent_faces[i] = { 18, { pafacenr, -1, -1, -1} };
//cout << "f "<<i<<":pf "<< pafacenr<< "C" <<endl; //cout << "f "<<i<<":pf "<< pafacenr<< "C" <<endl;
@ -1655,7 +1654,7 @@ namespace netgen
else{// all vertices are on fine level [fff] else{// all vertices are on fine level [fff]
// Here we only work with boundary fff face // Here we only work with boundary fff face
if (pa0[0]==pa1[0] && pa0[1]==pa2[0] && pa1[1]==pa2[1]){//type 3 bdry face if (pa0[0]==pa1[0] && pa0[1]==pa2[0] && pa1[1]==pa2[1]){//type 3 bdry face
INT<3> parentverts(pa0[0], pa0[1], pa1[1]); IVec<3> parentverts(pa0[0], pa0[1], pa1[1]);
int pafacenr = v2f[parentverts]; int pafacenr = v2f[parentverts];
parent_faces[i] = { 19, { pafacenr, -1, -1, -1} }; parent_faces[i] = { 19, { pafacenr, -1, -1, -1} };
//cout << "f "<<i<<":pf "<< pafacenr<< "D" <<endl; //cout << "f "<<i<<":pf "<< pafacenr<< "D" <<endl;

View File

@ -669,6 +669,8 @@ namespace netgen
BRepMesh_IncrementalMesh (geom.shape, 0.01, true); BRepMesh_IncrementalMesh (geom.shape, 0.01, true);
triangulation = BRep_Tool::Triangulation (face, loc); triangulation = BRep_Tool::Triangulation (face, loc);
} }
if(triangulation.IsNull())
throw Exception("OCC-Triangulation could not be built. Do you have a bounded shape?");
BRepAdaptor_Surface sf(face, Standard_True); BRepAdaptor_Surface sf(face, Standard_True);
// one prop for evaluating and one for derivatives // one prop for evaluating and one for derivatives

View File

@ -1,6 +1,7 @@
#ifdef NG_PYTHON #ifdef NG_PYTHON
#ifdef OCCGEOMETRY #ifdef OCCGEOMETRY
#include <memory> #include <memory>
#include <general/ngpython.hpp> #include <general/ngpython.hpp>

View File

@ -2,6 +2,7 @@
#ifdef OCCGEOMETRY #ifdef OCCGEOMETRY
#include <mystdlib.h> #include <mystdlib.h>
#include <myadt.hpp> #include <myadt.hpp>
#include <meshing.hpp> #include <meshing.hpp>

View File

@ -1,4 +1,5 @@
#include <mystdlib.h> #include <mystdlib.h>
#include <myadt.hpp> #include <myadt.hpp>
#include <linalg.hpp> #include <linalg.hpp>
#include <csg.hpp> #include <csg.hpp>
@ -6,7 +7,11 @@
#include <meshing.hpp> #include <meshing.hpp>
#include <inctcl.hpp> #include <inctcl.hpp>
#include <visual.hpp> #include <visual.hpp>
#include <stlgeom.hpp> #include <stlgeom.hpp>

View File

@ -239,7 +239,7 @@ namespace netgen
bool SelectSurfaceElement (int px, int py, Point<3> &p, bool select_on_clipping_plane); bool SelectSurfaceElement (int px, int py, Point<3> &p, bool select_on_clipping_plane);
bool Unproject(int px, int py, Point<3> &p); bool Unproject(int px, int py, Point<3> &p);
ngcore::INT<2> Project(Point<3> p); ngcore::IVec<2> Project(Point<3> p);
}; };
void DrawElement(const Mesh & mesh, SurfaceElementIndex sei); void DrawElement(const Mesh & mesh, SurfaceElementIndex sei);

View File

@ -13,10 +13,6 @@ Visualization
*/ */
// #ifdef PARALLEL
// #define PARALLELGL
// #endif
#include "visual_api.hpp" #include "visual_api.hpp"
#include "../include/incopengl.hpp" #include "../include/incopengl.hpp"

View File

@ -1,6 +1,5 @@
#include <mystdlib.h> #include <mystdlib.h>
// #include <incopengl.hpp> // #include <incopengl.hpp>
#include <inctcl.hpp>
#include <myadt.hpp> #include <myadt.hpp>
@ -8,7 +7,7 @@
#include <csg.hpp> #include <csg.hpp>
#include <stlgeom.hpp> #include <stlgeom.hpp>
#include <inctcl.hpp>
// #include <parallel.hpp> // #include <parallel.hpp>
#include <visual.hpp> #include <visual.hpp>

View File

@ -3373,13 +3373,13 @@ namespace netgen
return pz<1 && pz>0; return pz<1 && pz>0;
} }
ngcore::INT<2> VisualSceneMesh :: Project(Point<3> p) ngcore::IVec<2> VisualSceneMesh :: Project(Point<3> p)
{ {
Point<3> pwin; Point<3> pwin;
gluProject(p[0], p[1], p[2], transformationmat, select.projmat, select.viewport, gluProject(p[0], p[1], p[2], transformationmat, select.projmat, select.viewport,
&pwin[0], &pwin[1], &pwin[2]); &pwin[0], &pwin[1], &pwin[2]);
return ngcore::INT<2>(pwin[0]+0.5, select.viewport[3]-pwin[1]+0.5); return ngcore::IVec<2>(pwin[0]+0.5, select.viewport[3]-pwin[1]+0.5);
} }

View File

@ -1,8 +1,13 @@
#include <mystdlib.h> #include <mystdlib.h>
#include <inctcl.hpp>
#include <meshing.hpp> #include <meshing.hpp>
#include <inctcl.hpp>
#include <core/ngcore_api.hpp> #include <core/ngcore_api.hpp>
using std::string;
using std::endl;
using std::cout;
using std::cerr;
namespace netgen namespace netgen
{ {
NGCORE_API_EXPORT Flags parameters; NGCORE_API_EXPORT Flags parameters;

View File

@ -33,6 +33,11 @@ using netgen::verbose;
using netgen::NgArray; using netgen::NgArray;
using netgen::RegisterUserFormats; using netgen::RegisterUserFormats;
using std::string;
using std::endl;
using std::cout;
using std::cerr;
using std::ofstream;