This class implements writing meshes in the GMV format.
More...
#include <gmv_io.h>
|
| GMVIO (const MeshBase &) |
| Constructor. More...
|
|
| GMVIO (MeshBase &) |
| Constructor. More...
|
|
virtual void | write (const std::string &) override |
| This method implements writing a mesh to a specified file. More...
|
|
virtual void | read (const std::string &mesh_file) override |
| This method implements reading a mesh from a specified file. More...
|
|
virtual void | write_nodal_data (const std::string &, const std::vector< Number > &, const std::vector< std::string > &) override |
| This method implements writing a mesh with nodal data to a specified file where the nodal data and variable names are provided. More...
|
|
bool & | binary () |
| Flag indicating whether or not to write a binary file. More...
|
|
bool & | discontinuous () |
| Flag indicating whether or not to write the mesh as discontinuous cell patches. More...
|
|
bool & | partitioning () |
| Flag indicating whether or not to write the partitioning information for the mesh. More...
|
|
bool & | write_subdomain_id_as_material () |
| Flag to write element subdomain_id's as GMV "materials" instead of element processor_id's. More...
|
|
bool & | subdivide_second_order () |
| Flag indicating whether or not to subdivide second order elements. More...
|
|
bool & | p_levels () |
| Flag indicating whether or not to write p level information for p refined meshes. More...
|
|
void | write_discontinuous_gmv (const std::string &name, const EquationSystems &es, const bool write_partitioning, const std::set< std::string > *system_names=nullptr) const |
| Writes a GMV file with discontinuous data. More...
|
|
void | write_ascii_new_impl (const std::string &, const std::vector< Number > *=nullptr, const std::vector< std::string > *=nullptr) |
| This method implements writing a mesh with nodal data to a specified file where the nodal data and variable names are optionally provided. More...
|
|
void | add_cell_centered_data (const std::string &cell_centered_data_name, const std::vector< Real > *cell_centered_data_vals) |
| Takes a vector of cell-centered data to be plotted. More...
|
|
void | copy_nodal_solution (EquationSystems &es) |
| If we read in a nodal solution while reading in a mesh, we can attempt to copy that nodal solution into an EquationSystems object. More...
|
|
virtual void | write_equation_systems (const std::string &, const EquationSystems &, const std::set< std::string > *system_names=nullptr) |
| This method implements writing a mesh with data to a specified file where the data is taken from the EquationSystems object. More...
|
|
virtual void | write_discontinuous_equation_systems (const std::string &, const EquationSystems &, const std::set< std::string > *system_names=nullptr) |
| This method implements writing a mesh with discontinuous data to a specified file where the data is taken from the EquationSystems object. More...
|
|
virtual void | write_nodal_data (const std::string &, const NumericVector< Number > &, const std::vector< std::string > &) |
| This method may be overridden by "parallel" output formats for writing nodal data. More...
|
|
virtual void | write_nodal_data (const std::string &, const EquationSystems &, const std::set< std::string > *) |
| This method should be overridden by "parallel" output formats for writing nodal data. More...
|
|
virtual void | write_nodal_data_discontinuous (const std::string &, const std::vector< Number > &, const std::vector< std::string > &) |
| This method implements writing a mesh with discontinuous data to a specified file where the nodal data and variables names are provided. More...
|
|
unsigned int & | ascii_precision () |
| Return/set the precision to use when writing ASCII files. More...
|
|
|
void | write_ascii_old_impl (const std::string &, const std::vector< Number > *=nullptr, const std::vector< std::string > *=nullptr) |
| This method implements writing a mesh with nodal data to a specified file where the nodal data and variable names are optionally provided. More...
|
|
void | write_binary (const std::string &, const std::vector< Number > *=nullptr, const std::vector< std::string > *=nullptr) |
| This method implements writing a mesh with nodal data to a specified file where the nodal data and variable names are optionally provided. More...
|
|
void | _read_nodes () |
| Helper functions for reading nodes/cells from a GMV file. More...
|
|
void | _read_one_cell () |
|
ElemType | gmv_elem_to_libmesh_elem (std::string elemname) |
|
void | _read_materials () |
|
void | _read_var () |
|
This class implements writing meshes in the GMV format.
For a full description of the GMV format and to obtain the GMV software see http://www.generalmeshviewer.com
- Author
- Benjamin S. Kirk
- Date
- 2004
Definition at line 54 of file gmv_io.h.
◆ GMVIO() [1/2]
libMesh::GMVIO::GMVIO |
( |
const MeshBase & |
mesh | ) |
|
|
explicit |
Constructor.
Takes a reference to a constant mesh object. This constructor will only allow us to write the mesh.
Definition at line 242 of file gmv_io.C.
◆ GMVIO() [2/2]
libMesh::GMVIO::GMVIO |
( |
MeshBase & |
mesh | ) |
|
|
explicit |
Constructor.
Takes a writable reference to a mesh object. This constructor is required to let us read in a mesh.
Definition at line 256 of file gmv_io.C.
◆ _read_materials()
void libMesh::GMVIO::_read_materials |
( |
| ) |
|
|
private |
Definition at line 2042 of file gmv_io.C.
2044 #ifdef LIBMESH_HAVE_GMV
2047 libmesh_assert_equal_to (GMVLib::gmv_data.datatype, CELL);
2056 for (
int i = 0; i < GMVLib::gmv_data.nlongdata1; i++)
2058 cast_int<processor_id_type>(GMVLib::gmv_data.longdata1[i]-1);
Referenced by read().
◆ _read_nodes()
void libMesh::GMVIO::_read_nodes |
( |
| ) |
|
|
private |
Helper functions for reading nodes/cells from a GMV file.
Definition at line 2066 of file gmv_io.C.
2068 #ifdef LIBMESH_HAVE_GMV
2070 libmesh_assert_equal_to (GMVLib::gmv_data.datatype, UNSTRUCT);
2074 for (
int i = 0; i < GMVLib::gmv_data.num; i++)
2078 GMVLib::gmv_data.doubledata2[i],
2079 GMVLib::gmv_data.doubledata3[i]), i);
References libMesh::MeshInput< MT >::mesh().
Referenced by read().
◆ _read_one_cell()
void libMesh::GMVIO::_read_one_cell |
( |
| ) |
|
|
private |
Definition at line 2085 of file gmv_io.C.
2087 #ifdef LIBMESH_HAVE_GMV
2092 (GMVLib::gmv_data.datatype==REGULAR) ||
2093 (GMVLib::gmv_data.datatype==ENDKEYWORD);
2099 if (GMVLib::gmv_data.datatype == REGULAR)
2118 const ElementDefinition & eledef = eletypes[type];
2122 for (
int i=0; i<GMVLib::gmv_data.num2; i++)
2125 unsigned mapped_i = eledef.node_map[i];
2129 (cast_int<dof_id_type>(GMVLib::gmv_data.longdata1[mapped_i]-1));
2139 if (GMVLib::gmv_data.datatype == ENDKEYWORD)
References _next_elem_id, libMesh::MeshBase::add_elem(), libMesh::Elem::build(), libMesh::Elem::dim(), libMesh::MeshInput< MeshBase >::elems_of_dimension, gmv_elem_to_libmesh_elem(), libMesh::libmesh_assert(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshInput< MT >::mesh(), libMesh::MeshBase::node_ptr(), libMesh::DofObject::set_id(), and libMesh::Elem::set_node().
Referenced by read().
◆ _read_var()
void libMesh::GMVIO::_read_var |
( |
| ) |
|
|
private |
Definition at line 2030 of file gmv_io.C.
2032 #ifdef LIBMESH_HAVE_GMV
2035 _nodal_data.insert ( std::make_pair(std::string(GMVLib::gmv_data.name1),
2036 std::vector<Number>(GMVLib::gmv_data.doubledata1, GMVLib::gmv_data.doubledata1+GMVLib::gmv_data.num) ) );
References _nodal_data.
Referenced by read().
◆ add_cell_centered_data()
void libMesh::GMVIO::add_cell_centered_data |
( |
const std::string & |
cell_centered_data_name, |
|
|
const std::vector< Real > * |
cell_centered_data_vals |
|
) |
| |
Takes a vector of cell-centered data to be plotted.
You must ensure that for every active element e, v[e->id()] is a valid number. You can add an arbitrary number of different cell-centered data sets by calling this function multiple times.
.) GMV does not like spaces in the cell_centered_data_name .) No matter what order you add cell-centered data, it will be output alphabetically.
Definition at line 1862 of file gmv_io.C.
References _cell_centered_data, and libMesh::libmesh_assert().
◆ ascii_precision()
Return/set the precision to use when writing ASCII files.
By default we use numeric_limits<Real>::max_digits10, which should be enough to write out to ASCII and get the exact same Real back when reading in.
Definition at line 257 of file mesh_output.h.
◆ binary()
bool& libMesh::GMVIO::binary |
( |
| ) |
|
|
inline |
Flag indicating whether or not to write a binary file.
While binary files may end up being smaller than equivalent ASCII files, they are harder to debug if anything goes wrong, since they are not human-readable.
Definition at line 103 of file gmv_io.h.
References _binary.
Referenced by write(), and write_nodal_data().
◆ build_reading_element_map()
std::map< std::string, ElemType > libMesh::GMVIO::build_reading_element_map |
( |
| ) |
|
|
staticprivate |
Static function used to build the _reading_element_map.
Definition at line 209 of file gmv_io.C.
211 std::map<std::string, ElemType> ret;
223 ret[
"phex20"] =
HEX20;
224 ret[
"phex27"] =
HEX27;
226 ret[
"ptet10"] =
TET10;
228 ret[
"8quad"] =
QUAD8;
229 ret[
"3line"] =
EDGE3;
References libMesh::EDGE2, libMesh::EDGE3, libMesh::HEX20, libMesh::HEX27, libMesh::HEX8, libMesh::PRISM15, libMesh::PRISM6, libMesh::QUAD4, libMesh::QUAD8, libMesh::TET10, libMesh::TET4, libMesh::TRI3, and libMesh::TRI6.
◆ copy_nodal_solution()
If we read in a nodal solution while reading in a mesh, we can attempt to copy that nodal solution into an EquationSystems object.
Definition at line 2159 of file gmv_io.C.
2164 libMesh::err <<
"Unable to copy nodal solution: No nodal "
2165 <<
"solution has been read in from file." << std::endl;
2178 std::set<std::string> vars_copied;
2191 const std::string & var_name = pr.first;
2206 libMesh::err <<
"Only FIRST-order LAGRANGE variables can be read from GMV files. "
2207 <<
"Skipping variable " << var_name << std::endl;
2215 sz = cast_int<dof_id_type>(pr.second.size());
2220 const unsigned int dof_index =
2226 if ((dof_index >= system.
solution->first_local_index()) &&
2227 (dof_index < system.solution->last_local_index()))
2228 system.
solution->set (dof_index, pr.second [i]);
2232 vars_copied.insert (var_name);
2245 if (vars_copied.find(pr.first) == vars_copied.end())
2248 <<
" was not copied to the EquationSystems object."
References _nodal_data, libMesh::err, libMesh::FEType::family, libMesh::FIRST, libMesh::OrderWrapper::get_order(), libMesh::EquationSystems::get_system(), libMesh::System::has_variable(), libMesh::LAGRANGE, libMesh::libmesh_assert(), libMesh::MeshInput< MT >::mesh(), libMesh::EquationSystems::n_systems(), libMesh::FEType::order, libMesh::System::solution, libMesh::System::update(), libMesh::System::variable_number(), and libMesh::System::variable_type().
◆ discontinuous()
bool& libMesh::GMVIO::discontinuous |
( |
| ) |
|
|
inline |
Flag indicating whether or not to write the mesh as discontinuous cell patches.
Definition at line 109 of file gmv_io.h.
References _discontinuous.
◆ gmv_elem_to_libmesh_elem()
ElemType libMesh::GMVIO::gmv_elem_to_libmesh_elem |
( |
std::string |
elemname | ) |
|
|
private |
◆ mesh() [1/2]
- Returns
- The object as a writable reference.
Definition at line 169 of file mesh_input.h.
172 libmesh_error_msg(
"ERROR: _obj should not be nullptr!");
◆ mesh() [2/2]
- Returns
- The object as a read-only reference.
Definition at line 247 of file mesh_output.h.
◆ p_levels()
bool& libMesh::GMVIO::p_levels |
( |
| ) |
|
|
inline |
◆ partitioning()
bool& libMesh::GMVIO::partitioning |
( |
| ) |
|
|
inline |
◆ read()
void libMesh::GMVIO::read |
( |
const std::string & |
mesh_file | ) |
|
|
overridevirtual |
This method implements reading a mesh from a specified file.
Implements libMesh::MeshInput< MeshBase >.
Definition at line 1879 of file gmv_io.C.
1888 libmesh_experimental();
1890 #ifndef LIBMESH_HAVE_GMV
1892 libmesh_error_msg(
"Cannot read GMV file " <<
name <<
" without the GMV API.");
1911 int ierr = GMVLib::gmvread_open_fromfileskip(const_cast<char *>(
name.c_str()));
1913 libmesh_error_msg(
"GMVLib::gmvread_open_fromfileskip failed!");
1920 GMVLib::gmvread_data();
1923 if (GMVLib::gmv_data.keyword == GMVEND)
1926 GMVLib::gmvread_close();
1931 if (GMVLib::gmv_data.keyword == GMVERROR)
1932 libmesh_error_msg(
"Encountered GMVERROR while reading!");
1935 switch (GMVLib::gmv_data.keyword)
1939 if (GMVLib::gmv_data.num2 ==
NODES)
1942 else if (GMVLib::gmv_data.num2 == NODE_V)
1943 libmesh_error_msg(
"Unsupported GMV data type NODE_V!");
1970 if (GMVLib::gmv_data.datatype == ENDKEYWORD)
1975 if (GMVLib::gmv_data.datatype == NODE)
1984 << GMVLib::gmv_data.name1
1985 <<
" which is of unsupported GMV datatype "
1986 << GMVLib::gmv_data.datatype
1987 <<
". Nodal field data is currently the only type currently supported."
1995 libmesh_error_msg(
"Encountered unknown GMV keyword " << GMVLib::gmv_data.keyword);
2001 for (
unsigned char i=0; i!=4; ++i)
2007 libmesh_error_msg(
"Cannot open dimension " \
2009 <<
" mesh file when configured without " \
References _next_elem_id, _read_materials(), _read_nodes(), _read_one_cell(), _read_var(), libMesh::MeshBase::allow_renumbering(), libMesh::MeshBase::clear(), libMesh::MeshInput< MeshBase >::elems_of_dimension, libMesh::err, libMesh::ierr, libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshInput< MT >::mesh(), libMesh::MeshBase::mesh_dimension(), libMesh::Quality::name(), libMesh::Trees::NODES, libMesh::MeshBase::prepare_for_use(), and libMesh::MeshBase::set_mesh_dimension().
Referenced by libMesh::NameBasedIO::read().
◆ set_n_partitions()
Sets the number of partitions in the mesh.
Typically this gets done by the partitioner, but some parallel file formats begin "pre-partitioned".
Definition at line 91 of file mesh_input.h.
◆ skip_comment_lines()
Reads input from in
, skipping all the lines that start with the character comment_start
.
Definition at line 179 of file mesh_input.h.
184 while (in.get(c), c==comment_start)
185 in.getline (line, 255);
◆ subdivide_second_order()
bool& libMesh::GMVIO::subdivide_second_order |
( |
| ) |
|
|
inline |
◆ write()
void libMesh::GMVIO::write |
( |
const std::string & |
fname | ) |
|
|
overridevirtual |
◆ write_ascii_new_impl()
void libMesh::GMVIO::write_ascii_new_impl |
( |
const std::string & |
fname, |
|
|
const std::vector< Number > * |
v = nullptr , |
|
|
const std::vector< std::string > * |
solution_names = nullptr |
|
) |
| |
This method implements writing a mesh with nodal data to a specified file where the nodal data and variable names are optionally provided.
This will write an ASCII file. This is the new implementation (without subcells).
Definition at line 295 of file gmv_io.C.
299 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
301 libMesh::err <<
"WARNING: GMVIO::write_ascii_new_impl() not infinite-element aware!"
320 std::ofstream out_stream (fname.c_str());
325 if (!out_stream.good())
326 libmesh_file_error(fname.c_str());
328 unsigned int mesh_max_p_level = 0;
332 out_stream <<
"gmvinput ascii\n\n";
344 out_stream << 0. <<
" ";
352 out_stream << 0. <<
" ";
354 out_stream <<
"\n\n";
359 out_stream <<
"cells " << n_active_elem <<
"\n";
366 mesh_max_p_level = std::max(mesh_max_p_level,
373 const ElementDefinition & ele = eletypes[elem->type()];
377 libmesh_assert_less_equal (ele.node_map.size(), elem->n_nodes());
379 out_stream << ele.label <<
"\n";
381 out_stream << elem->node_id(ele.node_map[i])+1 <<
" ";
391 libmesh_error_msg(
"Not yet supported in GMVIO::write_ascii_new_impl");
395 out_stream <<
"material "
410 out_stream <<
"proc_" << proc <<
"\n";
414 out_stream << elem->processor_id()+1 <<
"\n";
423 bool write_variable =
false;
426 if (this->
p_levels() && mesh_max_p_level)
427 write_variable =
true;
430 if ((solution_names !=
nullptr) && (v !=
nullptr))
431 write_variable =
true;
435 write_variable =
true;
438 out_stream <<
"variable\n";
445 if (this->
p_levels() && mesh_max_p_level)
447 out_stream <<
"p_level 0\n";
451 const ElementDefinition & ele = eletypes[elem->type()];
455 libmesh_assert_less_equal (ele.node_map.size(), elem->n_nodes());
457 for (std::size_t i=0, enms=ele.node_map.size(); i < enms; i++)
458 out_stream << elem->p_level() <<
" ";
460 out_stream <<
"\n\n";
470 out_stream << pr.first <<
" 0\n";
472 const std::vector<Real> * the_array = pr.second;
480 libmesh_assert_less (elem->id(), the_array->size());
481 const Real the_value = the_array->operator[](elem->id());
484 for (
unsigned int se=0, nse=elem->n_sub_elem(); se<nse; se++)
485 out_stream << the_value <<
" ";
487 out_stream << the_value <<
" ";
490 out_stream <<
"\n\n";
496 if ((solution_names !=
nullptr) && (v !=
nullptr))
498 const unsigned int n_vars = solution_names->size();
509 for (
unsigned int c=0; c<
n_vars; c++)
512 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
518 out_stream <<
"r_" << (*solution_names)[c] <<
" 1\n";
521 out_stream << (*v)[n*
n_vars + c].real() <<
" ";
523 out_stream <<
"\n\n";
526 out_stream <<
"i_" << (*solution_names)[c] <<
" 1\n";
529 out_stream << (*v)[n*
n_vars + c].imag() <<
" ";
531 out_stream <<
"\n\n";
534 out_stream <<
"a_" << (*solution_names)[c] <<
" 1\n";
538 out_stream <<
"\n\n";
542 out_stream << (*solution_names)[c] <<
" 1\n";
545 out_stream << (*v)[n*
n_vars + c] <<
" ";
547 out_stream <<
"\n\n";
556 out_stream <<
"endvars\n";
560 out_stream <<
"\nendgmv\n";
References _cell_centered_data, std::abs(), libMesh::MeshBase::active_element_ptr_range(), libMesh::MeshOutput< MeshBase >::ascii_precision(), libMesh::err, libMesh::index_range(), libMesh::libmesh_assert(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), libMesh::MeshBase::n_active_elem(), libMesh::MeshBase::n_nodes(), libMesh::MeshBase::n_partitions(), n_vars, p_levels(), partitioning(), libMesh::MeshBase::point(), libMesh::Real, subdivide_second_order(), write_ascii_old_impl(), and write_subdomain_id_as_material().
◆ write_ascii_old_impl()
void libMesh::GMVIO::write_ascii_old_impl |
( |
const std::string & |
fname, |
|
|
const std::vector< Number > * |
v = nullptr , |
|
|
const std::vector< std::string > * |
solution_names = nullptr |
|
) |
| |
|
private |
This method implements writing a mesh with nodal data to a specified file where the nodal data and variable names are optionally provided.
This will write an ASCII file. This is the old implementation (using subcells) which was the default in libMesh-0.4.3-rc2.
Definition at line 570 of file gmv_io.C.
592 std::ofstream out_stream (fname.c_str());
598 if (!out_stream.good())
599 libmesh_file_error(fname.c_str());
613 unsigned int mesh_max_p_level = 0;
623 out_stream <<
"gmvinput ascii\n\n";
634 out_stream << 0. <<
" ";
643 out_stream << 0. <<
" ";
646 out_stream <<
'\n' <<
'\n';
654 out_stream <<
"cells ";
656 out_stream << n_active_sub_elem;
658 out_stream << n_active_elem;
662 std::vector<dof_id_type> conn;
666 mesh_max_p_level = std::max(mesh_max_p_level,
676 out_stream <<
"line 2\n";
677 elem->connectivity(se,
TECPLOT, conn);
678 for (
const auto &
idx : conn)
679 out_stream <<
idx <<
" ";
685 out_stream <<
"line 2\n";
686 if (elem->default_order() ==
FIRST)
687 elem->connectivity(0,
TECPLOT, conn);
691 for (
auto i : lo_elem->node_index_range())
692 lo_elem->set_node(i) = elem->node_ptr(i);
693 lo_elem->connectivity(0,
TECPLOT, conn);
695 for (
const auto &
idx : conn)
696 out_stream <<
idx <<
" ";
710 if ((elem->type() ==
QUAD4) ||
711 (elem->type() ==
QUAD8) ||
714 (elem->type() ==
QUAD9)
715 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
721 out_stream <<
"quad 4\n";
722 elem->connectivity(se,
TECPLOT, conn);
723 for (
const auto &
idx : conn)
724 out_stream <<
idx <<
" ";
728 else if ((elem->type() ==
TRI3) ||
729 (elem->type() ==
TRI6))
731 out_stream <<
"tri 3\n";
732 elem->connectivity(se,
TECPLOT, conn);
733 for (
unsigned int i=0; i<3; i++)
734 out_stream << conn[i] <<
" ";
742 if ((elem->type() ==
QUAD4)
743 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
748 elem->connectivity(0,
TECPLOT, conn);
749 out_stream <<
"quad 4\n";
750 for (
const auto &
idx : conn)
751 out_stream <<
idx <<
" ";
753 else if ((elem->type() ==
QUAD8) ||
754 (elem->type() ==
QUAD9)
755 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
761 for (
auto i : lo_elem->node_index_range())
762 lo_elem->set_node(i) = elem->node_ptr(i);
763 lo_elem->connectivity(0,
TECPLOT, conn);
764 out_stream <<
"quad 4\n";
765 for (
const auto &
idx : conn)
766 out_stream <<
idx <<
" ";
768 else if (elem->type() ==
TRI3)
770 elem->connectivity(0,
TECPLOT, conn);
771 out_stream <<
"tri 3\n";
772 for (
unsigned int i=0; i<3; i++)
773 out_stream << conn[i] <<
" ";
775 else if (elem->type() ==
TRI6)
778 for (
auto i : lo_elem->node_index_range())
779 lo_elem->set_node(i) = elem->node_ptr(i);
780 lo_elem->connectivity(0,
TECPLOT, conn);
781 out_stream <<
"tri 3\n";
782 for (
unsigned int i=0; i<3; i++)
783 out_stream << conn[i] <<
" ";
798 #ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
799 if ((elem->type() ==
HEX8) ||
800 (elem->type() ==
HEX27))
802 out_stream <<
"phex8 8\n";
803 elem->connectivity(se,
TECPLOT, conn);
804 for (
const auto &
idx : conn)
805 out_stream <<
idx <<
" ";
808 else if (elem->type() ==
HEX20)
810 out_stream <<
"phex20 20\n";
811 out_stream << elem->node_id(0)+1 <<
" "
812 << elem->node_id(1)+1 <<
" "
813 << elem->node_id(2)+1 <<
" "
814 << elem->node_id(3)+1 <<
" "
815 << elem->node_id(4)+1 <<
" "
816 << elem->node_id(5)+1 <<
" "
817 << elem->node_id(6)+1 <<
" "
818 << elem->node_id(7)+1 <<
" "
819 << elem->node_id(8)+1 <<
" "
820 << elem->node_id(9)+1 <<
" "
821 << elem->node_id(10)+1 <<
" "
822 << elem->node_id(11)+1 <<
" "
823 << elem->node_id(16)+1 <<
" "
824 << elem->node_id(17)+1 <<
" "
825 << elem->node_id(18)+1 <<
" "
826 << elem->node_id(19)+1 <<
" "
827 << elem->node_id(12)+1 <<
" "
828 << elem->node_id(13)+1 <<
" "
829 << elem->node_id(14)+1 <<
" "
830 << elem->node_id(15)+1 <<
" ";
885 #else // LIBMESH_ENABLE_INFINITE_ELEMENTS
890 if ((elem->type() ==
HEX8) ||
891 (elem->type() ==
HEX27) ||
895 (elem->type() ==
HEX20))
897 out_stream <<
"phex8 8\n";
898 elem->connectivity(se,
TECPLOT, conn);
899 for (
const auto &
idx : conn)
900 out_stream <<
idx <<
" ";
904 else if ((elem->type() ==
TET4) ||
905 (elem->type() ==
TET10))
907 out_stream <<
"tet 4\n";
912 elem->connectivity(se,
TECPLOT, conn);
913 out_stream << conn[0] <<
" "
918 #ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
919 else if ((elem->type() ==
PRISM6) ||
924 else if ((elem->type() ==
PRISM6) ||
934 out_stream <<
"phex8 8\n";
935 elem->connectivity(se,
TECPLOT, conn);
936 for (
const auto &
idx : conn)
937 out_stream <<
idx <<
" ";
941 libmesh_error_msg(
"Encountered an unrecognized element " \
942 <<
"type: " << elem->type() \
943 <<
"\nPossibly a dim-1 dimensional " \
944 <<
"element? Aborting...");
951 for (
auto i : lo_elem->node_index_range())
952 lo_elem->set_node(i) = elem->node_ptr(i);
953 if ((lo_elem->type() ==
HEX8)
954 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
955 || (lo_elem->type() ==
HEX27)
959 out_stream <<
"phex8 8\n";
960 lo_elem->connectivity(0,
TECPLOT, conn);
961 for (
const auto &
idx : conn)
962 out_stream <<
idx <<
" ";
965 else if (lo_elem->type() ==
TET4)
967 out_stream <<
"tet 4\n";
968 lo_elem->connectivity(0,
TECPLOT, conn);
969 out_stream << conn[0] <<
" "
974 else if ((lo_elem->type() ==
PRISM6)
975 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
982 out_stream <<
"phex8 8\n";
983 lo_elem->connectivity(0,
TECPLOT, conn);
984 for (
const auto &
idx : conn)
985 out_stream <<
idx <<
" ";
989 libmesh_error_msg(
"Encountered an unrecognized element " \
990 <<
"type. Possibly a dim-1 dimensional " \
991 <<
"element? Aborting...");
1000 libmesh_error_msg(
"Unsupported element dimension: " <<
1023 std::map<subdomain_id_type, unsigned> sbdid_map;
1027 sbdid_map.insert(std::make_pair(elem->subdomain_id(), 0));
1033 for (
auto & pr : sbdid_map)
1037 out_stream <<
"material "
1042 out_stream <<
"proc_" << sbdid <<
"\n";
1047 unsigned gmv_mat_number = libmesh_map_find(sbdid_map, elem->subdomain_id());
1050 for (
unsigned int se=0, nse=elem->n_sub_elem(); se<nse; se++)
1051 out_stream << gmv_mat_number+1 <<
'\n';
1053 out_stream << gmv_mat_number+1 <<
"\n";
1060 out_stream <<
"material "
1065 out_stream <<
"proc_" << proc <<
'\n';
1069 for (
unsigned int se=0, nse=elem->n_sub_elem(); se<nse; se++)
1070 out_stream << elem->processor_id()+1 <<
'\n';
1072 out_stream << elem->processor_id()+1 <<
'\n';
1083 bool write_variable =
false;
1086 if (this->
p_levels() && mesh_max_p_level)
1087 write_variable =
true;
1090 if ((solution_names !=
nullptr) && (v !=
nullptr))
1091 write_variable =
true;
1095 write_variable =
true;
1098 out_stream <<
"variable\n";
1102 if (this->
p_levels() && mesh_max_p_level)
1104 out_stream <<
"p_level 0\n";
1108 for (
unsigned int se=0, nse=elem->n_sub_elem(); se<nse; se++)
1109 out_stream << elem->p_level() <<
" ";
1111 out_stream << elem->p_level() <<
" ";
1112 out_stream <<
"\n\n";
1124 out_stream << pr.first <<
" 0\n";
1126 const std::vector<Real> * the_array = pr.second;
1134 libmesh_assert_less (elem->id(), the_array->size());
1135 const Real the_value = (*the_array)[elem->id()];
1138 for (
unsigned int se=0, nse=elem->n_sub_elem(); se<nse; se++)
1139 out_stream << the_value <<
" ";
1141 out_stream << the_value <<
" ";
1144 out_stream <<
"\n\n";
1152 if ((solution_names !=
nullptr) &&
1155 const unsigned int n_vars =
1156 cast_int<unsigned int>(solution_names->size());
1167 for (
unsigned int c=0; c<
n_vars; c++)
1170 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
1176 out_stream <<
"r_" << (*solution_names)[c] <<
" 1\n";
1179 out_stream << (*v)[n*
n_vars + c].real() <<
" ";
1181 out_stream <<
'\n' <<
'\n';
1185 out_stream <<
"i_" << (*solution_names)[c] <<
" 1\n";
1188 out_stream << (*v)[n*
n_vars + c].imag() <<
" ";
1190 out_stream <<
'\n' <<
'\n';
1193 out_stream <<
"a_" << (*solution_names)[c] <<
" 1\n";
1197 out_stream <<
'\n' <<
'\n';
1201 out_stream << (*solution_names)[c] <<
" 1\n";
1204 out_stream << (*v)[n*
n_vars + c] <<
" ";
1206 out_stream <<
'\n' <<
'\n';
1215 out_stream <<
"endvars\n";
1219 out_stream <<
"\nendgmv\n";
References _cell_centered_data, std::abs(), libMesh::MeshBase::active_element_ptr_range(), libMesh::MeshOutput< MeshBase >::ascii_precision(), libMesh::Elem::build(), libMesh::Utility::enum_to_string(), libMesh::err, libMesh::FIRST, libMesh::Elem::first_order_equivalent_type(), libMesh::HEX20, libMesh::HEX27, libMesh::HEX8, libMesh::MeshTools::Generation::Private::idx(), libMesh::INFHEX16, libMesh::INFHEX18, libMesh::INFHEX8, libMesh::INFPRISM12, libMesh::INFPRISM6, libMesh::INFQUAD4, libMesh::INFQUAD6, libMesh::MeshBase::max_node_id(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), libMesh::MeshBase::n_active_elem(), libMesh::MeshBase::n_active_sub_elem(), libMesh::MeshBase::n_nodes(), libMesh::MeshBase::n_partitions(), n_vars, p_levels(), partitioning(), libMesh::MeshBase::point(), libMesh::PRISM15, libMesh::PRISM18, libMesh::PRISM6, libMesh::PYRAMID5, libMesh::QUAD4, libMesh::QUAD8, libMesh::QUAD9, libMesh::Real, subdivide_second_order(), libMesh::TECPLOT, libMesh::TET10, libMesh::TET4, libMesh::TRI3, libMesh::TRI6, and write_subdomain_id_as_material().
Referenced by write(), write_ascii_new_impl(), and write_nodal_data().
◆ write_binary()
void libMesh::GMVIO::write_binary |
( |
const std::string & |
fname, |
|
|
const std::vector< Number > * |
vec = nullptr , |
|
|
const std::vector< std::string > * |
solution_names = nullptr |
|
) |
| |
|
private |
This method implements writing a mesh with nodal data to a specified file where the nodal data and variable names are optionally provided.
Definition at line 1228 of file gmv_io.C.
1245 std::ofstream out_stream (fname.c_str());
1249 unsigned int mesh_max_p_level = 0;
1256 buffer =
"gmvinput";
1257 out_stream.write(buffer.c_str(), buffer.size());
1259 buffer =
"ieeei4r4";
1260 out_stream.write(buffer.c_str(), buffer.size());
1268 out_stream.write(buffer.c_str(), buffer.size());
1271 out_stream.write(reinterpret_cast<char *>(&tempint),
sizeof(
unsigned int));
1276 temp[v] = static_cast<float>(
mesh.
point(v)(0));
1277 out_stream.write(reinterpret_cast<char *>(temp.data()),
sizeof(
float)*
mesh.
n_nodes());
1283 temp[v] = static_cast<float>(
mesh.
point(v)(1));
1288 out_stream.write(reinterpret_cast<char *>(temp.data()),
sizeof(
float)*
mesh.
n_nodes());
1294 temp[v] = static_cast<float>(
mesh.
point(v)(2));
1299 out_stream.write(reinterpret_cast<char *>(temp.data()),
sizeof(
float)*
mesh.
n_nodes());
1306 out_stream.write(buffer.c_str(), buffer.size());
1308 unsigned int tempint = n_active_elem;
1309 out_stream.write(reinterpret_cast<char *>(&tempint),
sizeof(
unsigned int));
1313 mesh_max_p_level = std::max(mesh_max_p_level,
1319 const ElementDefinition & ed = eletypes[elem->type()];
1328 buffer.erase(buffer.find_first_of(
' '), std::string::npos);
1331 while (buffer.size() < 8)
1332 buffer.insert(buffer.end(),
' ');
1335 out_stream.write(buffer.c_str(), buffer.size());
1342 tempint = cast_int<unsigned int>(ed.node_map.size());
1343 out_stream.write(reinterpret_cast<char *>(&tempint),
sizeof(
unsigned int));
1346 for (
const auto & ed_id : ed.node_map)
1349 out_stream.write(reinterpret_cast<char *>(&
id),
sizeof(
dof_id_type));
1360 libmesh_error_msg(
"Not yet supported in GMVIO::write_binary");
1364 buffer =
"material";
1365 out_stream.write(buffer.c_str(), buffer.size());
1368 out_stream.write(reinterpret_cast<char *>(&tmpint),
sizeof(
unsigned int));
1371 out_stream.write(reinterpret_cast<char *>(&tmpint),
sizeof(
unsigned int));
1378 std::ostringstream oss;
1379 oss <<
"proc_" << std::setw(3) << std::left << proc;
1380 out_stream.write(oss.str().c_str(), oss.str().size());
1383 std::vector<unsigned int> proc_id (n_active_elem);
1390 proc_id[n++] = elem->processor_id() + 1;
1392 out_stream.write(reinterpret_cast<char *>(proc_id.data()),
1393 sizeof(
unsigned int)*proc_id.size());
1401 bool write_variable =
false;
1404 if (this->
p_levels() && mesh_max_p_level)
1405 write_variable =
true;
1408 if ((solution_names !=
nullptr) && (vec !=
nullptr))
1409 write_variable =
true;
1417 buffer =
"variable";
1418 out_stream.write(buffer.c_str(), buffer.size());
1422 if (this->
p_levels() && mesh_max_p_level)
1424 unsigned int n_floats = n_active_elem;
1428 std::vector<float> temp(n_floats);
1431 out_stream.write(buffer.c_str(), buffer.size());
1433 unsigned int tempint = 0;
1434 out_stream.write(reinterpret_cast<char *>(&tempint),
sizeof(
unsigned int));
1438 for (
unsigned int se=0, nse=elem->n_sub_elem(); se<nse; se++)
1439 temp[n++] = static_cast<float>( elem->p_level() );
1441 out_stream.write(reinterpret_cast<char *>(temp.data()),
1442 sizeof(
float)*n_floats);
1448 libMesh::err <<
"Cell-centered data not (yet) supported in binary I/O mode!" << std::endl;
1454 if ((solution_names !=
nullptr) &&
1459 const unsigned int n_vars =
1460 cast_int<unsigned int>(solution_names->size());
1462 for (
unsigned int c=0; c<
n_vars; c++)
1465 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
1471 out_stream.write(buffer.c_str(), buffer.size());
1473 buffer = (*solution_names)[c];
1474 out_stream.write(buffer.c_str(), buffer.size());
1476 unsigned int tempint = 1;
1477 out_stream.write(reinterpret_cast<char *>(&tempint),
sizeof(
unsigned int));
1480 temp[n] = static_cast<float>( (*vec)[n*
n_vars + c].
real() );
1482 out_stream.write(reinterpret_cast<char *>(temp.data()),
sizeof(
float)*
mesh.
n_nodes());
1487 out_stream.write(buffer.c_str(), buffer.size());
1489 buffer = (*solution_names)[c];
1490 out_stream.write(buffer.c_str(), buffer.size());
1492 out_stream.write(reinterpret_cast<char *>(&tempint),
sizeof(
unsigned int));
1495 temp[n] = static_cast<float>( (*vec)[n*
n_vars + c].
imag() );
1497 out_stream.write(reinterpret_cast<char *>(temp.data()),
sizeof(
float)*
mesh.
n_nodes());
1501 out_stream.write(buffer.c_str(), buffer.size());
1502 buffer = (*solution_names)[c];
1503 out_stream.write(buffer.c_str(), buffer.size());
1505 out_stream.write(reinterpret_cast<char *>(&tempint),
sizeof(
unsigned int));
1510 out_stream.write(reinterpret_cast<char *>(temp.data()),
sizeof(
float)*
mesh.
n_nodes());
1514 buffer = (*solution_names)[c];
1515 out_stream.write(buffer.c_str(), buffer.size());
1517 unsigned int tempint = 1;
1518 out_stream.write(reinterpret_cast<char *>(&tempint),
sizeof(
unsigned int));
1521 temp[n] = static_cast<float>((*vec)[n*
n_vars + c]);
1523 out_stream.write(reinterpret_cast<char *>(temp.data()),
sizeof(
float)*
mesh.
n_nodes());
1532 buffer =
"endvars ";
1533 out_stream.write(buffer.c_str(), buffer.size());
1538 out_stream.write(buffer.c_str(), buffer.size());
References _cell_centered_data, std::abs(), libMesh::MeshBase::active_element_ptr_range(), libMesh::err, std::imag(), libMesh::libmesh_assert(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), libMesh::MeshBase::mesh_dimension(), libMesh::MeshBase::n_active_elem(), libMesh::MeshBase::n_nodes(), libMesh::ParallelObject::n_processors(), n_vars, p_levels(), partitioning(), libMesh::MeshBase::point(), std::real(), and write_subdomain_id_as_material().
Referenced by write(), and write_nodal_data().
◆ write_discontinuous_equation_systems()
This method implements writing a mesh with discontinuous data to a specified file where the data is taken from the EquationSystems
object.
Definition at line 87 of file mesh_output.C.
91 LOG_SCOPE(
"write_discontinuous_equation_systems()",
"MeshOutput");
95 MT & my_mesh = const_cast<MT &>(*
_obj);
99 libmesh_assert_equal_to(&es.get_mesh(),
_obj);
103 if (my_mesh.max_elem_id() != my_mesh.n_elem() ||
104 my_mesh.max_node_id() != my_mesh.n_nodes())
111 "Warning: This MeshOutput subclass only supports meshes which are contiguously renumbered!"
114 my_mesh.allow_renumbering(
true);
116 my_mesh.renumber_nodes_and_elements();
120 my_mesh.allow_renumbering(
false);
126 std::vector<std::string> names;
127 es.build_variable_names (names,
nullptr, system_names);
133 std::vector<Number> soln;
134 es.build_discontinuous_solution_vector (soln, system_names);
140 libmesh_not_implemented();
◆ write_discontinuous_gmv()
void libMesh::GMVIO::write_discontinuous_gmv |
( |
const std::string & |
name, |
|
|
const EquationSystems & |
es, |
|
|
const bool |
write_partitioning, |
|
|
const std::set< std::string > * |
system_names = nullptr |
|
) |
| const |
Writes a GMV file with discontinuous data.
Definition at line 1549 of file gmv_io.C.
1554 std::vector<std::string> solution_names;
1555 std::vector<Number> v;
1569 std::ofstream out_stream(
name.c_str());
1577 out_stream <<
"gmvinput ascii" << std::endl << std::endl;
1584 tw += elem->n_nodes();
1586 out_stream <<
"nodes " << tw << std::endl;
1594 for (
const Node & node : elem->node_ref_range())
1595 out_stream << node(0) <<
" ";
1597 out_stream << std::endl;
1604 for (
const Node & node : elem->node_ref_range())
1606 out_stream << node(1) <<
" ";
1608 out_stream << 0. <<
" ";
1611 out_stream << std::endl;
1618 for (
const Node & node : elem->node_ref_range())
1620 out_stream << node(2) <<
" ";
1622 out_stream << 0. <<
" ";
1625 out_stream << std::endl << std::endl;
1634 out_stream <<
"cells " << n_active_elem << std::endl;
1643 for (
unsigned int se=0, nse=elem->n_sub_elem(); se<nse; se++)
1645 if ((elem->type() ==
EDGE2) ||
1646 (elem->type() ==
EDGE3) ||
1647 (elem->type() ==
EDGE4)
1648 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1653 out_stream <<
"line 2" << std::endl;
1654 for (
unsigned int i=0, enn=elem->n_nodes(); i<enn; i++)
1655 out_stream << nn++ <<
" ";
1661 out_stream << std::endl;
1670 for (
unsigned int se=0, nse=elem->n_sub_elem(); se<nse; se++)
1672 if ((elem->type() ==
QUAD4) ||
1673 (elem->type() ==
QUAD8) ||
1676 (elem->type() ==
QUAD9)
1677 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1683 out_stream <<
"quad 4" << std::endl;
1684 for (
unsigned int i=0, enn=elem->n_nodes(); i<enn; i++)
1685 out_stream << nn++ <<
" ";
1688 else if ((elem->type() ==
TRI3) ||
1689 (elem->type() ==
TRI6))
1691 out_stream <<
"tri 3" << std::endl;
1692 for (
unsigned int i=0, enn=elem->n_nodes(); i<enn; i++)
1693 out_stream << nn++ <<
" ";
1699 out_stream << std::endl;
1709 for (
unsigned int se=0, nse=elem->n_sub_elem(); se<nse; se++)
1711 if ((elem->type() ==
HEX8) ||
1712 (elem->type() ==
HEX20) ||
1713 (elem->type() ==
HEX27)
1714 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1721 out_stream <<
"phex8 8" << std::endl;
1722 for (
unsigned int i=0, enn=elem->n_nodes(); i<enn; i++)
1723 out_stream << nn++ <<
" ";
1725 else if ((elem->type() ==
PRISM6) ||
1728 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1734 out_stream <<
"pprism6 6" << std::endl;
1735 for (
unsigned int i=0, enn=elem->n_nodes(); i<enn; i++)
1736 out_stream << nn++ <<
" ";
1738 else if ((elem->type() ==
TET4) ||
1739 (elem->type() ==
TET10))
1741 out_stream <<
"tet 4" << std::endl;
1742 for (
unsigned int i=0, enn=elem->n_nodes(); i<enn; i++)
1743 out_stream << nn++ <<
" ";
1748 out_stream << std::endl;
1758 out_stream << std::endl;
1764 if (write_partitioning)
1767 libmesh_error_msg(
"Not yet supported in GMVIO::write_discontinuous_gmv");
1771 out_stream <<
"material "
1773 <<
" 0"<< std::endl;
1776 out_stream <<
"proc_" << proc << std::endl;
1779 out_stream << elem->processor_id()+1 << std::endl;
1781 out_stream << std::endl;
1789 libMesh::err <<
"Cell-centered data not (yet) supported for discontinuous GMV files!" << std::endl;
1796 const unsigned int n_vars =
1797 cast_int<unsigned int>(solution_names.size());
1801 out_stream <<
"variable" << std::endl;
1804 for (
unsigned int c=0; c<
n_vars; c++)
1807 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
1813 out_stream <<
"r_" << solution_names[c] <<
" 1" << std::endl;
1815 for (
auto n : elem->node_index_range())
1816 out_stream << v[(n++)*
n_vars + c].real() <<
" ";
1817 out_stream << std::endl << std::endl;
1821 out_stream <<
"i_" << solution_names[c] <<
" 1" << std::endl;
1823 for (
auto n : elem->node_index_range())
1824 out_stream << v[(n++)*
n_vars + c].imag() <<
" ";
1825 out_stream << std::endl << std::endl;
1828 out_stream <<
"a_" << solution_names[c] <<
" 1" << std::endl;
1830 for (
auto n : elem->node_index_range())
1832 out_stream << std::endl << std::endl;
1836 out_stream << solution_names[c] <<
" 1" << std::endl;
1841 for (
unsigned int i=0, enn=elem->n_nodes(); i<enn; i++)
1842 out_stream << v[(nn++)*
n_vars + c] <<
" ";
1844 out_stream << std::endl << std::endl;
1850 out_stream <<
"endvars" << std::endl;
1855 out_stream << std::endl <<
"endgmv" << std::endl;
References _cell_centered_data, _write_subdomain_id_as_material, std::abs(), libMesh::MeshBase::active_element_ptr_range(), libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::EquationSystems::build_variable_names(), libMesh::EDGE2, libMesh::EDGE3, libMesh::EDGE4, libMesh::Utility::enum_to_string(), libMesh::err, libMesh::HEX20, libMesh::HEX27, libMesh::HEX8, libMesh::INFEDGE2, libMesh::INFHEX16, libMesh::INFHEX18, libMesh::INFHEX8, libMesh::INFPRISM12, libMesh::INFPRISM6, libMesh::INFQUAD4, libMesh::INFQUAD6, libMesh::libmesh_assert(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), libMesh::MeshBase::mesh_dimension(), libMesh::MeshBase::n_active_elem(), libMesh::ParallelObject::n_processors(), n_vars, libMesh::Quality::name(), libMesh::PRISM15, libMesh::PRISM18, libMesh::PRISM6, libMesh::ParallelObject::processor_id(), libMesh::QUAD4, libMesh::QUAD8, libMesh::QUAD9, libMesh::TET10, libMesh::TET4, libMesh::TRI3, and libMesh::TRI6.
Referenced by libMesh::ErrorVector::plot_error().
◆ write_equation_systems()
This method implements writing a mesh with data to a specified file where the data is taken from the EquationSystems
object.
Reimplemented in libMesh::NameBasedIO.
Definition at line 31 of file mesh_output.C.
35 LOG_SCOPE(
"write_equation_systems()",
"MeshOutput");
39 MT & my_mesh = const_cast<MT &>(*
_obj);
43 libmesh_assert_equal_to(&es.get_mesh(),
_obj);
47 if (my_mesh.max_elem_id() != my_mesh.n_elem() ||
48 my_mesh.max_node_id() != my_mesh.n_nodes())
55 "Warning: This MeshOutput subclass only supports meshes which are contiguously renumbered!"
58 my_mesh.allow_renumbering(
true);
60 my_mesh.renumber_nodes_and_elements();
64 my_mesh.allow_renumbering(
false);
72 std::vector<std::string> names;
73 es.build_variable_names (names,
nullptr, system_names);
77 std::vector<Number> soln;
78 es.build_solution_vector (soln, system_names);
◆ write_nodal_data() [1/3]
This method should be overridden by "parallel" output formats for writing nodal data.
Instead of getting a localized copy of the nodal solution vector, it directly uses EquationSystems current_local_solution vectors to look up nodal values.
If not implemented, reorders the solutions into a nodal-only NumericVector and calls the above version of this function.
Reimplemented in libMesh::Nemesis_IO.
Definition at line 158 of file mesh_output.C.
162 std::vector<std::string> names;
163 es.build_variable_names (names,
nullptr, system_names);
165 std::unique_ptr<NumericVector<Number>> parallel_soln =
166 es.build_parallel_solution_vector(system_names);
◆ write_nodal_data() [2/3]
This method may be overridden by "parallel" output formats for writing nodal data.
Instead of getting a localized copy of the nodal solution vector, it is passed a NumericVector of type=PARALLEL which is in node-major order i.e. (u0,v0,w0, u1,v1,w1, u2,v2,w2, u3,v3,w3, ...) and contains n_nodes*n_vars total entries. Then, it is up to the individual I/O class to extract the required solution values from this vector and write them in parallel.
If not implemented, localizes the parallel vector into a std::vector and calls the other version of this function.
Reimplemented in libMesh::Nemesis_IO.
Definition at line 145 of file mesh_output.C.
152 std::vector<Number> soln;
◆ write_nodal_data() [3/3]
void libMesh::GMVIO::write_nodal_data |
( |
const std::string & |
fname, |
|
|
const std::vector< Number > & |
soln, |
|
|
const std::vector< std::string > & |
names |
|
) |
| |
|
overridevirtual |
◆ write_nodal_data_discontinuous()
virtual void libMesh::MeshOutput< MeshBase >::write_nodal_data_discontinuous |
( |
const std::string & |
, |
|
|
const std::vector< Number > & |
, |
|
|
const std::vector< std::string > & |
|
|
) |
| |
|
inlinevirtualinherited |
This method implements writing a mesh with discontinuous data to a specified file where the nodal data and variables names are provided.
Reimplemented in libMesh::ExodusII_IO.
Definition at line 114 of file mesh_output.h.
117 { libmesh_not_implemented(); }
◆ write_subdomain_id_as_material()
bool& libMesh::GMVIO::write_subdomain_id_as_material |
( |
| ) |
|
|
inline |
◆ _ascii_precision
Precision to use when writing ASCII files.
Definition at line 195 of file mesh_output.h.
◆ _binary
bool libMesh::GMVIO::_binary |
|
private |
◆ _cell_centered_data
std::map<std::string, const std::vector<Real> * > libMesh::GMVIO::_cell_centered_data |
|
private |
◆ _discontinuous
bool libMesh::GMVIO::_discontinuous |
|
private |
◆ _is_parallel_format [1/2]
Flag specifying whether this format is parallel-capable.
If this is false (default) I/O is only permitted when the mesh has been serialized.
Definition at line 121 of file mesh_input.h.
◆ _is_parallel_format [2/2]
Flag specifying whether this format is parallel-capable.
If this is false (default) I/O is only permitted when the mesh has been serialized.
Definition at line 172 of file mesh_output.h.
◆ _next_elem_id
unsigned int libMesh::GMVIO::_next_elem_id |
|
private |
◆ _nodal_data
std::map<std::string, std::vector<Number> > libMesh::GMVIO::_nodal_data |
|
private |
◆ _obj
A pointer to a non-const object object.
This allows us to read the object from file.
Definition at line 114 of file mesh_input.h.
◆ _p_levels
bool libMesh::GMVIO::_p_levels |
|
private |
Flag to write the mesh p refinement levels.
Definition at line 225 of file gmv_io.h.
Referenced by p_levels().
◆ _partitioning
bool libMesh::GMVIO::_partitioning |
|
private |
◆ _reading_element_map
◆ _serial_only_needed_on_proc_0
Flag specifying whether this format can be written by only serializing the mesh to processor zero.
If this is false (default) the mesh will be serialized to all processors
Definition at line 181 of file mesh_output.h.
◆ _subdivide_second_order
bool libMesh::GMVIO::_subdivide_second_order |
|
private |
◆ _write_subdomain_id_as_material
bool libMesh::GMVIO::_write_subdomain_id_as_material |
|
private |
◆ elems_of_dimension
A vector of bools describing what dimension elements have been encountered when reading a mesh.
Definition at line 97 of file mesh_input.h.
The documentation for this class was generated from the following files:
bool _subdivide_second_order
Flag to subdivide second order elements.
Manages consistently variables, degrees of freedom, and coefficient vectors.
bool & p_levels()
Flag indicating whether or not to write p level information for p refined meshes.
const bool _serial_only_needed_on_proc_0
Flag specifying whether this format can be written by only serializing the mesh to processor zero.
int get_order() const
Explicitly request the order as an int.
unsigned int & set_n_partitions()
void write_ascii_old_impl(const std::string &, const std::vector< Number > *=nullptr, const std::vector< std::string > *=nullptr)
This method implements writing a mesh with nodal data to a specified file where the nodal data and va...
FEFamily family
The type of finite element.
bool _write_subdomain_id_as_material
Flag to write element subdomain_id's as GMV "materials" instead of element processor_id's.
virtual const Point & point(const dof_id_type i) const =0
virtual SimpleRange< element_iterator > active_element_ptr_range()=0
IntRange< std::size_t > index_range(const std::vector< T > &vec)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
virtual unsigned short dim() const =0
const T_sys & get_system(const std::string &name) const
bool & subdivide_second_order()
Flag indicating whether or not to subdivide second order elements.
unsigned int n_partitions() const
virtual const Node * node_ptr(const dof_id_type i) const =0
unsigned int mesh_dimension() const
virtual dof_id_type max_node_id() const =0
dof_id_type n_active_sub_elem() const
Same as n_sub_elem(), but only counts active elements.
bool _partitioning
Flag to write the mesh partitioning.
unsigned int & ascii_precision()
Return/set the precision to use when writing ASCII files.
The IntRange templated class is intended to make it easy to loop over integers which are indices of a...
bool _p_levels
Flag to write the mesh p refinement levels.
bool has_variable(const std::string &var) const
This is the MeshBase class.
MetaPhysicL::DualNumber< T, D > abs(const MetaPhysicL::DualNumber< T, D > &in)
virtual void localize(std::vector< T > &v_local) const =0
Creates a copy of the global vector in the local vector v_local.
Temporarily serialize a DistributedMesh for output; a distributed mesh is allgathered by the MeshSeri...
processor_id_type n_processors() const
void build_variable_names(std::vector< std::string > &var_names, const FEType *type=nullptr, const std::set< std::string > *system_names=nullptr) const
Fill the input vector var_names with the names of the variables for each system.
static ElemType first_order_equivalent_type(const ElemType et)
const bool _is_parallel_format
Flag specifying whether this format is parallel-capable.
processor_id_type processor_id() const
A Point defines a location in LIBMESH_DIM dimensional Real space.
static std::map< std::string, ElemType > _reading_element_map
Static map from string -> ElementType for use during reading.
A Node is like a Point, but with more information.
bool _binary
Flag to write binary data.
unsigned int n_systems() const
std::string enum_to_string(const T e)
virtual Node *& set_node(const unsigned int i)
unsigned int _next_elem_id
const FEType & variable_type(const unsigned int i) const
void _read_nodes()
Helper functions for reading nodes/cells from a GMV file.
virtual dof_id_type n_nodes() const =0
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
virtual void write_nodal_data(const std::string &, const std::vector< Number > &, const std::vector< std::string > &)
This method implements writing a mesh with nodal data to a specified file where the nodal data and va...
OrderWrapper order
The approximation order of the element.
void write_binary(const std::string &, const std::vector< Number > *=nullptr, const std::vector< std::string > *=nullptr)
This method implements writing a mesh with nodal data to a specified file where the nodal data and va...
virtual Elem * add_elem(Elem *e)=0
Add elem e to the end of the element array.
bool & partitioning()
Flag indicating whether or not to write the partitioning information for the mesh.
void build_discontinuous_solution_vector(std::vector< Number > &soln, const std::set< std::string > *system_names=nullptr, const std::vector< std::string > *var_names=nullptr, bool vertices_only=false) const
Fill the input vector soln with solution values.
bool & binary()
Flag indicating whether or not to write a binary file.
bool _discontinuous
Flag to write the mesh as discontinuous patches.
virtual void write_nodal_data_discontinuous(const std::string &, const std::vector< Number > &, const std::vector< std::string > &)
This method implements writing a mesh with discontinuous data to a specified file where the nodal dat...
This is the base class from which all geometric element types are derived.
unsigned short int variable_number(const std::string &var) const
bool & write_subdomain_id_as_material()
Flag to write element subdomain_id's as GMV "materials" instead of element processor_id's.
const MeshBase *const _obj
A pointer to a constant object.
ElemType gmv_elem_to_libmesh_elem(std::string elemname)
void allow_renumbering(bool allow)
If false is passed in then this mesh will no longer be renumbered when being prepared for use.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void prepare_for_use(const bool skip_renumber_nodes_and_elements=false, const bool skip_find_neighbors=false)
Prepare a newly ecreated (or read) mesh for use.
virtual void clear()
Deletes all the element and node data that is currently stored.
void set_mesh_dimension(unsigned char d)
Resets the logical dimension of the mesh.
static std::unique_ptr< Elem > build(const ElemType type, Elem *p=nullptr)
std::map< std::string, std::vector< Number > > _nodal_data
virtual void update()
Update the local values to reflect the solution on neighboring processors.
boost::multiprecision::float128 imag(const boost::multiprecision::float128)
virtual dof_id_type n_active_elem() const =0
unsigned int _ascii_precision
Precision to use when writing ASCII files.
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
ElemType
Defines an enum for geometric element types.
std::map< std::string, const std::vector< Real > * > _cell_centered_data
Storage for arbitrary cell-centered data.
boost::multiprecision::float128 real(const boost::multiprecision::float128 in)