Nalu
Nalu: a generalized unstructured massively parallel low Mach flow code designed to support a variety of energy applications of interest (most notably Wind ECP) built on the Sierra Toolkit and Trilinos solver Tpetra/Epetra stack. The open source BSD, clause 3 license model has been chosen for the code base. See LICENSE for more information. http://NaluCFD.org
PromotedElementIO.h
Go to the documentation of this file.
1 /*------------------------------------------------------------------------*/
2 /* Copyright 2014 Sandia Corporation. */
3 /* This software is released under the license detailed */
4 /* in the file, LICENSE, which is located in the top-level nalu */
5 /* directory structure */
6 /*------------------------------------------------------------------------*/
7 #ifndef PromotedElementIO_h
8 #define PromotedElementIO_h
9 
10 #include <stk_mesh/base/CoordinateSystems.hpp>
11 #include <stk_mesh/base/FieldBase.hpp>
12 #include <Ioss_Region.h>
13 #include <stk_mesh/base/Field.hpp>
14 #include <stk_mesh/base/Types.hpp>
15 
16 #include <stddef.h>
17 #include <iosfwd>
18 #include <map>
19 #include <memory>
20 #include <string>
21 #include <unordered_set>
22 #include <vector>
23 
24 namespace Ioss {
25 class DatabaseIO;
26 class ElementBlock;
27 class NodeBlock;
28 class SideBlock;
29 } // namespace Ioss
30 namespace sierra {
31 namespace nalu {
32 class PromoteElement;
33 struct ElementDescription;
34 } // namespace nalu
35 } // namespace sierra
36 
37 // field types
38 typedef stk::mesh::Field<double> ScalarFieldType;
39 typedef stk::mesh::Field<double, stk::mesh::SimpleArrayTag> GenericFieldType;
40 typedef stk::mesh::Field<double, stk::mesh::Cartesian> VectorFieldType;
41 
42 namespace stk {
43  namespace mesh {
44  class BulkData;
45  class MetaData;
46  class Part;
47 
48  typedef std::vector<Part*> PartVector;
49  }
50 }
51 
52 namespace sierra {
53 namespace nalu {
54 
56 {
57 
58 public:
59  // constructor/destructor
61  const ElementDescription& elem,
62  const stk::mesh::MetaData& metaData,
63  stk::mesh::BulkData& bulkData,
64  const stk::mesh::PartVector& baseParts,
65  const std::string& fileName,
66  const VectorFieldType& coordField
67  );
68 
69  virtual ~PromotedElementIO() = default;
70 
71  void add_fields(const std::vector<stk::mesh::FieldBase*>& fields);
72  bool has_field(const std::string field_name) { return (fields_.find(field_name) != fields_.end()); }
73  void write_database_data(double currentTime);
74 
75 private:
76  void output_results(const std::vector<const stk::mesh::FieldBase*> fields) const;
77 
78  void write_element_connectivity(
79  const stk::mesh::PartVector& baseParts,
80  const std::vector<stk::mesh::EntityId>& entityIds);
81 
82  void write_sideset_connectivity(
83  const stk::mesh::PartVector& baseParts);
84 
85  size_t sub_element_global_id() const;
86  void write_node_block_definitions(
87  const stk::mesh::PartVector& superElemParts);
88  void write_elem_block_definitions(const stk::mesh::PartVector& baseParts);
89  void write_sideset_definitions(const stk::mesh::PartVector& baseParts);
90  void write_coordinate_list(const stk::mesh::PartVector& superElemParts);
91 
92  template<typename T> void
93  put_data_on_node_block(
94  Ioss::NodeBlock& nodeBlock,
95  const std::vector<int64_t>& ids,
96  const stk::mesh::FieldBase& field,
97  const stk::mesh::BucketVector& buckets) const;
98 
99  std::string storage_name(const stk::mesh::FieldBase& field) const;
100 
101  // meta, bulk and io
103  const stk::mesh::MetaData& metaData_;
104  const stk::mesh::BulkData& bulkData_;
105  const std::string& fileName_;
107  const unsigned nDim_;
109 
110  std::map<const std::string, const stk::mesh::FieldBase*> fields_;
111  std::map<const stk::mesh::Part*, Ioss::ElementBlock*> elementBlockPointers_;
112  std::map<const stk::mesh::Part*, Ioss::SideBlock*> sideBlockPointers_;
113  Ioss::NodeBlock* nodeBlock_;
114 
115  std::unique_ptr<Ioss::Region> output_;
116  Ioss::DatabaseIO* databaseIO;
117 };
118 
119 } // namespace nalu
120 } // namespace Sierra
121 
122 #endif
Definition: ElementDescription.h:27
std::vector< Part * > PartVector
Definition: Algorithm.h:16
const ElementDescription & elem_
Definition: PromotedElementIO.h:102
Definition: ABLForcingAlgorithm.C:26
stk::mesh::PartVector superElemParts_
Definition: PromotedElementIO.h:108
stk::mesh::Field< double > ScalarFieldType
Definition: PromotedElementIO.h:38
const unsigned nDim_
Definition: PromotedElementIO.h:107
Definition: Algorithm.h:14
Ioss::DatabaseIO * databaseIO
Definition: PromotedElementIO.h:116
stk::mesh::Field< double, stk::mesh::Cartesian > VectorFieldType
Definition: FieldTypeDef.h:24
const stk::mesh::MetaData & metaData_
Definition: PromotedElementIO.h:103
stk::mesh::Field< double, stk::mesh::Cartesian > VectorFieldType
Definition: PromotedElementIO.h:40
const VectorFieldType & coordinates_
Definition: PromotedElementIO.h:106
bool has_field(const std::string field_name)
Definition: PromotedElementIO.h:72
Definition: PromotedElementIO.h:55
std::map< const std::string, const stk::mesh::FieldBase * > fields_
Definition: PromotedElementIO.h:110
const std::string & fileName_
Definition: PromotedElementIO.h:105
Ioss::NodeBlock * nodeBlock_
Definition: PromotedElementIO.h:113
std::map< const stk::mesh::Part *, Ioss::ElementBlock * > elementBlockPointers_
Definition: PromotedElementIO.h:111
std::vector< Bucket * > BucketVector
Definition: PromotedPartHelper.h:21
std::unique_ptr< Ioss::Region > output_
Definition: PromotedElementIO.h:115
stk::mesh::Field< double, stk::mesh::SimpleArrayTag > GenericFieldType
Definition: PromotedElementIO.h:39
Definition: PromotedElementIO.h:24
std::map< const stk::mesh::Part *, Ioss::SideBlock * > sideBlockPointers_
Definition: PromotedElementIO.h:112
const stk::mesh::BulkData & bulkData_
Definition: PromotedElementIO.h:104