Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ add_executable(
tests/test_rd_grid_bounds_checking.cpp
tests/test_rd_sum.cpp
tests/test_rd_type.cpp
tests/test_time_index.cpp
tests/test_rd_kw.cpp
tests/test_well_info.cpp
tests/test_well_keyword_validation.cpp
Expand Down
3 changes: 2 additions & 1 deletion lib/include/resdata/FortIO.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ class FortIO {
bool data_fskip(size_t element_size, size_t element_count,
size_t block_count);
void data_fseek(offset_type data_offset, size_t data_element,
size_t element_size, int element_count, int block_size);
size_t element_size, size_t element_count,
size_t block_size);
bool ftruncate(offset_type size);
int fclean();
bool fclose_stream();
Expand Down
2 changes: 1 addition & 1 deletion lib/include/resdata/rd_file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class File {
size_t occurence) {
return global_view->blockview(kw, kw, occurence);
}
std::shared_ptr<rd::FileView> summary_view(int report_step) {
std::shared_ptr<rd::FileView> summary_view(size_t report_step) {
return global_view->summary_view(report_step);
}

Expand Down
12 changes: 6 additions & 6 deletions lib/include/resdata/rd_file_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ class FileView {

/** Validates the arguments of index_fload_kw and returns the keyword.

Throws std::invalid_argument if @index is negative, if there is no
such keyword in the view, if the keyword does not hold data of type
Throws std::invalid_argument if there is no such keyword in the
view, if the keyword does not hold data of type
@expected, or if @out_count is smaller than @requested_count. */
[[nodiscard]] std::shared_ptr<FileKW>
validate_index_fload_kw(const std::string &kw, int index,
validate_index_fload_kw(const std::string &kw, size_t index,
rd_type_enum expected, size_t requested_count,
size_t out_count) const;

Expand Down Expand Up @@ -159,8 +159,8 @@ class FileView {
Throws std::ios_base::failure if the underlying file cannot be
opened; @out is only left unwritten when this function throws. */
template <typename T, size_t N>
void index_fload_kw(const std::string &kw, int index,
const std::vector<int> &index_map,
void index_fload_kw(const std::string &kw, size_t index,
const std::vector<size_t> &index_map,
std::array<T, N> &out) {
auto file_kw = validate_index_fload_kw(kw, index, iotype<T>::tag,
index_map.size(), N);
Expand Down Expand Up @@ -217,7 +217,7 @@ class FileView {
std::shared_ptr<FileView> restart_view_from_sim_time(time_t sim_time);
std::shared_ptr<FileView> restart_view_from_sim_days(double sim_days);

std::shared_ptr<FileView> summary_view(int report_step);
std::shared_ptr<FileView> summary_view(size_t report_step);

void close();
/** Write the index of this view to @ostream.
Expand Down
4 changes: 2 additions & 2 deletions lib/include/resdata/rd_kw.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ class KW {
the start of the keyword (i.e. its header) in the file, as stored by
rd_file_kw. */
static void fread_indexed_data(ERT::FortIO &fortio, offset_type kw_offset,
rd_data_type data_type, int element_count,
const std::vector<int> &index_map,
rd_data_type data_type, size_t element_count,
const std::vector<size_t> &index_map,
char *io_buffer);
static std::unique_ptr<rd::KW> make_actnum(const rd::KW *porv_kw,
float porv_limit);
Expand Down
52 changes: 27 additions & 25 deletions lib/include/resdata/rd_smspec.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <ctime>

#include <memory>
#include <optional>
#include <variant>
#include <vector>
#include <string>
Expand All @@ -16,15 +17,15 @@ namespace rd {

/** A summary which stores elapsed time in a TIME vector. */
struct TimeParamsIndex {
int params_index;
size_t params_index;
int seconds_per_unit;
};

/** A summary which stores the time of each step as a whole date. */
struct DateParamsIndex {
int day;
int month;
int year;
size_t day;
size_t month;
size_t year;
};

using TimeInfo = std::variant<TimeParamsIndex, DateParamsIndex>;
Expand All @@ -41,10 +42,11 @@ const rd::smspec_node &
rd_smspec_get_general_var_node(const rd_smspec_type *smspec,
const char *lookup_kw);
const rd::smspec_node &
rd_smspec_iget_node_w_node_index(const rd_smspec_type *smspec, int node_index);
rd_smspec_iget_node_w_node_index(const rd_smspec_type *smspec,
size_t node_index);
const rd::smspec_node &
rd_smspec_iget_node_w_params_index(const rd_smspec_type *smspec,
int params_index);
size_t params_index);
/**
These are the different variable types, see table 3.4 in the
ECLIPSE file format docuemntation for naming conventions.
Expand All @@ -55,9 +57,11 @@ rd_smspec_iget_node_w_params_index(const rd_smspec_type *smspec,
rd_smspec_install_gen_key() must be updated.
*/

std::vector<int> rd_smspec_alloc_mapping(const rd_smspec_type *self,
const rd_smspec_type *other);
const int *rd_smspec_get_index_map(const rd_smspec_type *smspec);
std::vector<std::optional<size_t>>
rd_smspec_alloc_mapping(const rd_smspec_type *self,
const rd_smspec_type *other);
const std::vector<size_t> &
rd_smspec_get_index_map(const rd_smspec_type *smspec);
rd_smspec_var_type rd_smspec_identify_var_type(const char *var);
rd_smspec_type *rd_smspec_alloc_restart_writer(
const char *key_join_string, const char *restart_case, int restart_step,
Expand All @@ -74,8 +78,8 @@ rd_smspec_type *rd_smspec_fread_alloc(const std::string &header_file,
bool include_restart);
void rd_smspec_free(rd_smspec_type *);

int rd_smspec_get_general_var_params_index(const rd_smspec_type *rd_smspec,
const char *lookup_kw);
size_t rd_smspec_get_general_var_params_index(const rd_smspec_type *rd_smspec,
const char *lookup_kw);
bool rd_smspec_has_general_var(const rd_smspec_type *rd_smspec,
const char *lookup_kw);
std::vector<std::string>
Expand All @@ -91,12 +95,12 @@ std::vector<std::string> rd_smspec_alloc_well_list(const rd_smspec_type *smspec,
const char *pattern);
std::vector<std::string>
rd_smspec_alloc_group_list(const rd_smspec_type *smspec, const char *pattern);
int rd_smspec_get_first_step(const rd_smspec_type *rd_smspec);
size_t rd_smspec_get_first_step(const rd_smspec_type *rd_smspec);
int rd_smspec_get_restart_step(const rd_smspec_type *rd_smspec);
const char *rd_smspec_get_restart_case(const rd_smspec_type *rd_smspec);
const int *rd_smspec_get_grid_dims(const rd_smspec_type *smspec);
int rd_smspec_get_params_size(const rd_smspec_type *smspec);
int rd_smspec_num_nodes(const rd_smspec_type *smspec);
size_t rd_smspec_get_params_size(const rd_smspec_type *smspec);
size_t rd_smspec_num_nodes(const rd_smspec_type *smspec);
bool rd_smspec_equal(const rd_smspec_type *self, const rd_smspec_type *other);
UnitSystem rd_smspec_get_unit_system(const rd_smspec_type *smspec);

Expand All @@ -123,18 +127,16 @@ const rd::smspec_node *rd_smspec_add_node(rd_smspec_type *rd_smspec,
const char *unit,
float default_value);

const rd::smspec_node *rd_smspec_add_node(rd_smspec_type *rd_smspec,
int params_index, const char *keyword,
const char *wgname, int num,
const char *unit,
float default_value);
const rd::smspec_node *
rd_smspec_add_node(rd_smspec_type *rd_smspec, size_t params_index,
const char *keyword, const char *wgname, int num,
const char *unit, float default_value);

const rd::smspec_node *rd_smspec_add_node(rd_smspec_type *rd_smspec,
int params_index, const char *keyword,
const char *wgname, int num,
const char *unit, const char *lgr,
int lgr_i, int lgr_j, int lgr_k,
float default_value);
const rd::smspec_node *
rd_smspec_add_node(rd_smspec_type *rd_smspec, size_t params_index,
const char *keyword, const char *wgname, int num,
const char *unit, const char *lgr, int lgr_i, int lgr_j,
int lgr_k, float default_value);

using rd_smspec_ptr =
std::unique_ptr<rd_smspec_type, decltype(&rd_smspec_free)>;
Expand Down
45 changes: 25 additions & 20 deletions lib/include/resdata/rd_sum.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,17 @@ double rd_sum_get_from_sim_time(const rd_sum_type *rd_sum, time_t sim_time,
const rd::smspec_node *node);
double rd_sum_time2days(const rd_sum_type *rd_sum, time_t sim_time);

int rd_sum_get_report_step_from_time(const rd_sum_type *sum, time_t sim_time);
int rd_sum_get_report_step_from_days(const rd_sum_type *sum, double sim_days);
std::optional<size_t> rd_sum_get_report_step_from_time(const rd_sum_type *sum,
time_t sim_time);
std::optional<size_t> rd_sum_get_report_step_from_days(const rd_sum_type *sum,
double sim_days);
bool rd_sum_check_sim_time(const rd_sum_type *sum, time_t sim_time);
bool rd_sum_check_sim_days(const rd_sum_type *sum, double sim_days);
const char *rd_sum_get_unit(const rd_sum_type *sum, const char *gen_key);

double rd_sum_iget(const rd_sum_type *rd_sum, int time_index, int param_index);
int rd_sum_get_data_length(const rd_sum_type *rd_sum);
double rd_sum_iget(const rd_sum_type *rd_sum, size_t time_index,
size_t param_index);
size_t rd_sum_get_data_length(const rd_sum_type *rd_sum);

rd_sum_type *rd_sum_fread_alloc(const char *,
const std::vector<std::string> &data_files,
Expand All @@ -49,10 +52,10 @@ rd_sum_ptr rd_sum_alloc_resample(const rd_sum_type *rd_sum, const char *rd_case,
bool lower_extrapolation,
bool upper_extrapolation);

double rd_sum_get_general_var(const rd_sum_type *rd_sum, int time_index,
double rd_sum_get_general_var(const rd_sum_type *rd_sum, size_t time_index,
const char *lookup_kw);
int rd_sum_get_general_var_params_index(const rd_sum_type *rd_sum,
const char *lookup_kw);
size_t rd_sum_get_general_var_params_index(const rd_sum_type *rd_sum,
const char *lookup_kw);
const rd::smspec_node *rd_sum_get_general_var_node(const rd_sum_type *rd_sum,
const char *lookup_kw);
bool rd_sum_has_general_var(const rd_sum_type *rd_sum, const char *lookup_kw);
Expand All @@ -64,19 +67,21 @@ double rd_sum_get_general_var_from_sim_time(const rd_sum_type *rd_sum,
UnitSystem rd_sum_get_unit_system(const rd_sum_type *rd_sum);

int rd_sum_get_restart_step(const rd_sum_type *rd_sum);
int rd_sum_get_first_gt(const rd_sum_type *rd_sum, int param_index,
double limit);
int rd_sum_get_first_lt(const rd_sum_type *rd_sum, int param_index,
double limit);
int rd_sum_get_last_report_step(const rd_sum_type *rd_sum);
int rd_sum_get_first_report_step(const rd_sum_type *rd_sum);
time_t rd_sum_get_report_time(const rd_sum_type *rd_sum, int report_step);
time_t rd_sum_iget_sim_time(const rd_sum_type *rd_sum, int index);
double rd_sum_iget_sim_days(const rd_sum_type *rd_sum, int time_index);
int rd_sum_iget_report_step(const rd_sum_type *rd_sum, int internal_index);
std::optional<size_t> rd_sum_get_first_gt(const rd_sum_type *rd_sum,
size_t param_index, double limit);
std::optional<size_t> rd_sum_get_first_lt(const rd_sum_type *rd_sum,
size_t param_index, double limit);
size_t rd_sum_get_last_report_step(const rd_sum_type *rd_sum);
size_t rd_sum_get_first_report_step(const rd_sum_type *rd_sum);
time_t rd_sum_get_report_time(const rd_sum_type *rd_sum, size_t report_step);
time_t rd_sum_iget_sim_time(const rd_sum_type *rd_sum, size_t index);
double rd_sum_iget_sim_days(const rd_sum_type *rd_sum, size_t time_index);
size_t rd_sum_iget_report_step(const rd_sum_type *rd_sum,
size_t internal_index);

std::vector<double> rd_sum_alloc_data_vector(const rd_sum_type *rd_sum,
int data_index, bool report_only);
size_t data_index,
bool report_only);
std::vector<time_t> rd_sum_alloc_time_vector(const rd_sum_type *rd_sum,
bool report_only);
time_t rd_sum_get_data_start(const rd_sum_type *rd_sum);
Expand All @@ -102,7 +107,7 @@ rd_sum_select_matching_general_var_list(const rd_sum_type *rd_sum,
rd_smspec_type *rd_sum_get_smspec(const rd_sum_type *rd_sum);
rd_smspec_var_type rd_sum_identify_var_type(const char *var);

int rd_sum_iget_report_end(const rd_sum_type *rd_sum, int report_step);
size_t rd_sum_iget_report_end(const rd_sum_type *rd_sum, size_t report_step);
void rd_sum_set_case(rd_sum_type *rd_sum, const std::string &input_arg);
void rd_sum_fwrite(const rd_sum_type *rd_sum);
bool rd_sum_can_write(const rd_sum_type *rd_sum);
Expand All @@ -117,7 +122,7 @@ const rd::smspec_node *rd_sum_add_local_var(rd_sum_type *rd_sum,
const char *unit, const char *lgr,
int lgr_i, int lgr_j, int lgr_k,
float default_value);
rd_sum_tstep_type *rd_sum_add_tstep(rd_sum_type *rd_sum, int report_step,
rd_sum_tstep_type *rd_sum_add_tstep(rd_sum_type *rd_sum, size_t report_step,
double sim_seconds);

void rd_sum_export_csv(const rd_sum_type *rd_sum, const std::string &filename,
Expand Down
55 changes: 32 additions & 23 deletions lib/include/resdata/rd_sum_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <ctime>

#include <memory>
#include <optional>
#include <vector>
#include <string>

Expand All @@ -25,36 +26,43 @@ bool rd_sum_data_fread(rd_sum_data_type *data,
rd_sum_data_type *rd_sum_data_alloc_writer(rd_smspec_type *smspec);
rd_sum_data_type *rd_sum_data_alloc(rd_smspec_type *smspec);
double rd_sum_data_time2days(const rd_sum_data_type *data, time_t sim_time);
int rd_sum_data_get_report_step_from_time(const rd_sum_data_type *data,
time_t sim_time);
int rd_sum_data_get_report_step_from_days(const rd_sum_data_type *data,
double days);
std::optional<size_t>
rd_sum_data_get_report_step_from_time(const rd_sum_data_type *data,
time_t sim_time);
std::optional<size_t>
rd_sum_data_get_report_step_from_days(const rd_sum_data_type *data,
double days);
bool rd_sum_data_check_sim_time(const rd_sum_data_type *data, time_t sim_time);
bool rd_sum_data_check_sim_days(const rd_sum_data_type *data, double sim_days);
/** One value per time step. Throws std::out_of_range for an invalid index. */
std::vector<double> rd_sum_data_alloc_data_vector(const rd_sum_data_type *data,
int data_index,
bool report_only);
std::vector<time_t> rd_sum_data_alloc_time_vector(const rd_sum_data_type *data,
bool report_only);
size_t params_index);
/** One value per report step present in the data. */
std::vector<double>
rd_sum_data_alloc_report_data_vector(const rd_sum_data_type *data,
size_t params_index);
std::vector<time_t> rd_sum_data_alloc_time_vector(const rd_sum_data_type *data);
std::vector<time_t>
rd_sum_data_alloc_report_time_vector(const rd_sum_data_type *data);
time_t rd_sum_data_get_data_start(const rd_sum_data_type *data);
time_t rd_sum_data_get_report_time(const rd_sum_data_type *data,
int report_step);
size_t report_step);
double rd_sum_data_get_first_day(const rd_sum_data_type *data);
time_t rd_sum_data_get_sim_end(const rd_sum_data_type *data);
double rd_sum_data_get_sim_length(const rd_sum_data_type *data);
double rd_sum_data_iget(const rd_sum_data_type *data, int internal_index,
int params_index);
double rd_sum_data_iget(const rd_sum_data_type *data, size_t internal_index,
size_t params_index);

double rd_sum_data_iget_sim_days(const rd_sum_data_type *, int);
time_t rd_sum_data_iget_sim_time(const rd_sum_data_type *, int);
double rd_sum_data_iget_sim_days(const rd_sum_data_type *, size_t);
time_t rd_sum_data_iget_sim_time(const rd_sum_data_type *, size_t);
std::vector<double>
rd_sum_data_get_interp_vector(const rd_sum_data_type *data, time_t sim_time,
const rd_sum_vector_type *keylist,
double missing_value);

void rd_sum_data_free(rd_sum_data_type *);
int rd_sum_data_get_last_report_step(const rd_sum_data_type *data);
int rd_sum_data_get_first_report_step(const rd_sum_data_type *data);
size_t rd_sum_data_get_last_report_step(const rd_sum_data_type *data);
size_t rd_sum_data_get_first_report_step(const rd_sum_data_type *data);

double rd_sum_data_get_from_sim_time(const rd_sum_data_type *data,
time_t sim_time,
Expand All @@ -63,19 +71,20 @@ double rd_sum_data_get_from_sim_days(const rd_sum_data_type *data,
double sim_days,
const rd::smspec_node &smspec_node);

int rd_sum_data_get_length(const rd_sum_data_type *data);
int rd_sum_data_iget_report_step(const rd_sum_data_type *data,
int internal_index);
int rd_sum_data_iget_report_end(const rd_sum_data_type *data, int report_step);
size_t rd_sum_data_get_length(const rd_sum_data_type *data);
size_t rd_sum_data_iget_report_step(const rd_sum_data_type *data,
size_t internal_index);
size_t rd_sum_data_iget_report_end(const rd_sum_data_type *data,
size_t report_step);
rd_sum_tstep_type *rd_sum_data_add_new_tstep(rd_sum_data_type *data,
int report_step,
size_t report_step,
double sim_seconds);
double rd_sum_data_iget_last_value(const rd_sum_data_type *data,
int param_index);
size_t param_index);
double rd_sum_data_iget_first_value(const rd_sum_data_type *data,
int param_index);
size_t param_index);
void rd_sum_data_init_double_vector(const rd_sum_data_type *data,
int params_index, double *output_data);
size_t params_index, double *output_data);
std::vector<double>
rd_sum_data_alloc_seconds_solution(const rd_sum_data_type *data,
const rd::smspec_node &node, double value,
Expand Down
Loading
Loading