Skip to content

Commit b3a62f2

Browse files
committed
test: Non uniform hierarchical cmaps
1 parent c687fe4 commit b3a62f2

1 file changed

Lines changed: 113 additions & 0 deletions

File tree

test/HierarchicalTPCMap_test.cpp

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,83 @@ TEST_CASE( "Simple hierarchical cmap 2" )
8787
CHECK( cmap.unrefinedAncestorDartOfCell( Face( 66 ) ).second.id() == 6 );
8888
}
8989

90+
TEST_CASE( "2d non-uniform hierarchical cmap" )
91+
{
92+
const auto topo1d_1 = std::make_shared<const CombinatorialMap1d>( 1 );
93+
const auto topo1d_2 = std::make_shared<const CombinatorialMap1d>( 2 );
94+
const auto topo1d_3 = std::make_shared<const CombinatorialMap1d>( 3 );
95+
const auto topo1d_4 = std::make_shared<const CombinatorialMap1d>( 4 );
96+
const auto tp_topo_1 = std::make_shared<const TPCombinatorialMap>( topo1d_1, topo1d_2 );
97+
const auto tp_topo_2 = std::make_shared<const TPCombinatorialMap>( topo1d_3, topo1d_4 );
98+
99+
const HierarchicalTPCombinatorialMap cmap( { tp_topo_1, tp_topo_2 }, {
100+
{ Face( Dart( 4 ) ) },
101+
{ Face( Dart( 0 ) ), Face( Dart( 4 ) ), Face( Dart( 8 ) ), Face( Dart( 12 ) ), Face( 16 ), Face( 20 ) }
102+
} );
103+
104+
CHECK( cellCount( cmap, 2 ) == 7 );
105+
CHECK( cellCount( cmap, 1 ) == 20 );
106+
CHECK( cellCount( cmap, 0 ) == 14 );
107+
108+
size_t n_darts = 0;
109+
iterateDartsWhile( cmap, [&]( const Dart& d ){
110+
const auto maybe_phi = phi( cmap, {1,-1}, d );
111+
CHECK( maybe_phi.has_value() );
112+
if( maybe_phi )
113+
{
114+
CHECK( maybe_phi.value() == d );
115+
}
116+
n_darts++;
117+
return true;
118+
} );
119+
120+
CHECK( n_darts == 30 );
121+
122+
CHECK( cmap.unrefinedAncestorDartOfCell( Face( 22 ) ) == cmap.dartRanges().toLocalDart( Dart( 22 ) ) );
123+
CHECK( cmap.unrefinedAncestorDartOfCell( Face( 5 ) ) == cmap.dartRanges().toLocalDart( Dart( 5 ) ) );
124+
CHECK( cmap.unrefinedAncestorDartOfCell( Face( 32 ) ).second.id() == 4 );
125+
CHECK( cmap.unrefinedAncestorDartOfCell( Face( 36 ) ).second.id() == 4 );
126+
CHECK( cmap.unrefinedAncestorDartOfCell( Face( 40 ) ).second.id() == 4 );
127+
}
128+
129+
TEST_CASE( "2d refine in only one direction hierarchical cmap" )
130+
{
131+
const auto topo1d_1 = std::make_shared<const CombinatorialMap1d>( 1 );
132+
const auto topo1d_2 = std::make_shared<const CombinatorialMap1d>( 2 );
133+
const auto topo1d_3 = std::make_shared<const CombinatorialMap1d>( 3 );
134+
const auto tp_topo_1 = std::make_shared<const TPCombinatorialMap>( topo1d_1, topo1d_2 );
135+
const auto tp_topo_2 = std::make_shared<const TPCombinatorialMap>( topo1d_3, topo1d_2 );
136+
137+
const HierarchicalTPCombinatorialMap cmap( { tp_topo_1, tp_topo_2 }, {
138+
{ Face( Dart( 4 ) ) },
139+
{ Face( Dart( 0 ) ), Face( Dart( 4 ) ), Face( Dart( 8 ) ) }
140+
} );
141+
142+
CHECK( cellCount( cmap, 2 ) == 4 );
143+
CHECK( cellCount( cmap, 1 ) == 13 );
144+
CHECK( cellCount( cmap, 0 ) == 10 );
145+
146+
size_t n_darts = 0;
147+
iterateDartsWhile( cmap, [&]( const Dart& d ){
148+
const auto maybe_phi = phi( cmap, {1,-1}, d );
149+
CHECK( maybe_phi.has_value() );
150+
if( maybe_phi )
151+
{
152+
CHECK( maybe_phi.value() == d );
153+
}
154+
n_darts++;
155+
return true;
156+
} );
157+
158+
CHECK( n_darts == 18 );
159+
160+
CHECK( cmap.unrefinedAncestorDartOfCell( Face( 10 ) ) == cmap.dartRanges().toLocalDart( Dart( 10 ) ) );
161+
CHECK( cmap.unrefinedAncestorDartOfCell( Face( 5 ) ) == cmap.dartRanges().toLocalDart( Dart( 5 ) ) );
162+
CHECK( cmap.unrefinedAncestorDartOfCell( Face( 20 ) ).second.id() == 4 );
163+
CHECK( cmap.unrefinedAncestorDartOfCell( Face( 24 ) ).second.id() == 4 );
164+
CHECK( cmap.unrefinedAncestorDartOfCell( Face( 28 ) ).second.id() == 4 );
165+
}
166+
90167
TEST_CASE( "Simplest 3d hierarchical cmap" )
91168
{
92169
const auto topo1d_1 = std::make_shared<const CombinatorialMap1d>( 1 );
@@ -122,6 +199,42 @@ TEST_CASE( "Simplest 3d hierarchical cmap" )
122199
CHECK( n_darts == 8 * 24 + 40 );
123200
}
124201

202+
TEST_CASE( "Non-uniform 3d hierarchical cmap" )
203+
{
204+
const auto topo1d_1 = std::make_shared<const CombinatorialMap1d>( 1 );
205+
const auto topo1d_2 = std::make_shared<const CombinatorialMap1d>( 2 );
206+
const auto topo1d_3 = std::make_shared<const CombinatorialMap1d>( 3 );
207+
const auto topo1d_4 = std::make_shared<const CombinatorialMap1d>( 4 );
208+
const auto tp2d_topo_1 = std::make_shared<const TPCombinatorialMap>( topo1d_1, topo1d_1 );
209+
const auto tp2d_topo_2 = std::make_shared<const TPCombinatorialMap>( topo1d_3, topo1d_1 );
210+
const auto tp3d_topo_1 = std::make_shared<const TPCombinatorialMap>( tp2d_topo_1, topo1d_2 );
211+
const auto tp3d_topo_2 = std::make_shared<const TPCombinatorialMap>( tp2d_topo_2, topo1d_4 );
212+
213+
const HierarchicalTPCombinatorialMap cmap( { tp3d_topo_1, tp3d_topo_2 }, {
214+
{ Volume( 24 ) },
215+
{ Volume( 0 ), Volume( 24 ), Volume( 48 ), Volume( 72 ), Volume( 96 ), Volume( 120 ) }
216+
} );
217+
218+
CHECK( cellCount( cmap, 3 ) == 7 );
219+
CHECK( cellCount( cmap, 2 ) == 34 );
220+
CHECK( cellCount( cmap, 1 ) == 54 );
221+
CHECK( cellCount( cmap, 0 ) == 28 );
222+
223+
size_t n_darts = 0;
224+
iterateDartsWhile( cmap, [&]( const Dart& d ){
225+
const auto maybe_phi = phi( cmap, {1,-1}, d );
226+
CHECK( maybe_phi.has_value() );
227+
if( maybe_phi )
228+
{
229+
CHECK( maybe_phi.value() == d );
230+
}
231+
n_darts++;
232+
return true;
233+
} );
234+
235+
CHECK( n_darts == 6 * 24 + 36 );
236+
}
237+
125238
TEST_CASE( "3d hierarchical cmap bug" )
126239
{
127240
const auto topo1d_1 = std::make_shared<const CombinatorialMap1d>( 1 );

0 commit comments

Comments
 (0)