IOSS  2.0
Ioss_DatabaseIO.h
Go to the documentation of this file.
1 // Copyright(C) 1999-2017 National Technology & Engineering Solutions
2 // of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
3 // NTESS, the U.S. Government retains certain rights in this software.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 //
12 // * Redistributions in binary form must reproduce the above
13 // copyright notice, this list of conditions and the following
14 // disclaimer in the documentation and/or other materials provided
15 // with the distribution.
16 //
17 // * Neither the name of NTESS nor the names of its
18 // contributors may be used to endorse or promote products derived
19 // from this software without specific prior written permission.
20 //
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 
33 #ifndef IOSS_Ioss_DatabaseIO_h
34 #define IOSS_Ioss_DatabaseIO_h
35 
36 #include <Ioss_BoundingBox.h>
37 #include <Ioss_CodeTypes.h>
38 #include <Ioss_DBUsage.h> // for DatabaseUsage, etc
39 #include <Ioss_DataSize.h> // for DataSize
40 #include <Ioss_EntityType.h> // for EntityType
41 #include <Ioss_Map.h>
42 #include <Ioss_ParallelUtils.h> // for ParallelUtils
43 #include <Ioss_PropertyManager.h> // for PropertyManager
44 #include <Ioss_State.h> // for State, State::STATE_INVALID
45 #include <Ioss_SurfaceSplit.h> // for SurfaceSplitType
46 #include <cstddef> // for size_t, nullptr
47 #include <cstdint> // for int64_t
48 #include <map> // for map
49 #include <string> // for string
50 #include <utility> // for pair
51 #include <vector> // for vector
52 namespace Ioss {
53  class CommSet;
54  class EdgeBlock;
55  class EdgeSet;
56  class ElementBlock;
57  class ElementSet;
58  class ElementTopology;
59  class FaceBlock;
60  class FaceSet;
61  class Field;
62  class GroupingEntity;
63  class NodeBlock;
64  class NodeSet;
65  class Region;
66  class SideBlock;
67  class SideSet;
68  class StructuredBlock;
69 } // namespace Ioss
70 
71 namespace Ioss {
72  class EntityBlock;
73 
74  // Contains (parent_element, side) topology pairs
75  using TopoContainer = std::vector<std::pair<const ElementTopology *, const ElementTopology *>>;
76 
77  /** \brief An input or output Database.
78  *
79  */
80  class DatabaseIO
81  {
82  public:
83  /** \brief Check to see if database state is OK.
84  *
85  * \param[in] write_message If true, then output a warning message indicating the problem.
86  * \param[in,out] error_message If non-null on input, then a warning message on output.
87  * \param[in,out] bad_count If non-null on input, then count of the number of processors
88  * where the file does not exist on output. If ok returns false, but
89  * *bad_count==0,
90  * then the routine does not support this argument.
91  * \returns True if database state is OK. False if not.
92  */
93  bool ok(bool write_message = false, std::string *error_message = nullptr,
94  int *bad_count = nullptr) const
95  {
96  IOSS_FUNC_ENTER(m_);
97  return ok__(write_message, error_message, bad_count);
98  }
99 
100  // Check capabilities of input/output database... Returns an
101  // unsigned int with the supported Ioss::EntityTypes or'ed
102  // together. If "return_value & Ioss::EntityType" is set, then the
103  // database supports that type (e.g. return_value & Ioss::FACESET)
104  virtual unsigned entity_field_support() const = 0;
105 
106  bool using_parallel_io() const { return usingParallelIO; }
107 
108  /** \brief Get the local (process-specific) node number corresponding to a global node number.
109  *
110  * \param[in] global The global node number
111  * \param[in] must_exist If true, error will occur if the global node number is not
112  * mapped to any local node number on the current process.
113  * \returns The local node number
114  */
115  int64_t node_global_to_local(int64_t global, bool must_exist) const
116  {
117  IOSS_FUNC_ENTER(m_);
118  return node_global_to_local__(global, must_exist);
119  }
120 
121  int64_t element_global_to_local(int64_t global) const
122  {
123  IOSS_FUNC_ENTER(m_);
124  return element_global_to_local__(global);
125  }
126 
127  /** If there is a single block of nodes in the model, then it is
128  * considered a node_major() database. If instead the nodes are
129  * local to each element block or structured block, then it is
130  * not a node_major database. Exodus is node major, CGNS is not.
131  */
132  virtual bool node_major() const { return true; }
133 
134  virtual ~DatabaseIO();
135 
136  // Eliminate as much memory as possible, but still retain meta data information
137  // Typically, eliminate the maps...
139  {
140  IOSS_FUNC_ENTER(m_);
142  }
143 
144  // Do anything that might be needed to the database prior to it
145  // being closed and destructed.
146  virtual void finalize_database() {}
147 
148  /** \brief Get the file name associated with the database.
149  *
150  * \returns The database file name.
151  */
152  std::string get_filename() const { return DBFilename; }
153 
154  /** \brief Get a file-per-processor filename associated with the database.
155  *
156  * \ returns The file-per-processor name for a file on this processor.
157  */
158  const std::string &decoded_filename() const;
159 
160  /** \brief Determine whether the database is an input database.
161  *
162  * \returns True if the database is an input database. False otherwise.
163  */
164  bool is_input() const { return isInput; }
165 
166  /** \brief Get the Ioss::DatabaseUsage type of the database.
167  *
168  * \returns The Ioss::DatabaseUsage type of the database.
169  */
170  Ioss::DatabaseUsage usage() const { return dbUsage; }
171 
172  /** \brief Determine whether the database needs information about process ownership of nodes.
173  *
174  * \returns True if database needs information about process ownership of nodes.
175  */
176  virtual bool needs_shared_node_information() const { return false; }
177 
179 
180  //! This function is used to create the path to an output directory (or history, restart, etc.)
181  // if it does not exist. Called by all processors. Will throw exception if path does not
182  // specify a valid directory or if the path cannot be created.
183  void create_path(const std::string &filename) const;
184 
185  void set_region(Region *region) { region_ = region; }
186 
187  void openDatabase() const
188  {
189  IOSS_FUNC_ENTER(m_);
190  openDatabase__();
191  }
192 
193  void closeDatabase() const
194  {
195  IOSS_FUNC_ENTER(m_);
196  closeDatabase__();
197  }
198 
199  void flush_database() const
200  {
201  IOSS_FUNC_ENTER(m_);
203  }
204 
205  /** \brief If a database type supports groups and if the database
206  * contains groups, open the specified group.
207  *
208  * If the group_name begins with '/', it specifies the absolute path
209  * name from the root with '/' separating groups. Otherwise, the
210  * group_name specifies a child group of the currently active group.
211  * If group_name == "/" then the root group is opened.
212  *
213  * \param[in] group_name The name of the group to open.
214  * \returns True if successful.
215  */
216  bool open_group(const std::string &group_name)
217  {
218  IOSS_FUNC_ENTER(m_);
219  return open_group__(group_name);
220  }
221 
222  /** \brief If a database type supports groups, create the specified
223  * group as a child of the current group.
224  *
225  * The name of the group must not contain a '/' character.
226  * If the command is successful, then the group will be the
227  * active group for all subsequent writes to the database.
228  *
229  * \param[in] group_name The name of the subgroup to create.
230  * \returns True if successful.
231  */
232  bool create_subgroup(const std::string &group_name)
233  {
234  IOSS_FUNC_ENTER(m_);
235  return create_subgroup__(group_name);
236  }
237 
238  /** \brief Set the database to the given State.
239  *
240  * All transitions must begin from the 'STATE_CLOSED' state or be to
241  * the 'STATE_CLOSED' state (There are no nested begin/end pairs at
242  * this time.)
243  *
244  * The database state is automatically set when Region::begin_mode is called
245  * for its associated region, so it may not be necessary to call this method
246  * directly.
247  *
248  * \param[in] state The new State to which the database should be set.
249  * \returns True if successful.
250  *
251  */
252  bool begin(Ioss::State state)
253  {
254  IOSS_FUNC_ENTER(m_);
255  return begin__(state);
256  }
257 
258  /** \brief Return the database to STATE_CLOSED.
259  *
260  * The database is automatically set to STATE_CLOSED when Region::end_mode
261  * is called for its associated region, so it may not be necessary to call this
262  * method directly.
263  *
264  * \param[in] state The State to end, i.e. the current state.
265  * \returns True if successful.
266  *
267  */
268  bool end(Ioss::State state)
269  {
270  IOSS_FUNC_ENTER(m_);
271  return end__(state);
272  }
273 
274  bool begin_state(Region *region, int state, double time)
275  {
276  IOSS_FUNC_ENTER(m_);
277  return begin_state__(region, state, time);
278  }
279  bool end_state(Region *region, int state, double time)
280  {
281  IOSS_FUNC_ENTER(m_);
282  return end_state__(region, state, time);
283  }
284  // Metadata-related functions.
286  {
287  IOSS_FUNC_ENTER(m_);
288  return read_meta_data__();
289  }
290 
292  {
293  IOSS_FUNC_ENTER(m_);
294  return get_step_times__();
295  }
296 
297  virtual bool internal_edges_available() const { return false; }
298  virtual bool internal_faces_available() const { return false; }
299 
300  // Information Records:
301 
302  /** \brief Get all information records (informative strings) for the database.
303  *
304  * \returns The informative strings.
305  */
306  const std::vector<std::string> &get_information_records() const { return informationRecords; }
307  void add_information_records(const std::vector<std::string> &info);
308  void add_information_record(const std::string &info);
309 
310  // QA Records:
311 
312  /** \brief Get all QA records, each of which consists of 4 strings, from the database
313  *
314  * The 4 strings that make up a database QA record are:
315  *
316  * 1. A descriptive code name, such as the application that modified the database.
317  *
318  * 2. A descriptive string, such as the version of the application that modified the database.
319  *
320  * 3. A relevant date, such as the date the database was modified.
321  *
322  * 4. A relevant time, such as the time the database was modified.
323  *
324  * \returns All QA records in a single vector. Every 4 consecutive elements of the
325  * vector make up a single QA record.
326  */
327  const std::vector<std::string> &get_qa_records() const { return qaRecords; }
328  void add_qa_record(const std::string &code, const std::string &code_qa, const std::string &date,
329  const std::string &time);
330 
331  bool get_logging() const { return doLogging && !singleProcOnly; }
332  void set_logging(bool on_off) { doLogging = on_off; }
333 
334  // The get_field and put_field functions are just a wrapper around the
335  // pure virtual get_field_internal and put_field_internal functions,
336  // but this lets me add some debug/checking/common code to the
337  // functions without having to do it in the calling code or in the
338  // derived classes code. This also fulfills the hueristic that a
339  // public interface should not contain pure virtual functions.
340  template <typename T>
341  int64_t get_field(const T *reg, const Field &field, void *data, size_t data_size) const
342  {
343  IOSS_FUNC_ENTER(m_);
344  verify_and_log(reg, field, 1);
345  int64_t retval = get_field_internal(reg, field, data, data_size);
346  verify_and_log(nullptr, field, 1);
347  return retval;
348  }
349 
350  template <typename T>
351  int64_t put_field(const T *reg, const Field &field, void *data, size_t data_size) const
352  {
353  IOSS_FUNC_ENTER(m_);
354  verify_and_log(reg, field, 0);
355  int64_t retval = put_field_internal(reg, field, data, data_size);
356  verify_and_log(nullptr, field, 0);
357  return retval;
358  }
359 
360  /** Determine whether application will make field data get/put calls parallel consistently.
361  *
362  * True is default and required for parallel-io databases.
363  * Even if false, metadata operations must be called by all processors.
364  *
365  * \returns True if application will make field data get/put calls parallel consistently.
366  *
367  */
369  void set_parallel_consistency(bool on_off) { isParallelConsistent = on_off; }
370 
373 
375  void ignore_database_names(bool yes_no) { ignoreDatabaseNames = yes_no; }
376 
377  /** \brief Get the length of the longest name in the database file.
378  *
379  * \returns The length, or 0 for unlimited.
380  */
381  virtual int maximum_symbol_length() const { return 0; } // Default is unlimited...
382  virtual void set_maximum_symbol_length(int /* requested_symbol_size */) {
383  } // Default does nothing...
384 
385  char get_field_separator() const { return fieldSeparator; }
387  void set_field_separator(char separator);
388  void set_field_recognition(bool yes_no) { enableFieldRecognition = yes_no; }
389 
390  void set_lower_case_variable_names(bool true_false) const
391  {
392  lowerCaseVariableNames = true_false;
393  }
394 
395  /* \brief Set the method used to split sidesets into homogenous blocks.
396  *
397  * \param[in] split_type The desired method.
398  *
399  */
400  void set_surface_split_type(Ioss::SurfaceSplitType split_type) { splitType = split_type; }
402 
403  void set_block_omissions(const std::vector<std::string> &omissions,
404  const std::vector<std::string> &inclusions = {});
405 
407  std::vector<std::string> &block_adjacency) const
408  {
409  IOSS_FUNC_ENTER(m_);
410  return get_block_adjacencies__(eb, block_adjacency);
411  }
413  std::vector<std::string> &block_membership) const
414  {
415  return compute_block_membership__(efblock, block_membership);
416  }
417 
420 
421  virtual int int_byte_size_db() const = 0; //! Returns 4 or 8
422  int int_byte_size_api() const; //! Returns 4 or 8
423  virtual void set_int_byte_size_api(Ioss::DataSize size) const;
424 
425  /*!
426  * The owning region of this database.
427  */
428  Region *get_region() const { return region_; }
429 
430  /*!
431  * The overlay_count specifies the number of restart outputs
432  * which will be overlaid on top of the currently written
433  * step before advancing to the next step on the restart
434  * database.
435  *
436  * For example, if restarts are being output every 0.1
437  * seconds and the overlay count is specified as 2, then
438  * restart will write time 0.1 to step 1 of the database.
439  * It will then write 0.2 and 0.3 also to step 1. It will
440  * then increment the database step and write 0.4 to step 2;
441  * overlay 0.5 and 0.6 on step 2... At the end of the
442  * analysis, assuming it runs to completion, the database
443  * would have times 0.3, 0.6, 0.9, ... However, if there
444  * were a problem during the analysis, the last step on the
445  * database would contain an intermediate step.
446  *
447  * The cycle_count specifies the number of restart steps
448  * which will be written to the restart database before
449  * previously written steps are overwritten.
450  *
451  * For example, if the cycle count is 5 and restart is written every 0.1
452  * seconds, the restart system will write data at times 0.1, 0.2, 0.3,
453  * 0.4, 0.5 to the database.
454  *
455  * It will then overwrite the first step with data from time 0.6, the
456  * second with time 0.7. At time 0.8, the database would contain data at
457  * times 0.6, 0.7, 0.8, 0.4, 0.5. Note that time will not necessarily be
458  * monotonically increasing on a database that specifies the cycle
459  * count.
460  *
461  * The cycle count and overlay count can both be used at the same time
462  * also. The basic formula is:
463  *
464  * db_step = (((output_step - 1) / overlay) % cycle) + 1
465  *
466  * where "output_step" is the step that this would have been on the
467  * database in a normal write (1,2,3,....) and "db_step" is the step
468  * number that this will be written to.
469  *
470  * If you only want the last step available on the database,
471  * use set_cycle_count(1)
472  */
473  void set_cycle_count(int count) const { cycleCount = count; }
474  int get_cycle_count() const { return cycleCount; }
475  void set_overlay_count(int count) const { overlayCount = count; }
476  int get_overlay_count() const { return overlayCount; }
477  void set_file_per_state(bool yes_no) const { filePerState = yes_no; }
478  bool get_file_per_state() const { return filePerState; }
479 
480  void set_time_scale_factor(double factor) { timeScaleFactor = factor; }
481 
482  const Ioss::ParallelUtils & util() const { return util_; }
484  /** \brief Get the processor that this mesh database is on.
485  *
486  * \returns The processor that this mesh database is on.
487  */
488  int parallel_rank() const { return myProcessor; }
489  int parallel_size() const { return util().parallel_size(); }
490  bool is_parallel() const { return isParallel; }
491 
492  protected:
493  DatabaseIO(Region *region, std::string filename, Ioss::DatabaseUsage db_usage,
494  MPI_Comm communicator, const Ioss::PropertyManager &props);
495 
496  /*!
497  * The properties member data contains properties that can be
498  * used to set database-specific options. Examples include
499  * compression, name lengths, integer sizes, floating point
500  * sizes. By convention, the property name is all
501  * uppercase. Some existing properties recognized by the Exodus
502  * DatabaseIO class are:
503  *
504  * | Property | Value
505  * |-----------------------|-------------------
506  * | COMPRESSION_LEVEL | In the range [0..9]. A value of 0 indicates no compression
507  * | COMPRESSION_SHUFFLE | (true/false) to enable/disable hdf5's shuffle compression
508  * algorithm.
509  * | FILE_TYPE | netcdf4
510  * | MAXIMUM_NAME_LENGTH | Maximum length of names that will be returned/passed via api call.
511  * | INTEGER_SIZE_DB | 4 or 8 indicating byte size of integers stored on the database.
512  * | INTEGER_SIZE_API | 4 or 8 indicating byte size of integers used in api functions.
513  * | LOGGING | (true/false) to enable/disable logging of field input/output
514  */
515 
517 
518  /*!
519  * Utility function that may be used by derived classes.
520  * Determines whether all elements in the model have the same side
521  * topology. This can be used to speed-up certain algorithms since
522  * they don't have to check each side (or group of sides)
523  * individually.
524  */
525  void set_common_side_topology() const;
527 
528  template <typename T>
529  void create_groups(const std::string &property_name, EntityType type,
530  const std::string &type_name, const T *set_type);
531  template <typename T>
532  void create_group(EntityType type, const std::string &type_name,
533  const std::vector<std::string> &group_spec, const T *set_type);
534 
535  // Create new sets as groups of existing exodus sets...
536  void handle_groups();
537 
538  /*!
539  * Filename that this Database is connected with. Derived
540  * DatabaseIO classes may need to change this if the passed in
541  * filename is not the same as the filename actually used E.g.,
542  * the Ioex_DatabaseIO (exodusII) changes if this is a parallel
543  * run since the passed in filename is just the basename, not the
544  * processor-specific filename.
545  */
546  std::string originalDBFilename;
547  std::string DBFilename;
548  mutable std::string decodedFilename;
549 
551 
552  bool isParallel{false}; //!< true if running in parallel
553  int myProcessor{0}; //!< number of processor this database is for
554 
555  int64_t nodeCount{0};
556  int64_t elementCount{0};
557 
558  /*!
559  * Check the topology of all face/element pairs in the model and
560  * fill the "TopoContainer faceTopology" variable with the
561  * unique pairs. This information is used for the
562  * faceblock/facesets and edgeblock/edgesets. If the
563  * 'topo_dimension' is 2, then face/element pairs are generated; if
564  * 'topo_dimension' is 1, then edge/element pairs are generated.
565  */
566  void check_side_topology() const;
567 
568  /// Used to speed up faceblock/edgeblock calculations.
570 
571  /*! Typically used for restart output, but can be used for all output...
572  * Maximum number of states on the output file. Overwrite the existing
573  * steps in a cyclic manner once exceed this count. Note that this breaks
574  * the convention that times be monotonically increasing on an exodusII file.
575  * Used by derived classes if they support this capability...
576  */
577  mutable int cycleCount{0};
578 
579  mutable int overlayCount{0};
580 
581  /*! EXPERIMENTAL If this is true, then each state (timestep)
582  * output will be directed to a separate file. Currently this is
583  * only implemented for the exodus (parallel or serial, single
584  * file or fpp) database type.
585  */
586  mutable bool filePerState{false};
587 
588  /*! Scale the time read/written from/to the file by the specified
589  scaleFactor. If the datbase times are 0.1, 0.2, 0.3 and the
590  scaleFactor is 20, then the application will think that the
591  times read are 20, 40, 60.
592 
593  If specified for an output database, then the analysis time
594  is divided by the scaleFactor time prior to output.
595  */
596  double timeScaleFactor{1.0};
597 
601  mutable bool lowerCaseVariableNames{true};
602  bool usingParallelIO{false};
603 
604  // List of element blocks that should be omitted or included from
605  // this model. Surfaces will take this into account while
606  // splitting; however, node and nodesets will not be filtered
607  // (perhaps this will be done at a later time...) NOTE: All local
608  // element ids and offsets are still calculated assuming that the
609  // blocks exist in the model...
610  // Only one of these can have values and the other must be empty.
611  std::vector<std::string> blockOmissions;
612  std::vector<std::string> blockInclusions;
613 
614  std::vector<std::string> informationRecords;
615  std::vector<std::string> qaRecords;
616 
617  //---Node Map -- Maps internal (1..NUMNP) ids to global ids used on the
618  // application side. global = nodeMap[local]
622  mutable Ioss::Map elemMap{"element", DBFilename, myProcessor};
623 
624  mutable std::vector<std::vector<bool>> blockAdjacency;
625 
626  private:
627  virtual bool ok__(bool write_message, std::string *error_message, int *bad_count) const
628  {
629  if (bad_count != nullptr) {
630  *bad_count = 0;
631  }
632  return dbState != Ioss::STATE_INVALID;
633  }
634 
635  virtual int64_t node_global_to_local__(int64_t global, bool must_exist) const
636  {
637  return nodeMap.global_to_local(global, must_exist);
638  }
639 
640  virtual int64_t element_global_to_local__(int64_t global) const
641  {
642  return elemMap.global_to_local(global);
643  }
644 
645  virtual void release_memory__()
646  {
651  }
652 
653  virtual void openDatabase__() const {}
654  virtual void closeDatabase__() const {}
655  virtual void flush_database__() const {}
656 
657  virtual bool open_group__(const std::string &group_name) { return false; }
658  virtual bool create_subgroup__(const std::string &group_name) { return false; }
659  virtual bool begin__(Ioss::State state) = 0;
660  virtual bool end__(Ioss::State state) = 0;
661 
662  virtual void read_meta_data__() = 0;
663  virtual void get_step_times__() {}
664 
665  virtual bool begin_state__(Region *region, int state, double time);
666  virtual bool end_state__(Region *region, int state, double time);
667 
669  std::vector<std::string> &block_adjacency) const;
670 
672  std::vector<std::string> &block_membership) const
673  {
674  }
675 
676  void compute_block_adjacencies() const;
677 
678  void verify_and_log(const GroupingEntity *ge, const Field &field, int in_out) const;
679 
680  virtual int64_t get_field_internal(const Region *reg, const Field &field, void *data,
681  size_t data_size) const = 0;
682  virtual int64_t get_field_internal(const NodeBlock *nb, const Field &field, void *data,
683  size_t data_size) const = 0;
684  virtual int64_t get_field_internal(const EdgeBlock *nb, const Field &field, void *data,
685  size_t data_size) const = 0;
686  virtual int64_t get_field_internal(const FaceBlock *nb, const Field &field, void *data,
687  size_t data_size) const = 0;
688  virtual int64_t get_field_internal(const ElementBlock *eb, const Field &field, void *data,
689  size_t data_size) const = 0;
690  virtual int64_t get_field_internal(const SideBlock *fb, const Field &field, void *data,
691  size_t data_size) const = 0;
692  virtual int64_t get_field_internal(const NodeSet *ns, const Field &field, void *data,
693  size_t data_size) const = 0;
694  virtual int64_t get_field_internal(const EdgeSet *ns, const Field &field, void *data,
695  size_t data_size) const = 0;
696  virtual int64_t get_field_internal(const FaceSet *ns, const Field &field, void *data,
697  size_t data_size) const = 0;
698  virtual int64_t get_field_internal(const ElementSet *ns, const Field &field, void *data,
699  size_t data_size) const = 0;
700  virtual int64_t get_field_internal(const SideSet *fs, const Field &field, void *data,
701  size_t data_size) const = 0;
702  virtual int64_t get_field_internal(const CommSet *cs, const Field &field, void *data,
703  size_t data_size) const = 0;
704  virtual int64_t get_field_internal(const StructuredBlock * /*sb*/, const Field & /*field*/,
705  void * /*data*/, size_t /*data_size*/) const
706  {
707  return 0;
708  }
709 
710  virtual int64_t put_field_internal(const Region *reg, const Field &field, void *data,
711  size_t data_size) const = 0;
712  virtual int64_t put_field_internal(const NodeBlock *nb, const Field &field, void *data,
713  size_t data_size) const = 0;
714  virtual int64_t put_field_internal(const EdgeBlock *nb, const Field &field, void *data,
715  size_t data_size) const = 0;
716  virtual int64_t put_field_internal(const FaceBlock *nb, const Field &field, void *data,
717  size_t data_size) const = 0;
718  virtual int64_t put_field_internal(const ElementBlock *eb, const Field &field, void *data,
719  size_t data_size) const = 0;
720  virtual int64_t put_field_internal(const SideBlock *fb, const Field &field, void *data,
721  size_t data_size) const = 0;
722  virtual int64_t put_field_internal(const NodeSet *ns, const Field &field, void *data,
723  size_t data_size) const = 0;
724  virtual int64_t put_field_internal(const EdgeSet *ns, const Field &field, void *data,
725  size_t data_size) const = 0;
726  virtual int64_t put_field_internal(const FaceSet *ns, const Field &field, void *data,
727  size_t data_size) const = 0;
728  virtual int64_t put_field_internal(const ElementSet *ns, const Field &field, void *data,
729  size_t data_size) const = 0;
730  virtual int64_t put_field_internal(const SideSet *fs, const Field &field, void *data,
731  size_t data_size) const = 0;
732  virtual int64_t put_field_internal(const CommSet *cs, const Field &field, void *data,
733  size_t data_size) const = 0;
734  virtual int64_t put_field_internal(const StructuredBlock * /*sb*/, const Field & /*field*/,
735  void * /*data*/, size_t /*data_size*/) const
736  {
737  return 0;
738  }
739 
740  DatabaseIO() = delete;
741  DatabaseIO(const DatabaseIO &) = delete;
742  DatabaseIO &operator=(const DatabaseIO &) = delete;
743 
744  mutable std::map<std::string, AxisAlignedBoundingBox> elementBlockBoundingBoxes;
745 
746  Ioss::ParallelUtils util_; // Encapsulate parallel and other utility functions.
747 #if defined(IOSS_THREADSAFE)
748  protected:
749  mutable std::mutex m_;
750 
751  private:
752 #endif
753  Region *region_{nullptr};
754  char fieldSeparator{'_'};
756  bool isInput;
758  true}; // True if application will make field data get/put calls parallel
759  // consistently.
760  // True is default and required for parallel-io databases.
761  // Even if false, metadata operations must be called by all processors
762 
763  bool singleProcOnly; // True if history or heartbeat which is only written from proc 0...
764  bool doLogging{false}; // True if logging field input/output
766  false}; // True if "block_id" is used as canonical name instead of the name
767  // given on the mesh file e.g. "fireset". Both names are still aliases.
768  bool ignoreDatabaseNames{false}; // True if "block_{id}" used as canonical name; ignore any
769  // names on database.
770  mutable bool blockAdjacenciesCalculated{false}; // True if the lazy creation of
771  // block adjacencies has been calculated.
772  };
773 } // namespace Ioss
774 #endif
bool isInput
Definition: Ioss_DatabaseIO.h:756
virtual void release_memory__()
Definition: Ioss_DatabaseIO.h:645
Ioss::IfDatabaseExistsBehavior open_create_behavior() const
Definition: Ioss_DatabaseIO.C:259
Represents an element topology.
Definition: Ioss_ElementTopology.h:72
virtual int64_t element_global_to_local__(int64_t global) const
Definition: Ioss_DatabaseIO.h:640
void get_block_adjacencies(const Ioss::ElementBlock *eb, std::vector< std::string > &block_adjacency) const
Definition: Ioss_DatabaseIO.h:406
Ioss::DatabaseUsage dbUsage
Definition: Ioss_DatabaseIO.h:599
void check_side_topology() const
Definition: Ioss_DatabaseIO.C:567
void release_memory()
Definition: Ioss_DatabaseIO.h:138
void create_groups(const std::string &property_name, EntityType type, const std::string &type_name, const T *set_type)
Definition: Ioss_DatabaseIO.C:392
void handle_groups()
Definition: Ioss_DatabaseIO.C:367
int64_t get_field(const T *reg, const Field &field, void *data, size_t data_size) const
Definition: Ioss_DatabaseIO.h:341
int64_t node_global_to_local(int64_t global, bool must_exist) const
Get the local (process-specific) node number corresponding to a global node number.
Definition: Ioss_DatabaseIO.h:115
virtual unsigned entity_field_support() const =0
void release_memory()
Definition: Ioss_Map.C:107
void create_path(const std::string &filename) const
This function is used to create the path to an output directory (or history, restart, etc.)
Definition: Ioss_DatabaseIO.C:268
void flush_database() const
Definition: Ioss_DatabaseIO.h:199
std::vector< std::string > qaRecords
Definition: Ioss_DatabaseIO.h:615
bool isParallelConsistent
Definition: Ioss_DatabaseIO.h:757
The main namespace for the Ioss library.
Definition: Iocgns_DatabaseIO.h:50
const Ioss::PropertyManager & get_property_manager() const
Definition: Ioss_DatabaseIO.h:483
An input or output Database.
Definition: Ioss_DatabaseIO.h:80
virtual void set_maximum_symbol_length(int)
Definition: Ioss_DatabaseIO.h:382
void openDatabase() const
Definition: Ioss_DatabaseIO.h:187
DataSize
The number of bytes used to store an integer type.
Definition: Ioss_DataSize.h:40
virtual int64_t put_field_internal(const Region *reg, const Field &field, void *data, size_t data_size) const =0
Ioss::DatabaseUsage usage() const
Get the Ioss::DatabaseUsage type of the database.
Definition: Ioss_DatabaseIO.h:170
virtual int maximum_symbol_length() const
Get the length of the longest name in the database file.
Definition: Ioss_DatabaseIO.h:381
virtual ~DatabaseIO()
A collection of nodes.
Definition: Ioss_NodeSet.h:53
int get_overlay_count() const
Definition: Ioss_DatabaseIO.h:476
A collection of element faces with the same topology.
Definition: Ioss_FaceBlock.h:53
void set_surface_split_type(Ioss::SurfaceSplitType split_type)
Definition: Ioss_DatabaseIO.h:400
int parallel_size() const
Definition: Ioss_ParallelUtils.C:223
Definition: Ioss_BoundingBox.h:37
A collection of element faces.
Definition: Ioss_FaceSet.h:54
Base class for all &#39;grouping&#39; entities. The following derived classes are typical: ...
Definition: Ioss_GroupingEntity.h:93
std::vector< std::string > blockOmissions
Definition: Ioss_DatabaseIO.h:611
void set_field_recognition(bool yes_no)
Definition: Ioss_DatabaseIO.h:388
virtual bool end__(Ioss::State state)=0
bool singleProcOnly
Definition: Ioss_DatabaseIO.h:763
bool is_input() const
Determine whether the database is an input database.
Definition: Ioss_DatabaseIO.h:164
bool get_use_generic_canonical_name() const
Definition: Ioss_DatabaseIO.h:371
Ioss::Map faceMap
Definition: Ioss_DatabaseIO.h:621
int64_t elementCount
Definition: Ioss_DatabaseIO.h:556
void set_overlay_count(int count) const
Definition: Ioss_DatabaseIO.h:475
Region * get_region() const
Definition: Ioss_DatabaseIO.h:428
A collection of element edges.
Definition: Ioss_EdgeSet.h:54
bool end_state(Region *region, int state, double time)
Definition: Ioss_DatabaseIO.h:279
std::string decodedFilename
Definition: Ioss_DatabaseIO.h:548
virtual int64_t get_field_internal(const Region *reg, const Field &field, void *data, size_t data_size) const =0
AxisAlignedBoundingBox get_bounding_box(const Ioss::ElementBlock *eb) const
Definition: Ioss_DatabaseIO.C:939
void get_block_adjacencies__(const Ioss::ElementBlock *eb, std::vector< std::string > &block_adjacency) const
Definition: Ioss_DatabaseIO.C:628
virtual bool internal_faces_available() const
Definition: Ioss_DatabaseIO.h:298
A collection of element sides having the same topology.
Definition: Ioss_SideBlock.h:61
bool get_logging() const
Definition: Ioss_DatabaseIO.h:331
bool open_group(const std::string &group_name)
If a database type supports groups and if the database contains groups, open the specified group...
Definition: Ioss_DatabaseIO.h:216
double timeScaleFactor
Definition: Ioss_DatabaseIO.h:596
const std::vector< std::string > & get_information_records() const
Get all information records (informative strings) for the database.
Definition: Ioss_DatabaseIO.h:306
void add_information_record(const std::string &info)
Add an information record (an informative string) to the database.
Definition: Ioss_DatabaseIO.C:529
char fieldSeparator
Definition: Ioss_DatabaseIO.h:754
bool lowerCaseVariableNames
Definition: Ioss_DatabaseIO.h:601
Ioss::Map elemMap
Definition: Ioss_DatabaseIO.h:622
std::string DBFilename
Definition: Ioss_DatabaseIO.h:547
bool is_parallel() const
Definition: Ioss_DatabaseIO.h:490
Ioss::DataSize dbIntSizeAPI
Definition: Ioss_DatabaseIO.h:600
Definition: Ioss_ParallelUtils.h:45
int64_t global_to_local(int64_t global, bool must_exist=true) const
Definition: Ioss_Map.C:544
bool ignoreDatabaseNames
Definition: Ioss_DatabaseIO.h:768
void set_use_generic_canonical_name(bool yes_no)
Definition: Ioss_DatabaseIO.h:372
Definition: Ioss_State.h:43
State
Access states for a database.
Definition: Ioss_State.h:42
virtual bool create_subgroup__(const std::string &group_name)
Definition: Ioss_DatabaseIO.h:658
void compute_block_membership(Ioss::SideBlock *efblock, std::vector< std::string > &block_membership) const
Definition: Ioss_DatabaseIO.h:412
std::vector< std::string > informationRecords
Definition: Ioss_DatabaseIO.h:614
bool begin(Ioss::State state)
Set the database to the given State.
Definition: Ioss_DatabaseIO.h:252
bool usingParallelIO
Definition: Ioss_DatabaseIO.h:602
bool using_parallel_io() const
Definition: Ioss_DatabaseIO.h:106
DatabaseIO()=delete
Ioss::State dbState
Definition: Ioss_DatabaseIO.h:550
A collection of elements having the same topology.
Definition: Ioss_ElementBlock.h:48
void get_step_times()
Definition: Ioss_DatabaseIO.h:291
int64_t put_field(const T *reg, const Field &field, void *data, size_t data_size) const
Definition: Ioss_DatabaseIO.h:351
DatabaseIO & operator=(const DatabaseIO &)=delete
bool filePerState
Definition: Ioss_DatabaseIO.h:586
A structured zone – i,j,k.
Definition: Ioss_StructuredBlock.h:103
int int_byte_size_api() const
Returns 4 or 8.
Definition: Ioss_DatabaseIO.C:225
ElementTopology * commonSideTopology
Definition: Ioss_DatabaseIO.h:526
Ioss::PropertyManager properties
Definition: Ioss_DatabaseIO.h:516
A collection of elements.
Definition: Ioss_ElementSet.h:54
virtual bool ok__(bool write_message, std::string *error_message, int *bad_count) const
Definition: Ioss_DatabaseIO.h:627
virtual int64_t put_field_internal(const StructuredBlock *, const Field &, void *, size_t) const
Definition: Ioss_DatabaseIO.h:734
DatabaseUsage
Specifies how an Ioss::DatabaseIO object will be used.
Definition: Ioss_DBUsage.h:40
virtual void read_meta_data__()=0
int overlayCount
Definition: Ioss_DatabaseIO.h:579
virtual void get_step_times__()
Definition: Ioss_DatabaseIO.h:663
void closeDatabase() const
Definition: Ioss_DatabaseIO.h:193
Ioss::Map edgeMap
Definition: Ioss_DatabaseIO.h:620
TopoContainer sideTopology
Used to speed up faceblock/edgeblock calculations.
Definition: Ioss_DatabaseIO.h:569
std::vector< std::vector< bool > > blockAdjacency
Definition: Ioss_DatabaseIO.h:624
void set_cycle_count(int count) const
Definition: Ioss_DatabaseIO.h:473
const std::string & decoded_filename() const
Get a file-per-processor filename associated with the database.
Definition: Ioss_DatabaseIO.C:327
bool useGenericCanonicalName
Definition: Ioss_DatabaseIO.h:765
void read_meta_data()
Definition: Ioss_DatabaseIO.h:285
Ioss::ParallelUtils util_
Definition: Ioss_DatabaseIO.h:746
A collection of all nodes in the region.
Definition: Ioss_NodeBlock.h:53
int64_t element_global_to_local(int64_t global) const
Definition: Ioss_DatabaseIO.h:121
bool end(Ioss::State state)
Return the database to STATE_CLOSED.
Definition: Ioss_DatabaseIO.h:268
virtual bool end_state__(Region *region, int state, double time)
Definition: Ioss_DatabaseIO.C:362
void set_region(Region *region)
Definition: Ioss_DatabaseIO.h:185
bool create_subgroup(const std::string &group_name)
If a database type supports groups, create the specified group as a child of the current group...
Definition: Ioss_DatabaseIO.h:232
virtual void flush_database__() const
Definition: Ioss_DatabaseIO.h:655
virtual int int_byte_size_db() const =0
virtual bool begin_state__(Region *region, int state, double time)
Definition: Ioss_DatabaseIO.C:357
void create_group(EntityType type, const std::string &type_name, const std::vector< std::string > &group_spec, const T *set_type)
Definition: Ioss_DatabaseIO.C:421
bool blockAdjacenciesCalculated
Definition: Ioss_DatabaseIO.h:770
void set_file_per_state(bool yes_no) const
Definition: Ioss_DatabaseIO.h:477
virtual void compute_block_membership__(Ioss::SideBlock *efblock, std::vector< std::string > &block_membership) const
Definition: Ioss_DatabaseIO.h:671
Definition: Ioss_Map.h:52
virtual void finalize_database()
Definition: Ioss_DatabaseIO.h:146
Region * region_
Definition: Ioss_DatabaseIO.h:753
Definition: Ioss_CommSet.h:51
std::map< std::string, AxisAlignedBoundingBox > elementBlockBoundingBoxes
Definition: Ioss_DatabaseIO.h:744
void set_field_separator(char separator)
Set the character used to separate a field suffix from the field basename when recognizing vector...
Definition: Ioss_DatabaseIO.C:247
Definition: Ioss_SurfaceSplit.h:40
Ioss::SurfaceSplitType splitType
Definition: Ioss_DatabaseIO.h:598
virtual bool node_major() const
Definition: Ioss_DatabaseIO.h:132
std::string get_filename() const
Get the file name associated with the database.
Definition: Ioss_DatabaseIO.h:152
bool begin_state(Region *region, int state, double time)
Definition: Ioss_DatabaseIO.h:274
virtual void set_int_byte_size_api(Ioss::DataSize size) const
Returns 4 or 8.
Definition: Ioss_DatabaseIO.C:237
int parallel_rank() const
Get the processor that this mesh database is on.
Definition: Ioss_DatabaseIO.h:488
std::vector< char > data
Definition: cth_pressure_map.C:73
A grouping entity that contains other grouping entities.
Definition: Ioss_Region.h:98
void add_information_records(const std::vector< std::string > &info)
Add multiple information records (informative strings) to the database.
Definition: Ioss_DatabaseIO.C:519
void set_logging(bool on_off)
Definition: Ioss_DatabaseIO.h:332
bool enableFieldRecognition
Definition: Ioss_DatabaseIO.h:755
Definition: Ioss_DataSize.h:40
bool is_parallel_consistent() const
Definition: Ioss_DatabaseIO.h:368
SurfaceSplitType
Method used to split sidesets into homogenous blocks.
Definition: Ioss_SurfaceSplit.h:38
virtual bool open_group__(const std::string &group_name)
Definition: Ioss_DatabaseIO.h:657
char get_field_separator() const
Definition: Ioss_DatabaseIO.h:385
bool ignore_database_names() const
Definition: Ioss_DatabaseIO.h:374
void ignore_database_names(bool yes_no)
Definition: Ioss_DatabaseIO.h:375
virtual bool begin__(Ioss::State state)=0
A collection of element sides.
Definition: Ioss_SideSet.h:59
Holds metadata for bulk data associated with a GroupingEntity.
Definition: Ioss_Field.h:47
bool get_file_per_state() const
Definition: Ioss_DatabaseIO.h:478
Ioss::Map nodeMap
Definition: Ioss_DatabaseIO.h:619
virtual bool internal_edges_available() const
Definition: Ioss_DatabaseIO.h:297
int MPI_Comm
Definition: Ioss_CodeTypes.h:80
void set_parallel_consistency(bool on_off)
Definition: Ioss_DatabaseIO.h:369
int parallel_size() const
Definition: Ioss_DatabaseIO.h:489
void verify_and_log(const GroupingEntity *ge, const Field &field, int in_out) const
Definition: Ioss_DatabaseIO.C:345
int64_t nodeCount
Definition: Ioss_DatabaseIO.h:555
const Ioss::ParallelUtils & util() const
Definition: Ioss_DatabaseIO.h:482
#define IOSS_FUNC_ENTER(m)
Definition: Ioss_CodeTypes.h:115
virtual int64_t node_global_to_local__(int64_t global, bool must_exist) const
Definition: Ioss_DatabaseIO.h:635
void set_common_side_topology() const
Definition: Ioss_DatabaseIO.C:489
virtual int64_t get_field_internal(const StructuredBlock *, const Field &, void *, size_t) const
Definition: Ioss_DatabaseIO.h:704
bool isParallel
true if running in parallel
Definition: Ioss_DatabaseIO.h:552
EntityType
The particular type of GroupingEntity.
Definition: Ioss_EntityType.h:39
bool ok(bool write_message=false, std::string *error_message=nullptr, int *bad_count=nullptr) const
Check to see if database state is OK.
Definition: Ioss_DatabaseIO.h:93
bool get_field_recognition() const
Definition: Ioss_DatabaseIO.h:386
int cycleCount
Definition: Ioss_DatabaseIO.h:577
int get_cycle_count() const
Definition: Ioss_DatabaseIO.h:474
A collection of Ioss::Property objects.
Definition: Ioss_PropertyManager.h:49
int myProcessor
number of processor this database is for
Definition: Ioss_DatabaseIO.h:553
IfDatabaseExistsBehavior
Definition: Ioss_DBUsage.h:56
bool doLogging
Definition: Ioss_DatabaseIO.h:764
std::vector< std::string > blockInclusions
Definition: Ioss_DatabaseIO.h:612
A collection of element edges with the same topology.
Definition: Ioss_EdgeBlock.h:53
std::string originalDBFilename
Definition: Ioss_DatabaseIO.h:546
void error_message(const Ioss::Field &field, Ioss::Field::BasicType requested_type)
Definition: Ioss_Field.C:63
void set_lower_case_variable_names(bool true_false) const
Definition: Ioss_DatabaseIO.h:390
virtual void openDatabase__() const
Definition: Ioss_DatabaseIO.h:653
virtual void closeDatabase__() const
Definition: Ioss_DatabaseIO.h:654
virtual bool needs_shared_node_information() const
Determine whether the database needs information about process ownership of nodes.
Definition: Ioss_DatabaseIO.h:176
Ioss::SurfaceSplitType get_surface_split_type() const
Definition: Ioss_DatabaseIO.h:401
void add_qa_record(const std::string &code, const std::string &code_qa, const std::string &date, const std::string &time)
Add a QA record, which consists of 4 strings, to the database.
Definition: Ioss_DatabaseIO.C:544
std::vector< std::pair< const ElementTopology *, const ElementTopology * > > TopoContainer
Definition: Ioss_DatabaseIO.h:75
void compute_block_adjacencies() const
Definition: Ioss_DatabaseIO.C:670
void set_block_omissions(const std::vector< std::string > &omissions, const std::vector< std::string > &inclusions={})
Definition: Ioss_DatabaseIO.C:553
void set_time_scale_factor(double factor)
Definition: Ioss_DatabaseIO.h:480
const std::vector< std::string > & get_qa_records() const
Get all QA records, each of which consists of 4 strings, from the database.
Definition: Ioss_DatabaseIO.h:327