Debian Codegraph @

packages/seacas/applications/zellij/UnitCell.h

raw
1 // Copyright(C) 2021, 2022, 2023 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 // See packages/seacas/LICENSE for details
6 #pragma once
7
8 #include <array>
9 #include <map>
10 #include <string>
11 #include <vector>
12
13 #include "Ioss_Region.h"
14
15 //! \file
16
17 enum class Bnd { MIN_I = 0, MAX_I = 1, MIN_J = 2, MAX_J = 3, MIN_K = 4, MAX_K = 5 };
18 enum class Flg { MIN_I = 1, MAX_I = 4, MIN_J = 2, MAX_J = 8, MIN_K = 16, MAX_K = 32 };
19
20 struct GeneratedSideBlock
21 {
22 //! List of faces (10*element_offset + face) in this SideBlock
23 //! indexed by element block name...
24 //!
25 //! Note that the `element_offset` is the 1-based index of the
26 //! element within the element block that it is a member of
27 GeneratedSideBlock() = default;
28 GeneratedSideBlock(const GeneratedSideBlock &) = delete;
29
30 std::map<std::string, std::vector<int64_t>> m_faces;
31
32 size_t size() const
33 {
34 size_t count = 0;
35 for (const auto &faces : m_faces) {
36 count += faces.second.size();
37 }
38 return count;
39 }
40 };
41
42 class UnitCell
43 {
44 public:
45 explicit UnitCell(std::shared_ptr<Ioss::Region> region);
46 UnitCell(const UnitCell &) = delete;
47
48 //! Create a vector of `node_count` length which has the following values:
49 //! * 0: Node that is not shared with any neighbors.
50 //! * 1: Node on `min_I` face
51 //! * 2: Node on `min_J` face
52 //! * 3: Node on `min_I-min_J` line
53 //! If `all_faces` is true, then also categorize the max_I (4) and max_J (8) faces and don't
54 //! consider neighbors (want all boundaries marked).
55 std::vector<int> categorize_nodes(bool neighbor_i, bool neighbor_j, bool all_faces = false) const;
56
57 std::shared_ptr<Ioss::Region> m_region{nullptr};
58
59 //!@{ The local node ids of the nodes that are on each face of this
60 //! unit cell. The I/J face nodes are in a structured configuration
61 //! and these vectors are sorted such that the `min_I_face` and
62 //! `max_I_face` nodes are at the same "parametric" location. In
63 //! other words, the nodes in the `max_I_face` of one unit cell will
64 //! line up with the nodes in the `min_I_face` of the neighboring
65 //! cell. They are also ordered such that the first `cell_KK` nodes
66 //! in the `min_I_face` and `min_J_face` lists should be the same
67 //! and are the nodes at the intersection of those two faces.
68 std::vector<int64_t> min_I_face{};
69 std::vector<int64_t> max_I_face{};
70 std::vector<int64_t> min_J_face{};
71 std::vector<int64_t> max_J_face{};
72 //!@}
73
74 ///@{
75 //! A pair containing the
76 //! minimum and maximum coordinate extent in the `x` and `y`
77 //! directions.
78 std::pair<double, double> minmax_x{};
79 std::pair<double, double> minmax_y{};
80 ///@}
81
82 void generate_boundary_faces(unsigned int which_faces);
83
84 //! Used by `generate_boundary_faces()` to categorize nodes on the +/- Z faces of unit cell.
85 void categorize_z_nodes(std::vector<int> &categorized_nodes);
86
87 std::array<GeneratedSideBlock, 6> boundary_blocks{};
88
89 ///@{
90 //! The outer boundary of a UnitCell has a
91 //! structured-configuration of the boundary faces on the non-K
92 //! faces. The `cell_II`, `cell_JJ`, and `cell_KK` variables give
93 //! the dimensions of this structured face mesh for the `min_I`,
94 //! `max_I`, `min_J`, and `max_J` faces. Note that the `min_K` and
95 //! `max_K` faces are *NOT* structured, but they will have `cell_II`
96 //! and `cell_JJ` nodes on the boundary of the faces.
97 size_t cell_II{};
98 size_t cell_JJ{};
99 size_t cell_KK{};
100 ///@}
101 };
102
103 using UnitCellMap = std::map<std::string, std::shared_ptr<UnitCell>>;