nemesis_io_helper.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2014 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 #ifndef LIBMESH_NEMESIS_IO_HELPER_H
19 #define LIBMESH_NEMESIS_IO_HELPER_H
20 
21 #include "libmesh/libmesh_config.h"
22 
23 #if defined(LIBMESH_HAVE_NEMESIS_API) && defined(LIBMESH_HAVE_EXODUS_API)
24 
25 // Local headers
27 
28 // C++ headers
29 #include <set>
30 #include <vector>
31 
32 namespace libMesh
33 {
34 
35 // The Nemesis API header file. Should already be
36 // correctly extern C'd but it doesn't hurt :)
37 namespace Nemesis {
38  extern "C" {
39  // this include guard gets set by exodus, but we included it
40  // in a namespace, so nemesis will not properly resolve e.g.
41  // ex_entity_id in the global namespace. undefine the guard
42  // to get ne_nemesisI.h to properly include the typedefs
43 # ifdef EXODUS_II_HDR
44 # undef EXODUS_II_HDR
45 # endif
46 # include "ne_nemesisI.h"
47  }
48 }
49 
50 
61 {
62 public:
66  explicit
67  Nemesis_IO_Helper(const ParallelObject &parent,
68  bool verbose=false);
69 
73  virtual ~Nemesis_IO_Helper();
74 
88  void get_init_global();
89 
94  void get_ss_param_global();
95  void get_ns_param_global();
96  void get_eb_info_global();
97  void get_init_info();
98  void get_loadbal_param();
99  void get_elem_map();
100  void get_node_map();
101  void get_cmap_params();
102  void get_node_cmap();
103  void get_elem_cmap();
104 
115  void put_init_info(unsigned num_proc,
116  unsigned num_proc_in_file,
117  const char* ftype);
118 
129  unsigned num_elem_blks_global,
130  unsigned num_node_sets_global,
131  unsigned num_side_sets_global);
132 
140  void put_eb_info_global(std::vector<int>& global_elem_blk_ids,
141  std::vector<int>& global_elem_blk_cnts);
142 
151  void put_ns_param_global(std::vector<int>& global_nodeset_ids,
152  std::vector<int>& num_global_node_counts,
153  std::vector<int>& num_global_node_df_counts);
154 
163  void put_ss_param_global(std::vector<int>& global_sideset_ids,
164  std::vector<int>& num_global_side_counts,
165  std::vector<int>& num_global_side_df_counts);
166 
167 
168 
182  unsigned num_border_nodes,
183  unsigned num_external_nodes,
184  unsigned num_internal_elems,
185  unsigned num_border_elems,
186  unsigned num_node_cmaps,
187  unsigned num_elem_cmaps);
188 
196  void put_cmap_params(std::vector<int>& node_cmap_ids,
197  std::vector<int>& node_cmap_node_cnts,
198  std::vector<int>& elem_cmap_ids,
199  std::vector<int>& elem_cmap_elem_cnts);
200 
219  void put_node_cmap(std::vector<std::vector<int> >& node_cmap_node_ids,
220  std::vector<std::vector<int> >& node_cmap_proc_ids);
221 
227  void put_node_map(std::vector<int>& node_mapi,
228  std::vector<int>& node_mapb,
229  std::vector<int>& node_mape);
230 
241  void put_elem_cmap(std::vector<std::vector<int> >& elem_cmap_elem_ids,
242  std::vector<std::vector<int> >& elem_cmap_side_ids,
243  std::vector<std::vector<int> >& elem_cmap_proc_ids);
244 
250  void put_elem_map(std::vector<int>& elem_mapi,
251  std::vector<int>& elem_mapb);
252 
257  void put_n_coord(unsigned start_node_num,
258  unsigned num_nodes,
259  std::vector<Real>& x_coor,
260  std::vector<Real>& y_coor,
261  std::vector<Real>& z_coor);
262 
263 
268  virtual void write_nodal_coordinates(const MeshBase & mesh);
269 
273  virtual void write_elements(const MeshBase & mesh);
274 
278  virtual void write_sidesets(const MeshBase & mesh);
279 
283  virtual void write_nodesets(const MeshBase & mesh);
284 
289  virtual void create(std::string filename);
290 
295  virtual void initialize(std::string title, const MeshBase & mesh);
296 
300  void write_nodal_solution(const std::vector<Number> & values, const std::vector<std::string> names, int timestep);
301 
306  std::string construct_nemesis_filename(const std::string& base_filename);
307 
317 
327 
332  int num_proc;
333 
340 
346  char ftype;
347 
355  std::vector<int> global_sideset_ids;
356  std::vector<int> num_global_side_counts;
357  std::vector<int> num_global_side_df_counts;
358 
359 
367  std::vector<int> global_nodeset_ids;
368  std::vector<int> num_global_node_counts;
369  std::vector<int> num_global_node_df_counts;
370 
371 
377  std::vector<int> global_elem_blk_ids;
378  std::vector<int> global_elem_blk_cnts;
379 
384 
388  std::map<subdomain_id_type, std::vector<unsigned int> > subdomain_map;
389 
394  std::map<int, std::vector<int> > block_id_to_elem_connectivity;
395 
405 
412 
419 
425 
432 
439 
446 
447 
448 
454  std::vector<int> elem_mapi;
455 
461  std::vector<int> elem_mapb;
462 
463 
464 
470  std::vector<int> node_mapi;
471 
477  std::vector<int> node_mapb;
478 
484  std::vector<int> node_mape;
485 
486 
493  std::vector<int> node_cmap_ids;
494  std::vector<int> node_cmap_node_cnts;
495  std::vector<int> elem_cmap_ids;
496  std::vector<int> elem_cmap_elem_cnts;
497 
498 
507  std::vector<std::vector<int> > node_cmap_node_ids;
508  std::vector<std::vector<int> > node_cmap_proc_ids;
509 
510 
516  std::vector<std::vector<int> > elem_cmap_elem_ids;
517  std::vector<std::vector<int> > elem_cmap_side_ids;
518  std::vector<std::vector<int> > elem_cmap_proc_ids;
519 
520 
521 private:
526  std::map<subdomain_id_type, unsigned> local_subdomain_counts;
527 
532  std::set<unsigned> border_node_ids;
533 
539  std::map<unsigned, std::set<unsigned> > proc_nodes_touched_intersections;
540 
544  typedef std::map<unsigned, std::set<unsigned> >::iterator proc_nodes_touched_iterator;
545 
549  std::map<unsigned, std::set<std::pair<unsigned,unsigned> > > proc_border_elem_sets;
550 
554  typedef std::map<unsigned, std::set<std::pair<unsigned,unsigned> > >::iterator proc_border_elem_sets_iterator;
555 
559  std::set<unsigned> internal_node_ids;
560 
564  std::set<unsigned> internal_elem_ids;
565 
569  std::set<unsigned> border_elem_ids;
570 
575  void compute_num_global_elem_blocks(const MeshBase& pmesh);
576 
581  void compute_num_global_nodesets(const MeshBase& pmesh);
582 
587  void compute_num_global_sidesets(const MeshBase& pmesh);
588 
595  void build_element_and_node_maps(const MeshBase& pmesh);
596 
602  void compute_border_node_ids(const MeshBase& pmesh);
603 
609 
615 
621 
627  void compute_node_maps();
628 
634 
639  void compute_element_maps();
640 
646  void write_exodus_initialization_info(const MeshBase& pmesh,
647  const std::string& title);
648 };
649 
650 } // namespace libMesh
651 
652 #endif // #if defined(LIBMESH_HAVE_NEMESIS_API) && defined(LIBMESH_HAVE_EXODUS_API)
653 #endif // LIBMESH_NEMESIS_IO_HELPER_H

Site Created By: libMesh Developers
Last modified: February 07 2014 16:57:06 UTC

Hosted By:
SourceForge.net Logo