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
a60eb771
There was an error fetching the commit references. Please try again later.
Commit
a60eb771
authored
8 years ago
by
Jakub Klinkovský
Browse files
Options
Downloads
Patches
Plain Diff
Added MeshReaderTest
parent
04e2e098
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/CMakeLists.txt
+26
-0
26 additions, 0 deletions
src/UnitTests/Meshes/CMakeLists.txt
src/UnitTests/Meshes/MeshReaderTest.cpp
+158
-0
158 additions, 0 deletions
src/UnitTests/Meshes/MeshReaderTest.cpp
with
184 additions
and
0 deletions
src/UnitTests/Meshes/CMakeLists.txt
+
26
−
0
View file @
a60eb771
...
@@ -29,3 +29,29 @@ ADD_TEST( MeshTest${mpiExt}${debugExt} ${EXECUTABLE_OUTPUT_PATH}/MeshTest${mpiEx
...
@@ -29,3 +29,29 @@ ADD_TEST( MeshTest${mpiExt}${debugExt} ${EXECUTABLE_OUTPUT_PATH}/MeshTest${mpiEx
ADD_TEST
(
MeshEntityTest
${
mpiExt
}${
debugExt
}
${
EXECUTABLE_OUTPUT_PATH
}
/MeshEntityTest
${
mpiExt
}${
debugExt
}
)
ADD_TEST
(
MeshEntityTest
${
mpiExt
}${
debugExt
}
${
EXECUTABLE_OUTPUT_PATH
}
/MeshEntityTest
${
mpiExt
}${
debugExt
}
)
ADD_TEST
(
MultimapTest
${
mpiExt
}${
debugExt
}
${
EXECUTABLE_OUTPUT_PATH
}
/MultimapTest
${
mpiExt
}${
debugExt
}
)
ADD_TEST
(
MultimapTest
${
mpiExt
}${
debugExt
}
${
EXECUTABLE_OUTPUT_PATH
}
/MultimapTest
${
mpiExt
}${
debugExt
}
)
ADD_TEST
(
StaticMultimapTest
${
mpiExt
}${
debugExt
}
${
EXECUTABLE_OUTPUT_PATH
}
/MultimapTest
${
mpiExt
}${
debugExt
}
)
ADD_TEST
(
StaticMultimapTest
${
mpiExt
}${
debugExt
}
${
EXECUTABLE_OUTPUT_PATH
}
/MultimapTest
${
mpiExt
}${
debugExt
}
)
##
## Tests with VTK
##
find_package
(
VTK
)
if
(
VTK_FOUND
)
include
(
${
VTK_USE_FILE
}
)
AddCompilerFlag
(
"-DHAVE_VTK "
)
add_executable
(
MeshReaderTest
${
mpiExt
}${
debugExt
}
MeshReaderTest.cpp
)
#target_link_libraries( MeshReaderTest${mpiExt}${debugExt}
# ${VTK_LIBRARIES}
# tnl${debugExt}-${tnlVersion} )
target_link_libraries
(
MeshReaderTest
${
mpiExt
}${
debugExt
}
vtkCommonCore
vtkIOLegacy
tnl
${
debugExt
}
-
${
tnlVersion
}
)
else
(
VTK_FOUND
)
message
(
"Please install VTK to enable the MeshReaderTest."
)
endif
(
VTK_FOUND
)
This diff is collapsed.
Click to expand it.
src/UnitTests/Meshes/MeshReaderTest.cpp
0 → 100644
+
158
−
0
View file @
a60eb771
#include
<TNL/Meshes/Mesh.h>
#include
<TNL/Meshes/MeshConfigBase.h>
#include
<TNL/Meshes/BuildConfigTags.h>
#include
<TNL/Meshes/TypeResolver/TypeResolver.h>
#include
<TNL/Debugging/MemoryUsage.h>
using
namespace
TNL
;
using
namespace
TNL
::
Meshes
;
template
<
typename
Cell
,
int
WorldDimension
=
Cell
::
dimension
,
typename
Real
=
double
,
typename
GlobalIndex
=
int
,
typename
LocalIndex
=
GlobalIndex
,
typename
Id
=
void
>
struct
MyMeshConfig
:
public
MeshConfigBase
<
Cell
,
WorldDimension
,
Real
,
GlobalIndex
,
LocalIndex
,
Id
>
{
static
constexpr
bool
entityStorage
(
int
dimension
)
{
return
true
;
// return dimension == 0 || dimension == Cell::dimension;
}
template
<
typename
EntityTopology
>
static
constexpr
bool
subentityStorage
(
EntityTopology
,
int
SubentityDimension
)
{
// return entityStorage( EntityTopology::dimension );
return
entityStorage
(
EntityTopology
::
dimension
)
&&
SubentityDimension
==
0
;
}
template
<
typename
EntityTopology
>
static
constexpr
bool
subentityOrientationStorage
(
EntityTopology
,
int
SubentityDimension
)
{
return
false
;
}
template
<
typename
EntityTopology
>
static
constexpr
bool
superentityStorage
(
EntityTopology
,
int
SuperentityDimension
)
{
// return entityStorage( EntityTopology::dimension );
return
entityStorage
(
EntityTopology
::
dimension
)
&&
SuperentityDimension
==
Cell
::
dimension
;
}
template
<
typename
EntityTopology
>
static
constexpr
bool
boundaryTagsStorage
(
EntityTopology
)
{
using
BaseType
=
MeshConfigBase
<
Cell
,
WorldDimension
,
Real
,
GlobalIndex
,
LocalIndex
,
Id
>
;
using
FaceTopology
=
typename
MeshSubtopology
<
Cell
,
BaseType
::
meshDimension
-
1
>::
Topology
;
return
entityStorage
(
BaseType
::
meshDimension
-
1
)
&&
superentityStorage
(
FaceTopology
(),
BaseType
::
meshDimension
)
&&
(
EntityTopology
::
dimension
>=
BaseType
::
meshDimension
-
1
||
subentityStorage
(
FaceTopology
(),
EntityTopology
::
dimension
)
);
//return false;
}
};
// specialization of BuildConfigTags
struct
MyBuildConfigTag
{};
namespace
TNL
{
namespace
Meshes
{
namespace
BuildConfigTags
{
// disable grids
template
<
int
Dimension
,
typename
Real
,
typename
Device
,
typename
Index
>
struct
GridTag
<
MyBuildConfigTag
,
Grid
<
Dimension
,
Real
,
Device
,
Index
>
>
{
enum
{
enabled
=
false
};
};
// enable all cell topologies
template
<
>
struct
MeshCellTopologyTag
<
MyBuildConfigTag
,
MeshEdgeTopology
>
{
enum
{
enabled
=
true
};
};
template
<
>
struct
MeshCellTopologyTag
<
MyBuildConfigTag
,
MeshTriangleTopology
>
{
enum
{
enabled
=
true
};
};
template
<
>
struct
MeshCellTopologyTag
<
MyBuildConfigTag
,
MeshQuadrilateralTopology
>
{
enum
{
enabled
=
true
};
};
template
<
>
struct
MeshCellTopologyTag
<
MyBuildConfigTag
,
MeshTetrahedronTopology
>
{
enum
{
enabled
=
true
};
};
template
<
>
struct
MeshCellTopologyTag
<
MyBuildConfigTag
,
MeshHexahedronTopology
>
{
enum
{
enabled
=
true
};
};
template
<
typename
CellTopology
,
int
WorldDimension
>
struct
MeshWorldDimensionTag
<
MyBuildConfigTag
,
CellTopology
,
WorldDimension
>
{
enum
{
enabled
=
(
WorldDimension
==
CellTopology
::
dimension
)
};
};
template
<
typename
Real
>
struct
MeshRealTag
<
MyBuildConfigTag
,
Real
>
{
enum
{
enabled
=
false
};
};
template
<
>
struct
MeshRealTag
<
MyBuildConfigTag
,
float
>
{
enum
{
enabled
=
true
};
};
template
<
>
struct
MeshRealTag
<
MyBuildConfigTag
,
double
>
{
enum
{
enabled
=
true
};
};
template
<
typename
GlobalIndex
>
struct
MeshGlobalIndexTag
<
MyBuildConfigTag
,
GlobalIndex
>
{
enum
{
enabled
=
false
};
};
template
<
>
struct
MeshGlobalIndexTag
<
MyBuildConfigTag
,
int
>
{
enum
{
enabled
=
true
};
};
template
<
typename
LocalIndex
>
struct
MeshLocalIndexTag
<
MyBuildConfigTag
,
LocalIndex
>
{
enum
{
enabled
=
false
};
};
template
<
>
struct
MeshLocalIndexTag
<
MyBuildConfigTag
,
short
int
>
{
enum
{
enabled
=
true
};
};
template
<
>
struct
MeshConfigTemplateTag
<
MyBuildConfigTag
>
{
template
<
typename
Cell
,
int
WorldDimension
,
typename
Real
,
typename
GlobalIndex
,
typename
LocalIndex
,
typename
Id
>
using
MeshConfig
=
MyMeshConfig
<
Cell
,
WorldDimension
,
Real
,
GlobalIndex
,
LocalIndex
,
Id
>
;
};
}
// namespace BuildConfigTags
}
// namespace Meshes
}
// namespace TNL
template
<
typename
MeshType
>
class
MeshTester
{
public:
static
bool
run
(
const
String
&
fileName
)
{
MeshType
mesh
;
std
::
cout
<<
"pre-init
\t
"
;
Debugging
::
printMemoryUsage
();
if
(
!
loadMesh
(
fileName
,
mesh
)
)
return
false
;
// TODO: add tests
std
::
cout
<<
"NOTE: there is no real test, but the file was loaded fine..."
<<
std
::
endl
;
std
::
cout
<<
"vertices: "
<<
mesh
.
template
getEntitiesCount
<
0
>()
<<
std
::
endl
;
std
::
cout
<<
"cells: "
<<
mesh
.
getCellsCount
()
<<
std
::
endl
;
std
::
cout
<<
"post-init
\t
"
;
Debugging
::
printMemoryUsage
();
mesh
.
save
(
"mesh-test.tnl"
);
return
true
;
}
};
int
main
(
int
argc
,
char
*
argv
[]
)
{
if
(
argc
<
2
)
{
std
::
cerr
<<
"Usage: "
<<
argv
[
0
]
<<
" filename.[tnl|ng|vtk] ..."
<<
std
::
endl
;
return
EXIT_FAILURE
;
}
bool
result
=
true
;
for
(
int
i
=
1
;
i
<
argc
;
i
++
)
{
String
fileName
=
argv
[
i
];
result
&=
resolveMeshType
<
MyBuildConfigTag
,
Devices
::
Host
,
MeshTester
>
(
fileName
,
fileName
// passed to MeshTester::run
);
}
std
::
cout
<<
"final
\t
"
;
Debugging
::
printMemoryUsage
();
return
!
result
;
}
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