IOSS 2.0
Loading...
Searching...
No Matches
Iotm_TextMeshSidesetSkinner.h
Go to the documentation of this file.
1// Copyright(C) 1999-2020, 2022 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#pragma once
6
7// ####################### Start Clang Header Tool Managed Headers ########################
8// clang-format off
9#include <ctype.h> // for toupper
10#include <stddef.h> // for size_t
11#include <algorithm> // for remove, etc
12#include <iterator> // for insert_iterator
13#include <map>
14#include <set> // for set
15#include <sstream> // for operator<<, etc
16#include <string> // for basic_string, etc
17#include <utility> // for pair
18#include <vector> // for vector
19#include <unordered_map>
20#include <sstream> // for ostringstream
21#include <iostream>
22#include <functional>
23#include <stdexcept>
24#include <numeric>
25#include <strings.h>
26
27#include "Iotm_TextMeshFuncs.h"
31
32// clang-format on
33// ####################### End Clang Header Tool Managed Headers ########################
34namespace Iotm {
35 namespace text_mesh {
36
37 using ErrorHandler = std::function<void(const std::ostringstream &)>;
38
39 template <typename EntityId, typename Topology>
40 class SidesetSkinner : public SideAdjacencyGraph<EntityId, Topology>
41 {
42 public:
44
45 SidesetSkinner() = default;
46
48
49 size_t get_num_elements() const override
50 {
51 assert(m_textMeshData != nullptr);
52 return m_textMeshData->elementDataVec.size();
53 }
54
55 int get_element_proc(const size_t elemIndex) const override
56 {
57 assert(m_textMeshData != nullptr);
58 const ElementData<EntityId, Topology> &elemData = m_textMeshData->elementDataVec[elemIndex];
59 return elemData.proc;
60 }
61
62 bool element_has_any_node_on_proc(const size_t elemIndex, int proc) const override
63 {
64 assert(m_textMeshData != nullptr);
65 const ElementData<EntityId, Topology> &elemData = m_textMeshData->elementDataVec[elemIndex];
66
67 for (const EntityId &nodeId : elemData.nodeIds) {
68 const std::set<int> &procsForNode = m_textMeshData->procs_for_node(nodeId);
69 if (procsForNode.count(proc) > 0) {
70 return true;
71 }
72 }
73
74 return false;
75 }
76
77 const std::string &get_element_block_name(const size_t elemIndex) const override
78 {
79 assert(m_textMeshData != nullptr);
80 const ElementData<EntityId, Topology> &elemData = m_textMeshData->elementDataVec[elemIndex];
81 return elemData.partName;
82 }
83
84 const std::vector<EntityId> &get_element_node_ids(const size_t elemIndex) const override
85 {
86 assert(m_textMeshData != nullptr);
87 const ElementData<EntityId, Topology> &elemData = m_textMeshData->elementDataVec[elemIndex];
88 return elemData.nodeIds;
89 }
90
91 const Topology &get_element_topology(const size_t elemIndex) const override
92 {
93 assert(m_textMeshData != nullptr);
94 const ElementData<EntityId, Topology> &elemData = m_textMeshData->elementDataVec[elemIndex];
95 return elemData.topology;
96 }
97
98 EntityId get_element_id(const size_t elemIndex) const override
99 {
100 assert(m_textMeshData != nullptr);
101 const ElementData<EntityId, Topology> &elemData = m_textMeshData->elementDataVec[elemIndex];
102 return elemData.identifier;
103 }
104
105 void set_skin_blocks(const std::vector<std::string> &skinBlocks)
106 {
107 m_skinBlocks = skinBlocks;
108 }
109
111 std::vector<std::pair<EntityId, int>> &elemSidePairs)
112 {
113 populate_skin_blocks(textMeshData.partIds);
114
115 if (!m_skinBlocks.empty()) {
116 set_text_mesh_data(textMeshData);
119
120 for (auto iter = BaseClass::begin(); iter != BaseClass::end(); iter++) {
121 size_t elemIndex = iter->first;
122 const auto &faceConnections = iter->second;
123
124 std::vector<bool> hasConnection(faceConnections.numSides, false);
125 for (const auto &connection : faceConnections.connections) {
126 hasConnection[connection.thisSide - 1] = true;
127 }
128
129 for (unsigned i = 0; i < faceConnections.numSides; i++) {
130 if (!hasConnection[i]) {
131 EntityId elemId = textMeshData.elementDataVec[elemIndex].identifier;
132 int side = i + 1;
133 elemSidePairs.push_back(std::make_pair(elemId, side));
134 }
135 }
136 }
137 }
138 }
139
140 private:
142 {
143 bool skinAll = false;
144 for (const std::string &block : m_skinBlocks) {
145 if (0 == strcasecmp("all", block.c_str())) {
146 skinAll = true;
147 break;
148 }
149 }
150
151 if (skinAll) {
152 m_skinBlocks = partIds.get_part_names();
153 }
154 }
155
157 {
158 m_textMeshData = &textMeshData;
159 }
160
162
164 std::vector<std::string> m_skinBlocks{};
165 };
166
167 } // namespace text_mesh
168} // namespace Iotm
Definition Iotm_TextMeshTopologyMapping.h:33
Definition Iotm_TextMeshDataTypes.h:59
const std::vector< std::string > & get_part_names() const
Definition Iotm_TextMeshDataTypes.h:116
Definition Iotm_TextMeshAdjacencyGraph.h:86
void create_graph(int proc=ANY_PROC)
Definition Iotm_TextMeshAdjacencyGraph.h:209
std::unordered_map< size_t, FaceConnections >::const_iterator end() const
Definition Iotm_TextMeshAdjacencyGraph.h:273
std::unordered_map< size_t, FaceConnections >::const_iterator begin() const
Definition Iotm_TextMeshAdjacencyGraph.h:269
Definition Iotm_TextMeshSidesetSkinner.h:41
~SidesetSkinner()
Definition Iotm_TextMeshSidesetSkinner.h:47
int get_element_proc(const size_t elemIndex) const override
Definition Iotm_TextMeshSidesetSkinner.h:55
void reset_text_mesh_data()
Definition Iotm_TextMeshSidesetSkinner.h:161
const TextMeshData< EntityId, Topology > * m_textMeshData
Definition Iotm_TextMeshSidesetSkinner.h:163
std::vector< std::string > m_skinBlocks
Definition Iotm_TextMeshSidesetSkinner.h:164
void populate_skin_blocks(const PartIdMapping &partIds)
Definition Iotm_TextMeshSidesetSkinner.h:141
const std::vector< EntityId > & get_element_node_ids(const size_t elemIndex) const override
Definition Iotm_TextMeshSidesetSkinner.h:84
EntityId get_element_id(const size_t elemIndex) const override
Definition Iotm_TextMeshSidesetSkinner.h:98
const Topology & get_element_topology(const size_t elemIndex) const override
Definition Iotm_TextMeshSidesetSkinner.h:91
size_t get_num_elements() const override
Definition Iotm_TextMeshSidesetSkinner.h:49
void skin_blocks(const TextMeshData< EntityId, Topology > &textMeshData, std::vector< std::pair< EntityId, int > > &elemSidePairs)
Definition Iotm_TextMeshSidesetSkinner.h:110
void set_skin_blocks(const std::vector< std::string > &skinBlocks)
Definition Iotm_TextMeshSidesetSkinner.h:105
void set_text_mesh_data(const TextMeshData< EntityId, Topology > &textMeshData)
Definition Iotm_TextMeshSidesetSkinner.h:156
const std::string & get_element_block_name(const size_t elemIndex) const override
Definition Iotm_TextMeshSidesetSkinner.h:77
bool element_has_any_node_on_proc(const size_t elemIndex, int proc) const override
Definition Iotm_TextMeshSidesetSkinner.h:62
std::function< void(const std::ostringstream &)> ErrorHandler
Definition Iotm_TextMeshAdjacencyGraph.h:35
A namespace for the textmesh database format.
Definition Iotm_DatabaseIO.C:95
int64_t EntityId
Definition Iotm_TextMesh.h:33
Definition Iotm_TextMeshDataTypes.h:277
Topology topology
Definition Iotm_TextMeshDataTypes.h:280
std::string partName
Definition Iotm_TextMeshDataTypes.h:282
int proc
Definition Iotm_TextMeshDataTypes.h:278
EntityId identifier
Definition Iotm_TextMeshDataTypes.h:279
std::vector< EntityId > nodeIds
Definition Iotm_TextMeshDataTypes.h:281
Definition Iotm_TextMeshDataTypes.h:315
std::vector< ElementData< EntityId, Topology > > elementDataVec
Definition Iotm_TextMeshDataTypes.h:317
PartIdMapping partIds
Definition Iotm_TextMeshDataTypes.h:318