BELFEM 0.9.3
Berkeley Lab Finite Element Framework
Loading...
Searching...
No Matches
cl_Mesh.hpp
Go to the documentation of this file.
1/*
2 * BELFEM -- The Berkeley Lab Finite Element Framework
3 * Copyright (c) 2026, The Regents of the University of California,
4 * through Lawrence Berkeley National Laboratory (subject to receipt of any required
5 * approvals from the U.S. Dept. of Energy). All rights reserved.
6 *
7 * Developers: Christian Messe, Gregory Giard
8 *
9 * See the top-level LICENSE file for the complete license and disclaimer.
10 */
11
12#ifndef BELFEM_CL_MESH_HPP
13#define BELFEM_CL_MESH_HPP
14
15#include "typedefs.hpp"
16#include "cl_Hash.hpp"
17#include "cl_Cell.hpp"
18#include "cl_Map.hpp"
19#include "cl_Element.hpp"
20#include "cl_Node.hpp"
21#include "cl_Facet.hpp"
22#include "cl_Face.hpp"
23#include "cl_ControlPoint.hpp"
24#include "cl_Block.hpp"
25#include "cl_SideSet.hpp"
27#include "cl_Mesh_Field.hpp"
28#include "cl_ThinShell.hpp"
29#include "cl_Curve.hpp"
30#include "cl_Bitset.hpp"
31#include "cl_DynamicBitset.hpp"
34#include "hdf5_types.hpp"
35
36namespace belfem
37{
38//------------------------------------------------------------------------------
39
40 namespace mesh
41 {
42 class ProtoMesh ;
43
44 class PeriodicityFactory ;
45
46 class GmshReader;
47
48 uint
49 compute_facet_index( Facet * aFacet, Element * aElement, Cell< Node * > & aNodes );
50 }
51
52
59 class Mesh
60 {
61//------------------------------------------------------------------------------
62 protected:
63//------------------------------------------------------------------------------
64
65 // master proc that owns this mesh, default: 0
69
70
71 // hash value for unique fingerprint, must be computed first
72 // refers to original unaltered mesh without cuts and thin shells
74
80 uint64_t mConfigTag = 0 ;
81 string mConfigText ;
82
83 string mPath ;
84
87 Cell< mesh::Facet * > mFacets; // facets refer to sidesets
88 Cell< mesh::Element * > mVertices; // not to be confused with mesh vertex
92
96
103
108
111
115
116 // how many partitions is this mesh split into?
118
122
124 uint mTimeStep = 1; // << -- timestep is 1-based for exodus compatibility
125
126
127 friend class mesh::GmshReader;
129 friend class mesh::ProtoMesh;
130
141
142 // maximum element order
144
146 bool mIsKernelMesh = false ;
147
149 bool mIsFinalized = false ;
150 bool mEdgesAreFinalized = false ;
151 bool mFacesAreFinalized = false ;
152
153 // we only call the symrcm once per mesh
154 bool mNodesAreSorted = false ;
155
156 // compute orientations on finalize
158
167
169
170 const TensorMeshConfig * mTensorConfig = nullptr ;
171
173
174 bool mMeshCheckerFlag = false ;
175
176//------------------------------------------------------------------------------
177 public:
178//------------------------------------------------------------------------------
179
183 Mesh( const uint aNumberOfDimensions, const proc_t aMasterProc=0, const bool aComputeConnectivities = true );
184
185//------------------------------------------------------------------------------
186
193 Mesh( const string & aPath,
194 const proc_t aMasterProc = 0,
195 const bool aComputeConnectivities = true,
196 const bool aParallelMode = true );
197
198//------------------------------------------------------------------------------
199
204 Mesh( const uint aOrder,
205 const Vector< index_t > aNumNodes,
206 const Vector< real > aStep,
207 const Vector< real > aOrigin = {},
208 const proc_t aMasterProc = 0 );
209
210//------------------------------------------------------------------------------
211
217 void
218 scale_mesh( const real aFactor );
219
220//------------------------------------------------------------------------------
221
222 ~Mesh();
223
224//------------------------------------------------------------------------------
225
226 const string &
227 path() const ;
228
229//------------------------------------------------------------------------------
230
231 bool
232 is_tensormesh() const ;
233
234//------------------------------------------------------------------------------
235
236 const TensorMeshConfig *
237 tensorconf() const;
238
239//------------------------------------------------------------------------------
240
242 void
243 save( const string & aFilePath );
244
245//------------------------------------------------------------------------------
246
247 uint
248 number_of_dimensions() const;
249
250//------------------------------------------------------------------------------
251
252 void
253 set_number_of_dimensions( const uint & aNumberOfDimensions );
254
255//------------------------------------------------------------------------------
256
257 index_t
258 number_of_nodes() const;
259
260//------------------------------------------------------------------------------
261
262 index_t
263 number_of_elements() const;
264
265//------------------------------------------------------------------------------
266
267 index_t
268 number_of_facets() const;
269
270//------------------------------------------------------------------------------
271
272 index_t
273 number_of_edges() const;
274
275//------------------------------------------------------------------------------
276
277 index_t
278 number_of_faces() const;
279
280//------------------------------------------------------------------------------
281
282 index_t
284
285//------------------------------------------------------------------------------
286
287 uint
288 number_of_blocks() const;
289
290//------------------------------------------------------------------------------
291
292 uint
293 number_of_fields() const;
294
295//------------------------------------------------------------------------------
296
297 uint
299
300//------------------------------------------------------------------------------
301
302 mesh::Node *
303 node( const id_t aID );
304
305//------------------------------------------------------------------------------
306
307 mesh::Node *
308 node( const index_t i, const index_t j );
309
310//------------------------------------------------------------------------------
311
312 mesh::Node *
313 node( const index_t i, const index_t j, const index_t k );
314
315//------------------------------------------------------------------------------
316
317 mesh::Edge *
318 edge( const id_t aID );
319
320//------------------------------------------------------------------------------
321
322 mesh::Face *
323 face( const id_t aID );
324
325//------------------------------------------------------------------------------
326
327 bool
328 element_exists( const id_t aID ) const;
329
331 element( const id_t aID );
332
334 element( const index_t i, const index_t j );
335
337 element( const index_t i, const index_t j, const index_t k );
338
339//------------------------------------------------------------------------------
340
342 control_point( const id_t aID );
343
345 control_point( const index_t i, const index_t j );
346
348 control_point( const index_t i, const index_t j, const index_t k );
349
350//------------------------------------------------------------------------------
351
352 bool
353 facet_exists( const id_t aID ) const;
354
356 facet( const id_t aID );
357
358//------------------------------------------------------------------------------
359
361 block( const id_t aID );
362
363//------------------------------------------------------------------------------
364
366 sideset( const id_t aID );
367
368//------------------------------------------------------------------------------
369
371 vertex( const id_t aID );
372
373//------------------------------------------------------------------------------
374
376 basis_by_index( const EntityType aType, const index_t aIndex );
377
379 basis( const EntityType aType, const id_t aID );
380
381//------------------------------------------------------------------------------
382
387 field( const string & aLabel );
388
389//------------------------------------------------------------------------------
390
392 field( const index_t aIndex );
393
394//------------------------------------------------------------------------------
395
396 // test if a field has already been created
397 bool
398 field_exists( const string & aLabel );
399
400//------------------------------------------------------------------------------
401
403 field_data( const string & aLabel );
404
405//------------------------------------------------------------------------------
406
409
410//------------------------------------------------------------------------------
411
413 global_variable( const id_t aID );
414
415//------------------------------------------------------------------------------
416
418 global_variable( const string & aLabel );
419
420//------------------------------------------------------------------------------
421
422 real &
423 global_variable_data( const string & aLabel );
424
425//------------------------------------------------------------------------------
426
427 // test if a global variable has already been created
428 bool
429 global_variable_exists( const string & aLabel );
430
431//------------------------------------------------------------------------------
432
433 uint
434 number_of_sidesets() const;
435
436//------------------------------------------------------------------------------
437
446
447 index_t
449
450//------------------------------------------------------------------------------
451
454 void
455 add_block( mesh::Block * aBlock );
456
457//------------------------------------------------------------------------------
458
461 void
462 add_sideset( mesh::SideSet * aSideSet );
463
464//------------------------------------------------------------------------------
465
468 const string & aLabel,
469 const EntityType aEntity=EntityType::NODE,
470 const id_t aID = 0 );
471
472//------------------------------------------------------------------------------
473
474 real &
475 create_global_variable( const string & aLabel,
476 const real aValue = 0.0,
477 const id_t aID = 0 );
478
479//------------------------------------------------------------------------------
480
481 void
483
484//------------------------------------------------------------------------------
485
486 void
488
489//------------------------------------------------------------------------------
490
491 void
493
494//------------------------------------------------------------------------------
495
496 void
498 Cell< mesh::Element * > & aElements,
499 const id_t aGroupId,
500 const ElementType aType = ElementType::EMPTY );
501
502//------------------------------------------------------------------------------
503
504 void
506
507//------------------------------------------------------------------------------
508
513 void
514 finalize();
515
516//------------------------------------------------------------------------------
517
518 bool
519 is_finalized() const ;
520
521 bool
522 edges_are_finalized() const ;
523
524 bool
525 faces_are_finalized() const ;
526
527//------------------------------------------------------------------------------
528
529 void
531
532//------------------------------------------------------------------------------
533
534 void
536
537//------------------------------------------------------------------------------
538
542 void
543 unfinalize();
544
545//------------------------------------------------------------------------------
546
547 void
549
550//------------------------------------------------------------------------------
551
552 void
554
555//------------------------------------------------------------------------------
556
557 void
559
560//------------------------------------------------------------------------------
561
562 void
563 unflag_everything( const uint aFlagIndex=0 );
564
565//------------------------------------------------------------------------------
566
567 void
568 unflag_all_nodes( const uint aFlagIndex=0 );
569
570//------------------------------------------------------------------------------
571
572 void
573 unflag_all_edges( const uint aFlagIndex=0 );
574
575//------------------------------------------------------------------------------
576
577 void
578 unflag_all_faces( const uint aFlagIndex=0 );
579
580//------------------------------------------------------------------------------
581
582 void
583 unflag_all_facets( const uint aFlagIndex=0 );
584
585//------------------------------------------------------------------------------
586
587 void
588 unflag_all_elements( const uint aFlagIndex=0 );
589
590//------------------------------------------------------------------------------
591
592 void
593 unflag_all_vertices( const uint aFlagIndex=0 );
594
595//------------------------------------------------------------------------------
596
597 void
598 unflag_all_control_points( const uint aFlagIndex=0 );
599
600//------------------------------------------------------------------------------
601
608 nodes();
609
610//------------------------------------------------------------------------------
611
616 blocks();
617
618//------------------------------------------------------------------------------
619
620 bool
621 block_exists( const id_t aID ) const ;
622
623//------------------------------------------------------------------------------
624
625 bool
626 sideset_exists( const id_t aID ) const ;
627
628//------------------------------------------------------------------------------
629
630 bool
631 node_exists( const id_t aID ) const ;
632
633//------------------------------------------------------------------------------
634
639 thin_shells();
640
641//------------------------------------------------------------------------------
642
648 elements();
649
650//------------------------------------------------------------------------------
651
657 facets();
658
659//------------------------------------------------------------------------------
660
666
667//------------------------------------------------------------------------------
668
673 sidesets();
674
675//------------------------------------------------------------------------------
676
681 curves();
682
683//------------------------------------------------------------------------------
684
689 curve( const id_t aID );
690
691//------------------------------------------------------------------------------
692
693 void
695
696//------------------------------------------------------------------------------
697
702 edges();
703
704//------------------------------------------------------------------------------
705
710 faces();
711
712//------------------------------------------------------------------------------
713
718 vertices();
719
720 //------------------------------------------------------------------------------
721
727
728//------------------------------------------------------------------------------
729
735 void
736 partition(
737 const uint & aNumberOfPartitions,
738 const bool aSetProcOwners = true,
739 const bool aForceContinuousPartitions = true,
740 const bool aResetVertexContainers = true );
741
742//------------------------------------------------------------------------------
743
747 void
748 partition( const uint & aNumberOfPartitions,
749 const Vector< id_t > & aSelectedBlocks,
750 const bool aSetProcOwners = true,
751 const bool aForceContinuousPartitions = false,
752 const bool aResetVertexContainers = true );
753
754//------------------------------------------------------------------------------
755
759 void
760 partition( const uint & aNumberOfPartitions,
761 const Vector< id_t > & aSelectedBlocks,
762 const Vector< id_t > & aSelectedSideSets,
763 const bool aSetProcOwners = true,
764 const bool aForceContinuousPartitions = false,
765 const bool aResetVertexContainers = true );
766
767
768//------------------------------------------------------------------------------
769
770 void
772
773//------------------------------------------------------------------------------
774
775 void
777
778//------------------------------------------------------------------------------
779
780 void
782
783//------------------------------------------------------------------------------
784
785 void
787
788//------------------------------------------------------------------------------
789
798 void
799 create_edges( const bool aPrint=false,
800 const Vector< id_t > aNedelecBlocks = Vector< id_t >(),
801 const Vector< id_t > aNedelecSideSets = Vector< id_t >(),
802 const bool aCreateEdgesOnAllSideSets = true );
803
804//------------------------------------------------------------------------------
805
806 void
807 reset_edges();
808
809//------------------------------------------------------------------------------
810
817 void
818 create_faces( const bool aPrint=false,
819 const Vector< id_t > aNedelecBlocks = Vector< id_t >(),
820 const Vector< id_t > aNedelecSideSets = Vector< id_t >() );
821
822 void
823 reset_faces();
824
825//------------------------------------------------------------------------------
826
827 void
829
830//------------------------------------------------------------------------------
831
832 void
834
835//------------------------------------------------------------------------------
836
837 void
839
840//------------------------------------------------------------------------------
841
846 real &
847 time_stamp();
848
849//------------------------------------------------------------------------------
850
854 const uint &
855 time_step() const;
856
857 uint &
858 time_step() ;
859
860//------------------------------------------------------------------------------
861
865 void
866 set_time_step( const uint aTimeStep );
867
868
869//------------------------------------------------------------------------------
870
871 void
872 set_connectivity( const Connectivity aConnectivity ) ;
873
874//------------------------------------------------------------------------------
875
876 void
877 reset_connectivity( const Connectivity aConnectivity ) ;
878
879//------------------------------------------------------------------------------
880
881 bool
882 test_connectivity( const Connectivity aConnectivity );
883
884//------------------------------------------------------------------------------
885
889 const proc_t &
890 master() const;
891
892//------------------------------------------------------------------------------
893
894 void
896
897//------------------------------------------------------------------------------
898
899 void
901
902//------------------------------------------------------------------------------
903
907 void
908 set_number_of_partitions( const proc_t & aNumberOfPartitions );
909
910//------------------------------------------------------------------------------
911
916 bool
917 edges_exist() const ;
918
919//------------------------------------------------------------------------------
920
924 bool
925 faces_exist() const ;
926
927//------------------------------------------------------------------------------
928
932 void
934
935//------------------------------------------------------------------------------
936
940 void
942
943//------------------------------------------------------------------------------
944
948 const uint &
949 max_element_order() const ;
950
951//------------------------------------------------------------------------------
952
956 void
958
959//------------------------------------------------------------------------------
960
961 bool
962 is_kernel_mesh() const ;
963
964//------------------------------------------------------------------------------
965
969 void
971
972//------------------------------------------------------------------------------
973
976 void
978
979//------------------------------------------------------------------------------
980
981 void
982 save_faces( const string & aPath );
983
984//------------------------------------------------------------------------------
985
986 id_t
987 max_node_id() ;
988
989//------------------------------------------------------------------------------
990
991 id_t
993
994//------------------------------------------------------------------------------
995
996 id_t
998
999//------------------------------------------------------------------------------
1000
1005 void
1007
1008//------------------------------------------------------------------------------
1009
1011 autopins();
1012
1013//------------------------------------------------------------------------------
1014
1017
1018//------------------------------------------------------------------------------
1019
1022
1023//------------------------------------------------------------------------------
1024
1025 // compute and return the checksum
1026 std::size_t
1027 checksum() ;
1028
1029//------------------------------------------------------------------------------
1030
1031 // enforces a checksum instead of computing it; used by BfmFile::load()
1032 // and by the controller to stamp a derived mesh
1033 void
1034 force_checksum( const std::size_t aChecksum ) ;
1035
1036//------------------------------------------------------------------------------
1037
1038 // the settings fingerprint that travels into the mesh file, see mConfigTag
1039 void
1040 set_config_tag( const uint64_t aTag, const string & aText ) ;
1041
1042 uint64_t
1043 config_tag() const ;
1044
1045 const string &
1046 config_text() const ;
1047
1048//------------------------------------------------------------------------------
1049
1050 void
1052
1053 void
1055
1056 void
1058
1059 id_t
1060 max_node_id() const ;
1061
1062 id_t
1063 max_element_id() const ;
1064
1065
1067 Mesh *
1069
1070 void
1072
1073 void
1074 set_compute_facet_orientation_flag( const bool aFlag );
1075
1076//------------------------------------------------------------------------------
1077
1081 size_t
1082 memory() const ;
1083
1084//------------------------------------------------------------------------------
1085
1086 bool
1087 has_periodicity() const;
1088
1090 periodicity();
1091
1093 void
1094 set_periodicity( mesh::Periodicity * aPeriodicity );
1095
1096
1097
1098 void
1099 save_meta( hid_t aFile, const uint aRunningTimestep=0 );
1100
1101 uint
1102 load_meta( hid_t aFile );
1103
1104 void
1105 save_fields( hid_t aFile );
1106
1107 void
1108 load_fields( hid_t aFile );
1109
1110 void
1111 save_globals( hid_t aFile );
1112
1113 void
1114 load_globals( hid_t aFile );
1115
1116 void
1118
1119 void
1121
1122 bool
1123 mesh_checker_flag() const;
1124
1125//------------------------------------------------------------------------------
1126 private:
1127//------------------------------------------------------------------------------
1128
1129 // Resize every existing field whose entity type matches aEntityType
1130 // to aSize and reset its values to 0.0. Called from finalize() for
1131 // NODE and ELEMENT, finalize_edges() for EDGE, and finalize_faces()
1132 // for FACE so that fields registered before mesh-topology updates
1133 // (cut duplication, partitioning, etc.) stay in sync with the
1134 // current entity counts.
1135 void
1136 resize_and_reset_fields( const EntityType aEntityType, const index_t aSize );
1137
1138//------------------------------------------------------------------------------
1139
1140 void
1141 create_maps();
1142
1143//------------------------------------------------------------------------------
1144
1145 void
1146 reset_maps();
1147
1148//------------------------------------------------------------------------------
1149
1150 // set the block ids of each element
1151 void
1152 set_block_ids();
1153
1154//------------------------------------------------------------------------------
1155
1156 // set the sideset ids of each facet
1157 void
1158 set_sideset_ids();
1159
1160
1161
1162//------------------------------------------------------------------------------
1163
1164 // set the indices for the sidesets (needed to create curves)
1165 void
1166 set_sideset_indices();
1167
1168//------------------------------------------------------------------------------
1169
1170 // set the indices for the blocks
1171 void
1172 set_block_indices();
1173
1174//------------------------------------------------------------------------------
1175
1179 void
1180 compute_max_element_order();
1181
1182//------------------------------------------------------------------------------
1183
1184 void
1185 compute_edge_directions();
1186
1187//------------------------------------------------------------------------------
1188
1189 void
1190 compute_checksum();
1191
1192//------------------------------------------------------------------------------
1193
1194 };
1195
1196//------------------------------------------------------------------------------
1197
1198 inline const string &
1200 {
1201 return mPath ;
1202 }
1203
1204//------------------------------------------------------------------------------
1205
1206 inline bool
1208 {
1209 return mTensorConfig != nullptr;
1210 }
1211
1212//------------------------------------------------------------------------------
1213
1214 inline const TensorMeshConfig *
1216 {
1217 return mTensorConfig;
1218 }
1219
1220//------------------------------------------------------------------------------
1221
1222 inline uint
1224 {
1225 return mNumberOfDimensions;
1226 }
1227
1228//------------------------------------------------------------------------------
1229
1230 inline void
1231 Mesh::set_number_of_dimensions( const uint & aNumberOfDimensions )
1232 {
1233 mNumberOfDimensions = aNumberOfDimensions;
1234 }
1235
1236//------------------------------------------------------------------------------
1237
1238 inline index_t
1240 {
1241 return mNodes.size();
1242 }
1243
1244//------------------------------------------------------------------------------
1245
1246 inline index_t
1248 {
1249 return mElements.size();
1250 }
1251
1252//------------------------------------------------------------------------------
1253
1254 inline index_t
1256 {
1257 return mFacets.size();
1258 }
1259
1260//------------------------------------------------------------------------------
1261
1262 inline index_t
1264 {
1265 return mEdges.size();
1266 }
1267
1268//------------------------------------------------------------------------------
1269
1270 inline index_t
1272 {
1273 return mFaces.size();
1274 }
1275
1276//------------------------------------------------------------------------------
1277
1278 inline index_t
1280 {
1281 return mControlPoints.size();
1282 }
1283
1284//------------------------------------------------------------------------------
1285
1286 inline uint
1288 {
1289 return mBlocks.size();
1290 }
1291
1292//------------------------------------------------------------------------------
1293
1294 inline uint
1296 {
1297 return mSideSets.size();
1298 }
1299
1300//------------------------------------------------------------------------------
1301
1302 inline mesh::Node *
1303 Mesh::node( const id_t aID )
1304 {
1306 "Tried to access invalid node id: %lu.",
1307 ( long unsigned int ) aID );
1308
1309 return mNodeMap( aID );
1310 }
1311
1312//------------------------------------------------------------------------------
1313
1314 inline mesh::Node *
1315 Mesh::node( const index_t i, const index_t j )
1316 {
1317 BELFEM_ASSERT( this->is_tensormesh() && this->number_of_dimensions() == 2,
1318 "can only access node over 2d index on 2d-tensormeshes" );
1319
1320 return mNodes( mTensorConfig->node_index( i, j ) );
1321 }
1322
1323//------------------------------------------------------------------------------
1324
1325 inline mesh::Node *
1326 Mesh::node( const index_t i, const index_t j, const index_t k )
1327 {
1328 BELFEM_ASSERT( this->is_tensormesh() && this->number_of_dimensions() == 3,
1329 "can only access node over 3d index on 3d-tensormeshes" );
1330
1331 return mNodes( mTensorConfig->node_index( i, j, k ) );
1332 }
1333//------------------------------------------------------------------------------
1334
1335 inline mesh::Edge *
1336 Mesh::edge( const id_t aID )
1337 {
1339 "Tried to access invalid edge id: %lu.",
1340 ( long unsigned int ) aID );
1341
1342 return mEdgeMap( aID );
1343 }
1344
1345//------------------------------------------------------------------------------
1346
1347 inline mesh::Face *
1348 Mesh::face( const id_t aID )
1349 {
1351 "Tried to access invalid face id: %lu.",
1352 ( long unsigned int ) aID );
1353
1354 return mFaceMap( aID );
1355 }
1356
1357//------------------------------------------------------------------------------
1358
1359 inline bool
1360 Mesh::element_exists( const id_t aID ) const
1361 {
1362 return mElementMap.key_exists( aID );
1363 }
1364
1365//------------------------------------------------------------------------------
1366
1367 inline mesh::Element *
1368 Mesh::element( const id_t aID )
1369 {
1371 "Tried to access invalid element id: %lu.",
1372 ( long unsigned int ) aID );
1373
1374 return mElementMap( aID ) ;
1375 }
1376
1377//------------------------------------------------------------------------------
1378
1379 inline mesh::Element *
1380 Mesh::element( const index_t i, const index_t j )
1381 {
1382 BELFEM_ASSERT( this->is_tensormesh() && this->number_of_dimensions() == 2,
1383 "can only access element over 2d index on 2d-tensormeshes" );
1384
1385 return mElements( mTensorConfig->element_index( i, j ) );
1386 }
1387
1388//------------------------------------------------------------------------------
1389
1390 inline mesh::Element *
1391 Mesh::element( const index_t i, const index_t j, const index_t k )
1392 {
1393 BELFEM_ASSERT( this->is_tensormesh() && this->number_of_dimensions() == 3,
1394 "can only access element over 3d index on 3d-tensormeshes" );
1395
1396 return mElements( mTensorConfig->element_index( i, j, k ) );
1397 }
1398
1399//------------------------------------------------------------------------------
1400
1401 inline mesh::ControlPoint *
1403 {
1405 "Tried to access invalid control point id: %lu.",
1406 ( long unsigned int ) aID );
1407
1408 return mControlPointMap( aID );
1409 }
1410
1411 inline mesh::ControlPoint *
1413 {
1414 BELFEM_ASSERT( this->is_tensormesh() && this->number_of_dimensions() == 2,
1415 "can only access control point over 2d index on 2d-tensormeshes" );
1416
1417 return mControlPoints(
1418 i * mTensorConfig->num_control_points( 1 ) + j );
1419 }
1420
1421 inline mesh::ControlPoint *
1422 Mesh::control_point( const index_t i, const index_t j, const index_t k )
1423 {
1424 BELFEM_ASSERT( this->is_tensormesh() && this->number_of_dimensions() == 3,
1425 "can only access control point over 3d index on 3d-tensormeshes" );
1426
1427 return mControlPoints(
1429 ( i * mTensorConfig->num_control_points( 1 ) + j ) + k );
1430 }
1431
1432
1433//------------------------------------------------------------------------------
1434
1435 inline bool
1436 Mesh::facet_exists( const id_t aID ) const
1437 {
1438 return mFacetMap.key_exists( aID );
1439 }
1440
1441//------------------------------------------------------------------------------
1442
1443 inline mesh::Facet *
1444 Mesh::facet( const id_t aID )
1445 {
1447 "Tried to access invalid facet id: %lu.",
1448 ( long unsigned int ) aID );
1449
1450 return mFacetMap( aID );
1451 }
1452
1453//------------------------------------------------------------------------------
1454
1455 inline mesh::Block *
1456 Mesh::block( const id_t aID )
1457 {
1459 "Tried to access invalid block id: %lu.",
1460 ( long unsigned int ) aID );
1461
1462 return mBlockMap( aID );
1463 }
1464
1465//------------------------------------------------------------------------------
1466
1467 inline mesh::SideSet *
1468 Mesh::sideset( const id_t aID )
1469 {
1471 "Tried to access invalid sideset id: %lu.",
1472 ( long unsigned int ) aID );
1473
1474 return mSideSetMap( aID );
1475 }
1476
1477//------------------------------------------------------------------------------
1478
1479 inline mesh::Element *
1480 Mesh::vertex( const id_t aID )
1481 {
1483 "Tried to access invalid vertex id: %lu.",
1484 ( long unsigned int ) aID );
1485
1486 return mVertexMap( aID );
1487 }
1488
1489//------------------------------------------------------------------------------
1490
1491 inline mesh::Field *
1492 Mesh::field( const index_t aIndex )
1493 {
1494 return mFields( aIndex );
1495 }
1496
1497//------------------------------------------------------------------------------
1498
1499 inline mesh::Field *
1500 Mesh::field( const string & aLabel )
1501 {
1503 "Field '%s' does not exist on mesh", aLabel.c_str());
1504
1505 return mFieldMap( aLabel );
1506 }
1507
1508//------------------------------------------------------------------------------
1509
1510 inline bool
1511 Mesh::field_exists( const string & aLabel )
1512 {
1513 return mFieldMap.key_exists( aLabel ) ;
1514 }
1515
1516
1517//------------------------------------------------------------------------------
1518
1519 inline Vector< real > &
1520 Mesh::field_data( const string & aLabel )
1521 {
1523 "Field '%s' does not exist on mesh", aLabel.c_str());
1524
1525 return mFieldMap( aLabel )->data();
1526 }
1527
1528//------------------------------------------------------------------------------
1529
1532 {
1533 return mGlobalVariables;
1534 }
1535
1536//------------------------------------------------------------------------------
1537
1538 inline mesh::GlobalVariable *
1540 {
1541 return mGlobalVariableIDMap( aID );
1542 }
1543
1544//------------------------------------------------------------------------------
1545
1546 inline mesh::GlobalVariable *
1547 Mesh::global_variable( const string & aLabel )
1548 {
1549 return mGlobalVariableMap( aLabel );
1550 }
1551
1552//------------------------------------------------------------------------------
1553
1554 inline real &
1555 Mesh::global_variable_data( const string & aLabel )
1556 {
1557 return mGlobalVariableMap( aLabel )->value();
1558 }
1559
1560//------------------------------------------------------------------------------
1561
1562 // test if a global variable has already been created
1563 inline bool
1564 Mesh::global_variable_exists( const string & aLabel )
1565 {
1566 return mGlobalVariableMap.key_exists( aLabel );
1567 }
1568
1569//------------------------------------------------------------------------------
1570
1571 inline uint
1573 {
1574 return mFields.size() ;
1575 }
1576
1577//------------------------------------------------------------------------------
1578
1579 inline uint
1581 {
1582 return mGlobalVariables.size();
1583 }
1584
1585//------------------------------------------------------------------------------
1586
1587 inline real &
1589 {
1590 return mTimeStamp;
1591 }
1592
1593//------------------------------------------------------------------------------
1594
1595 inline const uint &
1597 {
1598 return mTimeStep;
1599 }
1600
1601 inline uint &
1603 {
1604 return mTimeStep;
1605 }
1606
1607
1608//------------------------------------------------------------------------------
1609
1610 inline void
1611 Mesh::set_time_step( const uint aTimeStep )
1612 {
1613 mTimeStep = aTimeStep;
1614 }
1615
1616//------------------------------------------------------------------------------
1617
1618 inline void
1620 {
1621 mConnectivities.set( static_cast<index_t>( aConnectivity ));
1622 }
1623
1624//------------------------------------------------------------------------------
1625
1626 inline void
1628 {
1629 mConnectivities.reset( static_cast<index_t>( aConnectivity ));
1630 }
1631
1632//------------------------------------------------------------------------------
1633
1634 inline bool
1636 {
1637 return mConnectivities.test( static_cast<index_t>( aConnectivity ));
1638 }
1639
1640//------------------------------------------------------------------------------
1641
1642 inline const proc_t &
1644 {
1645 return mMasterProc;
1646 }
1647
1648//------------------------------------------------------------------------------
1649
1650 inline void
1651 Mesh::set_number_of_partitions( const proc_t & aNumberOfPartitions )
1652 {
1653 mNumberOfPartitions = aNumberOfPartitions;
1654 }
1655
1656//------------------------------------------------------------------------------
1657
1658 inline bool
1659 Mesh::block_exists( const id_t aID ) const
1660 {
1661 return mBlockMap.key_exists( aID );
1662 }
1663
1664//------------------------------------------------------------------------------
1665
1666 inline bool
1667 Mesh::sideset_exists( const id_t aID ) const
1668 {
1669 return mSideSetMap.key_exists( aID );
1670 }
1671
1672//------------------------------------------------------------------------------
1673
1674 inline bool
1675 Mesh::node_exists( const id_t aID ) const
1676 {
1677 return mNodeMap.key_exists( aID );
1678 }
1679
1680//------------------------------------------------------------------------------
1681
1682 inline bool
1684 {
1685 return mEdges.size() > 0 ;
1686 }
1687
1688//------------------------------------------------------------------------------
1689
1690 inline bool
1692 {
1693 return mFaces.size() > 0 ;
1694 }
1695
1696//------------------------------------------------------------------------------
1697
1698 inline const uint &
1700 {
1701 return mMaxElementOrder;
1702 }
1703
1704//------------------------------------------------------------------------------
1705
1706 inline Cell< mesh::Node * > &
1708 {
1709 return mNodes;
1710 }
1711
1712//------------------------------------------------------------------------------
1713
1714 inline Cell< mesh::Block * > &
1716 {
1717 return mBlocks;
1718 }
1719
1720
1721//------------------------------------------------------------------------------
1722
1725 {
1726 return mSideSets;
1727 }
1728
1729//------------------------------------------------------------------------------
1730
1731 inline Cell< mesh::Curve * > &
1733 {
1734 return mCurves;
1735 }
1736
1737//------------------------------------------------------------------------------
1738
1739 inline mesh::Curve *
1740 Mesh::curve( const id_t aID )
1741 {
1742 return mCurveMap( aID );
1743 }
1744
1745
1746//------------------------------------------------------------------------------
1747
1750 {
1751 return mThinShells;
1752 }
1753
1754//------------------------------------------------------------------------------
1755
1758 {
1759 return mElements;
1760 }
1761
1762//------------------------------------------------------------------------------
1763
1764 inline Cell< mesh::Facet * > &
1766 {
1767 return mFacets ;
1768 }
1769
1772 {
1773 return mControlPoints;
1774 }
1775
1776//------------------------------------------------------------------------------
1777
1778 inline Cell< mesh::Edge * > &
1780 {
1781 return mEdges ;
1782 }
1783
1784//------------------------------------------------------------------------------
1785
1786 inline Cell< mesh::Face * > &
1788 {
1789 return mFaces ;
1790 }
1791
1792//------------------------------------------------------------------------------
1793
1796 {
1797 return mBoundaryEdges;
1798 }
1799
1800//------------------------------------------------------------------------------
1801
1804 {
1805 return mVertices;
1806 }
1807
1808//------------------------------------------------------------------------------
1809
1810 inline void
1812 {
1813 mIsKernelMesh = true ;
1814 }
1815
1816//------------------------------------------------------------------------------
1817
1818 inline bool
1820 {
1821 return mIsKernelMesh ;
1822 }
1823
1824//------------------------------------------------------------------------------
1825
1826 inline Cell< mesh::Node * > &
1828 {
1829 return mAutoPins ;
1830 }
1831
1832//------------------------------------------------------------------------------
1833
1834 inline Cell< mesh::Node * > &
1836 {
1837 return mAbstractNodes ;
1838 }
1839
1840//------------------------------------------------------------------------------
1841
1842 inline Cell< mesh::Node * > &
1844 {
1845 return mOrphanedNodes ;
1846 }
1847
1848//------------------------------------------------------------------------------
1849
1850 inline mesh::Basis *
1851 Mesh::basis_by_index( const EntityType aType, const index_t aIndex )
1852 {
1853 switch ( aType )
1854 {
1855 case EntityType::NODE :
1856 {
1857 return mNodes( aIndex );
1858 }
1859 case EntityType::EDGE :
1860 {
1861 return mEdges( aIndex );
1862 }
1863 case EntityType::FACE :
1864 {
1865 return mFaces( aIndex );
1866 }
1867 case EntityType::ELEMENT :
1868 {
1869 return mElements( aIndex );
1870 }
1871 case EntityType::FACET :
1872 {
1873 return mFacets( aIndex );
1874 }
1876 {
1877 return mControlPoints( aIndex );
1878 }
1879 default:
1880 {
1881 BELFEM_ERROR( false, "Invalid entity type" );
1882 return nullptr;
1883 }
1884 }
1885
1886 }
1887
1888 inline mesh::Basis* Mesh::basis( const EntityType aType, const id_t aID )
1889 {
1890 switch ( aType )
1891 {
1892 case EntityType::NODE :
1893 {
1894 return this->node( aID );
1895 }
1896 case EntityType::EDGE :
1897 {
1898 return this->edge( aID );
1899 }
1900 case EntityType::FACE :
1901 {
1902 return this->face( aID );
1903 }
1904 case EntityType::ELEMENT :
1905 {
1906 return this->element( aID );
1907 }
1908 case EntityType::FACET :
1909 {
1910 return this->facet( aID );
1911 }
1913 {
1914 return this->control_point( aID );
1915 }
1916 default:
1917 {
1918 BELFEM_ERROR( false, "Invalid entity type" );
1919 return nullptr;
1920 }
1921 }
1922 }
1923
1924 inline void
1929
1930 inline bool
1932 {
1933 return mIsFinalized ;
1934 }
1935
1936 inline bool
1938 {
1939 return mEdgesAreFinalized ;
1940 }
1941
1942
1943 inline bool
1945 {
1946 return mFacesAreFinalized ;
1947 }
1948
1949
1950//------------------------------------------------------------------------------
1951
1958
1959 inline index_t
1969
1970
1971 inline void
1973 {
1974 BELFEM_ASSERT( mPeriodicity == nullptr, "Periodicity object has already been set for this mesh" );
1975 mPeriodicity = aPeriodicity;
1976 }
1977
1978 inline bool
1980 {
1981 return mPeriodicity != nullptr;
1982 }
1983
1984 inline mesh::Periodicity *
1986 {
1987 BELFEM_ASSERT( mPeriodicity != nullptr, "Periodicity object has not been set for this mesh" );
1988
1989 return mPeriodicity;
1990 }
1991
1992
1993 inline void
1995 {
1996 mMeshCheckerFlag = true;
1997 }
1998
1999 inline void
2004
2005 inline bool
2007 {
2008 return mMeshCheckerFlag;
2009 }
2010
2011
2012 namespace mesh
2013 {
2014 template< typename T >
2015 void
2016 collect_hanging_basis( Cell< T * > & aBasis, Cell< T * > & aHangingBasis )
2017 {
2018 index_t tCount = 0 ;
2019 for( T * tBasis : aBasis )
2020 {
2021 if( tBasis->is_hanging() )
2022 {
2023 ++tCount ;
2024 }
2025 }
2026
2027 if( tCount == 0 )
2028 {
2029 aHangingBasis.clear();
2030 }
2031 else
2032 {
2033 aHangingBasis.set_size( tCount, nullptr );
2034 tCount = 0;
2035 for ( T * tBasis: aBasis )
2036 {
2037 if ( tBasis->is_hanging())
2038 {
2039 aHangingBasis( tCount++ ) = tBasis;
2040 }
2041 }
2042 }
2043 }
2044
2045//------------------------------------------------------------------------------
2046
2047//------------------------------------------------------------------------------
2048 }
2049}
2050
2051#endif //BELFEM_CL_MESH_HPP
#define BELFEM_ERROR(aCheck,...)
Definition assert.hpp:264
#define BELFEM_ASSERT(aCheck,...)
Definition assert.hpp:244
void reset(const index_t aIndex)
set a bit to false
Definition cl_Bitset.hpp:103
void set(const index_t aIndex)
set a bit to true
Definition cl_Bitset.hpp:92
bool test(const index_t aIndex) const
test if a bit is set
Definition cl_Bitset.hpp:138
Bitset()=default
trivial constructor
A bounds-checked wrapper around std::vector.
Definition cl_Cell.hpp:45
void set_size(const size_t aSize)
New elements are value-initialized ( zero for arithmetic T, nullptr for pointers ).
Definition cl_Cell.hpp:199
size_t size() const
Definition cl_Cell.hpp:189
void clear()
Empties the Cell.
Definition cl_Cell.hpp:249
Incremental hash computation.
Definition cl_Hash.hpp:29
Hash map (unordered key-value).
Definition cl_Map.hpp:75
bool key_exists(const Key &aKey) const
Definition cl_Map.hpp:161
Top-level container for all mesh entities.
Definition cl_Mesh.hpp:60
Cell< mesh::Element * > mHangingElements
Definition cl_Mesh.hpp:101
Cell< mesh::ControlPoint * > & control_points()
Owned and deleted by the mesh.
Definition cl_Mesh.hpp:1771
Cell< mesh::Edge * > mHangingEdges
Definition cl_Mesh.hpp:98
mesh::Field * field(const string &aLabel)
get field by label
Definition cl_Mesh.hpp:1500
void update_facet_indices()
Definition cl_Mesh.cpp:433
const proc_t mCommSize
Definition cl_Mesh.hpp:68
bool mEdgesAreFinalized
Definition cl_Mesh.hpp:150
Cell< mesh::Element * > & vertices()
Owned and deleted by the mesh.
Definition cl_Mesh.hpp:1803
void set_kernel_flag()
called by kernel
Definition cl_Mesh.hpp:1811
void set_periodicity(mesh::Periodicity *aPeriodicity)
The mesh takes ownership and deletes aPeriodicity.
Definition cl_Mesh.hpp:1972
bool mesh_checker_flag() const
Definition cl_Mesh.hpp:2006
Cell< mesh::Curve * > & curves()
Owned and deleted by the mesh.
Definition cl_Mesh.hpp:1732
void update_sideset_map()
Definition cl_Mesh.cpp:2347
void unflag_all_nodes(const uint aFlagIndex=0)
Definition cl_Mesh.cpp:1018
Map< id_t, mesh::Element * > mElementMap
Definition cl_Mesh.hpp:132
Cell< mesh::Facet * > mFacets
Definition cl_Mesh.hpp:87
void add_sideset(mesh::SideSet *aSideSet)
Takes ownership of aSideSet: ~Mesh deletes the sideset and, through it, its facets.
Definition cl_Mesh.cpp:2162
Cell< mesh::Node * > & hanging_nodes()
Returns views of entities the mesh owns through the containers below.
Definition cl_Mesh.hpp:1952
index_t number_of_faces() const
Definition cl_Mesh.hpp:1271
void set_vertex_owners()
Definition cl_Mesh.cpp:1628
Map< id_t, mesh::GlobalVariable * > mGlobalVariableIDMap
Definition cl_Mesh.hpp:113
Cell< mesh::ControlPoint * > mHangingControlPoints
Definition cl_Mesh.hpp:102
Map< id_t, mesh::ControlPoint * > mControlPointMap
Definition cl_Mesh.hpp:139
void create_edge_map()
special function called by Kernel
Definition cl_Mesh.cpp:1520
mesh::Edge * edge(const id_t aID)
Definition cl_Mesh.hpp:1336
void update_element_indices()
Definition cl_Mesh.cpp:446
void update_element_map()
Definition cl_Mesh.cpp:2324
const uint & time_step() const
The current timestep index.
Definition cl_Mesh.hpp:1596
bool facet_exists(const id_t aID) const
Definition cl_Mesh.hpp:1436
proc_t mNumberOfPartitions
Definition cl_Mesh.hpp:117
Cell< mesh::Node * > & autopins()
Definition cl_Mesh.hpp:1827
void create_curve_map()
Definition cl_Mesh.cpp:2678
index_t number_of_facets() const
Definition cl_Mesh.hpp:1255
void unflag_all_control_points(const uint aFlagIndex=0)
Definition cl_Mesh.cpp:1169
Cell< mesh::Block * > mBlocks
Definition cl_Mesh.hpp:104
Cell< mesh::Face * > & faces()
Owned and deleted by the mesh.
Definition cl_Mesh.hpp:1787
Cell< mesh::Element * > mVertices
Definition cl_Mesh.hpp:88
Cell< mesh::Element * > mBoundaryEdges
Definition cl_Mesh.hpp:95
index_t number_of_elements() const
Definition cl_Mesh.hpp:1247
void compute_facet_orientations()
Definition cl_Mesh.cpp:713
bool node_exists(const id_t aID) const
Definition cl_Mesh.hpp:1675
uint load_meta(hid_t aFile)
Definition cl_Mesh.cpp:2876
void populate_element_neighbors()
Definition cl_Mesh.cpp:2532
Map< id_t, mesh::Node * > mNodeMap
Definition cl_Mesh.hpp:131
void finalize_faces()
Definition cl_Mesh.cpp:961
void update_block_map()
Definition cl_Mesh.cpp:2337
void unflag_all_faces(const uint aFlagIndex=0)
Definition cl_Mesh.cpp:1076
void update_facet_nodes()
Definition cl_Mesh.cpp:628
Cell< mesh::Facet * > mHangingFacets
Definition cl_Mesh.hpp:100
bool global_variable_exists(const string &aLabel)
Definition cl_Mesh.hpp:1564
uint mNumberOfGlobalVariables
Definition cl_Mesh.hpp:120
void save_meta(hid_t aFile, const uint aRunningTimestep=0)
Definition cl_Mesh.cpp:2859
void save_globals(hid_t aFile)
Definition cl_Mesh.cpp:2932
bool mMeshCheckerFlag
Definition cl_Mesh.hpp:174
void distribute_edge_directions()
Collective and asymmetric: every rank must enter; rank 0 distributes the per-owner edge signs,...
Definition cl_Mesh.cpp:1764
void set_time_step(const uint aTimeStep)
set the index of the time step
Definition cl_Mesh.hpp:1611
void collect_facets_from_sidesets()
Definition cl_Mesh.cpp:597
Cell< mesh::SideSet * > & sidesets()
The mesh owns the sidesets; a sideset owns and deletes its facets.
Definition cl_Mesh.hpp:1724
uint number_of_fields() const
Definition cl_Mesh.hpp:1572
const string & path() const
Definition cl_Mesh.hpp:1199
Vector< real > & field_data(const string &aLabel)
Definition cl_Mesh.hpp:1520
Map< id_t, mesh::Block * > mBlockMap
Definition cl_Mesh.hpp:134
uint64_t config_tag() const
Definition cl_Mesh.cpp:2268
const proc_t mMasterProc
Definition cl_Mesh.hpp:66
uint number_of_sidesets() const
Definition cl_Mesh.hpp:1295
Cell< mesh::Facet * > & facets()
A flat list of the facets of all sidesets.
Definition cl_Mesh.hpp:1765
id_t max_block_and_sideset_id()
Definition cl_Mesh.cpp:2116
uint number_of_dimensions() const
Definition cl_Mesh.hpp:1223
Cell< mesh::Node * > mAbstractNodes
Definition cl_Mesh.hpp:165
void save(const string &aFilePath)
Master rank only, a no-op elsewhere; the mesh must be finalized.
Definition cl_Mesh.cpp:316
void update_node_indices()
Definition cl_Mesh.cpp:397
void unflag_all_elements(const uint aFlagIndex=0)
Definition cl_Mesh.cpp:1132
void update_face_indices()
Definition cl_Mesh.cpp:421
index_t number_of_edges() const
Definition cl_Mesh.hpp:1263
bool block_exists(const id_t aID) const
Definition cl_Mesh.hpp:1659
Cell< mesh::ThinShell * > & thin_shells()
Owned and deleted by the mesh.
Definition cl_Mesh.hpp:1749
id_t max_element_id()
Definition cl_Mesh.cpp:2061
void set_compute_facet_orientation_flag(const bool aFlag)
Definition cl_Mesh.hpp:1925
void load_globals(hid_t aFile)
Definition cl_Mesh.cpp:2956
void collect_elements_from_blocks()
Definition cl_Mesh.cpp:563
void reset_connectivity(const Connectivity aConnectivity)
Definition cl_Mesh.hpp:1627
bool mIsKernelMesh
flag telling if this is a mesh on the kernel
Definition cl_Mesh.hpp:146
bool edges_exist() const
tells if Nedelec edges exist on this mesh
Definition cl_Mesh.hpp:1683
Cell< mesh::Node * > mOrphanedNodes
Definition cl_Mesh.hpp:166
const TensorMeshConfig * mTensorConfig
Definition cl_Mesh.hpp:170
void update_edge_indices()
Definition cl_Mesh.cpp:409
real & create_global_variable(const string &aLabel, const real aValue=0.0, const id_t aID=0)
Definition cl_Mesh.cpp:524
mesh::Periodicity * mPeriodicity
Definition cl_Mesh.hpp:172
mesh::Block * block(const id_t aID)
Definition cl_Mesh.hpp:1456
string mPath
Definition cl_Mesh.hpp:83
void update_vertex_indices()
Definition cl_Mesh.cpp:458
Bitset< static_cast< size_t >(Connectivity::UNDEFINED)> mConnectivities
Definition cl_Mesh.hpp:168
void set_number_of_partitions(const proc_t &aNumberOfPartitions)
to be called by partitioner
Definition cl_Mesh.hpp:1651
uint mNumberOfFields
Definition cl_Mesh.hpp:121
mesh::Curve * curve(const id_t aID)
return a curve by its ID
Definition cl_Mesh.hpp:1740
bool mNodesAreSorted
Definition cl_Mesh.hpp:154
Cell< mesh::Block * > & blocks()
The mesh owns the blocks; a block owns and deletes its elements.
Definition cl_Mesh.hpp:1715
Vector< real > & create_field(const string &aLabel, const EntityType aEntity=EntityType::NODE, const id_t aID=0)
Definition cl_Mesh.cpp:481
mesh::Basis * basis_by_index(const EntityType aType, const index_t aIndex)
Definition cl_Mesh.hpp:1851
bool has_periodicity() const
Definition cl_Mesh.hpp:1979
bool edges_are_finalized() const
Definition cl_Mesh.hpp:1937
void reset_faces()
Definition cl_Mesh.cpp:1381
mesh::SideSet * sideset(const id_t aID)
Definition cl_Mesh.hpp:1468
Map< id_t, mesh::Edge * > mEdgeMap
Definition cl_Mesh.hpp:137
bool mFacesAreFinalized
Definition cl_Mesh.hpp:151
real mTimeStamp
Definition cl_Mesh.hpp:123
mesh::Node * node(const id_t aID)
Definition cl_Mesh.hpp:1303
bool is_kernel_mesh() const
Definition cl_Mesh.hpp:1819
Cell< mesh::Node * > & nodes()
The nodes.
Definition cl_Mesh.hpp:1707
bool is_finalized() const
Definition cl_Mesh.hpp:1931
Cell< mesh::Element * > & hanging_elements()
Definition cl_Mesh.hpp:1956
mesh::Element * vertex(const id_t aID)
Definition cl_Mesh.hpp:1480
void create_face_map()
special function called by Kernel
Definition cl_Mesh.cpp:1533
mesh::GlobalVariable * global_variable(const id_t aID)
Definition cl_Mesh.hpp:1539
real & time_stamp()
Writable reference to the current time [s].
Definition cl_Mesh.hpp:1588
void collect_elements_from_group(Cell< mesh::Element * > &aElements, const id_t aGroupId, const ElementType aType=ElementType::EMPTY)
Definition cl_Mesh.cpp:661
Map< string, mesh::GlobalVariable * > mGlobalVariableMap
Definition cl_Mesh.hpp:112
std::size_t checksum()
Definition cl_Mesh.cpp:2239
void unfinalize()
unfinalizes all aspects of mesh but edges
Definition cl_Mesh.cpp:819
void save_fields(hid_t aFile)
Definition cl_Mesh.cpp:2914
void create_faces(const bool aPrint=false, const Vector< id_t > aNedelecBlocks=Vector< id_t >(), const Vector< id_t > aNedelecSideSets=Vector< id_t >())
creates the faces on the mesh
Definition cl_Mesh.cpp:1436
void expand_hanging_basis_sources()
Definition cl_Mesh.cpp:2009
void unflag_all_edges(const uint aFlagIndex=0)
Definition cl_Mesh.cpp:1045
bool faces_exist() const
tells if Nedelec faces exist on this mesh
Definition cl_Mesh.hpp:1691
bool faces_are_finalized() const
Definition cl_Mesh.hpp:1944
mesh::Periodicity * periodicity()
Definition cl_Mesh.hpp:1985
uint number_of_blocks() const
Definition cl_Mesh.hpp:1287
void set_number_of_dimensions(const uint &aNumberOfDimensions)
Definition cl_Mesh.hpp:1231
size_t memory() const
Compute the total memory used by the mesh in bytes.
Definition cl_Mesh.cpp:2690
const proc_t mCommRank
Definition cl_Mesh.hpp:67
bool sideset_exists(const id_t aID) const
Definition cl_Mesh.hpp:1667
Map< id_t, mesh::Facet * > mFacetMap
Definition cl_Mesh.hpp:133
void create_edges(const bool aPrint=false, const Vector< id_t > aNedelecBlocks=Vector< id_t >(), const Vector< id_t > aNedelecSideSets=Vector< id_t >(), const bool aCreateEdgesOnAllSideSets=true)
creates the edges on the mesh
Definition cl_Mesh.cpp:1303
uint number_of_global_variables() const
Definition cl_Mesh.hpp:1580
Cell< mesh::Face * > mFaces
Definition cl_Mesh.hpp:90
void partition(const uint &aNumberOfPartitions, const bool aSetProcOwners=true, const bool aForceContinuousPartitions=true, const bool aResetVertexContainers=true)
Only the master rank partitions the mesh and sets the element and node ownerships.
Definition cl_Mesh.cpp:1180
uint mNumberOfDimensions
Definition cl_Mesh.hpp:119
Cell< mesh::Field * > mFields
Definition cl_Mesh.hpp:110
Cell< mesh::Element * > & elements()
A flat list of the elements of all blocks.
Definition cl_Mesh.hpp:1757
string mConfigText
Definition cl_Mesh.hpp:81
void unflag_all_facets(const uint aFlagIndex=0)
Definition cl_Mesh.cpp:1106
mesh::Facet * facet(const id_t aID)
Definition cl_Mesh.hpp:1444
const TensorMeshConfig * tensorconf() const
Definition cl_Mesh.hpp:1215
void save_faces(const string &aPath)
Definition cl_Mesh.cpp:1851
Cell< mesh::GlobalVariable * > & global_variables()
Definition cl_Mesh.hpp:1531
Map< id_t, mesh::Element * > mVertexMap
Definition cl_Mesh.hpp:136
void scale_mesh(const real aFactor)
Multiplies the node and control-point coordinates by aFactor, e.g.
Definition cl_Mesh.cpp:278
uint mMaxElementOrder
Definition cl_Mesh.hpp:143
mesh::Element * element(const id_t aID)
Definition cl_Mesh.hpp:1368
Map< id_t, mesh::Curve * > mCurveMap
Definition cl_Mesh.hpp:140
bool field_exists(const string &aLabel)
Definition cl_Mesh.hpp:1511
Cell< mesh::SideSet * > mSideSets
Definition cl_Mesh.hpp:105
void reset_mesh_checker_flag()
Definition cl_Mesh.hpp:2000
void update_control_point_indices()
Definition cl_Mesh.cpp:470
void set_connectivity(const Connectivity aConnectivity)
Definition cl_Mesh.hpp:1619
mesh::Basis * basis(const EntityType aType, const id_t aID)
Definition cl_Mesh.hpp:1888
const proc_t & master() const
return the ID of the proc that owns this mesh
Definition cl_Mesh.hpp:1643
mesh::Face * face(const id_t aID)
Definition cl_Mesh.hpp:1348
Cell< mesh::ControlPoint * > mControlPoints
Definition cl_Mesh.hpp:91
Map< string, mesh::Field * > mFieldMap
Definition cl_Mesh.hpp:114
void reset_edges()
Definition cl_Mesh.cpp:1326
Cell< mesh::Node * > mHangingNodes
Definition cl_Mesh.hpp:97
Cell< mesh::Node * > & orphaned_nodes()
Definition cl_Mesh.hpp:1843
Cell< mesh::Curve * > mCurves
Definition cl_Mesh.hpp:106
void set_mesh_checker_flag()
Definition cl_Mesh.hpp:1994
void set_abstract_nodes(Cell< mesh::Node * > &aNodes)
Adopts the nodes.
Definition cl_Mesh.cpp:2182
Hash mHash
Definition cl_Mesh.hpp:73
Cell< mesh::Edge * > mEdges
Definition cl_Mesh.hpp:89
index_t number_of_control_points() const
Definition cl_Mesh.hpp:1279
Mesh(const uint aNumberOfDimensions, const proc_t aMasterProc=0, const bool aComputeConnectivities=true)
creates an empty mesh container but specifies number of dimension
Definition cl_Mesh.cpp:82
void finalize()
finalizes all aspects of the mesh; edges and faces are finalized too when connectivities are computed
Definition cl_Mesh.cpp:726
mesh::ControlPoint * control_point(const id_t aID)
Definition cl_Mesh.hpp:1402
Cell< mesh::ControlPoint * > & hanging_control_points()
Definition cl_Mesh.hpp:1957
Cell< mesh::Face * > & hanging_faces()
Definition cl_Mesh.hpp:1954
const string & config_text() const
Definition cl_Mesh.cpp:2276
Cell< mesh::GlobalVariable * > mGlobalVariables
Definition cl_Mesh.hpp:109
void flag_curved_elements()
flags elements that are curved
Definition cl_Mesh.cpp:1700
void load_fields(hid_t aFile)
Definition cl_Mesh.cpp:3001
uint64_t mConfigTag
Definition cl_Mesh.hpp:80
void finalize_edges()
Definition cl_Mesh.cpp:914
bool test_connectivity(const Connectivity aConnectivity)
Definition cl_Mesh.hpp:1635
Cell< mesh::Node * > & abstract_nodes()
Definition cl_Mesh.hpp:1835
void collect_hanging_basis()
Definition cl_Mesh.cpp:1997
Cell< mesh::Node * > mNodes
Definition cl_Mesh.hpp:86
real & global_variable_data(const string &aLabel)
Definition cl_Mesh.hpp:1555
id_t max_node_id()
Definition cl_Mesh.cpp:2045
Cell< mesh::Node * > mAutoPins
Definition cl_Mesh.hpp:164
void update_ownerships()
Definition cl_Mesh.cpp:1560
Cell< mesh::ThinShell * > mThinShells
Definition cl_Mesh.hpp:107
Map< id_t, mesh::SideSet * > mSideSetMap
Definition cl_Mesh.hpp:135
const uint & max_element_order() const
return the max interpolation order on the mesh
Definition cl_Mesh.hpp:1699
uint mTimeStep
Definition cl_Mesh.hpp:124
void unflag_everything(const uint aFlagIndex=0)
Definition cl_Mesh.cpp:1004
bool element_exists(const id_t aID) const
Definition cl_Mesh.hpp:1360
Cell< mesh::Face * > mHangingFaces
Definition cl_Mesh.hpp:99
void unflag_all_vertices(const uint aFlagIndex=0)
Definition cl_Mesh.cpp:1158
bool is_tensormesh() const
Definition cl_Mesh.hpp:1207
bool mComputeFacetOrientationsWhenFinalizing
Definition cl_Mesh.hpp:157
index_t number_of_hanging_basis() const
Definition cl_Mesh.hpp:1960
Cell< mesh::Edge * > & hanging_edges()
Definition cl_Mesh.hpp:1953
Cell< mesh::Element * > & boundary_edges()
The line elements of a 3D Gmsh mesh; owned and deleted by the mesh.
Definition cl_Mesh.hpp:1795
bool mIsFinalized
flag telling if mesh is finalized (master only)
Definition cl_Mesh.hpp:149
void add_block(mesh::Block *aBlock)
Takes ownership of aBlock: ~Mesh deletes the block and, through it, its elements.
Definition cl_Mesh.cpp:2153
void set_config_tag(const uint64_t aTag, const string &aText)
Definition cl_Mesh.cpp:2259
Cell< mesh::Facet * > & hanging_facets()
Definition cl_Mesh.hpp:1955
Map< id_t, mesh::Face * > mFaceMap
Definition cl_Mesh.hpp:138
index_t number_of_nodes() const
Definition cl_Mesh.hpp:1239
Cell< mesh::Element * > mElements
Definition cl_Mesh.hpp:85
Cell< mesh::Edge * > & edges()
Owned and deleted by the mesh.
Definition cl_Mesh.hpp:1779
void force_checksum(const std::size_t aChecksum)
Definition cl_Mesh.cpp:2251
Mesh * extract_thin_shell_mesh()
Returns a newly allocated mesh the caller owns and deletes.
Definition cl_Mesh.cpp:2436
Definition cl_TensorMeshConfig.hpp:22
uint num_control_points(const uint aDimension=BELFEM_UINT_MAX) const
Definition cl_TensorMeshConfig.hpp:124
index_t node_index(const index_t i, const index_t j) const
Definition cl_TensorMeshConfig.hpp:155
index_t element_index(const index_t i, const index_t j) const
Definition cl_TensorMeshConfig.hpp:175
Definition cl_Mesh_Basis.hpp:33
Definition cl_Block.hpp:27
Definition cl_ControlPoint.hpp:27
Definition cl_Curve.hpp:27
Special Edge class for NEDELEC-Type elements.
Definition cl_Edge.hpp:30
Lagrange Element baseclass.
Definition cl_Element.hpp:35
Definition cl_Face.hpp:29
Definition cl_Facet.hpp:24
Definition cl_Mesh_Field.hpp:28
Definition cl_Mesh_GlobalVariable.hpp:24
Definition cl_Mesh_GmshReader.hpp:40
Creates a Periodicity object by matching nodes on two periodic boundary planes.
Definition cl_Mesh_PeriodicityFactory.hpp:34
Stores matched periodic boundary entity pairs (nodes, edges, faces).
Definition cl_Mesh_Periodicity.hpp:39
Definition cl_ProtoMesh.hpp:39
Definition cl_SideSet.hpp:29
Definition cl_EF_EdgeFunction.hpp:24
void collect_hanging_basis(Cell< T * > &aBasis, Cell< T * > &aHangingBasis)
Definition cl_Mesh.hpp:2016
uint compute_facet_index(Facet *aFacet, Element *aElement, Cell< Node * > &aNodes)
Definition cl_Mesh.cpp:46
USER GUIDES:
Definition cl_Capacitor.cpp:16
int hid_t
Definition hdf5_types.hpp:20
unsigned int uint
Definition typedefs.hpp:30
unsigned int id_t
Definition typedefs.hpp:41
Connectivity
Definition Mesh_Enums.hpp:145
@ UNDEFINED
Definition Mesh_Enums.hpp:182
int proc_t
Definition commtypes.hpp:29
ElementType
Element types.
Definition Mesh_Enums.hpp:27
@ EMPTY
Definition Mesh_Enums.hpp:28
EntityType
Definition Mesh_Enums.hpp:116
@ NODE
Definition Mesh_Enums.hpp:117
@ FACE
Definition Mesh_Enums.hpp:119
@ CONTROLPOINT
Definition Mesh_Enums.hpp:123
@ EDGE
Definition Mesh_Enums.hpp:118
@ FACET
Definition Mesh_Enums.hpp:121
@ ELEMENT
Definition Mesh_Enums.hpp:122
uint32_t index_t
Definition typedefs.hpp:52
double real
Definition typedefs.hpp:36
Definition Element.py:1
Definition GmshReader.py:1
Definition Node.py:1
Definition __init__.py:1