mirror of
https://git.gfz-potsdam.de/naaice/poet.git
synced 2025-12-13 03:18:23 +01:00
fixing stuff and adding comments
This commit is contained in:
parent
99f2cb5ca0
commit
23d0ee51d8
@ -1,3 +1,4 @@
|
||||
## Time-stamp: "Last modified 2024-06-13 10:25:44 delucia"
|
||||
# prepare R environment (Rcpp + RInside)
|
||||
find_program(R_EXE "R")
|
||||
|
||||
|
||||
@ -13,7 +13,7 @@ macro(get_POET_version)
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE POET_GIT_VERSION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(NOT POET_GIT_BRANCH STREQUAL "master")
|
||||
if(NOT POET_GIT_BRANCH STREQUAL "main")
|
||||
set(POET_VERSION "${POET_GIT_BRANCH}/${POET_GIT_VERSION}")
|
||||
else()
|
||||
set(POET_VERSION "${POET_GIT_VERSION}")
|
||||
@ -21,7 +21,7 @@ macro(get_POET_version)
|
||||
elseif(EXISTS ${PROJECT_SOURCE_DIR}/.svn)
|
||||
file(STRINGS .gitversion POET_VERSION)
|
||||
else()
|
||||
set(POET_VERSION "0.1")
|
||||
set(POET_VERSION "not_versioned")
|
||||
endif()
|
||||
|
||||
message(STATUS "Configuring POET version ${POET_VERSION}")
|
||||
|
||||
@ -41,4 +41,4 @@ endif()
|
||||
|
||||
option(BUILD_DOC "Build documentation with doxygen" OFF)
|
||||
|
||||
add_subdirectory(docs)
|
||||
add_subdirectory(docs)
|
||||
|
||||
@ -1,15 +1,33 @@
|
||||
pqc_to_grid <- function(pqc_in, grid) {
|
||||
### Copyright (C) 2018-2024 Marco De Lucia, Max Luebke (GFZ Potsdam, University of Potsdam)
|
||||
###
|
||||
### POET is free software; you can redistribute it and/or modify it under the
|
||||
### terms of the GNU General Public License as published by the Free Software
|
||||
### Foundation; either version 2 of the License, or (at your option) any later
|
||||
### version.
|
||||
###
|
||||
### POET is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
### WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
### A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
###
|
||||
### You should have received a copy of the GNU General Public License along with
|
||||
### this program; if not, write to the Free Software Foundation, Inc., 51
|
||||
### Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
##' @param pqc_mat matrix, containing IDs and PHREEQC outputs
|
||||
##' @param grid matrix, zonation referring to pqc_mat$ID
|
||||
##' @return a data.frame
|
||||
pqc_to_grid <- function(pqc_mat, grid) {
|
||||
# Convert the input DataFrame to a matrix
|
||||
pqc_in <- as.matrix(pqc_in)
|
||||
pqc_mat <- as.matrix(pqc_mat)
|
||||
|
||||
# Flatten the matrix into a vector
|
||||
id_vector <- as.numeric(t(grid))
|
||||
id_vector <- as.integer(t(grid))
|
||||
|
||||
# Find the matching rows in the matrix
|
||||
row_indices <- match(id_vector, pqc_in[, "ID"])
|
||||
row_indices <- match(id_vector, pqc_mat[, "ID"])
|
||||
|
||||
# Extract the matching rows from pqc_in to size of grid matrix
|
||||
result_mat <- pqc_in[row_indices, ]
|
||||
# Extract the matching rows from pqc_mat to size of grid matrix
|
||||
result_mat <- pqc_mat[row_indices, ]
|
||||
|
||||
# Convert the result matrix to a data frame
|
||||
res_df <- as.data.frame(result_mat)
|
||||
@ -23,6 +41,12 @@ pqc_to_grid <- function(pqc_in, grid) {
|
||||
return(res_df)
|
||||
}
|
||||
|
||||
|
||||
##' @param pqc_mat matrix,
|
||||
##' @param transport_spec column name of species in pqc_mat
|
||||
##' @param id
|
||||
##' @title
|
||||
##' @return
|
||||
resolve_pqc_bound <- function(pqc_mat, transport_spec, id) {
|
||||
df <- as.data.frame(pqc_mat, check.names = FALSE)
|
||||
value <- df[df$ID == id, transport_spec]
|
||||
@ -34,6 +58,10 @@ resolve_pqc_bound <- function(pqc_mat, transport_spec, id) {
|
||||
return(value)
|
||||
}
|
||||
|
||||
##' @title
|
||||
##' @param init_grid
|
||||
##' @param new_names
|
||||
##' @return
|
||||
add_missing_transport_species <- function(init_grid, new_names) {
|
||||
# add 'ID' to new_names front, as it is not a transport species but required
|
||||
new_names <- c("ID", new_names)
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
## Time-stamp: "Last modified 2024-06-11 14:26:33 delucia"
|
||||
|
||||
### Copyright (C) 2018-2023 Marco De Lucia, Max Luebke (GFZ Potsdam)
|
||||
###
|
||||
### POET is free software; you can redistribute it and/or modify it under the
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
// Time-stamp: "Last modified 2024-06-13 11:30:34 delucia"
|
||||
|
||||
|
||||
#include <algorithm>
|
||||
#include <tug/Boundary.hpp>
|
||||
// leave above Rcpp includes, as eigen seem to have problems with a preceding
|
||||
@ -146,7 +149,7 @@ InitialList::resolveBoundaries(const Rcpp::List &boundaries_list,
|
||||
extend_initial_grid(this->initial_grid, this->transport_names);
|
||||
}
|
||||
|
||||
for (const auto &species : this->transport_names) {
|
||||
for (const auto &species_name : this->transport_names) {
|
||||
Rcpp::List spec_list;
|
||||
|
||||
for (const auto &side : tug_side_mapping) {
|
||||
@ -163,8 +166,8 @@ InitialList::resolveBoundaries(const Rcpp::List &boundaries_list,
|
||||
if (boundaries_list.containsElementNamed(side.second.c_str())) {
|
||||
const Rcpp::List mapping = boundaries_list[side.second];
|
||||
|
||||
const Rcpp::NumericVector cells = mapping["cell"];
|
||||
const Rcpp::NumericVector values = mapping["sol_id"];
|
||||
const Rcpp::IntegerVector cells = mapping["cell"]; // MDL 2024-06-13
|
||||
const Rcpp::IntegerVector values = mapping["sol_id"]; // MDL
|
||||
const Rcpp::CharacterVector type_str = mapping["type"];
|
||||
|
||||
if (cells.size() != values.size()) {
|
||||
@ -180,7 +183,7 @@ InitialList::resolveBoundaries(const Rcpp::List &boundaries_list,
|
||||
} else if (type_str[i] == "constant") {
|
||||
c_type[c_id] = tug::BC_TYPE_CONSTANT;
|
||||
c_value[c_id] = Rcpp::as<TugType>(
|
||||
resolve_R(this->phreeqc_mat, Rcpp::wrap(species), values[i]));
|
||||
resolve_R(this->phreeqc_mat, Rcpp::wrap(species_name), values[i]));
|
||||
} else {
|
||||
throw std::runtime_error("Unknown boundary type");
|
||||
}
|
||||
@ -191,7 +194,7 @@ InitialList::resolveBoundaries(const Rcpp::List &boundaries_list,
|
||||
Rcpp::Named("type") = c_type, Rcpp::Named("value") = c_value);
|
||||
}
|
||||
|
||||
bound_list[species] = spec_list;
|
||||
bound_list[species_name] = spec_list;
|
||||
|
||||
if (inner_boundaries.size() > 0) {
|
||||
const Rcpp::NumericVector &inner_row_vec = inner_boundaries["row"];
|
||||
@ -212,10 +215,10 @@ InitialList::resolveBoundaries(const Rcpp::List &boundaries_list,
|
||||
rows.push_back(inner_row_vec[i] - 1);
|
||||
cols.push_back(inner_col_vec[i] - 1);
|
||||
c_value.push_back(Rcpp::as<TugType>(resolve_R(
|
||||
this->phreeqc_mat, Rcpp::wrap(species), inner_pqc_id_vec[i])));
|
||||
this->phreeqc_mat, Rcpp::wrap(species_name), inner_pqc_id_vec[i])));
|
||||
}
|
||||
|
||||
inner_bound[species] =
|
||||
inner_bound[species_name] =
|
||||
Rcpp::List::create(Rcpp::Named("row") = Rcpp::wrap(rows),
|
||||
Rcpp::Named("col") = Rcpp::wrap(cols),
|
||||
Rcpp::Named("value") = Rcpp::wrap(c_value));
|
||||
@ -403,4 +406,4 @@ InitialList::DiffusionInit InitialList::getDiffusionInit() const {
|
||||
return diff_init;
|
||||
}
|
||||
|
||||
} // namespace poet
|
||||
} // namespace poet
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user