14 current_cell.reset ();
23 double hx,
double hy) {
42 if (
data !=
nullptr) {
65 if (data !=
nullptr) {
74 if (data->rowidx == 0)
77 data->rowidx = tmp % data->num_rows ();
78 data->colidx = tmp / data->num_rows ();
79 data->global_cell_idx = tmp;
80 data->local_cell_idx = tmp -
81 (data->start_cell_row () +
82 data->num_rows () * data->start_cell_col ());
85 if (data->rowidx == data->num_rows () - 1)
92 if (data->colidx == 1)
99 if (data->colidx == data->num_cols () - 1) {
108 data->rowidx = tmp % data->num_rows ();
109 data->colidx = tmp / data->num_rows ();
110 data->global_cell_idx = tmp;
111 data->local_cell_idx = tmp -
x
112 (data->start_cell_row () +
113 data->num_rows () * data->start_cell_col ());
163 static idx_t bottom_left = 0;
165 bottom_left = row_idx () + col_idx () * (
num_rows () + 1);
168 return (bottom_left);
171 return (bottom_left + 1);
174 return (bottom_left + (
num_rows () + 1));
177 return (bottom_left + (
num_rows () + 2));
191 static idx_t glob = 0;
229 static double bottom_left = 0.0;
237 if (inode == 1 || inode == 3)
240 return (bottom_left);
252 if (row_idx () == 0 && iedge == 0)
255 if (row_idx () ==
num_rows () - 1 && iedge == 1)
258 if (col_idx () == 0 && iedge == 2)
261 if (col_idx () ==
num_cols () - 1 && iedge == 3)
264 return (NOT_ON_BOUNDARY);
292 throw std::out_of_range (
"inode must be in range 0..3");
309 else if (idir == 1) {
319 else if (idir == 1) {
329 else if (idir == 1) {
339 else if (idir == 1) {
345 throw std::out_of_range (
"inode must be in range 0..3, idir must be either 0 or 1");
357 const std::map<std::string, T> & f)
const {
359 std::ofstream ofs (filename, std::ofstream::out);
364 "<VTKFile type=\"StructuredGrid\" version=\"StructuredGrid\" byte_order=\"LittleEndian\">\n\
365 <StructuredGrid WholeExtent=\"0 " <<
num_rows() <<
" 0 " <<
num_cols() <<
" 0 0\">\n \
368 ofs <<
" <PointData Scalars=\"";
369 for (
auto const & ii : f) {
370 ofs << ii.first <<
",";
374 for (
auto const & ii : f) {
375 ofs <<
" <DataArray type=\"Float64\" Name=\"" << ii.first <<
"\" format=\"ascii\">\n ";
376 for (
auto const & jj : ii.second) {
379 ofs << std::endl <<
" </DataArray>" << std::endl;
382 ofs <<
" </PointData>\n";
384 ofs <<
" <Points>\n <DataArray type=\"Float64\" NumberOfComponents=\"3\" format=\"ascii\">\n";
388 ofs << std::setprecision(16) <<
hx()*ii <<
" " <<
hy()*jj <<
" 0 ";
392 ofs <<
" </DataArray>\n </Points>\n";
407(
const char *filename,
408 std::map<std::string, T>
const & vars)
const {
410 std::ofstream os (filename, std::ofstream::out);
412 os <<
"# name: p" << std::endl
413 <<
"# type: matrix" << std::endl
414 <<
"# rows: 2" << std::endl
419 os << std::setprecision(16) << jj*
hx() <<
" ";
426 os << std::setprecision(16) << ii*
hy() <<
" ";
431 os <<
"# name: t" << std::endl
432 <<
"# type: matrix" << std::endl
433 <<
"# rows: 4" << std::endl
436 inode < quadgrid_t<std::vector<double>>::cell_t::nodes_per_cell;
440 os << std::setprecision(16) << icell->gt(inode) <<
" ";
446 os <<
"# name: vars" << std::endl
447 <<
"# type: scalar struct" << std::endl
448 <<
"# ndims: 2" << std::endl
449 <<
"1 1" << std::endl
450 <<
"# length: " << vars.size () << std::endl;
453 for (
auto const & ii : vars) {
454 os <<
"# name: " << ii.first << std::endl
455 <<
"# type: matrix" << std::endl
456 <<
"# rows: 1" << std::endl
457 <<
"# columns: " << ii.second.size () << std::endl;
458 for (
auto const & kk : ii.second) {
459 os << std::setprecision(16) << kk <<
" ";
Definition: quadgrid_cpp.h:55
cell_t * data
Definition: quadgrid_cpp.h:91
void operator++()
Definition: quadgrid_cpp_imp.h:40
idx_t start_cell_row() const
Definition: quadgrid_cpp.h:190
idx_t end_cell_col() const
Definition: quadgrid_cpp.h:178
idx_t global_cell_idx
Definition: quadgrid_cpp.h:240
double p(idx_t i, idx_t j) const
Definition: quadgrid_cpp_imp.h:227
idx_t num_rows() const
Definition: quadgrid_cpp.h:194
idx_t rowidx
Definition: quadgrid_cpp.h:237
idx_t colidx
Definition: quadgrid_cpp.h:238
idx_t local_cell_idx
Definition: quadgrid_cpp.h:239
idx_t end_cell_row() const
Definition: quadgrid_cpp.h:182
idx_t gt(idx_t i) const
Definition: quadgrid_cpp_imp.h:162
idx_t e(idx_t i) const
Definition: quadgrid_cpp_imp.h:249
double shp(double x, double y, idx_t inode) const
Definition: quadgrid_cpp_imp.h:273
double shg(double x, double y, idx_t idir, idx_t inode) const
Definition: quadgrid_cpp_imp.h:302
idx_t t(idx_t i) const
Definition: quadgrid_cpp_imp.h:190
idx_t start_cell_col() const
Definition: quadgrid_cpp.h:186
void operator++()
Definition: quadgrid_cpp_imp.h:63
Definition: quadgrid_cpp.h:15
idx_t num_local_cells() const
Definition: quadgrid_cpp_imp.h:123
idx_t num_owned_nodes()
Definition: quadgrid_cpp.h:316
idx_t num_cols() const
Definition: quadgrid_cpp.h:336
double hy() const
Definition: quadgrid_cpp.h:344
void vtk_export(const char *filename, const std::map< std::string, distributed_vector > &f) const
Definition: quadgrid_cpp_imp.h:356
void set_sizes(idx_t numrows, idx_t numcols, double hx, double hy)
Definition: quadgrid_cpp_imp.h:22
double hx() const
Definition: quadgrid_cpp.h:340
idx_t num_local_nodes() const
Definition: quadgrid_cpp_imp.h:151
idx_t num_global_nodes() const
Definition: quadgrid_cpp_imp.h:141
idx_t num_rows() const
Definition: quadgrid_cpp.h:332
int idx_t
Definition: quadgrid_cpp.h:19
cell_iterator begin_cell_sweep()
Definition: quadgrid_cpp_imp.h:4
void octave_ascii_export(const char *filename, const std::map< std::string, distributed_vector > &f) const
Definition: quadgrid_cpp_imp.h:407
grid_properties_t grid_properties
Definition: quadgrid_cpp.h:371
cell_iterator end_cell_sweep()
Definition: quadgrid_cpp.h:308
idx_t num_global_cells() const
Definition: quadgrid_cpp_imp.h:132
double hy
Definition: quadgrid_cpp.h:26
double hx
Definition: quadgrid_cpp.h:26
idx_t numcols
Definition: quadgrid_cpp.h:25
idx_t numrows
Definition: quadgrid_cpp.h:24
idx_t num_owned_nodes
Definition: quadgrid_cpp.h:32
idx_t start_owned_nodes
Definition: quadgrid_cpp.h:31