BELFEM
0.9.0
Berkeley Lab Finite Element Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
fn_check_facet_orientation.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, through
4
* 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_FN_CHECK_FACET_ORIENTATION_HPP
13
#define BELFEM_FN_CHECK_FACET_ORIENTATION_HPP
14
#include "
assert.hpp
"
15
#include "
cl_Facet.hpp
"
16
#include "
cl_Element.hpp
"
17
namespace
belfem
18
{
19
namespace
mesh
20
{
51
inline
bool
52
check_facet_orientation
(
const
Facet
* aA,
const
Facet
* aB )
53
{
54
const
Element
* tA = aA->
element
();
55
const
Element
* tB = aB->
element
();
56
uint
n = tA->
number_of_corner_nodes
();
57
uint
m = tB->
number_of_corner_nodes
();
58
59
if
( n == 2 && m == 2 )
60
{
61
id_t
tA0 = tA->
node
( 0 )->
original
()->
id
();
62
id_t
tA1 = tA->
node
( 1 )->
original
()->
id
();
63
id_t
tB0 = tB->
node
( 0 )->
original
()->
id
();
64
id_t
tB1 = tB->
node
( 1 )->
original
()->
id
();
65
66
// B continues A's traversal ( or reversed twin ): consistent
67
if
( tA1 == tB0 || tA0 == tB1 )
68
{
69
return
true
;
70
}
71
72
// both start or both end at the shared node
73
// ( or identical twin ): inverted
74
if
( tA0 == tB0 || tA1 == tB1 )
75
{
76
return
false
;
77
}
78
}
79
else
80
{
81
// loop over all edge pairs (p→q) from A and (r→s) from B
82
id_t
p ;
83
id_t
q
= tA->
node
( n-1 )->
id
();
84
id_t
r ;
85
id_t
s ;
86
87
for
(
uint
i = 0; i < n; ++i )
88
{
89
p =
q
;
90
q
= tA->
node
( i )->
id
();
91
s = tB->
node
( m-1 )->
id
();
92
for
(
uint
j = 0; j < m; ++j )
93
{
94
r = s ;
95
s = tB->
node
( j )->
id
();
96
97
// A traverses P→Q, B traverses Q→P: consistent normals
98
if
( p == s &&
q
== r )
99
{
100
return
true
;
101
}
102
103
// A traverses P→Q, B traverses P→Q: inverted normals
104
if
( p == r &&
q
== s )
105
{
106
return
false
;
107
}
108
}
109
}
110
}
111
112
BELFEM_ERROR
(
false
,
"Could not determine orientation of facets."
);
113
return
false
;
114
}
115
}
116
}
117
#endif
//BELFEM_FN_CHECK_FACET_ORIENTATION_HPP
assert.hpp
BELFEM_ERROR
#define BELFEM_ERROR(aCheck,...)
Definition
assert.hpp:264
cl_Element.hpp
cl_Facet.hpp
belfem::graph::Vertex::id
id_t id() const
Definition
cl_Graph_Vertex.hpp:218
belfem::mesh::Element
Lagrange Element baseclass.
Definition
cl_Element.hpp:35
belfem::mesh::Element::number_of_corner_nodes
virtual uint number_of_corner_nodes() const
Definition
cl_Element.hpp:140
belfem::mesh::Element::node
Node * node(const uint aIndex) override
Definition
cl_Element.hpp:254
belfem::mesh::Facet
Definition
cl_Facet.hpp:24
belfem::mesh::Facet::element
Element * element()
expose the element pointer
Definition
cl_Facet.hpp:361
belfem::mesh::Node::original
Node * original()
returns the original of this node
Definition
cl_Node.hpp:318
belfem::mesh
Definition
cl_EF_EdgeFunction.hpp:17
belfem::mesh::check_facet_orientation
bool check_facet_orientation(const Facet *aA, const Facet *aB)
Checks whether two adjacent facets have consistent orientation.
Definition
fn_check_facet_orientation.hpp:52
belfem
USER GUIDES:
Definition
cl_Capacitor.cpp:16
belfem::uint
unsigned int uint
Definition
typedefs.hpp:30
belfem::id_t
unsigned int id_t
Definition
typedefs.hpp:41
belfem::MaterialProperty::q
@ q
Definition
cl_Material.hpp:176
src
mesh
fn_check_facet_orientation.hpp
Generated by
1.18.0