IOSS 2.0
Loading...
Searching...
No Matches
UnitTestIotmTextMeshFixture.h
Go to the documentation of this file.
1// Copyright(C) 1999-2020, 2022, 2023, 2024 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
7#pragma once
8
9#include "Ioss_CodeTypes.h"
10
11#include "Ionit_Initializer.h"
12#include "Ioss_Assembly.h"
13#include "Ioss_CommSet.h"
14#include "Ioss_DBUsage.h"
15#include "Ioss_DatabaseIO.h" // for DatabaseIO
16#include "Ioss_ElementBlock.h"
18#include "Ioss_EntityType.h" // for EntityType, etc
19#include "Ioss_Field.h" // for Field, etc
20#include "Ioss_GroupingEntity.h" // for GroupingEntity
21#include "Ioss_IOFactory.h" // for IOFactory
22#include "Ioss_MeshType.h" // for MeshType, etc
23#include "Ioss_NodeBlock.h"
24#include "Ioss_NodeSet.h"
25#include "Ioss_ParallelUtils.h"
27#include "Ioss_Region.h"
28#include "Ioss_SideBlock.h"
29#include "Ioss_SideSet.h"
31
32#include <gtest/gtest.h>
33#ifdef SEACAS_HAVE_MPI
34#include <mpi.h>
35#endif
36#include <string>
37#include <unordered_map>
38
39#include <memory>
40#include <string>
41#include <strings.h>
42#include <vector>
43
48
49#define ThrowRequireWithMsg(expr, message) \
50 do { \
51 if (!(expr)) { \
52 std::ostringstream internal_throw_require_oss; \
53 internal_throw_require_oss << message; \
54 throw std::logic_error(internal_throw_require_oss.str()); \
55 } \
56 } while (false)
57
60using EntityId = int64_t;
61using EntityIdVector = std::vector<EntityId>;
62using EntityIdSet = std::set<EntityId>;
71using SideEntry = std::pair<EntityId, int>;
72using SideVector = std::vector<SideEntry>;
74
76{
77 using NeighborVector = std::vector<std::pair<int, SideAdjacencyGraph::IndexType>>;
78 using SimpleNeighborVector = std::vector<SideAdjacencyGraph::IndexType>;
79
80 size_t elemIndex;
82
83 Adjacency(size_t elemIndex_, const NeighborVector &neighborIndices_)
84 : elemIndex(elemIndex_), neighborIndices(neighborIndices_)
85 {
86 }
87
88 Adjacency(size_t elemIndex_, const SimpleNeighborVector &neighborIndices_)
89 : elemIndex(elemIndex_), neighborIndices(get_full_neighbor_vector(neighborIndices_))
90 {
91 }
92
94 {
95 NeighborVector fullNeighborVector;
96 fullNeighborVector.reserve(simpleNeighborVector.size());
97
98 for (unsigned i = 0; i < simpleNeighborVector.size(); i++) {
99 fullNeighborVector.push_back(std::make_pair(static_cast<int>(i), simpleNeighborVector[i]));
100 }
101 return fullNeighborVector;
102 }
103};
104
106{
107 inline bool operator()(const SideEntry &lhs, const SideEntry &rhs) const
108 {
109 if (lhs.first < rhs.first)
110 return true;
111 else if (lhs.first == rhs.first && lhs.second < rhs.second)
112 return true;
113
114 return false;
115 }
116};
117
118namespace Iotm {
119 namespace unit_test {
120
122 {
123 public:
126
128
129 public:
130 std::vector<std::string> get_unique_leaf_members(const std::string &name)
131 {
132 m_leafMembers.clear();
133 m_visitedAssemblies.clear();
134
135 for (Ioss::Assembly *assembly : m_region->get_assemblies()) {
136 m_visitedAssemblies[assembly] = false;
137 }
138
140
141 std::sort(m_leafMembers.begin(), m_leafMembers.end(), std::less<std::string>());
142 auto endIter = std::unique(m_leafMembers.begin(), m_leafMembers.end());
143 m_leafMembers.resize(endIter - m_leafMembers.begin());
144
145 return m_leafMembers;
146 }
147
148 private:
149 void traverse_tree(const Ioss::Assembly *assembly)
150 {
151 // Walk the tree without cyclic dependency
152 if (assembly != nullptr) {
153 if (m_visitedAssemblies[assembly] == false) {
154 m_visitedAssemblies[assembly] = true;
155
156 const Ioss::EntityType assemblyType = assembly->get_member_type();
157 if (Ioss::ASSEMBLY != assemblyType) {
158 for (const Ioss::GroupingEntity *ge : assembly->get_members()) {
159 m_leafMembers.push_back(ge->name());
160 }
161 }
162 else {
163 for (const Ioss::GroupingEntity *ge : assembly->get_members()) {
164 const Ioss::Assembly *assemblyMember = dynamic_cast<const Ioss::Assembly *>(ge);
165 ThrowRequireWithMsg(nullptr != assemblyMember,
166 "Non-assembly member: " << ge->name()
167 << " in ASSEMBLY rank assembly: "
168 << assembly->name());
169 traverse_tree(assemblyMember);
170 }
171 }
172 }
173 }
174 }
175
177 mutable std::unordered_map<const Ioss::Assembly *, bool> m_visitedAssemblies;
178 mutable std::vector<std::string> m_leafMembers;
179 };
180
181 class TextMeshFixture : public ::testing::Test
182 {
183 protected:
184 using PartNameId = std::pair<std::string, unsigned>;
185
187 {
190
191 ElementInfo() : topology(nullptr) {}
192 ElementInfo(const Ioss::ElementTopology *topology_, const EntityIdVector &connectivity_)
193 : topology(topology_), connectivity(connectivity_)
194 {
195 }
196 };
197
198 struct PartInfo
199 {
200 std::string blockName;
202 };
203
204 TextMeshFixture(unsigned spatialDimension) : m_spatialDimension(spatialDimension)
205 {
208 }
209
211
213
215
216 void fill_mesh(const std::string &meshDesc)
217 {
218 std::pair<std::string, std::string> result = get_database_type_and_filename(meshDesc);
219
220 std::string type = result.first;
221 std::string filename = result.second;
222
223 EXPECT_EQ("textmesh", type);
224
225 create_database(filename, type);
227 }
228
230
231 std::string get_mesh_desc(const std::string &textMeshDesc)
232 {
233 std::string header = "textmesh:";
234 std::string meshDesc = header + textMeshDesc;
235 return meshDesc;
236 }
237
238 std::string get_mesh_desc(const std::string &textMeshDesc, unsigned dimension)
239 {
240 std::stringstream dim;
241 dim << "|dimension:" << dimension;
242
243 std::string meshDesc = get_mesh_desc(textMeshDesc) + dim.str();
244 return meshDesc;
245 }
246
247 void verify_shared_nodes(const EntityIdVector &nodeIds, int sharingProc)
248 {
249 EXPECT_EQ(nodeIds.size(), get_node_sharing_count(sharingProc));
250
251 for (EntityId nodeId : nodeIds) {
252 EXPECT_TRUE(node_is_shared_with_proc(nodeId, sharingProc));
253 }
254 }
255
256 void verify_num_elements(size_t goldCount)
257 {
258 size_t count = get_element_count();
259 EXPECT_EQ(goldCount, count);
260 }
261
262 void verify_single_element(EntityId elemId, const std::string &textMeshTopologyName,
263 const EntityIdVector &nodeIds)
264 {
265 Topology topology = m_topologyMapping.topology(textMeshTopologyName);
266 ElementInfo info = get_element_info(elemId);
267 EXPECT_TRUE(is_valid_element(info));
268 EXPECT_EQ(topology, info.topology);
269 verify_nodes_on_element(info, nodeIds);
270 }
271
272 void verify_num_sidesets(size_t goldCount)
273 {
274 ThrowRequireWithMsg(m_region != nullptr, "Ioss region has not been created");
275 size_t count = m_region->get_sidesets().size();
276 EXPECT_EQ(goldCount, count);
277 }
278
279 void verify_sideset_subset(const Ioss::SideSet *sideset, const unsigned id,
280 const std::vector<std::string> &subsetNames)
281 {
282 EXPECT_TRUE(nullptr != sideset);
283 EXPECT_EQ(id, sideset->get_property("id").get_int());
284
285 if (subsetNames.empty()) {
286 EXPECT_EQ(1u, sideset->get_side_blocks().size());
287 }
288 else {
289 EXPECT_EQ(subsetNames.size(), sideset->get_side_blocks().size());
290 }
291
292 for (std::string subsetName : subsetNames) {
293 std::transform(subsetName.begin(), subsetName.end(), subsetName.begin(), ::toupper);
294 Ioss::SideBlock *sideBlock = sideset->get_side_block(subsetName);
295 EXPECT_TRUE(nullptr != sideBlock);
296 EXPECT_EQ(id, sideBlock->get_property("id").get_int());
297 }
298 }
299
300 void verify_single_sideset(const std::string &name, const unsigned id,
301 const SideVector &goldElemSidePairs)
302 {
303 verify_single_sideset(name, id, std::vector<std::string>{}, goldElemSidePairs);
304 }
305
306 void verify_single_sideset(const std::string &name, const unsigned id,
307 const std::vector<std::string> &subsets,
308 const SideVector &goldElemSidePairs)
309 {
310 Ioss::SideSet *sideset = get_sideset(name);
311 verify_sideset_subset(sideset, id, subsets);
312
313 EXPECT_TRUE(nullptr != sideset);
314
315 SideVector elemSidePairs = get_element_side_pairs_from_sideset(sideset);
316 std::sort(elemSidePairs.begin(), elemSidePairs.end(), SideEntryLess());
317
318 for (const SideEntry &sideEntry : goldElemSidePairs) {
319 EntityId elemId = sideEntry.first;
320 int side = sideEntry.second;
321
322 ElementInfo info = get_element_info(elemId);
323 EXPECT_TRUE(is_valid_element(info));
324
325 EXPECT_TRUE(side > 0);
326 EXPECT_TRUE(side <= (int)info.topology->number_boundaries());
327
328 EXPECT_TRUE(std::binary_search(elemSidePairs.begin(), elemSidePairs.end(), sideEntry,
329 SideEntryLess()));
330 }
331 }
332
333 void verify_num_nodesets(size_t goldCount)
334 {
335 ThrowRequireWithMsg(m_region != nullptr, "Ioss region has not been created");
336 size_t count = m_region->get_nodesets().size();
337 EXPECT_EQ(goldCount, count);
338 }
339
340 void verify_single_nodeset(const std::string &name, const unsigned id,
341 const EntityIdVector &goldNodeIds)
342 {
343 Ioss::NodeSet *nodeset = get_nodeset(name);
344 EXPECT_TRUE(nullptr != nodeset);
345 EXPECT_EQ(id, nodeset->get_property("id").get_int());
346
347 EntityIdVector nodeIds = get_node_ids_from_nodeset(nodeset);
348 std::sort(nodeIds.begin(), nodeIds.end());
349
350 for (EntityId node : goldNodeIds) {
351 EXPECT_TRUE(std::binary_search(nodeIds.begin(), nodeIds.end(), node));
352 }
353 }
354
355 void verify_num_assemblies(size_t goldCount)
356 {
357 ThrowRequireWithMsg(m_region != nullptr, "Ioss region has not been created");
358 size_t count = m_region->get_assemblies().size();
359 EXPECT_EQ(goldCount, count);
360 }
361
362 void verify_single_assembly(const std::string &name, const unsigned id,
363 const std::vector<std::string> &goldMembers)
364 {
365 Ioss::Assembly *assembly = get_assembly(name);
366 EXPECT_TRUE(nullptr != assembly);
367 EXPECT_EQ(id, assembly->get_property("id").get_int());
368
370 std::vector<std::string> leafMembers = graph.get_unique_leaf_members(name);
371 EXPECT_EQ(goldMembers.size(), leafMembers.size());
372
373 for (size_t i = 0; i < goldMembers.size(); i++) {
374 const std::string &goldMember = goldMembers[i];
375 const std::string &leafMember = leafMembers[i];
376 EXPECT_EQ(0, strcasecmp(goldMember.c_str(), leafMember.c_str()))
377 << "Comparison failure for " << name << ": " << goldMember << " <-> " << leafMember;
378 }
379 }
380
381 void verify_part_membership(const std::vector<PartInfo> golds)
382 {
383 for (const PartInfo &gold : golds) {
384 Ioss::ElementBlock *block = get_element_block(gold.blockName);
385
386 verify_block(block);
387 verify_elements_on_block(block, gold.ids);
388 }
389 }
390
391 void verify_part_ids(const std::vector<PartNameId> &golds)
392 {
393 for (const PartNameId &gold : golds) {
394 Ioss::ElementBlock *block = get_element_block(gold.first);
395
396 verify_block(block);
397 unsigned id = block->get_property("id").get_int();
398 EXPECT_EQ(id, gold.second);
399 }
400 }
401
402 void verify_nodes_on_element(const ElementInfo &info, const EntityIdVector &goldNodeIds)
403 {
404 EXPECT_EQ(goldNodeIds, info.connectivity);
405 }
406
407 void verify_coordinates(const EntityIdVector &goldNodeIds,
408 const std::vector<double> &goldCoordinates)
409 {
410 CoordinateVerifier cv(*m_region, goldNodeIds, goldCoordinates);
411 cv.verify();
412 }
413
414 void setup_text_mesh(const std::string &textMeshDesc)
415 {
417 }
418
419 std::string get_topology_name(const std::string &textMeshTopologyName)
420 {
421 return m_topologyMapping.topology(textMeshTopologyName).name();
422 }
423
424 size_t db_api_int_size() const
425 {
426 assert(m_database != nullptr);
428 }
429
430 size_t get_node_sharing_count(int sharingProc) const
431 {
432 if (db_api_int_size() == 4) {
433 return get_node_sharing_count_impl<int>(sharingProc);
434 }
435 else {
436 return get_node_sharing_count_impl<int64_t>(sharingProc);
437 }
438 }
439
440 template <typename INT> size_t get_node_sharing_count_impl(int sharingProc) const
441 {
442 ThrowRequireWithMsg(m_region != nullptr, "Ioss region has not been created");
443
444 Ioss::CommSet *io_cs = m_region->get_commset("commset_node");
445 size_t numSharings = io_cs->get_field("entity_processor").raw_count();
446
447 std::vector<INT> entityProc;
448 io_cs->get_field_data("entity_processor", entityProc);
449
450 size_t count = 0;
451
452 for (size_t i = 0; i < numSharings; ++i) {
453 int iossSharingProc = entityProc[i * 2 + 1];
454
455 if (iossSharingProc == sharingProc) {
456 count++;
457 }
458 }
459
460 return count;
461 }
462
463 template <typename INT>
465 {
466 EntityIdVector elemIds;
467
468 std::vector<INT> ids;
469
470 block->get_field_data("ids", ids);
471
472 for (INT id : ids) {
473 elemIds.push_back(static_cast<EntityId>(id));
474 }
475
476 return elemIds;
477 }
478
480 {
481 if (db_api_int_size() == 4) {
483 }
484 else {
486 }
487 }
488
489 template <typename INT>
491 {
492 EntityIdVector nodeIds;
493
494 std::vector<INT> ids;
495
496 ns->get_field_data("ids", ids);
497
498 for (INT id : ids) {
499 nodeIds.push_back(static_cast<EntityId>(id));
500 }
501
502 return nodeIds;
503 }
504
506 {
507 if (db_api_int_size() == 4) {
509 }
510 else {
512 }
513 }
514
515 template <typename INT>
517 {
518 SideVector elemSides;
519
520 for (const Ioss::SideBlock *sb : ss->get_side_blocks()) {
521 std::vector<INT> elemSideVec;
522 sb->get_field_data("element_side", elemSideVec);
523
524 for (unsigned i = 0; i < sb->entity_count(); i++) {
525 EntityId elem = elemSideVec[2 * i + 0];
526 int side = elemSideVec[2 * i + 1];
527 elemSides.push_back({elem, side});
528 }
529 }
530
531 return elemSides;
532 }
533
543
544 template <typename INT>
546 const Ioss::ElementBlock *block) const
547 {
548 const Ioss::ElementTopology *topo = nullptr;
549 EntityIdVector elemConn;
550
551 std::vector<INT> connectivity;
552 std::vector<INT> elemIds;
553
554 block->get_field_data("ids", elemIds);
555 block->get_field_data("connectivity", connectivity);
556
557 topo = block->topology();
558
559 size_t elementCount = elemIds.size();
560 int nodesPerElem = topo->number_nodes();
561
562 for (size_t i = 0; i < elementCount; ++i) {
563 INT *conn = &connectivity[i * nodesPerElem];
564 auto id = static_cast<EntityId>(elemIds[i]);
565
566 if (id == elemId) {
567 for (int j = 0; j < nodesPerElem; j++) {
568 elemConn.push_back(conn[j]);
569 }
570
571 return ElementInfo(topo, elemConn);
572 }
573 }
574
575 return ElementInfo(nullptr, EntityIdVector());
576 }
577
578 template <typename INT> ElementInfo get_element_info_impl(EntityId elemId) const
579 {
580 ThrowRequireWithMsg(m_region != nullptr, "Ioss region has not been created");
581 ElementInfo elemInfo;
582
583 EntityIdVector elemConn;
584
586 bool found = false;
587
588 for (const Ioss::ElementBlock *block : elemBlocks) {
590
591 if (is_valid_element(info)) {
592 ThrowRequireWithMsg(!found,
593 "Element with id " << elemId << " exists in more than one block!");
594 found = true;
595 elemInfo = info;
596 }
597 }
598
599 return elemInfo;
600 }
601
603 {
604 if (db_api_int_size() == 4) {
605 return get_element_info_impl<int>(elemId);
606 }
607 else {
608 return get_element_info_impl<int64_t>(elemId);
609 }
610 }
611
612 template <typename INT> size_t get_element_count_impl() const
613 {
614 ThrowRequireWithMsg(m_region != nullptr, "Ioss region has not been created");
615
617 size_t count = 0;
618
619 for (const Ioss::ElementBlock *block : elemBlocks) {
620 std::vector<INT> elemIds;
621 block->get_field_data("ids", elemIds);
622 count += elemIds.size();
623 }
624
625 return count;
626 }
627
628 size_t get_element_count() const
629 {
630 if (db_api_int_size() == 4) {
632 }
633 else {
635 }
636 }
637
638 template <typename INT>
639 bool node_is_shared_with_proc_impl(EntityId nodeId, int sharingProc) const
640 {
641 ThrowRequireWithMsg(m_region != nullptr, "Ioss region has not been created");
642
643 Ioss::CommSet *io_cs = m_region->get_commset("commset_node");
644 size_t numSharings = io_cs->get_field("entity_processor").raw_count();
645
646 std::vector<INT> entityProc;
647 io_cs->get_field_data("entity_processor", entityProc);
648
649 for (size_t i = 0; i < numSharings; ++i) {
650 EntityId iossNodeId = entityProc[i * 2];
651 int iossSharingProc = entityProc[i * 2 + 1];
652
653 if (iossNodeId == nodeId && iossSharingProc == sharingProc) {
654 return true;
655 }
656 }
657
658 return false;
659 }
660
661 bool node_is_shared_with_proc(EntityId nodeId, int sharingProc) const
662 {
663 if (db_api_int_size() == 4) {
664 return node_is_shared_with_proc_impl<int>(nodeId, sharingProc);
665 }
666 else {
667 return node_is_shared_with_proc_impl<int64_t>(nodeId, sharingProc);
668 }
669 }
670
671 bool is_valid_element(const ElementInfo &info) const
672 {
673 bool validTopology = info.topology != nullptr &&
675 bool validConnectivitySize = info.connectivity.size() != 0;
676 bool validNumNodes = validTopology ? info.topology->number_nodes() ==
677 static_cast<int>(info.connectivity.size())
678 : false;
679
680 return validConnectivitySize && validNumNodes;
681 }
682
683 Ioss::ElementBlock *get_element_block(const std::string &blockName) const
684 {
685 ThrowRequireWithMsg(m_region != nullptr, "Ioss region has not been created");
686
688 Ioss::ElementBlock *elemBlock = nullptr;
689
690 for (Ioss::ElementBlock *block : elemBlocks) {
691 if (strcasecmp(block->name().c_str(), blockName.c_str()) == 0) {
692 elemBlock = block;
693 }
694 }
695
696 return elemBlock;
697 }
698
699 Ioss::NodeSet *get_nodeset(const std::string &name) const
700 {
701 ThrowRequireWithMsg(m_region != nullptr, "Ioss region has not been created");
702
703 const Ioss::NodeSetContainer &nodesets = m_region->get_nodesets();
704 Ioss::NodeSet *nodeset = nullptr;
705
706 for (Ioss::NodeSet *ns : nodesets) {
707 if (strcasecmp(ns->name().c_str(), name.c_str()) == 0) {
708 nodeset = ns;
709 }
710 }
711
712 return nodeset;
713 }
714
715 Ioss::SideSet *get_sideset(const std::string &name) const
716 {
717 ThrowRequireWithMsg(m_region != nullptr, "Ioss region has not been created");
718
719 const Ioss::SideSetContainer &sidesets = m_region->get_sidesets();
720 Ioss::SideSet *sideset = nullptr;
721
722 for (Ioss::SideSet *ss : sidesets) {
723 if (strcasecmp(ss->name().c_str(), name.c_str()) == 0) {
724 sideset = ss;
725 }
726 }
727
728 return sideset;
729 }
730
731 Ioss::Assembly *get_assembly(const std::string &name) const
732 {
733 ThrowRequireWithMsg(m_region != nullptr, "Ioss region has not been created");
734
735 const Ioss::AssemblyContainer &assemblies = m_region->get_assemblies();
736 Ioss::Assembly *assembly = nullptr;
737
738 for (Ioss::Assembly *ass : assemblies) {
739 if (strcasecmp(ass->name().c_str(), name.c_str()) == 0) {
740 assembly = ass;
741 }
742 }
743
744 return assembly;
745 }
746
747 void verify_block(Ioss::ElementBlock *block) { ASSERT_TRUE(block != nullptr); }
748
750 const std::set<EntityId> &goldIds)
751 {
753
754 ASSERT_EQ(goldIds.size(), elemIds.size());
755 for (EntityId elemId : elemIds) {
756 EXPECT_EQ(1u, goldIds.count(elemId));
757 }
758 }
759
761 {
762 if (m_region == nullptr) {
763 EXPECT_TRUE(m_database != nullptr);
764 m_region = new Ioss::Region(m_database, "input_model");
765 EXPECT_TRUE(m_region != nullptr);
766 }
767 }
768
769 void create_database(const std::string &fileName, const std::string &meshType)
770 {
771 if (m_database == nullptr) {
773
774 std::string meshFileName = fileName;
775 filename_substitution(meshFileName);
776 m_database = Ioss::IOFactory::create(meshType, meshFileName, db_usage, get_comm(),
778 EXPECT_TRUE(m_database != nullptr);
779 EXPECT_TRUE(m_database->ok(true));
780 EXPECT_EQ(m_database->get_format(), "TextMesh");
781 }
782 }
783
784 void filename_substitution(std::string &filename)
785 {
786 // See if filename contains "%P" which is replaced by the number of processors...
787 // Assumes that %P only occurs once...
788 // filename is changed.
789 size_t pos = filename.find("%P");
790 if (pos != std::string::npos) {
791 // Found the characters... Replace with the processor count...
792 int num_proc = std::max(1, get_parallel_size());
793 std::string tmp(filename, 0, pos);
794 tmp += std::to_string(num_proc);
795 tmp += filename.substr(pos + 2);
796 filename = tmp;
797 }
798 }
799
800 std::pair<std::string, std::string>
801 get_database_type_and_filename(const std::string &meshDesc)
802 {
803 std::string type;
804 std::string filename;
805
806 size_t colon = meshDesc.find(':');
807 if (colon != std::string::npos && colon > 0) {
808 type = meshDesc.substr(0, colon);
809 filename = meshDesc.substr(colon + 1);
810 }
811 else {
812 type = "textmesh";
813 filename = meshDesc;
814 }
815
816 return std::make_pair(type, filename);
817 }
818
820 {
821 public:
823 const std::vector<double> &coords)
824 : region(r), spatialDim(region.get_property("spatial_dimension").get_int()),
825 goldNodeIds(ids), goldCoordinates(coords)
826 {
828 }
829
830 void verify()
831 {
832 for (size_t nodeIndex = 0; nodeIndex < goldNodeIds.size(); nodeIndex++) {
833 EntityId nodeId = goldNodeIds[nodeIndex];
834 EXPECT_TRUE(is_valid_node(nodeId));
835
836 const double *nodalCoords = get_nodal_coordinates(nodeId);
837 const double *goldCoords = &goldCoordinates[nodeIndex * spatialDim];
838
839 verify_nodal_coordinates(nodeId, goldCoords, nodalCoords);
840 }
841 }
842
843 private:
844 template <typename T>
845 size_t field_data_from_ioss(Ioss::GroupingEntity *io_entity, const std::string &io_fld_name,
846 std::vector<T> &io_field_data)
847 {
848 size_t io_entity_count = 0;
849 if (io_entity->field_exists(io_fld_name)) {
850 const Ioss::Field &io_field = io_entity->get_fieldref(io_fld_name);
851 io_entity_count = io_entity->get_field_data(io_field.get_name(), io_field_data);
852 }
853 return io_entity_count;
854 }
855
856 size_t db_api_int_size() const { return region.get_database()->int_byte_size_api(); }
857
858 template <typename INT> EntityIdVector get_node_ids_impl() const
859 {
860 const Ioss::NodeBlockContainer &node_blocks = region.get_node_blocks();
861 assert(node_blocks.size() == 1);
862
863 Ioss::NodeBlock *nb = node_blocks[0];
864
865 std::vector<INT> ids;
866 nb->get_field_data("ids", ids);
867
868 EntityIdVector nodeIds;
869 for (INT id : ids) {
870 nodeIds.push_back(static_cast<EntityId>(id));
871 }
872
873 return nodeIds;
874 }
875
877 {
878 if (db_api_int_size() == 4) {
879 return get_node_ids_impl<int>();
880 }
881 else {
883 }
884 }
885
886 template <typename INT> bool is_valid_node_impl(EntityId nodeId) const
887 {
889 auto iter = std::find(ids.begin(), ids.end(), INT(nodeId));
890 return iter != ids.end();
891 }
892
893 bool is_valid_node(EntityId nodeId) const
894 {
895 if (db_api_int_size() == 4) {
896 return is_valid_node_impl<int>(nodeId);
897 }
898 else {
899 return is_valid_node_impl<int64_t>(nodeId);
900 }
901 }
902
904 {
906 EXPECT_EQ(goldNodeIds.size(), ids.size());
907 }
908
910 const std::vector<double> &coordinates)
911 {
912 std::vector<double>::const_iterator coordIter = coordinates.begin();
913 for (const EntityId &nodeId : nodeIds) {
914 m_nodalCoords[nodeId] = std::vector<double>(coordIter, coordIter + spatialDim);
915 coordIter += spatialDim;
916 }
917 }
918
920 {
921 std::vector<double> iossCoordinates;
922
923 const Ioss::NodeBlockContainer &node_blocks = region.get_node_blocks();
924 assert(node_blocks.size() == 1);
925
926 Ioss::NodeBlock *nb = node_blocks[0];
927
928 size_t node_count = nb->get_property("entity_count").get_int();
929
930 EntityIdVector nodeIds = get_node_ids();
931
932 size_t numIossNodes =
933 field_data_from_ioss<double>(nb, "mesh_model_coordinates", iossCoordinates);
934 ThrowRequireWithMsg(node_count == numIossNodes, "Node count mismatch");
935 ThrowRequireWithMsg(iossCoordinates.size() == numIossNodes * spatialDim,
936 "Invalid coordinate data size");
937
938 fill_coordinate_map(nodeIds, iossCoordinates);
939 }
940
941 const std::vector<double> &operator[](const EntityId nodeId) const
942 {
943 auto it = m_nodalCoords.find(nodeId);
944 return it->second;
945 }
946
947 const double *get_nodal_coordinates(const EntityId &nodeId) const
948 {
949 return Data((*this)[nodeId]);
950 }
951
952 void verify_nodal_coordinates(const EntityId &nodeId, const double *goldCoords,
953 const double *nodalCoords)
954 {
955 for (unsigned i = 0; i < spatialDim; i++) {
956 EXPECT_NEAR(goldCoords[i], nodalCoords[i], 1.0e-9) << error_message(nodeId, i);
957 }
958 }
959
960 std::string error_message(const EntityId &nodeId, unsigned coordIndex)
961 {
962 std::stringstream message;
963 message << "Proc " << region.get_database()->util().parallel_rank() << ", Node ID "
964 << nodeId << ", coord index " << coordIndex;
965 return message.str();
966 }
967
969
970 const unsigned spatialDim;
971
973 const std::vector<double> &goldCoordinates;
974 std::unordered_map<EntityId, std::vector<double>> m_nodalCoords;
975 };
976
977 unsigned m_spatialDimension = 3;
982 };
983
984 } // namespace unit_test
985} // namespace Iotm
986
987namespace {
989 {
990 protected:
991 TestTextMesh() : TextMeshFixture(3) {}
992 };
993
995 {
996 protected:
997 TestTextMesh2d() : TextMeshFixture(2) {}
998 };
999
1001 {
1002 protected:
1003 TestTextMesh1d() : TextMeshFixture(1) {}
1004 };
1005
1007 {
1008 protected:
1009 TestTextMeshGraph() : TextMeshFixture(3) {}
1010
1012 {
1013 public:
1014 TextMeshGraph(const TextMeshData &data) : m_data(data) {}
1015
1016 size_t get_num_elements() const override { return m_data.elementDataVec.size(); }
1017
1018 int get_element_proc(const size_t elemIndex) const override
1019 {
1020 const ElementData &elemData = m_data.elementDataVec[elemIndex];
1021 return elemData.proc;
1022 }
1023
1024 bool element_has_any_node_on_proc(const size_t elemIndex, int proc) const override
1025 {
1026 const ElementData &elemData = m_data.elementDataVec[elemIndex];
1027
1028 for (const EntityId &nodeId : elemData.nodeIds) {
1029 const std::set<int> &procsForNode = m_data.procs_for_node(nodeId);
1030 if (procsForNode.count(proc) > 0) {
1031 return true;
1032 }
1033 }
1034
1035 return false;
1036 }
1037
1038 const std::string &get_element_block_name(const size_t elemIndex) const override
1039 {
1040 const ElementData &elemData = m_data.elementDataVec[elemIndex];
1041 return elemData.partName;
1042 }
1043
1044 const std::vector<EntityId> &get_element_node_ids(const size_t elemIndex) const override
1045 {
1046 const ElementData &elemData = m_data.elementDataVec[elemIndex];
1047 return elemData.nodeIds;
1048 }
1049
1050 const Topology &get_element_topology(const size_t elemIndex) const override
1051 {
1052 const ElementData &elemData = m_data.elementDataVec[elemIndex];
1053 return elemData.topology;
1054 }
1055
1056 EntityId get_element_id(const size_t elemIndex) const override
1057 {
1058 const ElementData &elemData = m_data.elementDataVec[elemIndex];
1059 return elemData.identifier;
1060 }
1061
1062 private:
1064 };
1065
1066 void dump_graph(std::ostream &out = std::cout) { m_graph->dump(m_data.elementDataVec, out); }
1067
1068 void setup_text_mesh_graph(const std::string &meshDesc,
1069 const std::vector<std::string> &selectedBlocks = {},
1071 {
1072 TextMeshParser parser;
1073 m_data = parser.parse(meshDesc);
1074 m_graph = std::make_shared<TextMeshGraph>(m_data);
1075 m_graph->create_graph(selectedBlocks, proc);
1076 }
1077
1078 void verify_side_adjacency(const std::vector<Adjacency> &goldNeighbors)
1079 {
1080 EXPECT_EQ(m_graph->size(), goldNeighbors.size());
1081 for (size_t i = 0; i < goldNeighbors.size(); ++i) {
1082 const auto &graphNeighborIndices = (*m_graph)[goldNeighbors[i].elemIndex];
1083 const auto &goldNeighborIndices = goldNeighbors[i].neighborIndices;
1084
1085 unsigned numActualGoldConnections = 0;
1086 for (const auto &entry : goldNeighborIndices) {
1087 if (entry.second >= 0) {
1088 numActualGoldConnections++;
1089 }
1090 }
1091
1092 EXPECT_EQ(numActualGoldConnections, graphNeighborIndices.connections.size());
1093
1094 for (const auto &entry : goldNeighborIndices) {
1095 int side = entry.first + 1;
1096 SideAdjacencyGraph::IndexType neighborElemIndex = entry.second;
1097
1098 if (neighborElemIndex >= 0) {
1099 EXPECT_LT(0, graphNeighborIndices.sideReference[side - 1]);
1100 EXPECT_TRUE(graphNeighborIndices.has_any_connection(side, neighborElemIndex));
1101 }
1102 else {
1103 EXPECT_EQ(0, graphNeighborIndices.sideReference[side - 1]);
1104 EXPECT_FALSE(graphNeighborIndices.has_any_connection(side));
1105 }
1106 }
1107 }
1108 }
1109
1111 std::shared_ptr<TextMeshGraph> m_graph;
1112 };
1113
1115} // namespace
int Ioss_MPI_Comm
Definition Ioss_CodeTypes.h:64
IOSS_NODISCARD constexpr T * Data(std::vector< T > &vec)
Definition Ioss_Utils.h:56
std::set< EntityId > EntityIdSet
Definition UnitTestIotmTextMeshFixture.h:62
#define ThrowRequireWithMsg(expr, message)
Definition UnitTestIotmTextMeshFixture.h:49
std::vector< EntityId > EntityIdVector
Definition UnitTestIotmTextMeshFixture.h:61
std::pair< EntityId, int > SideEntry
Definition UnitTestIotmTextMeshFixture.h:71
std::vector< SideEntry > SideVector
Definition UnitTestIotmTextMeshFixture.h:72
A homogeneous collection of other GroupingEntities.
Definition Ioss_Assembly.h:31
IOSS_NODISCARD const EntityContainer & get_members() const
Definition Ioss_Assembly.C:85
IOSS_NODISCARD EntityType get_member_type() const
Definition Ioss_Assembly.h:46
Definition Ioss_CommSet.h:27
An input or output Database.
Definition Ioss_DatabaseIO.h:63
virtual IOSS_NODISCARD std::string get_format() const =0
IOSS_NODISCARD 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:84
IOSS_NODISCARD int int_byte_size_api() const
Returns 4 or 8.
Definition Ioss_DatabaseIO.C:384
IOSS_NODISCARD const Ioss::ParallelUtils & util() const
Definition Ioss_DatabaseIO.h:623
A collection of elements having the same topology.
Definition Ioss_ElementBlock.h:29
Represents an element topology.
Definition Ioss_ElementTopology.h:68
static IOSS_NODISCARD ElementTopology * factory(const std::string &type, bool ok_to_fail=false)
Definition Ioss_ElementTopology.C:67
virtual IOSS_NODISCARD int number_nodes() const =0
IOSS_NODISCARD int number_boundaries() const
Definition Ioss_ElementTopology.C:229
IOSS_NODISCARD const ElementTopology * topology() const
Get the topology of the entities in the block.
Definition Ioss_EntityBlock.h:48
Holds metadata for bulk data associated with a GroupingEntity.
Definition Ioss_Field.h:25
IOSS_NODISCARD size_t raw_count() const
Definition Ioss_Field.h:171
IOSS_NODISCARD const std::string & get_name() const
Definition Ioss_Field.h:127
Base class for all 'grouping' entities. The following derived classes are typical:
Definition Ioss_GroupingEntity.h:67
IOSS_NODISCARD DatabaseIO * get_database() const
Definition Ioss_GroupingEntity.C:95
IOSS_NODISCARD Property get_property(const std::string &property_name) const
Get the Property from the property manager associated with the entity.
Definition Ioss_GroupingEntity.h:359
int64_t get_field_data(const std::string &field_name, void *data, size_t data_size) const
Read field data from the database file into memory using a pointer.
Definition Ioss_GroupingEntity.C:254
IOSS_NODISCARD Field get_field(const std::string &field_name) const
Get a field from the entity's field manager.
Definition Ioss_GroupingEntity.h:449
IOSS_NODISCARD bool field_exists(const std::string &field_name) const
Checks if a field with a given name exists in the entity's field manager.
Definition Ioss_GroupingEntity.h:438
IOSS_NODISCARD const Field & get_fieldref(const std::string &field_name) const
Get a reference to a field from the entity's field manager.
Definition Ioss_GroupingEntity.h:460
IOSS_NODISCARD const std::string & name() const
Get name of entity.
Definition Ioss_GroupingEntity.h:100
static IOSS_NODISCARD DatabaseIO * create(const std::string &type, const std::string &filename, DatabaseUsage db_usage, Ioss_MPI_Comm communicator=Ioss::ParallelUtils::comm_world(), const Ioss::PropertyManager &properties=Ioss::PropertyManager())
Create an IO database.
Definition Ioss_IOFactory.C:71
Initialization of the Ioss library.
Definition Ionit_Initializer.h:18
A collection of all nodes in the region.
Definition Ioss_NodeBlock.h:33
A collection of nodes.
Definition Ioss_NodeSet.h:29
Definition Ioss_ParallelUtils.h:32
IOSS_NODISCARD int parallel_size() const
Definition Ioss_ParallelUtils.C:206
IOSS_NODISCARD int parallel_rank() const
Definition Ioss_ParallelUtils.C:219
static IOSS_NODISCARD constexpr Ioss_MPI_Comm comm_world()
Definition Ioss_ParallelUtils.h:48
A collection of Ioss::Property objects.
Definition Ioss_PropertyManager.h:36
IOSS_NODISCARD int64_t get_int() const
Get the property value if it is of type INTEGER.
Definition Ioss_Property.C:253
A grouping entity that contains other grouping entities.
Definition Ioss_Region.h:93
IOSS_NODISCARD const SideSetContainer & get_sidesets() const
Get all the region's SideSet objects.
Definition Ioss_Region.C:1638
IOSS_NODISCARD CommSet * get_commset(const std::string &my_name) const
Get the comm set with the given name.
Definition Ioss_Region.C:2315
IOSS_NODISCARD Assembly * get_assembly(const std::string &my_name) const
Get the assembly with the given name.
Definition Ioss_Region.C:2045
IOSS_NODISCARD const ElementBlockContainer & get_element_blocks() const
Get all the region's ElementBlock objects.
Definition Ioss_Region.C:1626
IOSS_NODISCARD const NodeBlockContainer & get_node_blocks() const
Get all the region's NodeBlock objects.
Definition Ioss_Region.C:1608
IOSS_NODISCARD const NodeSetContainer & get_nodesets() const
Get all the region's NodeSet objects.
Definition Ioss_Region.C:1644
IOSS_NODISCARD const AssemblyContainer & get_assemblies() const
Get all the region's Assembly objects.
Definition Ioss_Region.C:1596
A collection of element sides having the same topology.
Definition Ioss_SideBlock.h:37
A collection of element sides.
Definition Ioss_SideSet.h:29
IOSS_NODISCARD const SideBlockContainer & get_side_blocks() const
Definition Ioss_SideSet.C:84
IOSS_NODISCARD SideBlock * get_side_block(const std::string &my_name) const
Definition Ioss_SideSet.C:96
static const char * name
Definition Ioss_Unknown.h:20
Definition Iotm_TextMeshTopologyMapping.h:947
void initialize_topology_map() override
Definition Iotm_TextMeshTopologyMapping.h:952
Definition Iotm_TextMeshTopologyMapping.h:33
const std::string name() const
Definition Iotm_TextMeshTopologyMapping.h:71
Definition Iotm_TextMeshDataTypes.h:214
Definition Iotm_TextMeshAdjacencyGraph.h:86
int64_t IndexType
Definition Iotm_TextMeshAdjacencyGraph.h:88
static constexpr int ANY_PROC
Definition Iotm_TextMeshAdjacencyGraph.h:90
Definition Iotm_TextMeshUtils.h:566
TextMeshData< EntityId, Topology > parse(const std::string &meshDescription)
Definition Iotm_TextMeshUtils.h:579
Topology topology(const std::string &textMeshName) const
Definition Iotm_TextMeshDataTypes.h:45
Definition UnitTestIotmTextMeshFixture.h:122
std::vector< std::string > get_unique_leaf_members(const std::string &name)
Definition UnitTestIotmTextMeshFixture.h:130
void traverse_tree(const Ioss::Assembly *assembly)
Definition UnitTestIotmTextMeshFixture.h:149
AssemblyTreeGraph(const AssemblyTreeGraph &)=delete
AssemblyTreeGraph(Ioss::Region *region)
Definition UnitTestIotmTextMeshFixture.h:127
std::unordered_map< const Ioss::Assembly *, bool > m_visitedAssemblies
Definition UnitTestIotmTextMeshFixture.h:177
std::vector< std::string > m_leafMembers
Definition UnitTestIotmTextMeshFixture.h:178
Ioss::Region * m_region
Definition UnitTestIotmTextMeshFixture.h:176
Definition UnitTestIotmTextMeshFixture.h:820
const Ioss::Region & region
Definition UnitTestIotmTextMeshFixture.h:968
const double * get_nodal_coordinates(const EntityId &nodeId) const
Definition UnitTestIotmTextMeshFixture.h:947
void verify()
Definition UnitTestIotmTextMeshFixture.h:830
const std::vector< double > & operator[](const EntityId nodeId) const
Definition UnitTestIotmTextMeshFixture.h:941
std::unordered_map< EntityId, std::vector< double > > m_nodalCoords
Definition UnitTestIotmTextMeshFixture.h:974
void fill_coordinates_from_ioss()
Definition UnitTestIotmTextMeshFixture.h:919
void fill_coordinate_map(const EntityIdVector &nodeIds, const std::vector< double > &coordinates)
Definition UnitTestIotmTextMeshFixture.h:909
CoordinateVerifier(const Ioss::Region &r, const EntityIdVector &ids, const std::vector< double > &coords)
Definition UnitTestIotmTextMeshFixture.h:822
std::string error_message(const EntityId &nodeId, unsigned coordIndex)
Definition UnitTestIotmTextMeshFixture.h:960
size_t field_data_from_ioss(Ioss::GroupingEntity *io_entity, const std::string &io_fld_name, std::vector< T > &io_field_data)
Definition UnitTestIotmTextMeshFixture.h:845
const unsigned spatialDim
Definition UnitTestIotmTextMeshFixture.h:970
void verify_num_nodes()
Definition UnitTestIotmTextMeshFixture.h:903
const std::vector< double > & goldCoordinates
Definition UnitTestIotmTextMeshFixture.h:973
size_t db_api_int_size() const
Definition UnitTestIotmTextMeshFixture.h:856
EntityIdVector get_node_ids_impl() const
Definition UnitTestIotmTextMeshFixture.h:858
bool is_valid_node_impl(EntityId nodeId) const
Definition UnitTestIotmTextMeshFixture.h:886
bool is_valid_node(EntityId nodeId) const
Definition UnitTestIotmTextMeshFixture.h:893
EntityIdVector get_node_ids() const
Definition UnitTestIotmTextMeshFixture.h:876
const EntityIdVector & goldNodeIds
Definition UnitTestIotmTextMeshFixture.h:972
void verify_nodal_coordinates(const EntityId &nodeId, const double *goldCoords, const double *nodalCoords)
Definition UnitTestIotmTextMeshFixture.h:952
Definition UnitTestIotmTextMeshFixture.h:182
SideVector get_element_side_pairs_from_sideset_impl(const Ioss::SideSet *ss) const
Definition UnitTestIotmTextMeshFixture.h:516
void verify_elements_on_block(const Ioss::ElementBlock *block, const std::set< EntityId > &goldIds)
Definition UnitTestIotmTextMeshFixture.h:749
EntityIdVector get_node_ids_from_nodeset_impl(const Ioss::NodeSet *ns) const
Definition UnitTestIotmTextMeshFixture.h:490
ElementInfo get_element_info_from_block_impl(EntityId elemId, const Ioss::ElementBlock *block) const
Definition UnitTestIotmTextMeshFixture.h:545
unsigned m_spatialDimension
Definition UnitTestIotmTextMeshFixture.h:977
EntityIdVector get_node_ids_from_nodeset(const Ioss::NodeSet *ns) const
Definition UnitTestIotmTextMeshFixture.h:505
SideVector get_element_side_pairs_from_sideset(const Ioss::SideSet *ss) const
Definition UnitTestIotmTextMeshFixture.h:534
std::pair< std::string, unsigned > PartNameId
Definition UnitTestIotmTextMeshFixture.h:184
std::string get_mesh_desc(const std::string &textMeshDesc)
Definition UnitTestIotmTextMeshFixture.h:231
void fill_mesh(const std::string &meshDesc)
Definition UnitTestIotmTextMeshFixture.h:216
Ioss::SideSet * get_sideset(const std::string &name) const
Definition UnitTestIotmTextMeshFixture.h:715
std::pair< std::string, std::string > get_database_type_and_filename(const std::string &meshDesc)
Definition UnitTestIotmTextMeshFixture.h:801
size_t get_node_sharing_count(int sharingProc) const
Definition UnitTestIotmTextMeshFixture.h:430
void verify_shared_nodes(const EntityIdVector &nodeIds, int sharingProc)
Definition UnitTestIotmTextMeshFixture.h:247
void verify_num_sidesets(size_t goldCount)
Definition UnitTestIotmTextMeshFixture.h:272
size_t get_element_count_impl() const
Definition UnitTestIotmTextMeshFixture.h:612
Ioss::DatabaseIO * m_database
Definition UnitTestIotmTextMeshFixture.h:979
bool node_is_shared_with_proc_impl(EntityId nodeId, int sharingProc) const
Definition UnitTestIotmTextMeshFixture.h:639
size_t get_element_count() const
Definition UnitTestIotmTextMeshFixture.h:628
void verify_num_elements(size_t goldCount)
Definition UnitTestIotmTextMeshFixture.h:256
void verify_sideset_subset(const Ioss::SideSet *sideset, const unsigned id, const std::vector< std::string > &subsetNames)
Definition UnitTestIotmTextMeshFixture.h:279
Ioss::NodeSet * get_nodeset(const std::string &name) const
Definition UnitTestIotmTextMeshFixture.h:699
void verify_num_nodesets(size_t goldCount)
Definition UnitTestIotmTextMeshFixture.h:333
void filename_substitution(std::string &filename)
Definition UnitTestIotmTextMeshFixture.h:784
void verify_block(Ioss::ElementBlock *block)
Definition UnitTestIotmTextMeshFixture.h:747
EntityIdVector get_element_ids_from_block_impl(const Ioss::ElementBlock *block) const
Definition UnitTestIotmTextMeshFixture.h:464
void create_database(const std::string &fileName, const std::string &meshType)
Definition UnitTestIotmTextMeshFixture.h:769
bool is_valid_element(const ElementInfo &info) const
Definition UnitTestIotmTextMeshFixture.h:671
int get_parallel_size()
Definition UnitTestIotmTextMeshFixture.h:212
IossTopologyMapping m_topologyMapping
Definition UnitTestIotmTextMeshFixture.h:981
TextMeshFixture(unsigned spatialDimension)
Definition UnitTestIotmTextMeshFixture.h:204
int get_parallel_rank()
Definition UnitTestIotmTextMeshFixture.h:214
void verify_single_sideset(const std::string &name, const unsigned id, const SideVector &goldElemSidePairs)
Definition UnitTestIotmTextMeshFixture.h:300
void verify_single_nodeset(const std::string &name, const unsigned id, const EntityIdVector &goldNodeIds)
Definition UnitTestIotmTextMeshFixture.h:340
~TextMeshFixture()
Definition UnitTestIotmTextMeshFixture.h:210
void verify_single_assembly(const std::string &name, const unsigned id, const std::vector< std::string > &goldMembers)
Definition UnitTestIotmTextMeshFixture.h:362
void create_ioss_region()
Definition UnitTestIotmTextMeshFixture.h:760
ElementInfo get_element_info(EntityId elemId) const
Definition UnitTestIotmTextMeshFixture.h:602
Ioss::ElementBlock * get_element_block(const std::string &blockName) const
Definition UnitTestIotmTextMeshFixture.h:683
void verify_single_element(EntityId elemId, const std::string &textMeshTopologyName, const EntityIdVector &nodeIds)
Definition UnitTestIotmTextMeshFixture.h:262
void verify_num_assemblies(size_t goldCount)
Definition UnitTestIotmTextMeshFixture.h:355
size_t get_node_sharing_count_impl(int sharingProc) const
Definition UnitTestIotmTextMeshFixture.h:440
Ioss::PropertyManager m_propertyManager
Definition UnitTestIotmTextMeshFixture.h:978
void setup_text_mesh(const std::string &textMeshDesc)
Definition UnitTestIotmTextMeshFixture.h:414
Ioss::Region * m_region
Definition UnitTestIotmTextMeshFixture.h:980
ElementInfo get_element_info_impl(EntityId elemId) const
Definition UnitTestIotmTextMeshFixture.h:578
void verify_coordinates(const EntityIdVector &goldNodeIds, const std::vector< double > &goldCoordinates)
Definition UnitTestIotmTextMeshFixture.h:407
Ioss_MPI_Comm get_comm() const
Definition UnitTestIotmTextMeshFixture.h:229
bool node_is_shared_with_proc(EntityId nodeId, int sharingProc) const
Definition UnitTestIotmTextMeshFixture.h:661
EntityIdVector get_element_ids_from_block(const Ioss::ElementBlock *block) const
Definition UnitTestIotmTextMeshFixture.h:479
Ioss::Assembly * get_assembly(const std::string &name) const
Definition UnitTestIotmTextMeshFixture.h:731
std::string get_topology_name(const std::string &textMeshTopologyName)
Definition UnitTestIotmTextMeshFixture.h:419
void verify_part_ids(const std::vector< PartNameId > &golds)
Definition UnitTestIotmTextMeshFixture.h:391
size_t db_api_int_size() const
Definition UnitTestIotmTextMeshFixture.h:424
void verify_single_sideset(const std::string &name, const unsigned id, const std::vector< std::string > &subsets, const SideVector &goldElemSidePairs)
Definition UnitTestIotmTextMeshFixture.h:306
std::string get_mesh_desc(const std::string &textMeshDesc, unsigned dimension)
Definition UnitTestIotmTextMeshFixture.h:238
void verify_part_membership(const std::vector< PartInfo > golds)
Definition UnitTestIotmTextMeshFixture.h:381
void verify_nodes_on_element(const ElementInfo &info, const EntityIdVector &goldNodeIds)
Definition UnitTestIotmTextMeshFixture.h:402
Definition UnitTestIotmTextMeshFixture.h:1001
TestTextMesh1d()
Definition UnitTestIotmTextMeshFixture.h:1003
Definition UnitTestIotmTextMeshFixture.h:995
TestTextMesh2d()
Definition UnitTestIotmTextMeshFixture.h:997
EntityId get_element_id(const size_t elemIndex) const override
Definition UnitTestIotmTextMeshFixture.h:1056
TextMeshGraph(const TextMeshData &data)
Definition UnitTestIotmTextMeshFixture.h:1014
int get_element_proc(const size_t elemIndex) const override
Definition UnitTestIotmTextMeshFixture.h:1018
bool element_has_any_node_on_proc(const size_t elemIndex, int proc) const override
Definition UnitTestIotmTextMeshFixture.h:1024
const std::vector< EntityId > & get_element_node_ids(const size_t elemIndex) const override
Definition UnitTestIotmTextMeshFixture.h:1044
const std::string & get_element_block_name(const size_t elemIndex) const override
Definition UnitTestIotmTextMeshFixture.h:1038
const Topology & get_element_topology(const size_t elemIndex) const override
Definition UnitTestIotmTextMeshFixture.h:1050
const TextMeshData & m_data
Definition UnitTestIotmTextMeshFixture.h:1063
size_t get_num_elements() const override
Definition UnitTestIotmTextMeshFixture.h:1016
TextMeshData m_data
Definition UnitTestIotmTextMeshFixture.h:1110
void verify_side_adjacency(const std::vector< Adjacency > &goldNeighbors)
Definition UnitTestIotmTextMeshFixture.h:1078
void dump_graph(std::ostream &out=std::cout)
Definition UnitTestIotmTextMeshFixture.h:1066
void setup_text_mesh_graph(const std::string &meshDesc, const std::vector< std::string > &selectedBlocks={}, int proc=SideAdjacencyGraph::ANY_PROC)
Definition UnitTestIotmTextMeshFixture.h:1068
std::shared_ptr< TextMeshGraph > m_graph
Definition UnitTestIotmTextMeshFixture.h:1111
TestTextMeshGraph()
Definition UnitTestIotmTextMeshFixture.h:1009
Definition UnitTestIotmTextMeshFixture.h:989
TestTextMesh()
Definition UnitTestIotmTextMeshFixture.h:991
std::vector< ElementBlock * > ElementBlockContainer
Definition Ioss_Region.h:69
DatabaseUsage
Specifies how an Ioss::DatabaseIO object will be used.
Definition Ioss_DBUsage.h:13
@ READ_MODEL
Definition Ioss_DBUsage.h:20
std::vector< NodeSet * > NodeSetContainer
Definition Ioss_Region.h:71
std::vector< SideSet * > SideSetContainer
Definition Ioss_Region.h:76
std::vector< Ioss::Assembly * > AssemblyContainer
Definition Ioss_Region.h:63
std::vector< NodeBlock * > NodeBlockContainer
Definition Ioss_Region.h:66
EntityType
The particular type of GroupingEntity.
Definition Ioss_EntityType.h:12
@ ASSEMBLY
Definition Ioss_EntityType.h:28
SplitType
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 UnitTestIotmTextMeshFixture.h:76
NeighborVector get_full_neighbor_vector(const SimpleNeighborVector &simpleNeighborVector)
Definition UnitTestIotmTextMeshFixture.h:93
std::vector< std::pair< int, SideAdjacencyGraph::IndexType > > NeighborVector
Definition UnitTestIotmTextMeshFixture.h:77
std::vector< SideAdjacencyGraph::IndexType > SimpleNeighborVector
Definition UnitTestIotmTextMeshFixture.h:78
size_t elemIndex
Definition UnitTestIotmTextMeshFixture.h:80
Adjacency(size_t elemIndex_, const NeighborVector &neighborIndices_)
Definition UnitTestIotmTextMeshFixture.h:83
NeighborVector neighborIndices
Definition UnitTestIotmTextMeshFixture.h:81
Adjacency(size_t elemIndex_, const SimpleNeighborVector &neighborIndices_)
Definition UnitTestIotmTextMeshFixture.h:88
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_TextMeshNodeset.h:41
Definition Iotm_TextMeshSidesetSplitter.h:39
Definition Iotm_TextMeshSidesetSplitter.h:64
Definition Iotm_TextMeshDataTypes.h:315
std::vector< ElementData< EntityId, Topology > > elementDataVec
Definition Iotm_TextMeshDataTypes.h:317
const std::set< int > & procs_for_node(const EntityId nodeId) const
Definition Iotm_TextMeshDataTypes.h:348
Definition UnitTestIotmTextMeshFixture.h:187
EntityIdVector connectivity
Definition UnitTestIotmTextMeshFixture.h:189
const Ioss::ElementTopology * topology
Definition UnitTestIotmTextMeshFixture.h:188
ElementInfo(const Ioss::ElementTopology *topology_, const EntityIdVector &connectivity_)
Definition UnitTestIotmTextMeshFixture.h:192
ElementInfo()
Definition UnitTestIotmTextMeshFixture.h:191
Definition UnitTestIotmTextMeshFixture.h:199
EntityIdSet ids
Definition UnitTestIotmTextMeshFixture.h:201
std::string blockName
Definition UnitTestIotmTextMeshFixture.h:200
Definition UnitTestIotmTextMeshFixture.h:106
bool operator()(const SideEntry &lhs, const SideEntry &rhs) const
Definition UnitTestIotmTextMeshFixture.h:107