waves
Basic FE playground
wFace.h
Go to the documentation of this file.
1 /*
2  * Copyright 2022 University of Liège
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef WFACE_H
18 #define WFACE_H
19 
20 #include "flow.h"
21 #include "wNode.h"
22 
23 #ifndef SWIG
24 namespace flow
25 {
26 
32 {
33 public:
34  std::vector<tbox::Node *> nods;
35  tbox::Element *el0;
36  tbox::Element *el1;
37 
38  Face(std::vector<tbox::Node *> const &_nods) : nods(_nods), el0(NULL), el1(NULL) {}
39 };
40 
46 {
47 public:
48  // Default parameters
49  static const size_t bucket_size = 4;
50  static const size_t min_buckets = 8;
51  // Function returning a unique size_t per Face
52  size_t operator()(Face *const f) const
53  {
54  size_t sum = 0;
55  for (auto n : f->nods)
56  sum += static_cast<size_t>(n->no);
57 
58  return sum; // sum of nodes id
59  }
60  // Function allowing to univoquely identify a Face
61  bool operator()(Face *const f0, Face *const f1) const
62  {
63  bool flag = false;
64  size_t cnt = 0;
65  // compare nodes of f0 to nodes of f1
66  for (auto n0 : f0->nods)
67  {
68  for (auto n1 : f1->nods)
69  {
70  if (n0 == n1)
71  {
72  cnt++;
73  break;
74  }
75  }
76  if (cnt == 0)
77  break;
78  }
79  // check the number of shared nodes
80  if (cnt == f0->nods.size())
81  flag = true;
82 
83  return flag; // true if f0 = f1 (ie, f0 and f1 share the same nodes)
84  }
85 };
86 
87 } // namespace flow
88 #endif
89 
90 #endif //WFACE_H
flow::EquFace
Face comparator.
Definition: wFace.h:45
FLOW_API
#define FLOW_API
Definition: flow.h:29
flow::EquFace::operator()
bool operator()(Face *const f0, Face *const f1) const
Definition: wFace.h:61
flow::Face::el0
tbox::Element * el0
Definition: wFace.h:35
flow
Namespace for flow module.
Definition: flow.h:37
flow::Face::el1
tbox::Element * el1
Definition: wFace.h:36
flow::Face::nods
std::vector< tbox::Node * > nods
Definition: wFace.h:34
flow::EquFace::operator()
size_t operator()(Face *const f) const
Definition: wFace.h:52
flow::Face::Face
Face(std::vector< tbox::Node * > const &_nods)
Definition: wFace.h:38
flow.h
flow::Face
Common face of two elements.
Definition: wFace.h:31