"src/mesh/gitlab@mmg-gitlab.fjfi.cvut.cz:tnl/tnl-dev.git" did not exist on "c25e83eb1ba7cb84869521d22bb0129a14947468"
Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#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 << "faces: " << mesh.template getEntitiesCount< MeshType::getMeshDimension() - 1 >() << std::endl;
std::cout << "cells: " << mesh.template getEntitiesCount< MeshType::getMeshDimension() >() << std::endl;
std::cout << "post-init\t";
Debugging::printMemoryUsage();
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
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;
}