Skip to content
Snippets Groups Projects
Commit 2dca66c5 authored by Behzad Safaei's avatar Behzad Safaei
Browse files

Add flags and shapes namespaces

parent 887e461b
No related branches found
No related tags found
No related merge requests found
...@@ -16,9 +16,9 @@ id_t create_halfspace(PairsRuntime *pr, ...@@ -16,9 +16,9 @@ id_t create_halfspace(PairsRuntime *pr,
auto positions = pr->getAsVectorProperty(pr->getPropertyByName("position")); auto positions = pr->getAsVectorProperty(pr->getPropertyByName("position"));
auto normals = pr->getAsVectorProperty(pr->getPropertyByName("normal")); auto normals = pr->getAsVectorProperty(pr->getPropertyByName("normal"));
if(pr->getDomainPartitioner()->isWithinSubdomain(x, y, z) || flag & (FLAGS_INFINITE | FLAGS_FIXED | FLAGS_GLOBAL) ){ if(pr->getDomainPartitioner()->isWithinSubdomain(x, y, z) || flag & (flags::INFINITE | flags::GLOBAL) ){
int n = pr->getTrackedVariableAsInteger("nlocal"); int n = pr->getTrackedVariableAsInteger("nlocal");
uid = (flag & FLAGS_GLOBAL) ? UniqueID::createGlobal(pr) : UniqueID::create(pr); uid = (flag & flags::GLOBAL) ? UniqueID::createGlobal(pr) : UniqueID::create(pr);
uids(n) = uid; uids(n) = uid;
positions(n, 0) = x; positions(n, 0) = x;
positions(n, 1) = y; positions(n, 1) = y;
...@@ -53,7 +53,7 @@ id_t create_sphere(PairsRuntime *pr, ...@@ -53,7 +53,7 @@ id_t create_sphere(PairsRuntime *pr,
if(pr->getDomainPartitioner()->isWithinSubdomain(x, y, z)) { if(pr->getDomainPartitioner()->isWithinSubdomain(x, y, z)) {
int n = pr->getTrackedVariableAsInteger("nlocal"); int n = pr->getTrackedVariableAsInteger("nlocal");
uid = (flag & FLAGS_GLOBAL) ? UniqueID::createGlobal(pr) : UniqueID::create(pr); uid = (flag & flags::GLOBAL) ? UniqueID::createGlobal(pr) : UniqueID::create(pr);
uids(n) = uid; uids(n) = uid;
radii(n) = radius; radii(n) = radius;
masses(n) = ((4.0 / 3.0) * M_PI) * radius * radius * radius * density; masses(n) = ((4.0 / 3.0) * M_PI) * radius * radius * radius * density;
......
...@@ -15,11 +15,20 @@ namespace pairs { ...@@ -15,11 +15,20 @@ namespace pairs {
#define PAIRS_ATTR_HOST_DEVICE #define PAIRS_ATTR_HOST_DEVICE
#endif #endif
constexpr int FLAGS_INFINITE = 1 << 0 ; namespace flags{
constexpr int FLAGS_GHOST = 1 << 1 ; constexpr int INFINITE = 1 << 0 ;
constexpr int FLAGS_FIXED = 1 << 2 ; constexpr int GHOST = 1 << 1 ;
constexpr int FLAGS_GLOBAL = 1 << 3 ; constexpr int FIXED = 1 << 2 ;
constexpr int GLOBAL = 1 << 3 ;
}
namespace shapes{
enum Type {
Sphere = 0,
Halfspace = 1,
PointMass = 2
};
}
//#ifdef USE_DOUBLE_PRECISION //#ifdef USE_DOUBLE_PRECISION
typedef double real_t; typedef double real_t;
//#else //#else
......
...@@ -114,8 +114,8 @@ size_t read_particle_data( ...@@ -114,8 +114,8 @@ size_t read_particle_data(
i++; i++;
} }
if(within_domain || flags & (FLAGS_INFINITE | FLAGS_FIXED | FLAGS_GLOBAL)) { if(within_domain || flags & (flags::INFINITE | flags::FIXED | flags::GLOBAL)) {
uid_ptr(n) = (flags & FLAGS_GLOBAL) ? UniqueID::createGlobal(ps) : UniqueID::create(ps); uid_ptr(n) = (flags & flags::GLOBAL) ? UniqueID::createGlobal(ps) : UniqueID::create(ps);
shape_ptr(n++) = shape_id; shape_ptr(n++) = shape_id;
} }
} }
......
...@@ -34,7 +34,7 @@ void vtk_write_data( ...@@ -34,7 +34,7 @@ void vtk_write_data(
ps->copyPropertyToHost(flags, ReadOnly); ps->copyPropertyToHost(flags, ReadOnly);
for(int i = start; i < end; i++) { for(int i = start; i < end; i++) {
if(flags(i) & FLAGS_INFINITE) { if(flags(i) & flags::INFINITE) {
n--; n--;
} }
} }
...@@ -47,7 +47,7 @@ void vtk_write_data( ...@@ -47,7 +47,7 @@ void vtk_write_data(
out_file << "POINTS " << n << " double\n"; out_file << "POINTS " << n << " double\n";
for(int i = start; i < end; i++) { for(int i = start; i < end; i++) {
if(!(flags(i) & FLAGS_INFINITE)) { if(!(flags(i) & flags::INFINITE)) {
out_file << std::fixed << std::setprecision(prec) << positions(i, 0) << " "; out_file << std::fixed << std::setprecision(prec) << positions(i, 0) << " ";
out_file << std::fixed << std::setprecision(prec) << positions(i, 1) << " "; out_file << std::fixed << std::setprecision(prec) << positions(i, 1) << " ";
out_file << std::fixed << std::setprecision(prec) << positions(i, 2) << "\n"; out_file << std::fixed << std::setprecision(prec) << positions(i, 2) << "\n";
...@@ -63,7 +63,7 @@ void vtk_write_data( ...@@ -63,7 +63,7 @@ void vtk_write_data(
out_file << "\n\n"; out_file << "\n\n";
out_file << "CELL_TYPES " << n << "\n"; out_file << "CELL_TYPES " << n << "\n";
for(int i = start; i < end; i++) { for(int i = start; i < end; i++) {
if(!(flags(i) & FLAGS_INFINITE)) { if(!(flags(i) & flags::INFINITE)) {
out_file << "1\n"; out_file << "1\n";
} }
} }
...@@ -73,7 +73,7 @@ void vtk_write_data( ...@@ -73,7 +73,7 @@ void vtk_write_data(
out_file << "SCALARS mass double\n"; out_file << "SCALARS mass double\n";
out_file << "LOOKUP_TABLE default\n"; out_file << "LOOKUP_TABLE default\n";
for(int i = start; i < end; i++) { for(int i = start; i < end; i++) {
if(!(flags(i) & FLAGS_INFINITE)) { if(!(flags(i) & flags::INFINITE)) {
out_file << std::fixed << std::setprecision(prec) << masses(i) << "\n"; out_file << std::fixed << std::setprecision(prec) << masses(i) << "\n";
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment