19#include <unordered_map>
36 using ErrorHandler = std::function<void(
const std::ostringstream &)>;
54 case SplitType::TOPOLOGY:
return out <<
"TOPOLOGY";
break;
55 case SplitType::ELEMENT_BLOCK:
return out <<
"ELEMENT_BLOCK";
break;
56 case SplitType::NO_SPLIT:
return out <<
"NO_SPLIT";
break;
57 default:
return out <<
"INVALID";
break;
59 return out <<
"INVALID[" << (unsigned)t <<
"]";
62 template <
typename EntityId>
using SidesetDataType = std::pair<EntityId, int>;
64 template <
typename EntityId,
typename Topology>
struct SidesetData;
71 ErrorHandler errorHandler = [](
const std::ostringstream &errmsg) {
79 ErrorHandler errorHandler = [](
const std::ostringstream &errmsg) {
103 std::ostringstream errmsg;
113 std::vector<SideBlockInfo> infoVec;
117 const std::string &sideBlockName = iter->first;
119 infoVec.push_back(info);
127 std::vector<size_t> indexForProc;
128 indexForProc.reserve(index.size());
130 for (
size_t elemPairIndex : index) {
132 indexForProc.push_back(elemPairIndex);
136 indexForProc.resize(indexForProc.size());
146 const SplitData &splitData = iter->second;
166 for (
size_t i = 0; i < sideset.
data.size(); ++i) {
168 EntityId elemId = elemSidePair.first;
170 auto iter =
bound_search(elementData.begin(), elementData.end(), elemId,
172 if (iter == elementData.end()) {
173 std::ostringstream errmsg;
174 errmsg <<
"Error! Sideset with id: " << sideset.
id <<
" and name: " << sideset.
name
175 <<
" has reference to invalid element '" << elemId <<
"'.";
188 std::ostringstream errmsg;
189 errmsg <<
"Sideset with name: " <<
m_sidesetName <<
" is referencing an invalid index "
194 return iter->second == proc;
217 splitData.
index.push_back(index);
241 for (
size_t index = 0; index < sideset.
data.size(); ++index) {
243 EntityId elemId = elemSidePair.first;
244 int side = elemSidePair.second;
246 auto iter =
bound_search(elementData.begin(), elementData.end(), elemId,
248 if (iter == elementData.end()) {
249 std::ostringstream errmsg;
250 errmsg <<
"Error! Sideset with id: " << sideset.
id <<
" and name: " << sideset.
name
251 <<
" has reference to invalid element '" << elemId <<
"'.";
255 std::string key = criterion(sideset, *iter, side);
266 return "SURFACE_" + elemData.topology.
name() +
"_" +
267 elemData.topology.side_topology_name(side) +
"_" + std::to_string(sideSet.
id);
269 return sideSet.
name +
"_" + elemData.topology.
name() +
"_" +
270 elemData.topology.side_topology_name(side);
282 return "SURFACE_" + elemData.partName +
"_" +
283 elemData.topology.side_topology_name(side) +
"_" + std::to_string(sideSet.
id);
285 return sideSet.
name +
"_" + elemData.partName +
"_" +
286 elemData.topology.side_topology_name(side);
295 std::vector<size_t> splitIndex(sideset.
data.size());
296 std::iota(std::begin(splitIndex), std::end(splitIndex), 0);
299 splitData.
index = splitIndex;
unsigned side_topology_num_nodes(unsigned side) const
Definition Iotm_TextMeshTopologyMapping.h:122
const std::string name() const
Definition Iotm_TextMeshTopologyMapping.h:71
std::string side_topology_name(unsigned side) const
Definition Iotm_TextMeshTopologyMapping.h:106
Definition Iotm_TextMeshSidesetSplitter.h:67
void split_by_no_split(const SidesetData< EntityId, Topology > &sideset, const std::vector< ElementData< EntityId, Topology > > &)
Definition Iotm_TextMeshSidesetSplitter.h:292
std::string m_sidesetName
Definition Iotm_TextMeshSidesetSplitter.h:308
SideBlockInfo get_side_block_info(const std::string &name) const
Definition Iotm_TextMeshSidesetSplitter.h:140
void split(const SidesetData< EntityId, Topology > &sideset, const std::vector< ElementData< EntityId, Topology > > &elementData)
Definition Iotm_TextMeshSidesetSplitter.h:87
SplitType m_splitType
Definition Iotm_TextMeshSidesetSplitter.h:307
SplitType get_split_type() const
Definition Iotm_TextMeshSidesetSplitter.h:159
std::function< std::string(const SidesetData< EntityId, Topology > &sideset, const ElementData< EntityId, Topology > &elemData, int side)> Criterion
Definition Iotm_TextMeshSidesetSplitter.h:233
SidesetSplitter()
Definition Iotm_TextMeshSidesetSplitter.h:77
SidesetSplitter(SplitType splitType)
Definition Iotm_TextMeshSidesetSplitter.h:69
bool is_index_local_to_proc(size_t elemPairIndex, int proc) const
Definition Iotm_TextMeshSidesetSplitter.h:183
ErrorHandler m_errorHandler
Definition Iotm_TextMeshSidesetSplitter.h:312
void set_split_type(SplitType inputSplitType)
Definition Iotm_TextMeshSidesetSplitter.h:160
void split_by_criterion(const SidesetData< EntityId, Topology > &sideset, const std::vector< ElementData< EntityId, Topology > > &elementData, Criterion criterion)
Definition Iotm_TextMeshSidesetSplitter.h:237
void split_by_topology(const SidesetData< EntityId, Topology > &sideset, const std::vector< ElementData< EntityId, Topology > > &elementData)
Definition Iotm_TextMeshSidesetSplitter.h:260
std::vector< size_t > get_indices_local_to_proc(const std::vector< size_t > &index, int proc) const
Definition Iotm_TextMeshSidesetSplitter.h:124
void split_by_element_block(const SidesetData< EntityId, Topology > &sideset, const std::vector< ElementData< EntityId, Topology > > &elementData)
Definition Iotm_TextMeshSidesetSplitter.h:276
std::vector< SideBlockInfo > get_side_block_info() const
Definition Iotm_TextMeshSidesetSplitter.h:111
void build_index_proc_map(const SidesetData< EntityId, Topology > &sideset, const std::vector< ElementData< EntityId, Topology > > &elementData)
Definition Iotm_TextMeshSidesetSplitter.h:163
void set_error_handler(ErrorHandler errorHandler)
Definition Iotm_TextMeshSidesetSplitter.h:85
std::unordered_map< size_t, int > m_indexProcMap
Definition Iotm_TextMeshSidesetSplitter.h:310
std::unordered_map< std::string, SplitData > m_splitMap
Definition Iotm_TextMeshSidesetSplitter.h:311
void fill_split_data(std::string key, size_t index, const ElementData< EntityId, Topology > &elemData, int side)
Definition Iotm_TextMeshSidesetSplitter.h:210
ForwardIt bound_search(ForwardIt first, ForwardIt last, const T &value)
Definition Iotm_TextMeshFuncs.h:38
void convert_to_upper_case(std::string &str)
Definition Iotm_TextMeshFuncs.h:88
std::function< void(const std::ostringstream &)> ErrorHandler
Definition Iotm_TextMeshAdjacencyGraph.h:35
std::ostream & operator<<(std::ostream &out, const AssemblyType &t)
Definition Iotm_TextMeshAssembly.h:41
std::pair< EntityId, int > SidesetDataType
Definition Iotm_TextMeshSideset.h:40
void default_error_handler(const std::ostringstream &message)
Definition Iotm_TextMeshFuncs.h:32
SplitType
Definition Iotm_TextMeshSidesetSplitter.h:49
@ INVALID_SPLIT
Definition Iotm_TextMeshSidesetSplitter.h:49
@ TOPOLOGY
Definition Iotm_TextMeshSidesetSplitter.h:49
@ NO_SPLIT
Definition Iotm_TextMeshSidesetSplitter.h:49
@ ELEMENT_BLOCK
Definition Iotm_TextMeshSidesetSplitter.h:49
A namespace for the textmesh database format.
Definition Iotm_DatabaseIO.C:95
int64_t EntityId
Definition Iotm_TextMesh.h:33
Definition Iotm_TextMeshDataTypes.h:288
Definition Iotm_TextMeshDataTypes.h:277
Topology topology
Definition Iotm_TextMeshDataTypes.h:280
std::string partName
Definition Iotm_TextMeshDataTypes.h:282
std::string name
Definition Iotm_TextMeshEntityGroup.h:43
unsigned id
Definition Iotm_TextMeshEntityGroup.h:42
std::vector< DataType > data
Definition Iotm_TextMeshEntityGroup.h:45
Definition Iotm_TextMeshSidesetSplitter.h:39
unsigned numNodesPerSide
Definition Iotm_TextMeshSidesetSplitter.h:46
std::string elementTopology
Definition Iotm_TextMeshSidesetSplitter.h:43
std::string parentName
Definition Iotm_TextMeshSidesetSplitter.h:41
std::vector< size_t > sideIndex
Definition Iotm_TextMeshSidesetSplitter.h:45
std::string sideTopology
Definition Iotm_TextMeshSidesetSplitter.h:42
std::string touchingBlock
Definition Iotm_TextMeshSidesetSplitter.h:44
std::string name
Definition Iotm_TextMeshSidesetSplitter.h:40
Definition Iotm_TextMeshSidesetSplitter.h:64
bool has_default_exodus_name() const
Definition Iotm_TextMeshSideset.h:88
Definition Iotm_TextMeshSidesetSplitter.h:198
std::string touchingBlock
Definition Iotm_TextMeshSidesetSplitter.h:201
SplitData()
Definition Iotm_TextMeshSidesetSplitter.h:207
int sideNodeCount
Definition Iotm_TextMeshSidesetSplitter.h:204
std::string sideTopology
Definition Iotm_TextMeshSidesetSplitter.h:203
std::string sidesetName
Definition Iotm_TextMeshSidesetSplitter.h:200
bool metaDataSet
Definition Iotm_TextMeshSidesetSplitter.h:199
std::vector< size_t > index
Definition Iotm_TextMeshSidesetSplitter.h:205
std::string elemTopology
Definition Iotm_TextMeshSidesetSplitter.h:202