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  IOSS_FUNC_ENTER(m_);
416  return compute_block_membership__(efblock, block_membership);
417  }
418 
421 
422  virtual int int_byte_size_db() const = 0; //! Returns 4 or 8
423  int int_byte_size_api() const; //! Returns 4 or 8
424  virtual void set_int_byte_size_api(Ioss::DataSize size) const;
425 
426  /*!
427  * The owning region of this database.
428  */
429  Region *get_region() const { return region_; }
430 
431  /*!
432  * The overlay_count specifies the number of restart outputs
433  * which will be overlaid on top of the currently written
434  * step before advancing to the next step on the restart
435  * database.
436  *
437  * For example, if restarts are being output every 0.1
438  * seconds and the overlay count is specified as 2, then
439  * restart will write time 0.1 to step 1 of the database.
440  * It will then write 0.2 and 0.3 also to step 1. It will
441  * then increment the database step and write 0.4 to step 2;
442  * overlay 0.5 and 0.6 on step 2... At the end of the
443  * analysis, assuming it runs to completion, the database
444  * would have times 0.3, 0.6, 0.9, ... However, if there
445  * were a problem during the analysis, the last step on the
446  * database would contain an intermediate step.
447  *
448  * The cycle_count specifies the number of restart steps
449  * which will be written to the restart database before
450  * previously written steps are overwritten.
451  *
452  * For example, if the cycle count is 5 and restart is written every 0.1
453  * seconds, the restart system will write data at times 0.1, 0.2, 0.3,
454  * 0.4, 0.5 to the database.
455  *
456  * It will then overwrite the first step with data from time 0.6, the
457  * second with time 0.7. At time 0.8, the database would contain data at
458  * times 0.6, 0.7, 0.8, 0.4, 0.5. Note that time will not necessarily be
459  * monotonically increasing on a database that specifies the cycle
460  * count.
461  *
462  * The cycle count and overlay count can both be used at the same time
463  * also. The basic formula is:
464  *
465  * db_step = (((output_step - 1) / overlay) % cycle) + 1
466  *
467  * where "output_step" is the step that this would have been on the
468  * database in a normal write (1,2,3,....) and "db_step" is the step
469  * number that this will be written to.
470  *
471  * If you only want the last step available on the database,
472  * use set_cycle_count(1)
473  */
474  void set_cycle_count(int count) const { cycleCount = count; }
475  void set_overlay_count(int count) const { overlayCount = count; }
476 
477  void set_time_scale_factor(double factor) { timeScaleFactor = factor; }
478 
479  const Ioss::ParallelUtils & util() const { return util_; }
481  /** \brief Get the processor that this mesh database is on.
482  *
483  * \returns The processor that this mesh database is on.
484  */
485  int parallel_rank() const { return myProcessor; }
486  int parallel_size() const { return util().parallel_size(); }
487  bool is_parallel() const { return isParallel; }
488 
489  protected:
490  DatabaseIO(Region *region, std::string filename, Ioss::DatabaseUsage db_usage,
491  MPI_Comm communicator, const Ioss::PropertyManager &props);
492 
493  /*!
494  * The properties member data contains properties that can be
495  * used to set database-specific options. Examples include
496  * compression, name lengths, integer sizes, floating point
497  * sizes. By convention, the property name is all
498  * uppercase. Some existing properties recognized by the Exodus
499  * DatabaseIO class are:
500  *
501  * | Property | Value
502  * |-----------------------|-------------------
503  * | COMPRESSION_LEVEL | In the range [0..9]. A value of 0 indicates no compression
504  * | COMPRESSION_SHUFFLE | (true/false) to enable/disable hdf5's shuffle compression
505  * algorithm.
506  * | FILE_TYPE | netcdf4
507  * | MAXIMUM_NAME_LENGTH | Maximum length of names that will be returned/passed via api call.
508  * | INTEGER_SIZE_DB | 4 or 8 indicating byte size of integers stored on the database.
509  * | INTEGER_SIZE_API | 4 or 8 indicating byte size of integers used in api functions.
510  * | LOGGING | (true/false) to enable/disable logging of field input/output
511  */
512 
514 
515  /*!
516  * Utility function that may be used by derived classes.
517  * Determines whether all elements in the model have the same side
518  * topology. This can be used to speed-up certain algorithms since
519  * they don't have to check each side (or group of sides)
520  * individually.
521  */
522  void set_common_side_topology() const;
524 
525  template <typename T>
526  void create_groups(const std::string &property_name, EntityType type,
527  const std::string &type_name, const T *set_type);
528  template <typename T>
529  void create_group(EntityType type, const std::string &type_name,
530  const std::vector<std::string> &group_spec, const T *set_type);
531 
532  // Create new sets as groups of existing exodus sets...
533  void handle_groups();
534 
535  /*!
536  * Filename that this Database is connected with. Derived
537  * DatabaseIO classes may need to change this if the passed in
538  * filename is not the same as the filename actually used E.g.,
539  * the Ioex_DatabaseIO (exodusII) changes if this is a parallel
540  * run since the passed in filename is just the basename, not the
541  * processor-specific filename.
542  */
543  std::string DBFilename;
544  mutable std::string decodedFilename;
545 
547 
548  bool isParallel{false}; //!< true if running in parallel
549  int myProcessor{0}; //!< number of processor this database is for
550 
551  int64_t nodeCount{0};
552  int64_t elementCount{0};
553 
554  /*!
555  * Check the topology of all face/element pairs in the model and
556  * fill the "TopoContainer faceTopology" variable with the
557  * unique pairs. This information is used for the
558  * faceblock/facesets and edgeblock/edgesets. If the
559  * 'topo_dimension' is 2, then face/element pairs are generated; if
560  * 'topo_dimension' is 1, then edge/element pairs are generated.
561  */
562  void check_side_topology() const;
563 
564  /// Used to speed up faceblock/edgeblock calculations.
566 
567  /*! Typically used for restart output, but can be used for all output...
568  * Maximum number of states on the output file. Overwrite the existing
569  * steps in a cyclic manner once exceed this count. Note that this breaks
570  * the convention that times be monotonically increasing on an exodusII file.
571  * Used by derived classes if they support this capability...
572  */
573  mutable int cycleCount{0};
574 
575  mutable int overlayCount{0};
576 
577  /*! Scale the time read/written from/to the file by the specified
578  scaleFactor. If the datbase times are 0.1, 0.2, 0.3 and the
579  scaleFactor is 20, then the application will think that the
580  times read are 20, 40, 60.
581 
582  If specified for an output database, then the analysis time
583  is divided by the scaleFactor time prior to output.
584  */
585  double timeScaleFactor{1.0};
586 
590  mutable bool lowerCaseVariableNames{true};
591  bool usingParallelIO{false};
592 
593  // List of element blocks that should be omitted or included from
594  // this model. Surfaces will take this into account while
595  // splitting; however, node and nodesets will not be filtered
596  // (perhaps this will be done at a later time...) NOTE: All local
597  // element ids and offsets are still calculated assuming that the
598  // blocks exist in the model...
599  // Only one of these can have values and the other must be empty.
600  std::vector<std::string> blockOmissions;
601  std::vector<std::string> blockInclusions;
602 
603  std::vector<std::string> informationRecords;
604  std::vector<std::string> qaRecords;
605 
606  //---Node Map -- Maps internal (1..NUMNP) ids to global ids used on the
607  // application side. global = nodeMap[local]
609  mutable Ioss::Map edgeMap{"edge", DBFilename, myProcessor};
610  mutable Ioss::Map faceMap{"face", DBFilename, myProcessor};
611  mutable Ioss::Map elemMap{"element", DBFilename, myProcessor};
612 
613  mutable std::vector<std::vector<bool>> blockAdjacency;
614 
615  private:
616  virtual bool ok__(bool write_message, std::string *error_message, int *bad_count) const
617  {
618  if (bad_count != nullptr) {
619  *bad_count = 0;
620  }
621  return dbState != Ioss::STATE_INVALID;
622  }
623 
624  virtual int64_t node_global_to_local__(int64_t global, bool must_exist) const
625  {
626  return nodeMap.global_to_local(global, must_exist);
627  }
628 
629  virtual int64_t element_global_to_local__(int64_t global) const
630  {
631  return elemMap.global_to_local(global);
632  }
633 
634  virtual void release_memory__()
635  {
640  }
641 
642  virtual void openDatabase__() const {}
643  virtual void closeDatabase__() const {}
644  virtual void flush_database__() const {}
645 
646  virtual bool open_group__(const std::string &group_name) { return false; }
647  virtual bool create_subgroup__(const std::string &group_name) { return false; }
648  virtual bool begin__(Ioss::State state) = 0;
649  virtual bool end__(Ioss::State state) = 0;
650 
651  virtual void read_meta_data__() = 0;
652  virtual void get_step_times__() {}
653 
654  virtual bool begin_state__(Region *region, int state, double time);
655  virtual bool end_state__(Region *region, int state, double time);
656 
658  std::vector<std::string> &block_adjacency) const;
659 
661  std::vector<std::string> &block_membership) const
662  {
663  }
664 
665  void compute_block_adjacencies() const;
666 
667  void verify_and_log(const GroupingEntity *ge, const Field &field, int in_out) const;
668 
669  virtual int64_t get_field_internal(const Region *reg, const Field &field, void *data,
670  size_t data_size) const = 0;
671  virtual int64_t get_field_internal(const NodeBlock *nb, const Field &field, void *data,
672  size_t data_size) const = 0;
673  virtual int64_t get_field_internal(const EdgeBlock *nb, const Field &field, void *data,
674  size_t data_size) const = 0;
675  virtual int64_t get_field_internal(const FaceBlock *nb, const Field &field, void *data,
676  size_t data_size) const = 0;
677  virtual int64_t get_field_internal(const ElementBlock *eb, const Field &field, void *data,
678  size_t data_size) const = 0;
679  virtual int64_t get_field_internal(const SideBlock *fb, const Field &field, void *data,
680  size_t data_size) const = 0;
681  virtual int64_t get_field_internal(const NodeSet *ns, const Field &field, void *data,
682  size_t data_size) const = 0;
683  virtual int64_t get_field_internal(const EdgeSet *ns, const Field &field, void *data,
684  size_t data_size) const = 0;
685  virtual int64_t get_field_internal(const FaceSet *ns, const Field &field, void *data,
686  size_t data_size) const = 0;
687  virtual int64_t get_field_internal(const ElementSet *ns, const Field &field, void *data,
688  size_t data_size) const = 0;
689  virtual int64_t get_field_internal(const SideSet *fs, const Field &field, void *data,
690  size_t data_size) const = 0;
691  virtual int64_t get_field_internal(const CommSet *cs, const Field &field, void *data,
692  size_t data_size) const = 0;
693  virtual int64_t get_field_internal(const StructuredBlock * /*sb*/, const Field & /*field*/,
694  void * /*data*/, size_t /*data_size*/) const
695  {
696  return 0;
697  }
698 
699  virtual int64_t put_field_internal(const Region *reg, const Field &field, void *data,
700  size_t data_size) const = 0;
701  virtual int64_t put_field_internal(const NodeBlock *nb, const Field &field, void *data,
702  size_t data_size) const = 0;
703  virtual int64_t put_field_internal(const EdgeBlock *nb, const Field &field, void *data,
704  size_t data_size) const = 0;
705  virtual int64_t put_field_internal(const FaceBlock *nb, const Field &field, void *data,
706  size_t data_size) const = 0;
707  virtual int64_t put_field_internal(const ElementBlock *eb, const Field &field, void *data,
708  size_t data_size) const = 0;
709  virtual int64_t put_field_internal(const SideBlock *fb, const Field &field, void *data,
710  size_t data_size) const = 0;
711  virtual int64_t put_field_internal(const NodeSet *ns, const Field &field, void *data,
712  size_t data_size) const = 0;
713  virtual int64_t put_field_internal(const EdgeSet *ns, const Field &field, void *data,
714  size_t data_size) const = 0;
715  virtual int64_t put_field_internal(const FaceSet *ns, const Field &field, void *data,
716  size_t data_size) const = 0;
717  virtual int64_t put_field_internal(const ElementSet *ns, const Field &field, void *data,
718  size_t data_size) const = 0;
719  virtual int64_t put_field_internal(const SideSet *fs, const Field &field, void *data,
720  size_t data_size) const = 0;
721  virtual int64_t put_field_internal(const CommSet *cs, const Field &field, void *data,
722  size_t data_size) const = 0;
723  virtual int64_t put_field_internal(const StructuredBlock * /*sb*/, const Field & /*field*/,
724  void * /*data*/, size_t /*data_size*/) const
725  {
726  return 0;
727  }
728 
729  DatabaseIO() = delete;
730  DatabaseIO(const DatabaseIO &) = delete;
731  DatabaseIO &operator=(const DatabaseIO &) = delete;
732 
733  mutable std::map<std::string, AxisAlignedBoundingBox> elementBlockBoundingBoxes;
734 
735  Ioss::ParallelUtils util_; // Encapsulate parallel and other utility functions.
736 #if defined(IOSS_THREADSAFE)
737  protected:
738  mutable std::mutex m_;
739 
740  private:
741 #endif
742  Region *region_{nullptr};
743  char fieldSeparator{'_'};
745  bool isInput;
747  true}; // True if application will make field data get/put calls parallel
748  // consistently.
749  // True is default and required for parallel-io databases.
750  // Even if false, metadata operations must be called by all processors
751 
752  bool singleProcOnly; // True if history or heartbeat which is only written from proc 0...
753  bool doLogging{false}; // True if logging field input/output
755  false}; // True if "block_id" is used as canonical name instead of the name
756  // given on the mesh file e.g. "fireset". Both names are still aliases.
758  false}; // True if "block_{id}" used as canonical name; ignore any names on
759  // database.
760  mutable bool blockAdjacenciesCalculated{false}; // True if the lazy creation of
761  // block adjacencies has been calculated.
762  };
763 } // namespace Ioss
764 #endif
bool isInput
Definition: Ioss_DatabaseIO.h:745
virtual void release_memory__()
Definition: Ioss_DatabaseIO.h:634
Ioss::IfDatabaseExistsBehavior open_create_behavior() const
Definition: Ioss_DatabaseIO.C:255
Represents an element topology.
Definition: Ioss_ElementTopology.h:72
virtual int64_t element_global_to_local__(int64_t global) const
Definition: Ioss_DatabaseIO.h:629
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:588
void check_side_topology() const
Definition: Ioss_DatabaseIO.C:563
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:388
void handle_groups()
Definition: Ioss_DatabaseIO.C:363
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:264
void flush_database() const
Definition: Ioss_DatabaseIO.h:199
std::vector< std::string > qaRecords
Definition: Ioss_DatabaseIO.h:604
bool isParallelConsistent
Definition: Ioss_DatabaseIO.h:746
The main namespace for the Ioss library.
Definition: Iocgns_DatabaseIO.h:50
const Ioss::PropertyManager & get_property_manager() const
Definition: Ioss_DatabaseIO.h:480
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
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:203
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:600
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:752
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:610
int64_t elementCount
Definition: Ioss_DatabaseIO.h:552
void set_overlay_count(int count) const
Definition: Ioss_DatabaseIO.h:475
Region * get_region() const
Definition: Ioss_DatabaseIO.h:429
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:544
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:935
void get_block_adjacencies__(const Ioss::ElementBlock *eb, std::vector< std::string > &block_adjacency) const
Definition: Ioss_DatabaseIO.C:624
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:585
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:525
char fieldSeparator
Definition: Ioss_DatabaseIO.h:743
bool lowerCaseVariableNames
Definition: Ioss_DatabaseIO.h:590
Ioss::Map elemMap
Definition: Ioss_DatabaseIO.h:611
std::string DBFilename
Definition: Ioss_DatabaseIO.h:543
bool is_parallel() const
Definition: Ioss_DatabaseIO.h:487
Ioss::DataSize dbIntSizeAPI
Definition: Ioss_DatabaseIO.h:589
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:757
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:647
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:603
bool begin(Ioss::State state)
Set the database to the given State.
Definition: Ioss_DatabaseIO.h:252
bool usingParallelIO
Definition: Ioss_DatabaseIO.h:591
bool using_parallel_io() const
Definition: Ioss_DatabaseIO.h:106
DatabaseIO()=delete
Ioss::State dbState
Definition: Ioss_DatabaseIO.h:546
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
A structured zone – i,j,k.
Definition: Ioss_StructuredBlock.h:98
int int_byte_size_api() const
Returns 4 or 8.
Definition: Ioss_DatabaseIO.C:221
ElementTopology * commonSideTopology
Definition: Ioss_DatabaseIO.h:523
Ioss::PropertyManager properties
Definition: Ioss_DatabaseIO.h:513
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:616
virtual int64_t put_field_internal(const StructuredBlock *, const Field &, void *, size_t) const
Definition: Ioss_DatabaseIO.h:723
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:575
virtual void get_step_times__()
Definition: Ioss_DatabaseIO.h:652
void closeDatabase() const
Definition: Ioss_DatabaseIO.h:193
Ioss::Map edgeMap
Definition: Ioss_DatabaseIO.h:609
TopoContainer sideTopology
Used to speed up faceblock/edgeblock calculations.
Definition: Ioss_DatabaseIO.h:565
std::vector< std::vector< bool > > blockAdjacency
Definition: Ioss_DatabaseIO.h:613
void set_cycle_count(int count) const
Definition: Ioss_DatabaseIO.h:474
const std::string & decoded_filename() const
Get a file-per-processor filename associated with the database.
Definition: Ioss_DatabaseIO.C:323
bool useGenericCanonicalName
Definition: Ioss_DatabaseIO.h:754
void read_meta_data()
Definition: Ioss_DatabaseIO.h:285
Ioss::ParallelUtils util_
Definition: Ioss_DatabaseIO.h:735
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:358
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:644
virtual int int_byte_size_db() const =0
virtual bool begin_state__(Region *region, int state, double time)
Definition: Ioss_DatabaseIO.C:353
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:417
bool blockAdjacenciesCalculated
Definition: Ioss_DatabaseIO.h:760
virtual void compute_block_membership__(Ioss::SideBlock *efblock, std::vector< std::string > &block_membership) const
Definition: Ioss_DatabaseIO.h:660
Definition: Ioss_Map.h:52
virtual void finalize_database()
Definition: Ioss_DatabaseIO.h:146
Region * region_
Definition: Ioss_DatabaseIO.h:742
Definition: Ioss_CommSet.h:51
std::map< std::string, AxisAlignedBoundingBox > elementBlockBoundingBoxes
Definition: Ioss_DatabaseIO.h:733
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:243
Definition: Ioss_SurfaceSplit.h:40
Ioss::SurfaceSplitType splitType
Definition: Ioss_DatabaseIO.h:587
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:233
int parallel_rank() const
Get the processor that this mesh database is on.
Definition: Ioss_DatabaseIO.h:485
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:515
void set_logging(bool on_off)
Definition: Ioss_DatabaseIO.h:332
bool enableFieldRecognition
Definition: Ioss_DatabaseIO.h:744
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:646
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
Ioss::Map nodeMap
Definition: Ioss_DatabaseIO.h:608
virtual bool internal_edges_available() const
Definition: Ioss_DatabaseIO.h:297
int MPI_Comm
Definition: Ioss_CodeTypes.h:79
void set_parallel_consistency(bool on_off)
Definition: Ioss_DatabaseIO.h:369
int parallel_size() const
Definition: Ioss_DatabaseIO.h:486
void verify_and_log(const GroupingEntity *ge, const Field &field, int in_out) const
Definition: Ioss_DatabaseIO.C:341
int64_t nodeCount
Definition: Ioss_DatabaseIO.h:551
const Ioss::ParallelUtils & util() const
Definition: Ioss_DatabaseIO.h:479
#define IOSS_FUNC_ENTER(m)
Definition: Ioss_CodeTypes.h:114
virtual int64_t node_global_to_local__(int64_t global, bool must_exist) const
Definition: Ioss_DatabaseIO.h:624
void set_common_side_topology() const
Definition: Ioss_DatabaseIO.C:485
virtual int64_t get_field_internal(const StructuredBlock *, const Field &, void *, size_t) const
Definition: Ioss_DatabaseIO.h:693
bool isParallel
true if running in parallel
Definition: Ioss_DatabaseIO.h:548
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:573
A collection of Ioss::Property objects.
Definition: Ioss_PropertyManager.h:49
int myProcessor
number of processor this database is for
Definition: Ioss_DatabaseIO.h:549
IfDatabaseExistsBehavior
Definition: Ioss_DBUsage.h:56
bool doLogging
Definition: Ioss_DatabaseIO.h:753
std::vector< std::string > blockInclusions
Definition: Ioss_DatabaseIO.h:601
std::vector< char > data
Definition: Ioss_Utils.C:78
A collection of element edges with the same topology.
Definition: Ioss_EdgeBlock.h:53
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:642
virtual void closeDatabase__() const
Definition: Ioss_DatabaseIO.h:643
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:540
std::vector< std::pair< const ElementTopology *, const ElementTopology * > > TopoContainer
Definition: Ioss_DatabaseIO.h:75
void compute_block_adjacencies() const
Definition: Ioss_DatabaseIO.C:666
void set_block_omissions(const std::vector< std::string > &omissions, const std::vector< std::string > &inclusions={})
Definition: Ioss_DatabaseIO.C:549
void set_time_scale_factor(double factor)
Definition: Ioss_DatabaseIO.h:477
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