$extrastylesheet
00001 // The libMesh Finite Element Library. 00002 // Copyright (C) 2002-2014 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner 00003 00004 // This library is free software; you can redistribute it and/or 00005 // modify it under the terms of the GNU Lesser General Public 00006 // License as published by the Free Software Foundation; either 00007 // version 2.1 of the License, or (at your option) any later version. 00008 00009 // This library is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 // Lesser General Public License for more details. 00013 00014 // You should have received a copy of the GNU Lesser General Public 00015 // License along with this library; if not, write to the Free Software 00016 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 00018 #ifndef LIBMESH_NEMESIS_IO_HELPER_H 00019 #define LIBMESH_NEMESIS_IO_HELPER_H 00020 00021 #include "libmesh/libmesh_config.h" 00022 00023 #if defined(LIBMESH_HAVE_NEMESIS_API) && defined(LIBMESH_HAVE_EXODUS_API) 00024 00025 // Local headers 00026 #include "libmesh/exodusII_io_helper.h" 00027 00028 using namespace libMesh::exII; 00029 00030 // C++ headers 00031 #include <set> 00032 #include <vector> 00033 00034 namespace libMesh 00035 { 00036 00037 // The Nemesis API header file. Should already be 00038 // correctly extern C'd but it doesn't hurt :) 00039 namespace Nemesis { 00040 extern "C" { 00041 // this include guard gets set by exodus, but we included it 00042 // in a namespace, so nemesis will not properly resolve e.g. 00043 // ex_entity_id in the global namespace. undefine the guard 00044 // to get ne_nemesisI.h to properly include the typedefs 00045 # ifdef EXODUS_II_HDR 00046 # undef EXODUS_II_HDR 00047 # endif 00048 # include "ne_nemesisI.h" 00049 } 00050 } 00051 00052 00062 class Nemesis_IO_Helper : public ExodusII_IO_Helper 00063 { 00064 public: 00068 explicit 00069 Nemesis_IO_Helper(const ParallelObject &parent, 00070 bool verbose=false, bool single_precision=false); 00071 00075 virtual ~Nemesis_IO_Helper(); 00076 00090 void get_init_global(); 00091 00096 void get_ss_param_global(); 00097 void get_ns_param_global(); 00098 void get_eb_info_global(); 00099 void get_init_info(); 00100 void get_loadbal_param(); 00101 void get_elem_map(); 00102 void get_node_map(); 00103 void get_cmap_params(); 00104 void get_node_cmap(); 00105 void get_elem_cmap(); 00106 00117 void put_init_info(unsigned num_proc, 00118 unsigned num_proc_in_file, 00119 const char* ftype); 00120 00129 void put_init_global(dof_id_type num_nodes_global, 00130 dof_id_type num_elems_global, 00131 unsigned num_elem_blks_global, 00132 unsigned num_node_sets_global, 00133 unsigned num_side_sets_global); 00134 00142 void put_eb_info_global(std::vector<int>& global_elem_blk_ids, 00143 std::vector<int>& global_elem_blk_cnts); 00144 00153 void put_ns_param_global(std::vector<int>& global_nodeset_ids, 00154 std::vector<int>& num_global_node_counts, 00155 std::vector<int>& num_global_node_df_counts); 00156 00165 void put_ss_param_global(std::vector<int>& global_sideset_ids, 00166 std::vector<int>& num_global_side_counts, 00167 std::vector<int>& num_global_side_df_counts); 00168 00169 00170 00183 void put_loadbal_param(unsigned num_internal_nodes, 00184 unsigned num_border_nodes, 00185 unsigned num_external_nodes, 00186 unsigned num_internal_elems, 00187 unsigned num_border_elems, 00188 unsigned num_node_cmaps, 00189 unsigned num_elem_cmaps); 00190 00198 void put_cmap_params(std::vector<int>& node_cmap_ids, 00199 std::vector<int>& node_cmap_node_cnts, 00200 std::vector<int>& elem_cmap_ids, 00201 std::vector<int>& elem_cmap_elem_cnts); 00202 00221 void put_node_cmap(std::vector<std::vector<int> >& node_cmap_node_ids, 00222 std::vector<std::vector<int> >& node_cmap_proc_ids); 00223 00229 void put_node_map(std::vector<int>& node_mapi, 00230 std::vector<int>& node_mapb, 00231 std::vector<int>& node_mape); 00232 00243 void put_elem_cmap(std::vector<std::vector<int> >& elem_cmap_elem_ids, 00244 std::vector<std::vector<int> >& elem_cmap_side_ids, 00245 std::vector<std::vector<int> >& elem_cmap_proc_ids); 00246 00252 void put_elem_map(std::vector<int>& elem_mapi, 00253 std::vector<int>& elem_mapb); 00254 00259 void put_n_coord(unsigned start_node_num, 00260 unsigned num_nodes, 00261 std::vector<Real>& x_coor, 00262 std::vector<Real>& y_coor, 00263 std::vector<Real>& z_coor); 00264 00265 00270 virtual void write_nodal_coordinates(const MeshBase & mesh, bool use_discontinuous=false); 00271 00275 virtual void write_elements(const MeshBase & mesh, bool use_discontinuous=false); 00276 00280 virtual void write_sidesets(const MeshBase & mesh); 00281 00285 virtual void write_nodesets(const MeshBase & mesh); 00286 00291 virtual void create(std::string filename); 00292 00297 virtual void initialize(std::string title, const MeshBase & mesh, bool use_discontinuous=false); 00298 00302 void write_nodal_solution(const std::vector<Number>& values, 00303 const std::vector<std::string>& names, 00304 int timestep); 00305 00310 std::string construct_nemesis_filename(const std::string& base_filename); 00311 00320 int nemesis_err_flag; 00321 00326 int num_nodes_global; 00327 int num_elems_global; 00328 int num_elem_blks_global; 00329 int num_node_sets_global; 00330 int num_side_sets_global; 00331 00336 int num_proc; 00337 00343 int num_proc_in_file; 00344 00350 char ftype; 00351 00359 std::vector<int> global_sideset_ids; 00360 std::vector<int> num_global_side_counts; 00361 std::vector<int> num_global_side_df_counts; 00362 00363 00371 std::vector<int> global_nodeset_ids; 00372 std::vector<int> num_global_node_counts; 00373 std::vector<int> num_global_node_df_counts; 00374 00375 00381 std::vector<int> global_elem_blk_ids; 00382 std::vector<int> global_elem_blk_cnts; 00383 00387 std::set<int> nodes_attached_to_local_elems; 00388 00392 std::map<subdomain_id_type, std::vector<unsigned int> > subdomain_map; 00393 00398 std::map<int, std::vector<int> > block_id_to_elem_connectivity; 00399 00408 int num_internal_nodes; 00409 00415 int num_border_nodes; 00416 00422 int num_external_nodes; 00423 00428 int num_internal_elems; 00429 00435 int num_border_elems; 00436 00442 int num_node_cmaps; 00443 00449 int num_elem_cmaps; 00450 00451 00452 00458 std::vector<int> elem_mapi; 00459 00465 std::vector<int> elem_mapb; 00466 00467 00468 00474 std::vector<int> node_mapi; 00475 00481 std::vector<int> node_mapb; 00482 00488 std::vector<int> node_mape; 00489 00490 00497 std::vector<int> node_cmap_ids; 00498 std::vector<int> node_cmap_node_cnts; 00499 std::vector<int> elem_cmap_ids; 00500 std::vector<int> elem_cmap_elem_cnts; 00501 00502 00511 std::vector<std::vector<int> > node_cmap_node_ids; 00512 std::vector<std::vector<int> > node_cmap_proc_ids; 00513 00514 00520 std::vector<std::vector<int> > elem_cmap_elem_ids; 00521 std::vector<std::vector<int> > elem_cmap_side_ids; 00522 std::vector<std::vector<int> > elem_cmap_proc_ids; 00523 00524 00525 private: 00530 std::map<subdomain_id_type, unsigned> local_subdomain_counts; 00531 00536 std::set<unsigned> border_node_ids; 00537 00543 std::map<unsigned, std::set<unsigned> > proc_nodes_touched_intersections; 00544 00548 typedef std::map<unsigned, std::set<unsigned> >::iterator proc_nodes_touched_iterator; 00549 00553 std::map<unsigned, std::set<std::pair<unsigned,unsigned> > > proc_border_elem_sets; 00554 00558 typedef std::map<unsigned, std::set<std::pair<unsigned,unsigned> > >::iterator proc_border_elem_sets_iterator; 00559 00563 std::set<unsigned> internal_node_ids; 00564 00568 std::set<unsigned> internal_elem_ids; 00569 00573 std::set<unsigned> border_elem_ids; 00574 00579 void compute_num_global_elem_blocks(const MeshBase& pmesh); 00580 00585 void compute_num_global_nodesets(const MeshBase& pmesh); 00586 00591 void compute_num_global_sidesets(const MeshBase& pmesh); 00592 00599 void build_element_and_node_maps(const MeshBase& pmesh); 00600 00606 void compute_border_node_ids(const MeshBase& pmesh); 00607 00612 void compute_internal_and_border_elems_and_internal_nodes(const MeshBase& pmesh); 00613 00618 void compute_communication_map_parameters(); 00619 00624 void compute_node_communication_maps(); 00625 00631 void compute_node_maps(); 00632 00637 void compute_elem_communication_maps(); 00638 00643 void compute_element_maps(); 00644 00650 void write_exodus_initialization_info(const MeshBase& pmesh, 00651 const std::string& title); 00652 }; 00653 00654 } // namespace libMesh 00655 00656 #endif // #if defined(LIBMESH_HAVE_NEMESIS_API) && defined(LIBMESH_HAVE_EXODUS_API) 00657 #endif // LIBMESH_NEMESIS_IO_HELPER_H