Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
jtwhite79 committed Aug 15, 2023
2 parents a3137fe + af65584 commit 7c73793
Show file tree
Hide file tree
Showing 27 changed files with 404 additions and 119 deletions.
Binary file not shown.
6 changes: 3 additions & 3 deletions documentation/pestpp_users_manual.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@

<img src="0d3cb7750c90b712af04ea3a51c8ecb968d784cc.png" style="width:6.26806in;height:1.68194in" alt="A close up of a purple sign Description automatically generated" />

# <a id='s1' />Version 5.2.4
# <a id='s1' />Version 5.2.6

<img src="0e14ec9848f78a9809081572ca785af9990c2d38.png" style="width:6.26806in;height:3.05972in" />

PEST++ Development Team

May 2023
August 2023

# <a id='s2' />Acknowledgements

Expand Down Expand Up @@ -70,7 +70,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI

# Table of Contents

- [Version 5.2.4](#s1)
- [Version 5.2.6](#s1)
- [Acknowledgements](#s2)
- [Preface](#s3)
- [License](#s4)
Expand Down
2 changes: 1 addition & 1 deletion scripts/build_pestpp_linux.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# this should be run from one dir level up - the repo root...
rm -rf build
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=g++-9 ..
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER=g++ ..
make -j install
cpack -G TGZ
2 changes: 1 addition & 1 deletion src/libs/common/config_os.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define CONFIG_OS_H_


#define PESTPP_VERSION "5.2.4";
#define PESTPP_VERSION "5.2.6";

#if defined(_WIN32) || defined(_WIN64)
#define OS_WIN
Expand Down
2 changes: 0 additions & 2 deletions src/libs/common/system_variables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ const std::string OperSys::DIR_SEP = "/";
const std::string OperSys::COMMAND_LINE_APPEND = " & ";
#endif

const int OperSys::thread_sleep_milli_secs=1000;

using namespace std;

void OperSys::string2pathname(string &s)
Expand Down
2 changes: 0 additions & 2 deletions src/libs/common/system_variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
class OperSys
{
public:
//const static int thread_sleep_secs = 1;
static const int thread_sleep_milli_secs;
static const std::string DIR_SEP;
static const std::string COMMAND_LINE_APPEND;
void string2pathname(std::string &s);
Expand Down
16 changes: 10 additions & 6 deletions src/libs/common/utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,7 @@ void read_dense_binary(const string& filename, vector<string>& row_names, vector
pest_utils::upper_ip(name);
col_names.push_back(name);
i++;
delete[] col_name;
}
i = 0;
double data = -1.;
Expand Down Expand Up @@ -956,6 +957,7 @@ void read_dense_binary(const string& filename, vector<string>& row_names, vector
break;
}
name = string(row_name, name_size);
delete[] row_name;
pest_utils::strip_ip(name);
pest_utils::upper_ip(name);
if (!in.good())
Expand All @@ -965,10 +967,12 @@ void read_dense_binary(const string& filename, vector<string>& row_names, vector
cout << ss.str();
break;
}

//skip the values
//in.seekg(col_names.size() * sizeof(double), ios_base::cur);
row_name = new char[sizeof(double) * col_names.size()];
in.read(row_name, sizeof(double)* col_names.size());
char* rest_of_line = new char[sizeof(double) * col_names.size()];
in.read(rest_of_line, sizeof(double)* col_names.size());
delete[] rest_of_line;
if (in.eof())
break;
if (!in.good())
Expand Down Expand Up @@ -1520,7 +1524,7 @@ void ExternalCtlFile::read_file(ofstream& f_rec)
throw_externalctrlfile_error("filename '" + filename + "' not found");
}
ifstream f_in(filename);
if (!f_in.good())
if (f_in.bad())
{
throw_externalctrlfile_error("error opening filename '" + filename + "' for reading");
}
Expand All @@ -1542,10 +1546,10 @@ void ExternalCtlFile::read_file(ofstream& f_rec)
cleaned = true;
}
}
if (cleaned)
{
// if (cleaned)
// {
strip_ip(t);
}
// }
}
int hsize = col_names.size();
set<string> tset;
Expand Down
82 changes: 81 additions & 1 deletion src/libs/pestpp_common/Ensemble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3169,14 +3169,17 @@ void ParameterEnsemble::to_dense_ordered(string file_name)
fout.write((char*)&tmp, sizeof(tmp));
mx = max(tmp, mx);
}

for (vector<string>::const_iterator b = vnames.begin(), e = vnames.end();
b != e; ++b)
{
string name = pest_utils::lower_cp(*b);
char* par_name = new char[name.size()];
pest_utils::string_to_fortran_char(name, par_name, name.size());
fout.write(par_name, name.size());
delete[] par_name;
}


//write matrix
n = 0;
Expand All @@ -3191,6 +3194,7 @@ void ParameterEnsemble::to_dense_ordered(string file_name)
par_transform.ctl2model_ip(org_pars);
else if (tstat == transStatus::NUM)
par_transform.ctl2numeric_ip(org_pars);

for (int irow = 0; irow < n_real; ++irow)
{
//Parameters pars(var_names, reals.row(irow));
Expand All @@ -3212,6 +3216,7 @@ void ParameterEnsemble::to_dense_ordered(string file_name)
fout.write((char*)&tmp, sizeof(tmp));
pest_utils::string_to_fortran_char(name, real_name, tmp);
fout.write(real_name, tmp);
delete[] real_name;
for (int jcol = 0; jcol < n_var; ++jcol)
{
data = pars[vnames[jcol]];
Expand Down Expand Up @@ -3296,6 +3301,7 @@ void ParameterEnsemble::to_dense_unordered(string file_name)
char* par_name = new char[name.size()];
pest_utils::string_to_fortran_char(name, par_name, name.size());
fout.write(par_name, name.size());
delete[] par_name;
}

//write matrix
Expand All @@ -3313,6 +3319,7 @@ void ParameterEnsemble::to_dense_unordered(string file_name)
fout.write((char*)&tmp, sizeof(tmp));
pest_utils::string_to_fortran_char(name, real_name, tmp);
fout.write(real_name, tmp);
delete[] real_name;
for (int jcol = 0; jcol < var_names.size(); ++jcol)
{
data = t[jcol];
Expand Down Expand Up @@ -4299,14 +4306,86 @@ void FixedParInfo::add_realization(string rname, Eigen::VectorXd& rvals, vector<
map<string, double> v;
for (int i = 0; i < rvals.size(); i++)
v[pnames[i]] = rvals[i];
map<string,double>::iterator end = v.end();
for (auto& name : fixed_names)
{
if (v.find(name) == v.end())
if (v.find(name) == end)
throw runtime_error("FixedParInfo::add_realization(): fixed name '" + name + "' not in pnames");
fixed_info.at(name)[rname] = v.at(name);
}
}

vector<string> FixedParInfo::get_real_names()
{
if (!initialized)
{
return vector<string>();
}
if (fixed_names.size() == 0)
{
return vector<string>();
}
vector<string> rnames;
for (auto& fi : fixed_info)
{
for (auto& ri : fi.second)
{
rnames.push_back(ri.first);
}
}
return rnames;

}

void FixedParInfo::add_realizations(map<string,map<string,double>>& other_fixed_info)
{
if (!initialized)
{
throw runtime_error("FixedParInfo::update_realizations: not initialized");
}
if (fixed_names.size() == 0)
{
//this needs to be error checked..
fixed_info = other_fixed_info;
return;
}
map<string,map<string,double>>::iterator end = fixed_info.end();
for (auto& ofi : other_fixed_info)
{
if (fixed_info.find(ofi.first) == end)
{
throw runtime_error("FixedParInfo::add_realizations() error: pname "+ofi.first+" not in fixed_info");
}
for (auto& ori : ofi.second)
{
//probably should error check this also to make sure other_fixed_info isnt replacing things...
fixed_info.at(ofi.first)[ori.first] = ori.second;
}
}
}


void FixedParInfo::add_realization(string rname, map<string, double>& rvals)
{
if (!initialized)
{
throw runtime_error("FixedParInfo::add_realization(): not initialized");
}
if (fixed_names.size() == 0)
{
return;
}
map<string,double>::iterator end = rvals.end();
for (auto& name : fixed_names)
{
if (rvals.find(name) == end)
throw runtime_error("FixedParInfo::add_realization(): fixed name '" + name + "' not in pnames");
fixed_info.at(name)[rname] = rvals.at(name);
}


}

void FixedParInfo::keep_realizations(const vector<string>& keep)
{
if (!initialized)
Expand Down Expand Up @@ -4342,6 +4421,7 @@ void FixedParInfo::keep_realizations(const vector<string>& keep)
}
}


void FixedParInfo::update_realizations(const vector<string>& other_var_names, const vector<string>& other_real_names, const Eigen::MatrixXd& other_mat)
{
if (!initialized)
Expand Down
6 changes: 6 additions & 0 deletions src/libs/pestpp_common/Ensemble.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,18 @@ class FixedParInfo
vector<double> get_real_fixed_values(const string& rname, vector<string>& pnames);
map<string, double> get_real_fixed_values(const string& rname);
void add_realization(string rname, Eigen::VectorXd& rvals, vector<string>& pnames);
void add_realization(string rname, map<string, double>& rvals);
void keep_realizations(const vector<string>& keep);
void update_realizations(const vector<string>& other_var_names, const vector<string>& other_real_names, const Eigen::MatrixXd& other_mat);
void add_realizations(map<string,map<string,double>>& other_fixed_info);
void update_par_values(const map<string, double>& pval_map);
void clear() { fixed_info.clear(); fixed_names.clear(); }
void fill_fixed(map<string, double>& fixed_map, vector<string>& rnames);
int get_map_size() {return fixed_info.size();}
vector<string> get_real_names();
vector<string> get_fixed_names() {return fixed_names;}
map<string,map<string,double>> get_fixed_info_map() {return fixed_info;}

private:
bool initialized;
vector<string> fixed_names;
Expand Down
Loading

0 comments on commit 7c73793

Please sign in to comment.