tetrahedron orientation test
This commit is contained in:
@ -18,6 +18,8 @@
|
||||
#include <cuda_runtime.h>
|
||||
#include <cuda.h>
|
||||
|
||||
#include <amsculib3/amsculib3.hpp>
|
||||
|
||||
//Dependencies
|
||||
|
||||
//Predeclarations
|
||||
@ -30,46 +32,121 @@ class cuvec4f;
|
||||
|
||||
//Need a way to define the same symbols using both host and device code
|
||||
//A solution was found here: https://stackoverflow.com/questions/9457572/cuda-host-and-device-using-same-constant-memory
|
||||
#ifdef __CUDA_ARCH__
|
||||
#define AMSCU_CONST __constant__
|
||||
#else
|
||||
#define AMSCU_CONST
|
||||
#endif
|
||||
// #ifdef __CUDA_ARCH__
|
||||
// #define AMSCU_CONST __constant__
|
||||
// #else
|
||||
// #define AMSCU_CONST
|
||||
// #endif
|
||||
|
||||
namespace amscuda
|
||||
{
|
||||
namespace fractallevelset
|
||||
{
|
||||
|
||||
//default thread and block execution
|
||||
AMSCU_CONST static const int amscu_defnblocks = 256;
|
||||
AMSCU_CONST static const int amscu_defnthreads = 512;
|
||||
__device__ __host__ int isignf(float f);
|
||||
|
||||
//default numthreads to execute on cpu
|
||||
AMSCU_CONST static const int amscu_defcputhreads = 8;
|
||||
class bagoftriangles
|
||||
{
|
||||
public:
|
||||
cuarray<float> vertices;
|
||||
|
||||
AMSCU_CONST static const int amscu_success = 1;
|
||||
AMSCU_CONST static const int amscu_meh = 0;
|
||||
AMSCU_CONST static const int amscu_failure = -1;
|
||||
__host__ int ntris() const {return vertices.length/9;}
|
||||
__host__ int nverts() const {return vertices.length/3;}
|
||||
|
||||
__host__ bagoftriangles();
|
||||
__host__ ~bagoftriangles();
|
||||
|
||||
__host__ int save_stl(const char *fname);
|
||||
|
||||
};
|
||||
|
||||
class triangle
|
||||
{
|
||||
public:
|
||||
cuvec3f p0;
|
||||
cuvec3f p1;
|
||||
cuvec3f p2;
|
||||
|
||||
cuvec3f normal() const;
|
||||
float area() const;
|
||||
__device__ __host__ triangle();
|
||||
__device__ __host__ ~triangle();
|
||||
};
|
||||
|
||||
}; //end namespace amscuda
|
||||
class tetrahedron
|
||||
{
|
||||
public:
|
||||
cuvec3f p0;
|
||||
cuvec3f p1;
|
||||
cuvec3f p2;
|
||||
cuvec3f p3;
|
||||
|
||||
//Components
|
||||
#include <amsculib3/amscu_cudafunctions.hpp>
|
||||
#include <amsculib3/math/amscumath.hpp>
|
||||
#include <amsculib3/geom/amscugeom.hpp>
|
||||
#include <amsculib3/util/amscu_util.hpp>
|
||||
__device__ __host__ float volume();
|
||||
__device__ __host__ int volume_sign();
|
||||
|
||||
#include <amsculib3/amscuarray.hpp>
|
||||
#include <amsculib3/amscuda_binarrrw.hpp>
|
||||
__device__ __host__ tetrahedron();
|
||||
__device__ __host__ ~tetrahedron();
|
||||
};
|
||||
|
||||
#include <amsculib3/random/amscurandom.cuh>
|
||||
class tetrahedron_feinds
|
||||
{
|
||||
public:
|
||||
int index0;
|
||||
int index1;
|
||||
int index2;
|
||||
int index3;
|
||||
float eval0;
|
||||
float eval1;
|
||||
float eval2;
|
||||
float eval3;
|
||||
|
||||
#include <amsculib3/amscuarray_dops.hpp>
|
||||
__device__ __host__ tetrahedron_feinds();
|
||||
__device__ __host__ ~tetrahedron_feinds();
|
||||
__device__ __host__ int trianglecount();
|
||||
|
||||
#include <amsculib3/amscurarray.cuh>
|
||||
};
|
||||
|
||||
class mtcube
|
||||
{
|
||||
public:
|
||||
cuvec3f xyz_min;
|
||||
cuvec3f xyz_max;
|
||||
|
||||
float fevals[15];
|
||||
|
||||
__device__ __host__ cuvec3f get_point(const int node_index) const; //node_index [0,15)
|
||||
//corner nodes (0,1,2,3,4,5,6,7)
|
||||
//center node 8
|
||||
//face center nodes 9,10,11,12,13,14
|
||||
__device__ __host__ tetrahedron get_tetrahedron(const int tet_index) const; //tet_index [0,24)
|
||||
__device__ __host__ tetrahedron_feinds get_feinds(const int tet_index) const; //tet_index [0,24)
|
||||
__device__ __host__ void eval_function(); //calls a function under consideration at each of the 15 node points
|
||||
|
||||
__device__ __host__ mtcube();
|
||||
__device__ __host__ ~mtcube();
|
||||
};
|
||||
|
||||
struct marchingtet_pars
|
||||
{
|
||||
public:
|
||||
cuvec3f xyz_min;
|
||||
cuvec3f xyz_max;
|
||||
int Nx;
|
||||
int Ny;
|
||||
int Nz;
|
||||
|
||||
int fractaliter;
|
||||
|
||||
__device__ __host__ marchingtet_pars();
|
||||
};
|
||||
|
||||
void test_tetorientation();
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user