From: Vaishnavi Kale Date: Mon, 9 Dec 2024 22:25:46 +0000 (-0700) Subject: Renamed field_data as cell_data and changed type from std::vector to Vector... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=33244764f5a6558ca14d1945d64e1f8d6723cf21;p=dealii.git Renamed field_data as cell_data and changed type from std::vector to Vector --- diff --git a/include/deal.II/grid/grid_in.h b/include/deal.II/grid/grid_in.h index 20ecab5d36..90b33327ac 100644 --- a/include/deal.II/grid/grid_in.h +++ b/include/deal.II/grid/grid_in.h @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -769,22 +770,23 @@ public: get_format_names(); /** - * Return a map containing field data associated with the elements of an + * Return a map containing cell data associated with the elements of an * external vtk format mesh imported using read_vtk(). * The format of the returned map is as * follows: * - std::string stores the name of the field data (identifier) as specified * in the external mesh - * - std::vector stores value for the given identifier in each cell. - * To access the value, use field_data[name_field][cell_id]. For example, if - * the vtk mesh contains field data 'Density' defined at the cells, - * field_data['Density'][0] would be the density defined at cell ID '0', + * - Vector stores value for the given identifier in each cell. + * To access the value, use cell_data[name_field][cell->active_cell_index()]. + * + * For example, if the vtk mesh contains field data 'Density' defined at the + * cells, cell_data['Density'][0] would be the density defined at cell ID '0', * which corresponds to index 0 of the vector. The length of the vector in - * field_data['Density'] would equal the number of elements in the coarse + * cell_data['Density'] would equal the number of elements in the coarse * mesh. */ - const std::map> & - get_field_data() const; + const std::map> & + get_cell_data() const; /** * Exception @@ -973,11 +975,11 @@ private: * The format is as follows: * - std::string stores the name of the field data (identifier) as specified * in the external mesh - * - std::vector stores value for the given identifier in each - * cell_id. - * To access the value use field_data[name_field][cell_id]. + * - Vector stores value for the given identifier in each cell id. + * + * To access the value use cell_data[name_field][cell->active_cell_index()]. */ - std::map> field_data; + std::map> cell_data; }; /* -------------- declaration of explicit specializations ------------- */ diff --git a/source/grid/grid_in.cc b/source/grid/grid_in.cc index 84054b8b19..01523b6140 100644 --- a/source/grid/grid_in.cc +++ b/source/grid/grid_in.cc @@ -625,15 +625,15 @@ GridIn::read_vtk(std::istream &in) subcelldata.boundary_lines.size()) + ") in 2d.")); in >> data_type; - std::vector temp_data; - temp_data.resize(n_ids); + Vector temp_data; + temp_data.reinit(n_ids); for (unsigned int j = 0; j < n_ids; ++j) { in >> data; if (j < cells.size()) temp_data[j] = data; } - this->field_data[section_name] = std::move(temp_data); + this->cell_data[section_name] = std::move(temp_data); } } else @@ -654,10 +654,10 @@ GridIn::read_vtk(std::istream &in) } template -const std::map> & -GridIn::get_field_data() const +const std::map> & +GridIn::get_cell_data() const { - return this->field_data; + return this->cell_data; } template diff --git a/tests/grid/grid_in_vtk_2d_field_data.cc b/tests/grid/grid_in_vtk_2d_field_data.cc index 152f30a8f0..537fb26ddf 100644 --- a/tests/grid/grid_in_vtk_2d_field_data.cc +++ b/tests/grid/grid_in_vtk_2d_field_data.cc @@ -45,16 +45,16 @@ check_file(const std::string name, typename GridIn::Format format) gridin.read(name, format); deallog << '\t' << triangulation.n_vertices() << '\t' << triangulation.n_cells() << std::endl; - std::map> field_data; + std::map> cell_data; - field_data = gridin.get_field_data(); - if (field_data.size() > 0) + cell_data = gridin.get_cell_data(); + if (cell_data.size() > 0) { - std::map>::const_iterator iter = - field_data.find("Density"); - if (iter != field_data.end()) + std::map>::const_iterator iter = + cell_data.find("Density"); + if (iter != cell_data.end()) { - std::vector cell_density = iter->second; + Vector cell_density = iter->second; for (typename Triangulation::active_cell_iterator cell = triangulation.begin_active(); cell != triangulation.end();