BELFEM 0.9.0
Berkeley Lab Finite Element Framework
Loading...
Searching...
No Matches
cl_Facet.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_FACET_HPP
13#define BELFEM_CL_FACET_HPP
14
15#include "typedefs.hpp"
16#include "cl_Cell.hpp"
17#include "cl_Element.hpp"
18
19namespace belfem
20{
21 namespace mesh
22 {
23 class Facet : public Vertex
24 {
25 // wrapped element
26 Element * mElement;
27
28 // master element for facet
29 Element * mMaster = nullptr;
30
31 // slave element for facet
32 Element * mSlave = nullptr;
33
34 // periodic partner
35 Facet * mPeriodic = nullptr ;
36
37 // id on master element
38 suint mMasterFaceID = BELFEM_SUINT_MAX;
39
40 // id on slave element
41 suint mSlaveFaceID = BELFEM_SUINT_MAX;
42
43 // orientation on slave element
44 suint mOrientationOnSlave = BELFEM_SUINT_MAX ;
45
46//------------------------------------------------------------------------------
47 public:
48//------------------------------------------------------------------------------
49
50 Facet( Element * aElement );
51
52//------------------------------------------------------------------------------
53
54 ~Facet() override;
55
56//------------------------------------------------------------------------------
57
59 entity_type() const override ;
60
61//------------------------------------------------------------------------------
62
66 Element *
67 element();
68
69 const Element *
70 element() const;
71
72//------------------------------------------------------------------------------
73
77 const Element *
78 element( const uint aIndex ) const override ;
79
80//------------------------------------------------------------------------------
81
82 id_t
83 master_id() const;
84
85//------------------------------------------------------------------------------
86
87 id_t
88 slave_id() const;
89
90//------------------------------------------------------------------------------
91
92 auto
93 index_on_master() const -> decltype( mMasterFaceID );
94
95//------------------------------------------------------------------------------
96
97 auto
98 index_on_slave() const -> decltype( mSlaveFaceID );
99
100//------------------------------------------------------------------------------
101
105 Node *
106 node( uint aIndex ) override ;
107
108 const Node *
109 node( uint aIndex ) const override ;
110
111//------------------------------------------------------------------------------
112
116 uint
117 number_of_nodes() const override ;
118
119//------------------------------------------------------------------------------
120
124 uint
125 number_of_corner_nodes() const ;
126
127//------------------------------------------------------------------------------
128
132 uint
133 number_of_edges() const override ;
134
135 Edge *
136 edge( const uint aIndex ) override ;
137
138 const Edge *
139 edge( const uint aIndex ) const override ;
140
141 Face *
142 face( const uint aIndex=0 ) override ;
143
144 const Face *
145 face( const uint aIndex=0 ) const override ;
146
147//------------------------------------------------------------------------------
148
152 void
153 unflag_nodes( const uint8_t aIndex=0 ) override ;
154
155//------------------------------------------------------------------------------
156
160 void
161 flag_nodes( const uint8_t aIndex=0 ) override ;
162
163//------------------------------------------------------------------------------
164
168 void
170
171//------------------------------------------------------------------------------
172
176 void
178
179//------------------------------------------------------------------------------
180
184 void
186
187//------------------------------------------------------------------------------
188
189 void
190 set_owner( const proc_t aOwner ) override ;
191
192//------------------------------------------------------------------------------
193
194 proc_t
195 owner() const override ;
196
197//------------------------------------------------------------------------------
198
199 void
200 set_master( Element * aElement, const uint aIndex, const bool aLinkNodes=true );
201
202//------------------------------------------------------------------------------
203
204 void
205 set_slave( Element * aElement, const uint aIndex );
206
207//------------------------------------------------------------------------------
208
209 void
210 set_slave( Element * aElement, const uint aIndex, const uint aOrientation );
211
212//------------------------------------------------------------------------------
213
214 void
216
217//------------------------------------------------------------------------------
218
219 bool
220 has_master() const;
221
222//------------------------------------------------------------------------------
223
224 bool
225 has_slave() const;
226
227//------------------------------------------------------------------------------
228
229 Element *
230 master();
231
232 const Element *
233 master() const ;
234
235
236//------------------------------------------------------------------------------
237
238 Element *
239 slave();
240
241 const Element *
242 slave() const ;
243
244//------------------------------------------------------------------------------
245
246 uint
247 number_of_elements() const override ;
248
249//------------------------------------------------------------------------------
250
251 Element *
252 element( const uint aIndex ) override ;
253
254//------------------------------------------------------------------------------
255
256 void
257 flag( const uint8_t aIndex = 0 ) override ;
258
259//------------------------------------------------------------------------------
260
261 void
262 unflag( const uint8_t aIndex = 0 ) override ;
263
264//------------------------------------------------------------------------------
265
266 bool
267 is_flagged( const uint8_t aIndex = 0 ) const override;
268
269//------------------------------------------------------------------------------
270
271 void
272 set_index( const index_t aIndex ) override ;
273
274//------------------------------------------------------------------------------
275
276 index_t
277 index() const override ;
278
279//------------------------------------------------------------------------------
280
281 void
282 flip();
283
284//------------------------------------------------------------------------------
285
286 void
288
289//------------------------------------------------------------------------------
290
291 uint
292 orientation_on_slave() const ;
293
294//----------------------------------------------------------------------------
295
296 bool
297 is_curved() const ;
298
299//----------------------------------------------------------------------------
300
301 id_t
302 sideset_id() const ;
303
304//----------------------------------------------------------------------------
305
306 void
307 set_sideset_id( const id_t aSidesetID ) ;
308
309//-----------------------------------------------------------------------------
310
311 uint
312 physical_tag() const ;
313
314//-----------------------------------------------------------------------------
315
316 void
317 set_physical_tag( const uint aTag );
318
319//-----------------------------------------------------------------------------
320
321 void
322 set_facet_counter( const uint aCount );
323
324//-----------------------------------------------------------------------------
325
326 void
327 set_periodic( Facet * aFacet );
328
329//-----------------------------------------------------------------------------
330
331 Facet *
332 periodic();
333
334 const Facet *
335 periodic() const ;
336
337 bool
338 is_periodic() const ;
339
340//-----------------------------------------------------------------------------
341
342 size_t
343 memory() const ;
344
345//-----------------------------------------------------------------------------
346 };
347
348//------------------------------------------------------------------------------
349
350 inline
353 {
354 return EntityType::FACET ;
355 }
356
357//------------------------------------------------------------------------------
358
359 inline
360 Element *
362 {
363 return mElement;
364 }
365
366 inline
367 const Element *
369 {
370 return mElement;
371 }
372
373//------------------------------------------------------------------------------
374
375 inline Node *
377 {
378 return mElement->node( aIndex );
379 }
380
381 inline const Node *
382 Facet::node( uint aIndex ) const
383 {
384 return mElement->node( aIndex );
385 }
386
387//------------------------------------------------------------------------------
388
389 inline uint
391 {
392 return mElement->number_of_nodes();
393 }
394
395//------------------------------------------------------------------------------
396
397 inline uint
399 {
400 return mElement->number_of_corner_nodes();
401 }
402
403//------------------------------------------------------------------------------
404
405 inline uint
407 {
408 return mElement->number_of_edges() ;
409 }
410
411//------------------------------------------------------------------------------
412
413 inline Edge *
414 Facet::edge( const uint aIndex )
415 {
416 return mElement->edge( aIndex );
417 }
418
419//------------------------------------------------------------------------------
420
421 inline const Edge *
422 Facet::edge( const uint aIndex ) const
423 {
424 return mElement->edge( aIndex );
425 }
426
427//------------------------------------------------------------------------------
428
429 inline Face *
430 Facet::face( const uint aIndex )
431 {
432 return mElement->face( aIndex );
433 }
434
435//------------------------------------------------------------------------------
436
437 inline const Face *
438 Facet::face( const uint aIndex ) const
439 {
440 return mElement->face( aIndex );
441 }
442
443//------------------------------------------------------------------------------
444
445 inline void
446 Facet::unflag_nodes( const uint8_t aIndex )
447 {
448 mElement->unflag_nodes( aIndex );
449 }
450
451//------------------------------------------------------------------------------
452
453 inline void
454 Facet::flag_nodes( const uint8_t aIndex )
455 {
456 mElement->flag_nodes( aIndex );
457 }
458
459//------------------------------------------------------------------------------
460
461 inline void
463 {
464 if( this->has_master() )
465 {
466 mMaster->flag_nodes() ;
467 }
468 if( this->has_slave() )
469 {
470 mSlave->flag_nodes() ;
471 }
472 }
473
474//------------------------------------------------------------------------------
475
476 inline void
478 {
479 if( this->has_master() )
480 {
481 mMaster->flag_corner_nodes() ;
482 }
483 if( this->has_slave() )
484 {
485 mSlave->flag_corner_nodes() ;
486 }
487 }
488
489//------------------------------------------------------------------------------
490
491 inline void
493 {
494 mElement->flag_corner_nodes();
495 }
496
497//------------------------------------------------------------------------------
498
499 inline id_t
501 {
502 BELFEM_ASSERT( mMaster != nullptr,
503 "Facet %lu has no master element",
504 ( long unsigned int ) this->id() );
505 return mMaster->index() + 1;
506 //return mMaster->id();
507 }
508
509//------------------------------------------------------------------------------
510
511 inline id_t
513 {
514 BELFEM_ASSERT( mSlave != nullptr,
515 "Facet %lu has no slave element",
516 ( long unsigned int ) this->id() );
517
518 return mSlave->id();
519 }
520
521//------------------------------------------------------------------------------
522 inline auto
523 Facet::index_on_master() const -> decltype( mMasterFaceID )
524 {
525 return mMasterFaceID;
526 }
527
528//------------------------------------------------------------------------------
529
530 inline auto
531 Facet::index_on_slave() const -> decltype( mSlaveFaceID )
532 {
533 return mSlaveFaceID;
534 }
535
536//------------------------------------------------------------------------------
537
538 inline bool
540 {
541 return mMaster != nullptr;
542 }
543
544//------------------------------------------------------------------------------
545
546 inline bool
548 {
549 return mSlave != nullptr;
550 }
551
552//------------------------------------------------------------------------------
553
554 inline Element *
556 {
557 return mMaster;
558 }
559
560 inline const Element *
562 {
563 return mMaster;
564 }
565
566//------------------------------------------------------------------------------
567
568 inline Element *
570 {
571 return mSlave;
572 }
573
574 inline const Element *
576 {
577 return mSlave;
578 }
579
580
581//-----------------------------------------------------------------------------
582
583 inline uint
585 {
586 uint aNumElems = 0 ;
587 if ( mMaster != nullptr ) ++ aNumElems ;
588 if ( mSlave != nullptr ) ++ aNumElems ;
589 return aNumElems ;
590 }
591
592//-----------------------------------------------------------------------------
593
594 inline Element *
595 Facet::element(const uint aIndex)
596 {
597 if ( aIndex == 0 )
598 {
599 if ( mMaster != nullptr ) return mMaster ;
600 if ( mSlave != nullptr ) return mSlave ;
601 BELFEM_ASSERT( false, "Element index %u out of bounds.", aIndex );
602 return nullptr ;
603 }
604 else
605 {
606 BELFEM_ASSERT( mMaster != nullptr, "Element index %u out of bounds.", aIndex );
607 BELFEM_ASSERT( mSlave != nullptr, "Element index %u out of bounds.", aIndex );
608 return mSlave ;
609 }
610 }
611
612//-----------------------------------------------------------------------------
613
614 inline const Element *
615 Facet::element(const uint aIndex) const
616 {
617 if ( aIndex == 0 )
618 {
619 if ( mMaster != nullptr ) return mMaster ;
620 if ( mSlave != nullptr ) return mSlave ;
621 BELFEM_ASSERT( false, "Element index %u out of bounds.", aIndex );
622 return nullptr ;
623 }
624 else
625 {
626 BELFEM_ASSERT( mMaster != nullptr, "Element index %u out of bounds.", aIndex );
627 BELFEM_ASSERT( mSlave != nullptr, "Element index %u out of bounds.", aIndex );
628 return mSlave ;
629 }
630 }
631
632//------------------------------------------------------------------------------
633
634 inline void
635 Facet::set_owner( const proc_t aOwner )
636 {
637 mElement->set_owner( aOwner );
638 }
639
640//------------------------------------------------------------------------------
641
642 inline proc_t
644 {
645 return mElement->owner() ;
646 }
647
648//------------------------------------------------------------------------------
649
650 inline void
651 Facet::flag( const uint8_t aIndex )
652 {
653 mElement->flag( aIndex ) ;
654 }
655
656//------------------------------------------------------------------------------
657
658 inline void
659 Facet::unflag( const uint8_t aIndex )
660 {
661 mElement->unflag( aIndex ) ;
662 }
663
664//------------------------------------------------------------------------------
665
666 inline bool
667 Facet::is_flagged( const uint8_t aIndex ) const
668 {
669 return mElement->is_flagged( aIndex ) ;
670 }
671
672//------------------------------------------------------------------------------
673
674 inline void
675 Facet::set_index( const index_t aIndex )
676 {
677 mElement->set_index( aIndex );
678 }
679
680//------------------------------------------------------------------------------
681
682 inline index_t
684 {
685 return mElement->index() ;
686 }
687//------------------------------------------------------------------------------
688
689 inline uint
691 {
692 return mOrientationOnSlave ;
693 }
694
695//----------------------------------------------------------------------------
696
697 inline bool
699 {
700 return mElement->is_curved() ;
701 }
702
703//----------------------------------------------------------------------------
704
705 inline id_t
707 {
708 return mElement->block_id() ;
709 }
710
711//----------------------------------------------------------------------------
712
713 inline void
715 {
716 mElement->set_physical_tag( aTag );
717 }
718
719 inline uint
721 {
722 return mElement->physical_tag();
723 }
724
725//----------------------------------------------------------------------------
726
727 inline void
728 Facet::set_sideset_id( const id_t aSidesetID )
729 {
730 mElement->set_block_id( aSidesetID );
731 }
732
733//----------------------------------------------------------------------------
734
735 inline void
737 {
738 mFacetCounter = aCount ;
739 }
740
741//------------------------------------------------------------------------------
742
743
744 inline void
746 {
747 mPeriodic = aFacet ;
748 }
749
750//------------------------------------------------------------------------------
751
752 inline Facet *
754 {
755 return mPeriodic ;
756 }
757
758//------------------------------------------------------------------------------
759
760 inline const Facet *
762 {
763 return mPeriodic ;
764 }
765
766//------------------------------------------------------------------------------
767
768 inline bool
770 {
771 return mPeriodic != nullptr ;
772 }
773
774//------------------------------------------------------------------------------
775 }
776}
777#endif //BELFEM_CL_FACET_HPP
#define BELFEM_ASSERT(aCheck,...)
Definition assert.hpp:244
virtual void set_owner(const proc_t aOwner)
Definition cl_Graph_Vertex.hpp:242
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
bool has_slave() const
Definition cl_Facet.hpp:547
void disconnect_slave()
Definition cl_Facet.cpp:79
proc_t owner() const override
Definition cl_Facet.hpp:643
Element * element()
expose the element pointer
Definition cl_Facet.hpp:361
Edge * edge(const uint aIndex) override
Definition cl_Facet.hpp:414
void set_periodic(Facet *aFacet)
Definition cl_Facet.hpp:745
void flip()
Definition cl_Facet.cpp:90
uint physical_tag() const
Definition cl_Facet.hpp:720
uint number_of_nodes() const override
get the number of nodes
Definition cl_Facet.hpp:390
Node * node(uint aIndex) override
get a node pointer
Definition cl_Facet.hpp:376
Facet(Element *aElement)
Definition cl_Facet.cpp:20
size_t memory() const
Definition cl_Facet.cpp:135
id_t master_id() const
Definition cl_Facet.hpp:500
uint number_of_corner_nodes() const
get the number of corner nodes
Definition cl_Facet.hpp:398
uint number_of_edges() const override
get the number of edges
Definition cl_Facet.hpp:406
Element * slave()
Definition cl_Facet.hpp:569
Face * face(const uint aIndex=0) override
Definition cl_Facet.hpp:430
bool has_master() const
Definition cl_Facet.hpp:539
void flag_master_and_slave_nodes()
flag all nodes of the master and the slave element
Definition cl_Facet.hpp:462
void flag_nodes(const uint8_t aIndex=0) override
flag all nodes that belong to this facet
Definition cl_Facet.hpp:454
void flag_corner_nodes()
flag corner nodes nodes that belong to this facet
Definition cl_Facet.hpp:492
auto index_on_slave() const -> decltype(mSlaveFaceID)
Definition cl_Facet.hpp:531
index_t index() const override
Definition cl_Facet.hpp:683
void flag(const uint8_t aIndex=0) override
Definition cl_Facet.hpp:651
void set_facet_counter(const uint aCount)
Definition cl_Facet.hpp:736
bool is_curved() const
Definition cl_Facet.hpp:698
void unflag_nodes(const uint8_t aIndex=0) override
unflag all nodes that belong to this facet
Definition cl_Facet.hpp:446
void set_slave(Element *aElement, const uint aIndex)
Definition cl_Facet.cpp:60
bool is_flagged(const uint8_t aIndex=0) const override
Definition cl_Facet.hpp:667
uint number_of_elements() const override
Definition cl_Facet.hpp:584
bool is_periodic() const
Definition cl_Facet.hpp:769
Facet * periodic()
Definition cl_Facet.hpp:753
void set_sideset_id(const id_t aSidesetID)
Definition cl_Facet.hpp:728
uint orientation_on_slave() const
Definition cl_Facet.hpp:690
void flag_master_and_slave_corner_nodes()
flag the corner nodes of the master and the slave element
Definition cl_Facet.hpp:477
EntityType entity_type() const override
returns the type of this vertex
Definition cl_Facet.hpp:352
void unflag(const uint8_t aIndex=0) override
Definition cl_Facet.hpp:659
Element * master()
Definition cl_Facet.hpp:555
auto index_on_master() const -> decltype(mMasterFaceID)
Definition cl_Facet.hpp:523
void compute_orientation()
Definition cl_Facet.cpp:104
void set_owner(const proc_t aOwner) override
Definition cl_Facet.hpp:635
id_t sideset_id() const
Definition cl_Facet.hpp:706
void set_index(const index_t aIndex) override
Definition cl_Facet.hpp:675
void set_physical_tag(const uint aTag)
Definition cl_Facet.hpp:714
void set_master(Element *aElement, const uint aIndex, const bool aLinkNodes=true)
Definition cl_Facet.cpp:36
id_t slave_id() const
Definition cl_Facet.hpp:512
Definition cl_Node.hpp:30
virtual void unflag_nodes(const uint8_t aIndex=0)
Definition cl_Vertex.cpp:315
uint16_t mFacetCounter
Definition cl_Vertex.hpp:62
Face * face(const uint aIndex) override
Definition cl_Vertex.hpp:411
Node * node(const uint aIndex) override
Definition cl_Vertex.hpp:349
Edge * edge(const uint aIndex) override
Definition cl_Vertex.hpp:377
Vertex()
Definition cl_Vertex.cpp:24
Definition cl_EF_EdgeFunction.hpp:17
USER GUIDES:
Definition cl_Capacitor.cpp:16
unsigned int uint
Definition typedefs.hpp:30
unsigned int id_t
Definition typedefs.hpp:41
int proc_t
Definition commtypes.hpp:29
EntityType
Definition Mesh_Enums.hpp:116
@ FACET
Definition Mesh_Enums.hpp:121
short unsigned int suint
Definition typedefs.hpp:32
uint32_t index_t
Definition typedefs.hpp:52
#define BELFEM_SUINT_MAX
Definition typedefs.hpp:79