mirror of
https://git.gfz-potsdam.de/naaice/iphreeqc.git
synced 2025-12-16 08:38:23 +01:00
cl1 variables converted to std::vector
This commit is contained in:
parent
1e0d410577
commit
9d9fbfb85e
25
Phreeqc.cpp
25
Phreeqc.cpp
@ -1002,8 +1002,6 @@ void Phreeqc::init(void)
|
||||
//have_punch_name = FALSE;
|
||||
print_density = 0;
|
||||
print_viscosity = 0;
|
||||
zeros = NULL;
|
||||
zeros_max = 1;
|
||||
cell_pore_volume = 0;
|
||||
cell_volume = 0;
|
||||
cell_porosity = 0;
|
||||
@ -1178,24 +1176,7 @@ void Phreeqc::init(void)
|
||||
/* model.cpp ------------------------------- */
|
||||
gas_in = FALSE;
|
||||
min_value = 1e-10;
|
||||
//normal = NULL;
|
||||
//ineq_array = NULL;
|
||||
//res = NULL;
|
||||
//cu = NULL;
|
||||
zero = NULL;
|
||||
//delta1 = NULL;
|
||||
//iu = NULL;
|
||||
//is = NULL;
|
||||
//back_eq = NULL;
|
||||
//normal_max = 0;
|
||||
////ineq_array_max = 0;
|
||||
//res_max = 0;
|
||||
//cu_max = 0;
|
||||
//zero_max = 0;
|
||||
//delta1_max = 0;
|
||||
//iu_max = 0;
|
||||
//is_max = 0;
|
||||
//back_eq_max = 0;
|
||||
|
||||
/* phrq_io_output.cpp ------------------------------- */
|
||||
forward_output_to_log = 0;
|
||||
/* phreeqc_files.cpp ------------------------------- */
|
||||
@ -1859,10 +1840,6 @@ Phreeqc::InternalCopy(const Phreeqc *pSrc)
|
||||
count_phases = 0;
|
||||
max_phases = MAX_PHASES;
|
||||
*/
|
||||
//max_phases = pSrc->max_phases;
|
||||
//phases = (struct phase **) PHRQ_malloc((size_t)max_phases * sizeof(struct phase));
|
||||
//space((void **)((void *)&phases), INIT, &max_phases,
|
||||
// sizeof(struct phase *));
|
||||
count_phases = 0;
|
||||
for (int i = 0; i < pSrc->count_phases; i++)
|
||||
{
|
||||
|
||||
12
Phreeqc.h
12
Phreeqc.h
@ -1144,7 +1144,6 @@ protected:
|
||||
int string_trim_right(char *str);
|
||||
int string_trim_left(char *str);
|
||||
static LDBLE under(LDBLE xval);
|
||||
void zero_double(LDBLE * target, int n);
|
||||
int get_input_errors(void);
|
||||
int isamong(char c, const char *s_l);
|
||||
Address Hash_multi(HashTable * Table, const char *Key);
|
||||
@ -1754,9 +1753,6 @@ protected:
|
||||
/* VP: Density End */
|
||||
|
||||
int print_viscosity;
|
||||
LDBLE *zeros;
|
||||
int zeros_max;
|
||||
|
||||
LDBLE viscos, viscos_0, viscos_0_25; // viscosity of the solution, of pure water, of pure water at 25 C
|
||||
LDBLE cell_pore_volume;
|
||||
LDBLE cell_porosity;
|
||||
@ -1865,12 +1861,8 @@ protected:
|
||||
/* model.cpp ------------------------------- */
|
||||
int gas_in;
|
||||
LDBLE min_value;
|
||||
LDBLE *normal, *ineq_array, *res, *cu, *zero, *delta1;
|
||||
std::vector<double> normal_v, ineq_array_v, res_v, cu_v, zero_v, delta1_v;
|
||||
int *iu, *is, *back_eq;
|
||||
std::vector<int> iu_v, is_v, back_eq_v;
|
||||
//int normal_max, ineq_array_max, res_max, cu_max, zero_max,
|
||||
// delta1_max, iu_max, is_max, back_eq_max;
|
||||
std::vector<double> normal, ineq_array, res, cu, zero, delta1;
|
||||
std::vector<int> iu, is, back_eq;
|
||||
|
||||
/* phrq_io_output.cpp ------------------------------- */
|
||||
int forward_output_to_log;
|
||||
|
||||
51
cl1.cpp
51
cl1.cpp
@ -849,61 +849,12 @@ cl1(int k, int l, int m, int n,
|
||||
void Phreeqc::
|
||||
cl1_space(int check, int l_n2d, int klm, int l_nklmd)
|
||||
{
|
||||
#ifdef SKIP
|
||||
if (check == 1)
|
||||
{
|
||||
if (x_arg == NULL)
|
||||
{
|
||||
x_arg = (LDBLE*)PHRQ_malloc((size_t)(l_n2d * sizeof(LDBLE)));
|
||||
}
|
||||
else if (l_n2d > x_arg_max)
|
||||
{
|
||||
x_arg =
|
||||
(LDBLE*)PHRQ_realloc(x_arg, (size_t)(l_n2d * sizeof(LDBLE)));
|
||||
x_arg_max = l_n2d;
|
||||
}
|
||||
if (x_arg == NULL)
|
||||
malloc_error();
|
||||
zero_double(x_arg, l_n2d);
|
||||
|
||||
if (res_arg == NULL)
|
||||
{
|
||||
res_arg = (LDBLE*)PHRQ_malloc((size_t)((klm) * sizeof(LDBLE)));
|
||||
}
|
||||
else if (klm > res_arg_max)
|
||||
{
|
||||
res_arg =
|
||||
(LDBLE*)PHRQ_realloc(res_arg,
|
||||
(size_t)((klm) * sizeof(LDBLE)));
|
||||
res_arg_max = klm;
|
||||
}
|
||||
if (res_arg == NULL)
|
||||
malloc_error();
|
||||
zero_double(res_arg, klm);
|
||||
}
|
||||
|
||||
/* Make scratch space */
|
||||
if (scratch == NULL)
|
||||
{
|
||||
scratch = (LDBLE*)PHRQ_malloc((size_t)l_nklmd * sizeof(LDBLE));
|
||||
}
|
||||
else if (l_nklmd > scratch_max)
|
||||
{
|
||||
scratch =
|
||||
(LDBLE*)PHRQ_realloc(scratch, (size_t)l_nklmd * sizeof(LDBLE));
|
||||
scratch_max = l_nklmd;
|
||||
}
|
||||
if (scratch == NULL)
|
||||
malloc_error();
|
||||
zero_double(scratch, l_nklmd);
|
||||
#endif
|
||||
if (l_n2d > x_arg_v.size())
|
||||
{
|
||||
x_arg_v.resize(l_n2d);
|
||||
x_arg = &x_arg_v[0];
|
||||
}
|
||||
memset(x_arg_v.data(), 0, sizeof(double) * (size_t)l_n2d);
|
||||
//zero_double(x_arg, l_n2d);
|
||||
|
||||
if (klm > res_arg_v.size())
|
||||
{
|
||||
@ -911,7 +862,6 @@ cl1_space(int check, int l_n2d, int klm, int l_nklmd)
|
||||
res_arg = &res_arg_v[0];
|
||||
}
|
||||
memset(res_arg_v.data(), 0, sizeof(double) * (size_t)klm);
|
||||
//zero_double(res_arg, klm);
|
||||
|
||||
if (l_nklmd > scratch_v.size())
|
||||
{
|
||||
@ -919,5 +869,4 @@ cl1_space(int check, int l_n2d, int klm, int l_nklmd)
|
||||
scratch = &scratch_v[0];
|
||||
}
|
||||
memset(scratch_v.data(), 0, sizeof(double) * (size_t)l_nklmd);
|
||||
//zero_double(scratch, l_nklmd);
|
||||
}
|
||||
|
||||
@ -228,12 +228,6 @@ initialize(void)
|
||||
// Allocate space for sit
|
||||
sit_init();
|
||||
|
||||
// Allocate zeros
|
||||
zeros = (LDBLE *) PHRQ_malloc(sizeof(LDBLE));
|
||||
if (zeros == NULL)
|
||||
malloc_error();
|
||||
zeros[0] = 0.0;
|
||||
zeros_max = 1;
|
||||
use_kinetics_limiter = false;
|
||||
|
||||
return;
|
||||
|
||||
72
model.cpp
72
model.cpp
@ -1023,14 +1023,8 @@ ineq(int in_kode)
|
||||
/*
|
||||
* Normalize column
|
||||
*/
|
||||
//space((void **) ((void *) &normal), count_unknowns, &normal_max,
|
||||
// sizeof(LDBLE));
|
||||
normal_v.resize((size_t)count_unknowns);
|
||||
normal = normal_v.data();
|
||||
|
||||
for (i = 0; i < count_unknowns; i++)
|
||||
normal[i] = 1.0;
|
||||
|
||||
normal.resize((size_t)count_unknowns);
|
||||
std::fill(normal.begin(), normal.end(), 1.0);
|
||||
|
||||
for (i = 0; i < count_unknowns; i++)
|
||||
{
|
||||
@ -1126,38 +1120,14 @@ ineq(int in_kode)
|
||||
*/
|
||||
max_row_count = 2 * count_unknowns + 2;
|
||||
max_column_count = count_unknowns + 2;
|
||||
//space((void **) ((void *) &ineq_array), max_row_count * max_column_count,
|
||||
// &ineq_array_max, sizeof(LDBLE));
|
||||
ineq_array_v.resize((size_t)max_row_count * (size_t)max_column_count);
|
||||
ineq_array = ineq_array_v.data();
|
||||
|
||||
//space((void **) ((void *) &back_eq), max_row_count, &back_eq_max,
|
||||
// sizeof(int));
|
||||
back_eq_v.resize((size_t)max_row_count);
|
||||
back_eq = back_eq_v.data();
|
||||
|
||||
//space((void **) ((void *) &zero), max_row_count, &zero_max,
|
||||
// sizeof(LDBLE));
|
||||
//zero_double(zero, max_row_count);
|
||||
zero_v.resize((size_t)max_row_count);
|
||||
zero = zero_v.data();
|
||||
memset(zero, 0, (size_t)max_row_count * sizeof(double));
|
||||
//zero_double(zero, max_row_count);
|
||||
|
||||
|
||||
//space((void **) ((void *) &res), max_row_count, &res_max, sizeof(LDBLE));
|
||||
res_v.resize((size_t)max_row_count);
|
||||
res = res_v.data();
|
||||
memset(res, 0, (size_t)max_row_count * sizeof(double));
|
||||
//zero_double(res, max_row_count);
|
||||
|
||||
//space((void **) ((void *) &delta1), max_column_count, &delta1_max,
|
||||
// sizeof(LDBLE));
|
||||
delta1_v.resize((size_t)max_column_count);
|
||||
delta1 = delta1_v.data();
|
||||
memset(delta1, 0,(size_t)max_column_count * sizeof(double));
|
||||
//zero_double(delta1, max_column_count);
|
||||
|
||||
ineq_array.resize((size_t)max_row_count * (size_t)max_column_count);
|
||||
back_eq.resize((size_t)max_row_count);
|
||||
zero.resize((size_t)max_row_count);
|
||||
memset(zero.data(), 0, (size_t)max_row_count * sizeof(double));
|
||||
res.resize((size_t)max_row_count);
|
||||
memset(res.data(), 0, (size_t)max_row_count * sizeof(double));
|
||||
delta1.resize((size_t)max_column_count);
|
||||
memset(delta1.data(), 0,(size_t)max_column_count * sizeof(double));
|
||||
/*
|
||||
* Copy equations to optimize into ineq_array
|
||||
*/
|
||||
@ -1723,7 +1693,7 @@ ineq(int in_kode)
|
||||
if (debug_model == TRUE)
|
||||
{
|
||||
output_msg(sformatf( "\nA and B arrays:\n\n"));
|
||||
array_print(ineq_array, l_count_rows, count_unknowns + 1,
|
||||
array_print(ineq_array.data(), l_count_rows, count_unknowns + 1,
|
||||
max_column_count);
|
||||
}
|
||||
/*
|
||||
@ -1781,17 +1751,9 @@ ineq(int in_kode)
|
||||
/*
|
||||
* Allocate space for arrays
|
||||
*/
|
||||
//space((void **) ((void *) &cu), 2 * l_nklmd, &cu_max, sizeof(LDBLE));
|
||||
cu_v.resize(2 * (size_t)l_nklmd);
|
||||
cu = cu_v.data();
|
||||
|
||||
//space((void **) ((void *) &iu), 2 * l_nklmd, &iu_max, sizeof(int));
|
||||
iu_v.resize(2 * (size_t)l_nklmd);
|
||||
iu = iu_v.data();
|
||||
|
||||
//space((void **) ((void *) &is), l_klmd, &is_max, sizeof(int));
|
||||
is_v.resize(l_klmd);
|
||||
is = is_v.data();
|
||||
cu.resize(2 * (size_t)l_nklmd);
|
||||
iu.resize(2 * (size_t)l_nklmd);
|
||||
is.resize(l_klmd);
|
||||
|
||||
#ifdef SLNQ
|
||||
slnq_array =
|
||||
@ -1817,9 +1779,9 @@ ineq(int in_kode)
|
||||
/*
|
||||
* Call CL1
|
||||
*/
|
||||
cl1(k, l, m, n,
|
||||
l_nklmd, l_n2d, ineq_array,
|
||||
&l_kode, ineq_tol, &l_iter, delta1, res, &l_error, cu, iu, is, FALSE);
|
||||
cl1(k, l, m, n, l_nklmd, l_n2d, ineq_array.data(),
|
||||
&l_kode, ineq_tol, &l_iter, delta1.data(), res.data(),
|
||||
&l_error, cu.data(), iu.data(), is.data(), FALSE);
|
||||
/* Set return_kode */
|
||||
if (l_kode == 1)
|
||||
{
|
||||
|
||||
@ -308,25 +308,6 @@ clean_up(void)
|
||||
line = (char *) free_check_null(line);
|
||||
line_save = (char *) free_check_null(line_save);
|
||||
|
||||
zeros = (LDBLE *) free_check_null(zeros);
|
||||
//scratch = (LDBLE *) free_check_null(scratch);
|
||||
//x_arg = (LDBLE *) free_check_null(x_arg);
|
||||
//res_arg = (LDBLE *) free_check_null(res_arg);
|
||||
|
||||
//normal = (LDBLE *) free_check_null(normal);
|
||||
//ineq_array = (LDBLE *) free_check_null(ineq_array);
|
||||
//back_eq = (int *) free_check_null(back_eq);
|
||||
zero = (LDBLE *) free_check_null(zero);
|
||||
//res = (LDBLE *) free_check_null(res);
|
||||
//delta1 = (LDBLE *) free_check_null(delta1);
|
||||
//cu = (LDBLE *) free_check_null(cu);
|
||||
//iu = (int *) free_check_null(iu);
|
||||
//is = (int *) free_check_null(is);
|
||||
|
||||
/* x_arg = res_arg = scratch = NULL; */
|
||||
x_arg_max = res_arg_max = scratch_max = 0;
|
||||
|
||||
|
||||
/* free user database name if defined */
|
||||
user_database = (char *) free_check_null(user_database);
|
||||
//selected_output_file_name =
|
||||
|
||||
@ -1992,27 +1992,6 @@ string_pad(const char *str, int i)
|
||||
return (str_ptr);
|
||||
}
|
||||
/* ---------------------------------------------------------------------- */
|
||||
void Phreeqc::
|
||||
zero_double(LDBLE * target, int n)
|
||||
/* ---------------------------------------------------------------------- */
|
||||
{
|
||||
int i;
|
||||
|
||||
if (n > zeros_max)
|
||||
{
|
||||
zeros = (LDBLE *) PHRQ_realloc(zeros, (size_t) (n * sizeof(LDBLE)));
|
||||
if (zeros == NULL)
|
||||
malloc_error();
|
||||
for (i = zeros_max; i < n; i++)
|
||||
{
|
||||
zeros[i] = 0.0;
|
||||
}
|
||||
zeros_max = n;
|
||||
}
|
||||
memcpy((void *) target, (void *) zeros, (size_t) (n * sizeof(LDBLE)));
|
||||
return;
|
||||
}
|
||||
/* ---------------------------------------------------------------------- */
|
||||
int Phreeqc::
|
||||
get_input_errors()
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user