Skip to content
Snippets Groups Projects
Commit 738aaa51 authored by Rafael Ravedutti Lucio Machado's avatar Rafael Ravedutti Lucio Machado
Browse files

Fix DEM case for CMake


Signed-off-by: default avatarRafael Ravedutti <rafael.r.ravedutti@fau.de>
parent e8fd8409
No related merge requests found
...@@ -69,6 +69,7 @@ if(NOT PYTHON_EXECUTABLE) ...@@ -69,6 +69,7 @@ if(NOT PYTHON_EXECUTABLE)
endif() endif()
file(COPY runtime DESTINATION ${CMAKE_BINARY_DIR}) file(COPY runtime DESTINATION ${CMAKE_BINARY_DIR})
file(COPY data DESTINATION ${CMAKE_BINARY_DIR})
execute_process( execute_process(
COMMAND ${PYTHON_EXECUTABLE} setup.py build COMMAND ${PYTHON_EXECUTABLE} setup.py build
...@@ -99,7 +100,6 @@ add_custom_command( ...@@ -99,7 +100,6 @@ add_custom_command(
add_custom_target(gen_cpu DEPENDS ${CMAKE_BINARY_DIR}/${CPU_SRC}) add_custom_target(gen_cpu DEPENDS ${CMAKE_BINARY_DIR}/${CPU_SRC})
add_dependencies(${CPU_BIN} gen_cpu) add_dependencies(${CPU_BIN} gen_cpu)
if(COMPILE_CUDA) if(COMPILE_CUDA)
find_package(CUDA REQUIRED) find_package(CUDA REQUIRED)
enable_language(CUDA) enable_language(CUDA)
......
...@@ -12,20 +12,23 @@ void read_grid_data(PairsRuntime *ps, const char *filename, real_t *grid_buffer) ...@@ -12,20 +12,23 @@ void read_grid_data(PairsRuntime *ps, const char *filename, real_t *grid_buffer)
std::ifstream in_file(filename, std::ifstream::in); std::ifstream in_file(filename, std::ifstream::in);
std::string line; std::string line;
if(in_file.is_open()) { if(!in_file.is_open()) {
std::getline(in_file, line); std::cerr << "Error: Could not open file \"" << filename << "\"" << std::endl;
std::stringstream line_stream(line); exit(-1);
std::string in0; }
int i = 0;
while(std::getline(line_stream, in0, ',')) { std::getline(in_file, line);
//PAIRS_ASSERT(i < ndims * 2); std::stringstream line_stream(line);
grid_buffer[i] = std::stod(in0); std::string in0;
i++; int i = 0;
}
in_file.close(); while(std::getline(line_stream, in0, ',')) {
//PAIRS_ASSERT(i < ndims * 2);
grid_buffer[i] = std::stod(in0);
i++;
} }
in_file.close();
} }
size_t read_particle_data( size_t read_particle_data(
...@@ -37,79 +40,79 @@ size_t read_particle_data( ...@@ -37,79 +40,79 @@ size_t read_particle_data(
auto shape_ptr = ps->getAsIntegerProperty(ps->getPropertyByName("shape")); auto shape_ptr = ps->getAsIntegerProperty(ps->getPropertyByName("shape"));
int n = start; int n = start;
if(in_file.is_open()) { if(!in_file.is_open()) {
//std::getline(in_file, line); std::cerr << "Error: Could not open file \"" << filename << "\"" << std::endl;
while(std::getline(in_file, line)) { exit(-1);
std::stringstream line_stream(line); }
std::string in0;
int within_domain = 1;
int i = 0;
int flags = 0;
while(std::getline(line_stream, in0, ',')) {
property_t p_id = properties[i];
auto prop = ps->getProperty(p_id);
auto prop_type = prop.getType();
if(prop_type == Prop_Vector) { while(std::getline(in_file, line)) {
auto vector_ptr = ps->getAsVectorProperty(prop); std::stringstream line_stream(line);
std::string in1, in2; std::string in0;
std::getline(line_stream, in1, ','); int within_domain = 1;
std::getline(line_stream, in2, ','); int i = 0;
real_t x = std::stod(in0); int flags = 0;
real_t y = std::stod(in1);
real_t z = std::stod(in2);
vector_ptr(n, 0) = x;
vector_ptr(n, 1) = y;
vector_ptr(n, 2) = z;
if(prop.getName() == "position") {
within_domain = ps->getDomainPartitioner()->isWithinSubdomain(x, y, z);
}
} else if(prop_type == Prop_Matrix) {
auto matrix_ptr = ps->getAsMatrixProperty(prop);
constexpr int nelems = 9;
std::string in_buf;
matrix_ptr(n, 0) = std::stod(in0);
for(int e = 1; e < nelems; e++) {
std::getline(line_stream, in_buf, ',');
matrix_ptr(n, e) = std::stod(in_buf);
}
} else if(prop_type == Prop_Quaternion) {
auto quat_ptr = ps->getAsQuaternionProperty(prop);
constexpr int nelems = 4;
std::string in_buf;
quat_ptr(n, 0) = std::stod(in0);
for(int e = 1; e < nelems; e++) {
std::getline(line_stream, in_buf, ',');
quat_ptr(n, e) = std::stod(in_buf);
}
} else if(prop_type == Prop_Integer) {
auto int_ptr = ps->getAsIntegerProperty(prop);
int_ptr(n) = std::stoi(in0);
if(prop.getName() == "flags") { while(std::getline(line_stream, in0, ',')) {
flags = int_ptr(n); property_t p_id = properties[i];
} auto prop = ps->getProperty(p_id);
} else if(prop_type == Prop_Real) { auto prop_type = prop.getType();
auto float_ptr = ps->getAsFloatProperty(prop);
float_ptr(n) = std::stod(in0); if(prop_type == Prop_Vector) {
} else { auto vector_ptr = ps->getAsVectorProperty(prop);
std::cerr << "read_particle_data(): Invalid property type!" << std::endl; std::string in1, in2;
return 0; std::getline(line_stream, in1, ',');
std::getline(line_stream, in2, ',');
real_t x = std::stod(in0);
real_t y = std::stod(in1);
real_t z = std::stod(in2);
vector_ptr(n, 0) = x;
vector_ptr(n, 1) = y;
vector_ptr(n, 2) = z;
if(prop.getName() == "position") {
within_domain = ps->getDomainPartitioner()->isWithinSubdomain(x, y, z);
}
} else if(prop_type == Prop_Matrix) {
auto matrix_ptr = ps->getAsMatrixProperty(prop);
constexpr int nelems = 9;
std::string in_buf;
matrix_ptr(n, 0) = std::stod(in0);
for(int e = 1; e < nelems; e++) {
std::getline(line_stream, in_buf, ',');
matrix_ptr(n, e) = std::stod(in_buf);
}
} else if(prop_type == Prop_Quaternion) {
auto quat_ptr = ps->getAsQuaternionProperty(prop);
constexpr int nelems = 4;
std::string in_buf;
quat_ptr(n, 0) = std::stod(in0);
for(int e = 1; e < nelems; e++) {
std::getline(line_stream, in_buf, ',');
quat_ptr(n, e) = std::stod(in_buf);
} }
} else if(prop_type == Prop_Integer) {
auto int_ptr = ps->getAsIntegerProperty(prop);
int_ptr(n) = std::stoi(in0);
i++; if(prop.getName() == "flags") {
flags = int_ptr(n);
}
} else if(prop_type == Prop_Real) {
auto float_ptr = ps->getAsFloatProperty(prop);
float_ptr(n) = std::stod(in0);
} else {
std::cerr << "read_particle_data(): Invalid property type!" << std::endl;
return 0;
} }
if(within_domain || flags & (FLAGS_INFINITE | FLAGS_FIXED | FLAGS_GLOBAL)) { i++;
shape_ptr(n++) = shape_id;
}
} }
in_file.close(); if(within_domain || flags & (FLAGS_INFINITE | FLAGS_FIXED | FLAGS_GLOBAL)) {
shape_ptr(n++) = shape_id;
}
} }
return n; return n;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment