Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tnl-dev
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
TNL
tnl-dev
Commits
5bbaf0e7
There was an error fetching the commit references. Please try again later.
Commit
5bbaf0e7
authored
8 years ago
by
Jakub Klinkovský
Browse files
Options
Downloads
Patches
Plain Diff
Fixed MeshEntityTest and MultimapTest
parent
25599f7f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/UnitTests/Meshes/MeshEntityTest.h
+59
-27
59 additions, 27 deletions
src/UnitTests/Meshes/MeshEntityTest.h
src/UnitTests/Meshes/MultimapTest.cpp
+50
-5
50 additions, 5 deletions
src/UnitTests/Meshes/MultimapTest.cpp
with
109 additions
and
32 deletions
src/UnitTests/Meshes/MeshEntityTest.h
+
59
−
27
View file @
5bbaf0e7
...
...
@@ -49,6 +49,9 @@ class TestTetrahedronMeshConfig : public MeshConfigBase< MeshTetrahedronTopology
}
};
template
<
typename
MeshConfig
,
typename
EntityTopology
,
int
Dimensions
>
using
StorageNetwork
=
typename
MeshSuperentityTraits
<
MeshConfig
,
EntityTopology
,
Dimensions
>::
StorageNetworkType
;
// stupid wrapper around MeshEntity to expose protected members needed for tests
template
<
typename
MeshConfig
,
typename
EntityTopology
>
class
TestMeshEntity
...
...
@@ -58,11 +61,18 @@ class TestMeshEntity
public:
template
<
int
Subdimensions
>
void
setSubentityIndex
(
const
typename
BaseType
::
LocalIndexType
localIndex
,
const
typename
BaseType
::
GlobalIndexType
globalIndex
)
void
setSubentityIndex
(
const
typename
BaseType
::
LocalIndexType
&
localIndex
,
const
typename
BaseType
::
GlobalIndexType
&
globalIndex
)
{
BaseType
::
template
setSubentityIndex
<
Subdimensions
>(
localIndex
,
globalIndex
);
}
template
<
int
Superdimensions
>
void
setSuperentityIndex
(
const
typename
BaseType
::
LocalIndexType
&
localIndex
,
const
typename
BaseType
::
GlobalIndexType
&
globalIndex
)
{
BaseType
::
template
setSuperentityIndex
<
Superdimensions
>(
localIndex
,
globalIndex
);
}
};
using
RealType
=
double
;
...
...
@@ -428,38 +438,60 @@ TEST( MeshEntityTest, TwoTrianglesMeshEntityTest )
ASSERT_TRUE
(
triangleEntities
[
1
].
template
getSubentityIndex
<
1
>(
1
)
==
3
);
ASSERT_TRUE
(
triangleEntities
[
1
].
template
getSubentityIndex
<
1
>(
2
)
==
4
);
// vertexEntities[ 0 ].template setNumberOfSuperentities< 1 >( 2 );
// vertexEntities[ 0 ].template setSuperentityIndex< 1 >( 0, 2 );
// vertexEntities[ 0 ].template setSuperentityIndex< 1 >( 1, 1 );
// vertexEntities[ 1 ].template setNumberOfSuperentities< 1 >( 3 );
// vertexEntities[ 1 ].template setSuperentityIndex< 1 >( 0, 0 );
// vertexEntities[ 1 ].template setSuperentityIndex< 1 >( 1, 2 );
// vertexEntities[ 1 ].template setSuperentityIndex< 1 >( 2, 4 );
/*
* Tests for the superentities layer.
*/
StorageNetwork
<
TestTriangleMeshConfig
,
MeshVertexTopology
,
1
>
vertexEdgeSuperentities
;
vertexEdgeSuperentities
.
setRanges
(
4
,
3
);
vertexEdgeSuperentities
.
allocate
(
3
);
vertexEntities
[
0
].
template
bindSuperentitiesStorageNetwork
<
1
>(
vertexEdgeSuperentities
.
getValues
(
0
)
);
vertexEntities
[
0
].
template
setNumberOfSuperentities
<
1
>(
2
);
vertexEntities
[
0
].
template
setSuperentityIndex
<
1
>(
0
,
2
);
vertexEntities
[
0
].
template
setSuperentityIndex
<
1
>(
1
,
1
);
ASSERT_EQ
(
vertexEntities
[
0
].
template
getNumberOfSuperentities
<
1
>(),
2
);
ASSERT_EQ
(
vertexEntities
[
0
].
template
getSuperentityIndex
<
1
>(
0
),
2
);
ASSERT_EQ
(
vertexEntities
[
0
].
template
getSuperentityIndex
<
1
>(
1
),
1
);
vertexEntities
[
1
].
template
bindSuperentitiesStorageNetwork
<
1
>(
vertexEdgeSuperentities
.
getValues
(
1
)
);
vertexEntities
[
1
].
template
setNumberOfSuperentities
<
1
>(
3
);
vertexEntities
[
1
].
template
setSuperentityIndex
<
1
>(
0
,
0
);
vertexEntities
[
1
].
template
setSuperentityIndex
<
1
>(
1
,
2
);
vertexEntities
[
1
].
template
setSuperentityIndex
<
1
>(
2
,
4
);
ASSERT_EQ
(
vertexEntities
[
1
].
template
getNumberOfSuperentities
<
1
>(),
3
);
ASSERT_EQ
(
vertexEntities
[
1
].
template
getSuperentityIndex
<
1
>(
0
),
0
);
ASSERT_EQ
(
vertexEntities
[
1
].
template
getSuperentityIndex
<
1
>(
1
),
2
);
ASSERT_EQ
(
vertexEntities
[
1
].
template
getSuperentityIndex
<
1
>(
2
),
4
);
StorageNetwork
<
TestTriangleMeshConfig
,
MeshVertexTopology
,
2
>
vertexCellSuperentities
;
vertexCellSuperentities
.
setRanges
(
4
,
2
);
vertexCellSuperentities
.
allocate
(
2
);
// vertexEntities[ 1 ].template setNumberOfSuperentities< 2 >( 2 );
// vertexEntities[ 1 ].template setSuperentityIndex< 2 >( 0, 0 );
// vertexEntities[ 1 ].template setSuperentityIndex< 2 >( 1, 1 );
vertexEntities
[
1
].
template
bindSuperentitiesStorageNetwork
<
2
>(
vertexCellSuperentities
.
getValues
(
1
)
);
vertexEntities
[
1
].
template
setNumberOfSuperentities
<
2
>(
2
);
vertexEntities
[
1
].
template
setSuperentityIndex
<
2
>(
0
,
0
);
vertexEntities
[
1
].
template
setSuperentityIndex
<
2
>(
1
,
1
);
//
ASSERT_
TRU
E( vertexEntities[
0
].template getNumberOfSuperentities<
1
>()
==
2 );
//
ASSERT_
TRU
E( vertexEntities[
0
].template getSuperentityIndex<
1
>( 0 )
== 2
);
//
ASSERT_
TRU
E( vertexEntities[
0
].template getSuperentityIndex<
1
>( 1 )
==
1 );
ASSERT_E
Q
(
vertexEntities
[
1
].
template
getNumberOfSuperentities
<
2
>()
,
2
);
ASSERT_E
Q
(
vertexEntities
[
1
].
template
getSuperentityIndex
<
2
>(
0
)
,
0
);
ASSERT_E
Q
(
vertexEntities
[
1
].
template
getSuperentityIndex
<
2
>(
1
)
,
1
);
// ASSERT_TRUE( vertexEntities[ 1 ].template getNumberOfSuperentities< 1 >() == 3 );
// ASSERT_TRUE( vertexEntities[ 1 ].template getSuperentityIndex< 1 >( 0 ) == 0 );
// ASSERT_TRUE( vertexEntities[ 1 ].template getSuperentityIndex< 1 >( 1 ) == 2 );
// ASSERT_TRUE( vertexEntities[ 1 ].template getSuperentityIndex< 1 >( 2 ) == 4 );
//
ASSERT_TRUE( vertexEntities[ 1 ].template getNumberOfSuperentities< 2 >() == 2 )
;
//
ASSERT_TRUE( vertexEntities[ 1 ].template getSuperentityIndex< 2 >( 0 ) == 0
);
//
ASSERT_TRUE( vertexEntities[ 1 ].template getSuperentityIndex< 2 >( 1 ) == 1
);
StorageNetwork
<
TestTriangleMeshConfig
,
MeshEdgeTopology
,
2
>
edgeCellSuperentities
;
edgeCellSuperentities
.
setRanges
(
5
,
2
);
edgeCellSuperentities
.
allocate
(
2
);
// edgeEntities[ 0 ].template setNumberOfSuperentities< 2 >( 2 );
// edgeEntities[ 0 ].template setSuperentityIndex< 2 >( 0, 0 );
// edgeEntities[ 0 ].template setSuperentityIndex< 2 >( 1, 1 );
edgeEntities
[
0
].
template
bindSuperentitiesStorageNetwork
<
2
>(
edgeCellSuperentities
.
getValues
(
0
)
);
edgeEntities
[
0
].
template
setNumberOfSuperentities
<
2
>(
2
);
edgeEntities
[
0
].
template
setSuperentityIndex
<
2
>(
0
,
0
);
edgeEntities
[
0
].
template
setSuperentityIndex
<
2
>(
1
,
1
);
//
ASSERT_
TRU
E( edgeEntities[ 0 ].template getNumberOfSuperentities< 2 >()
==
2
);
//
ASSERT_
TRU
E( edgeEntities[ 0 ].template getSuperentityIndex< 2 >( 0 )
==
0 );
ASSERT_E
Q
(
edgeEntities
[
0
].
template
getNumberOfSuperentities
<
2
>()
,
2
);
ASSERT_E
Q
(
edgeEntities
[
0
].
template
getSuperentityIndex
<
2
>(
0
)
,
0
);
}
#endif
This diff is collapsed.
Click to expand it.
src/UnitTests/Meshes/MultimapTest.cpp
+
50
−
5
View file @
5bbaf0e7
...
...
@@ -20,6 +20,49 @@ TEST( MultimapTest, TestTypedefs )
ASSERT_TRUE
(
same_localindex
);
}
TEST
(
MultimapTest
,
TestSettingSizes
)
{
using
MultimapType
=
TNL
::
EllpackIndexMultimap
<
IndexType
,
Device
,
LocalIndexType
>
;
IndexType
inputs
=
10
;
LocalIndexType
valuesRange
=
4
;
LocalIndexType
valuesGlobalMax
=
3
;
LocalIndexType
valuesLocalMax
=
2
;
MultimapType
map
;
map
.
setRanges
(
inputs
,
valuesRange
);
ASSERT_EQ
(
map
.
getKeysRange
(),
inputs
);
ASSERT_EQ
(
map
.
getValuesRange
(),
valuesRange
);
typename
MultimapType
::
ValuesAllocationVectorType
allocationRanges
;
ASSERT_TRUE
(
allocationRanges
.
setSize
(
inputs
)
);
allocationRanges
.
setValue
(
valuesGlobalMax
);
ASSERT_TRUE
(
map
.
allocate
(
allocationRanges
)
);
for
(
IndexType
i
=
0
;
i
<
inputs
;
i
++
)
{
auto
values
=
map
.
getValues
(
i
);
const
auto
constValues
=
(
(
const
MultimapType
)
map
).
getValues
(
i
);
ASSERT_TRUE
(
values
.
setSize
(
valuesLocalMax
)
);
ASSERT_EQ
(
values
.
getSize
(),
valuesLocalMax
);
ASSERT_EQ
(
constValues
.
getSize
(),
valuesLocalMax
);
// setting wrong local sizes should not be allowed
ASSERT_FALSE
(
values
.
setSize
(
valuesGlobalMax
+
1
)
);
ASSERT_EQ
(
values
.
getSize
(),
valuesLocalMax
);
ASSERT_EQ
(
constValues
.
getSize
(),
valuesLocalMax
);
}
for
(
IndexType
i
=
0
;
i
<
inputs
;
i
++
)
{
auto
values
=
map
.
getValues
(
i
);
const
auto
constValues
=
(
(
const
MultimapType
)
map
).
getValues
(
i
);
ASSERT_TRUE
(
values
.
setSize
(
valuesGlobalMax
)
);
ASSERT_EQ
(
values
.
getSize
(),
valuesGlobalMax
);
ASSERT_EQ
(
constValues
.
getSize
(),
valuesGlobalMax
);
}
}
TEST
(
MultimapTest
,
TestSettingValues
)
{
using
MultimapType
=
TNL
::
EllpackIndexMultimap
<
IndexType
,
Device
,
LocalIndexType
>
;
...
...
@@ -42,13 +85,15 @@ TEST( MultimapTest, TestSettingValues )
auto
values
=
map
.
getValues
(
i
);
const
auto
constValues
=
(
(
const
MultimapType
)
map
).
getValues
(
i
);
ASSERT_TRUE
(
values
.
setSize
(
allocatedValues
)
);
for
(
LocalIndexType
o
=
0
;
o
<
allocatedValues
;
o
++
)
values
.
set
Output
(
o
,
i
+
o
);
values
.
set
Value
(
o
,
i
+
o
);
for
(
LocalIndexType
o
=
0
;
o
<
allocatedValues
;
o
++
)
{
ASSERT_EQ
(
values
.
get
Output
(
o
),
i
+
o
);
ASSERT_EQ
(
values
.
get
Value
(
o
),
i
+
o
);
ASSERT_EQ
(
values
[
o
],
i
+
o
);
ASSERT_EQ
(
constValues
.
get
Output
(
o
),
i
+
o
);
ASSERT_EQ
(
constValues
.
get
Value
(
o
),
i
+
o
);
ASSERT_EQ
(
constValues
[
o
],
i
+
o
);
}
...
...
@@ -56,9 +101,9 @@ TEST( MultimapTest, TestSettingValues )
values
[
o
]
=
i
*
o
;
for
(
LocalIndexType
o
=
0
;
o
<
allocatedValues
;
o
++
)
{
ASSERT_EQ
(
values
.
get
Output
(
o
),
i
*
o
);
ASSERT_EQ
(
values
.
get
Value
(
o
),
i
*
o
);
ASSERT_EQ
(
values
[
o
],
i
*
o
);
ASSERT_EQ
(
constValues
.
get
Output
(
o
),
i
*
o
);
ASSERT_EQ
(
constValues
.
get
Value
(
o
),
i
*
o
);
ASSERT_EQ
(
constValues
[
o
],
i
*
o
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment