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) {
482 return get_element_ids_from_block_impl<int>(block);
483 }
484 else {
485 return get_element_ids_from_block_impl<int64_t>(block);
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) {
508 return get_node_ids_from_nodeset_impl<int>(ns);
509 }
510 else {
511 return get_node_ids_from_nodeset_impl<int64_t>(ns);
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
535 {
536 if (db_api_int_size() == 4) {
537 return get_element_side_pairs_from_sideset_impl<int>(ss);
538 }
539 else {
540 return get_element_side_pairs_from_sideset_impl<int64_t>(ss);
541 }
542 }
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) {
589 ElementInfo info = get_element_info_from_block_impl<INT>(elemId, block);
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) {
631 return get_element_count_impl<int>();
632 }
633 else {
634 return get_element_count_impl<int64_t>();
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 {
833
834 for (size_t nodeIndex = 0; nodeIndex < goldNodeIds.size(); nodeIndex++) {
835 EntityId nodeId = goldNodeIds[nodeIndex];
836 EXPECT_TRUE(is_valid_node(nodeId));
837
838 const double *nodalCoords = get_nodal_coordinates(nodeId);
839 const double *goldCoords = &goldCoordinates[nodeIndex * spatialDim];
840
841 verify_nodal_coordinates(nodeId, goldCoords, nodalCoords);
842 }
843 }
844
845 private:
846 template <typename T>
847 size_t field_data_from_ioss(Ioss::GroupingEntity *io_entity, const std::string &io_fld_name,
848 std::vector<T> &io_field_data)
849 {
850 size_t io_entity_count = 0;
851 if (io_entity->field_exists(io_fld_name)) {
852 const Ioss::Field &io_field = io_entity->get_fieldref(io_fld_name);
853 io_entity_count = io_entity->get_field_data(io_field.get_name(), io_field_data);
854 }
855 return io_entity_count;
856 }
857
858 size_t db_api_int_size() const { return region.get_database()->int_byte_size_api(); }
859
860 template <typename INT> EntityIdVector get_node_ids_impl() const
861 {
862 const Ioss::NodeBlockContainer &node_blocks = region.get_node_blocks();
863 assert(node_blocks.size() == 1);
864
865 Ioss::NodeBlock *nb = node_blocks[0];
866
867 std::vector<INT> ids;
868 nb->get_field_data("ids", ids);
869
870 EntityIdVector nodeIds;
871 for (INT id : ids) {
872 nodeIds.push_back(static_cast<EntityId>(id));
873 }
874
875 return nodeIds;
876 }
877
879 {
880 if (db_api_int_size() == 4) {
881 return get_node_ids_impl<int>();
882 }
883 else {
884 return get_node_ids_impl<int64_t>();
885 }
886 }
887
888 template <typename INT> bool is_valid_node_impl(EntityId nodeId) const
889 {
890 EntityIdVector ids = get_node_ids_impl<INT>();
891 auto iter = std::find(ids.begin(), ids.end(), INT(nodeId));
892 return iter != ids.end();
893 }
894
895 bool is_valid_node(EntityId nodeId) const
896 {
897 if (db_api_int_size() == 4) {
898 return is_valid_node_impl<int>(nodeId);
899 }
900 else {
901 return is_valid_node_impl<int64_t>(nodeId);
902 }
903 }
904
906 {
908 EXPECT_EQ(goldNodeIds.size(), ids.size());
909 }
910
912 const std::vector<double> &coordinates)
913 {
914 std::vector<double>::const_iterator coordIter = coordinates.begin();
915 for (const EntityId &nodeId : nodeIds) {
916 m_nodalCoords[nodeId] = std::vector<double>(coordIter, coordIter + spatialDim);
917 coordIter += spatialDim;
918 }
919 }
920
922 {
923 std::vector<double> iossCoordinates;
924
925 const Ioss::NodeBlockContainer &node_blocks = region.get_node_blocks();
926 assert(node_blocks.size() == 1);
927
928 Ioss::NodeBlock *nb = node_blocks[0];
929
930 size_t node_count = nb->get_property("entity_count").get_int();
931
932 EntityIdVector nodeIds = get_node_ids();
933
934 size_t numIossNodes =
935 field_data_from_ioss<double>(nb, "mesh_model_coordinates", iossCoordinates);
936 ThrowRequireWithMsg(node_count == numIossNodes, "Node count mismatch");
937 ThrowRequireWithMsg(iossCoordinates.size() == numIossNodes * spatialDim,
938 "Invalid coordinate data size");
939
940 fill_coordinate_map(nodeIds, iossCoordinates);
941 }
942
943 const std::vector<double> &operator[](const EntityId nodeId) const
944 {
945 auto it = m_nodalCoords.find(nodeId);
946 return it->second;
947 }
948
949 const double *get_nodal_coordinates(const EntityId &nodeId) const
950 {
951 return Data((*this)[nodeId]);
952 }
953
954 void verify_nodal_coordinates(const EntityId &nodeId, const double *goldCoords,
955 const double *nodalCoords)
956 {
957 for (unsigned i = 0; i < spatialDim; i++) {
958 EXPECT_NEAR(goldCoords[i], nodalCoords[i], 1.0e-9) << error_message(nodeId, i);
959 }
960 }
961
962 std::string error_message(const EntityId &nodeId, unsigned coordIndex)
963 {
964 std::stringstream message;
965 message << "Proc " << region.get_database()->util().parallel_rank() << ", Node ID "
966 << nodeId << ", coord index " << coordIndex;
967 return message.str();
968 }
969
971
972 const unsigned spatialDim;
973
975 const std::vector<double> &goldCoordinates;
976 std::unordered_map<EntityId, std::vector<double>> m_nodalCoords;
977 };
978
979 unsigned m_spatialDimension = 3;
984 };
985
986 } // namespace unit_test
987} // namespace Iotm
988
989namespace {
991 {
992 protected:
993 TestTextMesh() : TextMeshFixture(3) {}
994 };
995
997 {
998 protected:
999 TestTextMesh2d() : TextMeshFixture(2) {}
1000 };
1001
1003 {
1004 protected:
1005 TestTextMesh1d() : TextMeshFixture(1) {}
1006 };
1007
1009 {
1010 protected:
1011 TestTextMeshGraph() : TextMeshFixture(3) {}
1012
1014 {
1015 public:
1016 TextMeshGraph(const TextMeshData &data) : m_data(data) {}
1017
1018 size_t get_num_elements() const override { return m_data.elementDataVec.size(); }
1019
1020 int get_element_proc(const size_t elemIndex) const override
1021 {
1022 const ElementData &elemData = m_data.elementDataVec[elemIndex];
1023 return elemData.proc;
1024 }
1025
1026 bool element_has_any_node_on_proc(const size_t elemIndex, int proc) const override
1027 {
1028 const ElementData &elemData = m_data.elementDataVec[elemIndex];
1029
1030 for (const EntityId &nodeId : elemData.nodeIds) {
1031 const std::set<int> &procsForNode = m_data.procs_for_node(nodeId);
1032 if (procsForNode.count(proc) > 0) {
1033 return true;
1034 }
1035 }
1036
1037 return false;
1038 }
1039
1040 const std::string &get_element_block_name(const size_t elemIndex) const override
1041 {
1042 const ElementData &elemData = m_data.elementDataVec[elemIndex];
1043 return elemData.partName;
1044 }
1045
1046 const std::vector<EntityId> &get_element_node_ids(const size_t elemIndex) const override
1047 {
1048 const ElementData &elemData = m_data.elementDataVec[elemIndex];
1049 return elemData.nodeIds;
1050 }
1051
1052 const Topology &get_element_topology(const size_t elemIndex) const override
1053 {
1054 const ElementData &elemData = m_data.elementDataVec[elemIndex];
1055 return elemData.topology;
1056 }
1057
1058 EntityId get_element_id(const size_t elemIndex) const override
1059 {
1060 const ElementData &elemData = m_data.elementDataVec[elemIndex];
1061 return elemData.identifier;
1062 }
1063
1064 private:
1066 };
1067
1068 void dump_graph(std::ostream &out = std::cout) { m_graph->dump(m_data.elementDataVec, out); }
1069
1070 void setup_text_mesh_graph(const std::string &meshDesc,
1071 const std::vector<std::string> &selectedBlocks = {},
1073 {
1074 TextMeshParser parser;
1075 m_data = parser.parse(meshDesc);
1076 m_graph = std::make_shared<TextMeshGraph>(m_data);
1077 m_graph->create_graph(selectedBlocks, proc);
1078 }
1079
1080 void verify_side_adjacency(const std::vector<Adjacency> &goldNeighbors)
1081 {
1082 EXPECT_EQ(m_graph->size(), goldNeighbors.size());
1083 for (size_t i = 0; i < goldNeighbors.size(); ++i) {
1084 const auto &graphNeighborIndices = (*m_graph)[goldNeighbors[i].elemIndex];
1085 const auto &goldNeighborIndices = goldNeighbors[i].neighborIndices;
1086
1087 unsigned numActualGoldConnections = 0;
1088 for (const auto &entry : goldNeighborIndices) {
1089 if (entry.second >= 0) {
1090 numActualGoldConnections++;
1091 }
1092 }
1093
1094 EXPECT_EQ(numActualGoldConnections, graphNeighborIndices.connections.size());
1095
1096 for (const auto &entry : goldNeighborIndices) {
1097 int side = entry.first + 1;
1098 SideAdjacencyGraph::IndexType neighborElemIndex = entry.second;
1099
1100 if (neighborElemIndex >= 0) {
1101 EXPECT_LT(0, graphNeighborIndices.sideReference[side - 1]);
1102 EXPECT_TRUE(graphNeighborIndices.has_any_connection(side, neighborElemIndex));
1103 }
1104 else {
1105 EXPECT_EQ(0, graphNeighborIndices.sideReference[side - 1]);
1106 EXPECT_FALSE(graphNeighborIndices.has_any_connection(side));
1107 }
1108 }
1109 }
1110 }
1111
1113 std::shared_ptr<TextMeshGraph> m_graph;
1114 };
1115
1117} // namespace
int Ioss_MPI_Comm
Definition Ioss_CodeTypes.h:63
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
int64_t EntityId
Definition UnitTestIotmTextMeshFixture.h:60
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:382
IOSS_NODISCARD const Ioss::ParallelUtils & util() const
Definition Ioss_DatabaseIO.h:565
A collection of elements having the same topology.
Definition Ioss_ElementBlock.h:29
Represents an element topology.
Definition Ioss_ElementTopology.h:69
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:164
IOSS_NODISCARD const std::string & get_name() const
Definition Ioss_Field.h:124
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:360
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:450
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:439
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:461
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:31
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:47
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:90
IOSS_NODISCARD const SideSetContainer & get_sidesets() const
Get all the region's SideSet objects.
Definition Ioss_Region.C:1544
IOSS_NODISCARD CommSet * get_commset(const std::string &my_name) const
Get the comm set with the given name.
Definition Ioss_Region.C:2221
IOSS_NODISCARD Assembly * get_assembly(const std::string &my_name) const
Get the assembly with the given name.
Definition Ioss_Region.C:1951
IOSS_NODISCARD const ElementBlockContainer & get_element_blocks() const
Get all the region's ElementBlock objects.
Definition Ioss_Region.C:1532
IOSS_NODISCARD const NodeBlockContainer & get_node_blocks() const
Get all the region's NodeBlock objects.
Definition Ioss_Region.C:1514
IOSS_NODISCARD const NodeSetContainer & get_nodesets() const
Get all the region's NodeSet objects.
Definition Ioss_Region.C:1550
IOSS_NODISCARD const AssemblyContainer & get_assemblies() const
Get all the region's Assembly objects.
Definition Ioss_Region.C:1502
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:22
Definition Iotm_TextMeshTopologyMapping.h:941
void initialize_topology_map() override
Definition Iotm_TextMeshTopologyMapping.h:946
Definition Iotm_TextMeshTopologyMapping.h:34
const std::string name() const
Definition Iotm_TextMeshTopologyMapping.h:72
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:970
const double * get_nodal_coordinates(const EntityId &nodeId) const
Definition UnitTestIotmTextMeshFixture.h:949
void verify()
Definition UnitTestIotmTextMeshFixture.h:830
const std::vector< double > & operator[](const EntityId nodeId) const
Definition UnitTestIotmTextMeshFixture.h:943
std::unordered_map< EntityId, std::vector< double > > m_nodalCoords
Definition UnitTestIotmTextMeshFixture.h:976
void fill_coordinates_from_ioss()
Definition UnitTestIotmTextMeshFixture.h:921
void fill_coordinate_map(const EntityIdVector &nodeIds, const std::vector< double > &coordinates)
Definition UnitTestIotmTextMeshFixture.h:911
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:962
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:847
const unsigned spatialDim
Definition UnitTestIotmTextMeshFixture.h:972
void verify_num_nodes()
Definition UnitTestIotmTextMeshFixture.h:905
const std::vector< double > & goldCoordinates
Definition UnitTestIotmTextMeshFixture.h:975
size_t db_api_int_size() const
Definition UnitTestIotmTextMeshFixture.h:858
EntityIdVector get_node_ids_impl() const
Definition UnitTestIotmTextMeshFixture.h:860
bool is_valid_node_impl(EntityId nodeId) const
Definition UnitTestIotmTextMeshFixture.h:888
bool is_valid_node(EntityId nodeId) const
Definition UnitTestIotmTextMeshFixture.h:895
EntityIdVector get_node_ids() const
Definition UnitTestIotmTextMeshFixture.h:878
const EntityIdVector & goldNodeIds
Definition UnitTestIotmTextMeshFixture.h:974
void verify_nodal_coordinates(const EntityId &nodeId, const double *goldCoords, const double *nodalCoords)
Definition UnitTestIotmTextMeshFixture.h:954
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:979
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:981
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:983
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:980
void setup_text_mesh(const std::string &textMeshDesc)
Definition UnitTestIotmTextMeshFixture.h:414
Ioss::Region * m_region
Definition UnitTestIotmTextMeshFixture.h:982
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:1003
TestTextMesh1d()
Definition UnitTestIotmTextMeshFixture.h:1005
Definition UnitTestIotmTextMeshFixture.h:997
TestTextMesh2d()
Definition UnitTestIotmTextMeshFixture.h:999
EntityId get_element_id(const size_t elemIndex) const override
Definition UnitTestIotmTextMeshFixture.h:1058
TextMeshGraph(const TextMeshData &data)
Definition UnitTestIotmTextMeshFixture.h:1016
int get_element_proc(const size_t elemIndex) const override
Definition UnitTestIotmTextMeshFixture.h:1020
bool element_has_any_node_on_proc(const size_t elemIndex, int proc) const override
Definition UnitTestIotmTextMeshFixture.h:1026
const std::vector< EntityId > & get_element_node_ids(const size_t elemIndex) const override
Definition UnitTestIotmTextMeshFixture.h:1046
const std::string & get_element_block_name(const size_t elemIndex) const override
Definition UnitTestIotmTextMeshFixture.h:1040
const Topology & get_element_topology(const size_t elemIndex) const override
Definition UnitTestIotmTextMeshFixture.h:1052
const TextMeshData & m_data
Definition UnitTestIotmTextMeshFixture.h:1065
size_t get_num_elements() const override
Definition UnitTestIotmTextMeshFixture.h:1018
TextMeshData m_data
Definition UnitTestIotmTextMeshFixture.h:1112
void verify_side_adjacency(const std::vector< Adjacency > &goldNeighbors)
Definition UnitTestIotmTextMeshFixture.h:1080
void dump_graph(std::ostream &out=std::cout)
Definition UnitTestIotmTextMeshFixture.h:1068
void setup_text_mesh_graph(const std::string &meshDesc, const std::vector< std::string > &selectedBlocks={}, int proc=SideAdjacencyGraph::ANY_PROC)
Definition UnitTestIotmTextMeshFixture.h:1070
std::shared_ptr< TextMeshGraph > m_graph
Definition UnitTestIotmTextMeshFixture.h:1113
TestTextMeshGraph()
Definition UnitTestIotmTextMeshFixture.h:1011
Definition UnitTestIotmTextMeshFixture.h:991
TestTextMesh()
Definition UnitTestIotmTextMeshFixture.h:993
std::vector< ElementBlock * > ElementBlockContainer
Definition Ioss_Region.h:66
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:68
std::vector< SideSet * > SideSetContainer
Definition Ioss_Region.h:73
std::vector< Ioss::Assembly * > AssemblyContainer
Definition Ioss_Region.h:60
std::vector< NodeBlock * > NodeBlockContainer
Definition Ioss_Region.h:63
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 generated 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_TextMeshSideset.h:44
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