mirror of
https://git.gfz-potsdam.de/naaice/poet.git
synced 2025-12-16 12:54:50 +01:00
Update include statement and add CMakeLists.txt for DataStructures
This commit is contained in:
parent
8cd69bcde4
commit
2797351057
@ -1,3 +1,5 @@
|
|||||||
|
add_subdirectory(DataStructures)
|
||||||
|
|
||||||
add_library(poetinitlib
|
add_library(poetinitlib
|
||||||
Init/InitialList.cpp
|
Init/InitialList.cpp
|
||||||
Init/GridInit.cpp
|
Init/GridInit.cpp
|
||||||
@ -5,6 +7,7 @@ add_library(poetinitlib
|
|||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(poetinitlib PUBLIC
|
target_link_libraries(poetinitlib PUBLIC
|
||||||
|
DataStructures
|
||||||
RRuntime
|
RRuntime
|
||||||
IPhreeqcPOET
|
IPhreeqcPOET
|
||||||
tug
|
tug
|
||||||
@ -27,11 +30,11 @@ add_library(poetlib
|
|||||||
Chemistry/SurrogateModels/HashFunctions.cpp
|
Chemistry/SurrogateModels/HashFunctions.cpp
|
||||||
Chemistry/SurrogateModels/InterpolationModule.cpp
|
Chemistry/SurrogateModels/InterpolationModule.cpp
|
||||||
Chemistry/SurrogateModels/ProximityHashTable.cpp
|
Chemistry/SurrogateModels/ProximityHashTable.cpp
|
||||||
DataStructures/Field.cpp
|
|
||||||
Transport/DiffusionModule.cpp
|
Transport/DiffusionModule.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(poetlib PUBLIC
|
target_link_libraries(poetlib PUBLIC
|
||||||
|
DataStructures
|
||||||
MPI::MPI_C
|
MPI::MPI_C
|
||||||
${MATH_LIBRARY}
|
${MATH_LIBRARY}
|
||||||
RRuntime
|
RRuntime
|
||||||
|
|||||||
@ -17,6 +17,20 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace poet {
|
namespace poet {
|
||||||
|
|
||||||
|
struct WorkPackage {
|
||||||
|
std::size_t size;
|
||||||
|
std::vector<std::vector<double>> input;
|
||||||
|
std::vector<std::vector<double>> output;
|
||||||
|
std::vector<std::uint8_t> mapping;
|
||||||
|
|
||||||
|
WorkPackage(size_t _size) : size(_size) {
|
||||||
|
input.resize(size);
|
||||||
|
output.resize(size);
|
||||||
|
mapping.resize(size, CHEM_PQC);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
inline std::string get_string(int root, MPI_Comm communicator) {
|
inline std::string get_string(int root, MPI_Comm communicator) {
|
||||||
int count;
|
int count;
|
||||||
MPI_Bcast(&count, 1, MPI_INT, root, communicator);
|
MPI_Bcast(&count, 1, MPI_INT, root, communicator);
|
||||||
|
|||||||
11
src/DataStructures/CMakeLists.txt
Normal file
11
src/DataStructures/CMakeLists.txt
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
add_library(DataStructures OBJECT
|
||||||
|
Field.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(DataStructures
|
||||||
|
PUBLIC RRuntime
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(DataStructures
|
||||||
|
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
)
|
||||||
@ -1,4 +1,4 @@
|
|||||||
#include "DataStructures.hpp"
|
#include "Field.hpp"
|
||||||
|
|
||||||
#include <Rcpp.h>
|
#include <Rcpp.h>
|
||||||
#include <Rinternals.h>
|
#include <Rinternals.h>
|
||||||
|
|||||||
@ -1,54 +1,14 @@
|
|||||||
#ifndef DATASTRUCTURES_H_
|
#ifndef DATASTRUCTURES_H_
|
||||||
#define DATASTRUCTURES_H_
|
#define DATASTRUCTURES_H_
|
||||||
|
|
||||||
#include "../Chemistry/enums.hpp"
|
|
||||||
|
|
||||||
#include <Rcpp.h>
|
#include <Rcpp.h>
|
||||||
|
|
||||||
#include <cassert>
|
|
||||||
#include <cinttypes>
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <iostream>
|
|
||||||
#include <list>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace poet {
|
namespace poet {
|
||||||
|
|
||||||
struct WorkPackage {
|
|
||||||
std::size_t size;
|
|
||||||
std::vector<std::vector<double>> input;
|
|
||||||
std::vector<std::vector<double>> output;
|
|
||||||
std::vector<std::uint8_t> mapping;
|
|
||||||
|
|
||||||
WorkPackage(size_t _size) : size(_size) {
|
|
||||||
input.resize(size);
|
|
||||||
output.resize(size);
|
|
||||||
mapping.resize(size, CHEM_PQC);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T> class NamedVector : public Rcpp::NumericVector {
|
|
||||||
public:
|
|
||||||
NamedVector() : Rcpp::NumericVector(){};
|
|
||||||
|
|
||||||
NamedVector(const std::vector<std::string> &in_names,
|
|
||||||
const std::vector<T> &in_values)
|
|
||||||
: Rcpp::NumericVector(Rcpp::wrap(in_values)) {
|
|
||||||
this->names() = Rcpp::CharacterVector(Rcpp::wrap(in_names));
|
|
||||||
}
|
|
||||||
|
|
||||||
NamedVector(const SEXP &s) : Rcpp::NumericVector(s){};
|
|
||||||
|
|
||||||
bool empty() const { return (this->size() == 0); }
|
|
||||||
|
|
||||||
std::vector<std::string> getNames() const {
|
|
||||||
return Rcpp::as<std::vector<std::string>>(this->names());
|
|
||||||
}
|
|
||||||
std::vector<T> getValues() const { return Rcpp::as<std::vector<T>>(*this); }
|
|
||||||
};
|
|
||||||
|
|
||||||
using FieldColumn = std::vector<double>;
|
using FieldColumn = std::vector<double>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
25
src/DataStructures/NamedVector.hpp
Normal file
25
src/DataStructures/NamedVector.hpp
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Rcpp.h>
|
||||||
|
|
||||||
|
namespace poet {
|
||||||
|
template <typename T> class NamedVector : public Rcpp::NumericVector {
|
||||||
|
public:
|
||||||
|
NamedVector() : Rcpp::NumericVector(){};
|
||||||
|
|
||||||
|
NamedVector(const std::vector<std::string> &in_names,
|
||||||
|
const std::vector<T> &in_values)
|
||||||
|
: Rcpp::NumericVector(Rcpp::wrap(in_values)) {
|
||||||
|
this->names() = Rcpp::CharacterVector(Rcpp::wrap(in_names));
|
||||||
|
}
|
||||||
|
|
||||||
|
NamedVector(const SEXP &s) : Rcpp::NumericVector(s){};
|
||||||
|
|
||||||
|
bool empty() const { return (this->size() == 0); }
|
||||||
|
|
||||||
|
std::vector<std::string> getNames() const {
|
||||||
|
return Rcpp::as<std::vector<std::string>>(this->names());
|
||||||
|
}
|
||||||
|
std::vector<T> getValues() const { return Rcpp::as<std::vector<T>>(*this); }
|
||||||
|
};
|
||||||
|
} // namespace poet
|
||||||
Loading…
x
Reference in New Issue
Block a user