tmp update
This commit is contained in:
parent
586f543a11
commit
ec540eead1
@ -79,7 +79,7 @@ void gctl::meshdata_scalar::show_stats(std::ostream &os)
|
||||
}
|
||||
}
|
||||
|
||||
os << "Mean = " << mean(tmp) << ", STD = " << std(tmp) << ", RMS = " << rms(tmp) << std::endl;
|
||||
os << "Mean = " << tmp.mean() << ", STD = " << tmp.std() << ", RMS = " << tmp.rms() << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -67,9 +67,9 @@ void gctl::meshdata_tensor::show_stats(std::ostream &os)
|
||||
t[n] = datval[n].at(i, j);
|
||||
}
|
||||
|
||||
m[j + i*3] = mean(t);
|
||||
s[j + i*3] = std(t);
|
||||
r[j + i*3] = rms(t);
|
||||
m[j + i*3] = t.mean();
|
||||
s[j + i*3] = t.std();
|
||||
r[j + i*3] = t.rms();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,19 +62,19 @@ void gctl::meshdata_vector::show_stats(std::ostream &os)
|
||||
{
|
||||
t[i] = datval[i].x;
|
||||
}
|
||||
m[0] = mean(t); s[0] = std(t); r[0] = rms(t);
|
||||
m[0] = t.mean(); s[0] = t.std(); r[0] = t.rms();
|
||||
|
||||
for (size_t i = 0; i < datval.size(); i++)
|
||||
{
|
||||
t[i] = datval[i].y;
|
||||
}
|
||||
m[1] = mean(t); s[1] = std(t); r[1] = rms(t);
|
||||
m[1] = t.mean(); s[1] = t.std(); r[1] = t.rms();
|
||||
|
||||
for (size_t i = 0; i < datval.size(); i++)
|
||||
{
|
||||
t[i] = datval[i].z;
|
||||
}
|
||||
m[2] = mean(t); s[2] = std(t); r[2] = rms(t);
|
||||
m[2] = t.mean(); s[2] = t.std(); r[2] = t.rms();
|
||||
|
||||
os << "Mean = (" << m[0] << "," << m[1] << "," << m[2] << ")"
|
||||
<< "\nSTD = (" << s[0] << "," << s[1] << "," << s[2] << ")"
|
||||
|
@ -455,7 +455,8 @@ void gctl::regular_grid::load_netcdf_grid(std::string filename, mesh_data_type_e
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::regular_grid::save_netcdf_grid(std::string filename, mesh_data_type_e d_type)
|
||||
void gctl::regular_grid::save_netcdf_grid(std::string filename, mesh_data_type_e d_type,
|
||||
std::string xname, std::string yname)
|
||||
{
|
||||
if (!initialized)
|
||||
{
|
||||
@ -476,12 +477,12 @@ void gctl::regular_grid::save_netcdf_grid(std::string filename, mesh_data_type_e
|
||||
if (!if_append)
|
||||
{
|
||||
gctl::save_netcdf_grid(filename, *data_ptr, rg_xnum, rg_ynum, rg_xmin,
|
||||
rg_dx, rg_ymin, rg_dy, "x", "y", curr_data->get_datname());
|
||||
rg_dx, rg_ymin, rg_dy, xname, yname, curr_data->get_datname());
|
||||
if_append = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
gctl::append_netcdf_grid(filename, *data_ptr, "x", "y", curr_data->get_datname());
|
||||
gctl::append_netcdf_grid(filename, *data_ptr, xname, yname, curr_data->get_datname());
|
||||
}
|
||||
}
|
||||
else if (curr_data->get_dattype() == d_type && d_type == ElemData &&
|
||||
@ -492,12 +493,12 @@ void gctl::regular_grid::save_netcdf_grid(std::string filename, mesh_data_type_e
|
||||
if (!if_append)
|
||||
{
|
||||
gctl::save_netcdf_grid(filename, *data_ptr, rg_xnum-1, rg_ynum-1, rg_xmin+0.5*rg_dx,
|
||||
rg_dx, rg_ymin+0.5*rg_dy, rg_dy, "x", "y", curr_data->get_datname());
|
||||
rg_dx, rg_ymin+0.5*rg_dy, rg_dy, xname, yname, curr_data->get_datname());
|
||||
if_append = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
gctl::append_netcdf_grid(filename, *data_ptr, "x", "y", curr_data->get_datname());
|
||||
gctl::append_netcdf_grid(filename, *data_ptr, xname, yname, curr_data->get_datname());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -505,7 +506,8 @@ void gctl::regular_grid::save_netcdf_grid(std::string filename, mesh_data_type_e
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::regular_grid::save_netcdf_grid(std::string filename, std::string datname)
|
||||
void gctl::regular_grid::save_netcdf_grid(std::string filename, std::string datname,
|
||||
std::string xname, std::string yname)
|
||||
{
|
||||
meshdata *curr_data = get_data(datname);
|
||||
|
||||
@ -523,13 +525,13 @@ void gctl::regular_grid::save_netcdf_grid(std::string filename, std::string datn
|
||||
{
|
||||
array<double>* data_ptr = (array<double>*)curr_data->get_datval_ptr();
|
||||
gctl::save_netcdf_grid(filename, *data_ptr, rg_xnum, rg_ynum, rg_xmin,
|
||||
rg_dx, rg_ymin, rg_dy, "x", "y", curr_data->get_datname());
|
||||
rg_dx, rg_ymin, rg_dy, xname, yname, curr_data->get_datname());
|
||||
}
|
||||
else if (curr_data->get_valtype() == Scalar && curr_data->get_dattype() == ElemData)
|
||||
{
|
||||
array<double>* data_ptr = (array<double>*)curr_data->get_datval_ptr();
|
||||
gctl::save_netcdf_grid(filename, *data_ptr, rg_xnum-1, rg_ynum-1, rg_xmin+0.5*rg_dx,
|
||||
rg_dx, rg_ymin+0.5*rg_dy, rg_dy, "x", "y", curr_data->get_datname());
|
||||
rg_dx, rg_ymin+0.5*rg_dy, rg_dy, xname, yname, curr_data->get_datname());
|
||||
}
|
||||
|
||||
return;
|
||||
@ -929,7 +931,13 @@ void gctl::regular_grid::extract_profile(std::string datname, const point2dc &st
|
||||
throw std::runtime_error("[gctl::regular_grid] Invalid profile size.");
|
||||
}
|
||||
|
||||
linespace(start_p, end_p, size_p, out_posi);
|
||||
point2dc dp = 1.0/(size_p - 1)*(end_p - start_p);
|
||||
out_posi.resize(size_p);
|
||||
for (size_t i = 0; i < size_p; i++)
|
||||
{
|
||||
out_posi[i] = start_p + (1.0*i)*dp;
|
||||
}
|
||||
|
||||
extract_points(datname, out_posi, out_val);
|
||||
return;
|
||||
}
|
||||
|
@ -81,8 +81,10 @@ namespace gctl
|
||||
|
||||
void load_netcdf_grid(std::string filename, mesh_data_type_e d_type,
|
||||
std::string xname = "x", std::string yname = "y", std::string zname = "null");
|
||||
void save_netcdf_grid(std::string filename, mesh_data_type_e d_type);
|
||||
void save_netcdf_grid(std::string filename, std::string datname);
|
||||
void save_netcdf_grid(std::string filename, mesh_data_type_e d_type,
|
||||
std::string xname = "x", std::string yname = "y");
|
||||
void save_netcdf_grid(std::string filename, std::string datname,
|
||||
std::string xname = "x", std::string yname = "y");
|
||||
|
||||
#endif // GCTL_NETCDF
|
||||
|
||||
|
@ -352,18 +352,22 @@ void open_netcdf(const std::vector<std::string> &cmd_units)
|
||||
|
||||
void save_netcdf(const std::vector<std::string> &cmd_units)
|
||||
{
|
||||
// save netcdf <file> [<data-name>|node|cell]
|
||||
// save netcdf <file> [<data-name>|node|cell] [xname] [yname]
|
||||
if (cmd_units.size() < 3) throw std::runtime_error("save: insufficient parameters.");
|
||||
|
||||
gctl::array<std::string> copy_str(2, "null");
|
||||
for (size_t i = 0; i < GCTL_MIN(cmd_units.size() - 2, 2); i++)
|
||||
gctl::array<std::string> copy_str(4, "null");
|
||||
for (size_t i = 0; i < GCTL_MIN(cmd_units.size() - 2, 4); i++)
|
||||
{
|
||||
copy_str[i] = cmd_units[i + 2];
|
||||
}
|
||||
|
||||
if (copy_str[1] == "null") rg.save_netcdf_grid(copy_str[0], NodeData);
|
||||
else if (copy_str[1] == "cell") rg.save_netcdf_grid(copy_str[0], ElemData);
|
||||
else rg.save_netcdf_grid(copy_str[0], copy_str[1]);
|
||||
std::string xname = "x", yname = "y";
|
||||
if (copy_str[2] != "null") xname = copy_str[2];
|
||||
if (copy_str[3] != "null") yname = copy_str[3];
|
||||
|
||||
if (copy_str[1] == "null") rg.save_netcdf_grid(copy_str[0], NodeData, xname, yname);
|
||||
else if (copy_str[1] == "cell") rg.save_netcdf_grid(copy_str[0], ElemData, xname, yname);
|
||||
else rg.save_netcdf_grid(copy_str[0], copy_str[1], xname, yname);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -453,17 +457,21 @@ void data_cloud(const std::vector<std::string> &cmd_units)
|
||||
else if (copy_str[1] == "cell") d_type = ElemData;
|
||||
else throw std::runtime_error("open-surfer: invalid grid data type.");
|
||||
|
||||
std::string order_str = "0,1,2";
|
||||
char delimiter = ' ';
|
||||
char annotate = '#';
|
||||
int head_record = 0;
|
||||
text_descriptor desc;
|
||||
desc.file_name_ = copy_str[2];
|
||||
desc.file_ext_ = ".txt";
|
||||
desc.col_str_ = "0,1,2";
|
||||
desc.delimiter_ = ' ';
|
||||
desc.att_sym_ = '#';
|
||||
desc.head_num_ = 0;
|
||||
if (copy_str[6] != "null")
|
||||
{
|
||||
parse_string_to_value(copy_str[6], '/', true, order_str, delimiter, annotate, head_record);
|
||||
parse_string_to_value(copy_str[6], '/', true, desc.col_str_,
|
||||
desc.delimiter_, desc.att_sym_, desc.head_num_);
|
||||
}
|
||||
|
||||
std::vector<double> posix_vec, posiy_vec, data_vec;
|
||||
read_text2vectors(copy_str[2], order_str, delimiter, annotate, head_record, posix_vec, posiy_vec, data_vec);
|
||||
read_text2vectors(desc, posix_vec, posiy_vec, data_vec);
|
||||
|
||||
array<point2dc> posi_arr(posix_vec.size());
|
||||
array<double> posi_val;
|
||||
@ -717,16 +725,22 @@ void get_profile(const std::vector<std::string> &cmd_units)
|
||||
}
|
||||
else // File exist
|
||||
{
|
||||
std::string od_str = "0,1";
|
||||
char deli = ' ', antot = '#';
|
||||
int hr = 0;
|
||||
text_descriptor desc;
|
||||
desc.file_name_ = copy_str[2];
|
||||
desc.file_ext_ = ".txt";
|
||||
desc.att_sym_ = '#';
|
||||
desc.col_str_ = "0,1";
|
||||
desc.delimiter_ = ' ';
|
||||
desc.head_num_ = 0;
|
||||
|
||||
if (copy_str[3] != "null")
|
||||
{
|
||||
gctl::parse_string_to_value(copy_str[3], '/', true, od_str, deli, antot, hr);
|
||||
gctl::parse_string_to_value(copy_str[3], '/', true, desc.col_str_, desc.delimiter_,
|
||||
desc.att_sym_, desc.head_num_);
|
||||
}
|
||||
|
||||
std::vector<double> xs, ys;
|
||||
gctl::read_text2vectors(copy_str[2], od_str, deli, antot, hr, xs, ys);
|
||||
gctl::read_text2vectors(desc, xs, ys);
|
||||
|
||||
xys.resize(xs.size());
|
||||
for (size_t i = 0; i < xys.size(); i++)
|
||||
|
@ -17,7 +17,7 @@ Mathematic expresstions could be used to specify the grid ranges.
|
||||
|
||||
#### save binary|netcdf|surfer|gmsh \<file\>
|
||||
1. `save binary <file>` Save the grid using the GCTL native binary format (.2m file).
|
||||
2. `save netcdf <file> [<data-name>|node|cell]` Save grid data using the netCDF format. A \<data-name\> could be given to write the specficed data. Use 'node' (default) or 'cell' to write all node or cell registed data, respectively.
|
||||
2. `save netcdf <file> [<data-name>|node|cell] [xname] [yname]` Save grid data using the netCDF format. A \<data-name\> could be given to write the specficed data. Use 'node' (default) or 'cell' to write all node or cell registed data, respectively.
|
||||
3. `save surfer <file> <data-name> [surfer6-text|surfer6-binary|surfer7]` Save grid data using the Surfer format. A \<data-name\> must be given to write the specficed data. 'surfer6-text', 'surfer6-binary' and 'surfer7' are the outputing grid format.
|
||||
4. `save gmsh <file>` Save the grid using the Gmsh legacy format. This command will write all data that are allowed for outputing.
|
||||
5. `save text <file>` Save the grid data to text file.
|
||||
|
Loading…
Reference in New Issue
Block a user