CEPS  24.01
Cardiac ElectroPhysiology Simulator
GeomCellJunction.cpp
Go to the documentation of this file.
1 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2  This file is part of CEPS.
3 
4  CEPS is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  CEPS is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with CEPS (see file LICENSE at root of project).
16  If not, see <https://www.gnu.org/licenses/>.
17 
18 
19  Copyright 2019-2024 Inria, Universite de Bordeaux
20 
21  Authors, in alphabetical order:
22 
23  Pierre-Elliott BECUE, Florian CARO, Yves COUDIERE(*), Andjela DAVIDOVIC,
24  Charlie DOUANLA-LONTSI, Marc FUENTES, Mehdi JUHOOR, Michael LEGUEBE(*),
25  Pauline MIGERDITICHAN, Valentin PANNETIER(*), Nejib ZEMZEMI.
26  * : currently active authors
27 
28 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
31 
34  m_type (JunctionType::TYPE_UNKNOWN)
35 {
36 }
37 
40 {
41 }
42 
44 get3dcells () const
45 {
46  return m_3d;
47 }
48 
50 get2dcells () const
51 {
52  return m_2d;
53 }
54 
56 get1dcells () const
57 {
58  return m_1d;
59 }
60 
62 getType () const
63 {
64  return m_type;
65 }
66 
68 addCell(GeomCell* cell)
69 {
70  CEPS_ABORT_IF(ceps::isNullPtr(cell),"Cannot add nullptr cell to cell junction");
71 
72  CepsUInt dim = cell->getDimension();
73  switch (dim)
74  {
75  case 3:
76  m_3d.push_back(cell);
77  break;
78  case 2:
79  m_2d.push_back(cell);
80  break;
81  case 1:
82  m_1d.push_back(cell);
83  break;
84  default:
85  CEPS_ABORT("Cannot add cell to dimension for dimension " << dim);
86  }
88  return;
89 }
90 
93 {
94  CEPS_ABORT_IF(ceps::isNullPtr(cell),"Cannot add nullptr boundary cell to cell junction");
95 
96  CepsUInt dim = cell->getDimension();
97  switch (dim)
98  {
99  case 2:
100  m_3dBoundary.push_back(cell);
101  break;
102  case 1:
103  m_2dBoundary.push_back(cell);
104  break;
105  default:
106  CEPS_ABORT("Cannot add boundary cell to dimension for dimension " << dim);
107  }
108  checkIntegrity();
109  return;
110 }
111 
114 {
115  // Determine junction cell type
116  CepsBool has1d = (m_1d.size () != 0);
117  CepsBool has2d = (m_2d.size () != 0) or (m_2dBoundary.size () != 0);
118  CepsBool has3d = (m_3d.size () != 0) or (m_3dBoundary.size () != 0);
119 
120  if (has1d)
121  {
122  if (has3d)
124  else
125  {
126  if (has2d)
128  else
129  {
131  CEPS_WARNS ("unknown junction type for this junction cell.");
132  }
133  }
134  }
135  else
136  {
137  if (has3d and has2d)
139  else
140  {
142  CEPS_WARNS ("unknown junction type for this junction cell.");
143  }
144  }
145  return;
146 }
#define CEPS_ABORT(message)
Stops the execution with a message. If testing is enabled, only throws a runtime_error.
#define CEPS_ABORT_IF(condition, message)
Stops the execution with a message if condition is true. If testing is enabled, only throws a runtime...
#define CEPS_WARNS(message)
Writes a warning in the debug log and in the terminal (stderr).
std::vector< _Type, _Alloc > CepsVector
C++ vector.
Definition: CepsTypes.hpp:155
bool CepsBool
Booleans.
Definition: CepsTypes.hpp:124
std::make_unsigned_t< CepsInt > CepsUInt
Unsigned version on CepsInt.
Definition: CepsTypes.hpp:109
JunctionType
Structure that holds the junction type.
@ TYPE_1D2D3D
Pt, tri and tetra junction.
@ TYPE_1D3D
Point to tetra.
@ TYPE_2D3D
Tri to tetra.
@ TYPE_1D2D
Point to triangle.
@ TYPE_UNKNOWN
other
CepsVector< GeomCell * > m_3d
3d volume
CepsVector< GeomCell * > m_2d
2d surface
const CepsVector< GeomCell * > & get2dcells() const
Connected 2d cells.
void addBoundaryCell(GeomCell *cell)
Add a boundary cell to the junction.
CepsVector< GeomCell * > m_3dBoundary
2d boundary of 3d volume
CepsVector< GeomCell * > m_1d
1d cable
void checkIntegrity()
Checks sanity of junction cell and determines its type.
CepsVector< GeomCell * > m_2dBoundary
1d boundary of 2d surfaces
virtual ~GeomCellJunction()
Destructor.
JunctionType m_type
Type of linked cells.
void addCell(GeomCell *cell)
Add a cell to the junction.
GeomCellJunction()
Default constructor.
const CepsVector< GeomCell * > & get3dcells() const
Connected 3d cells.
JunctionType getType() const
Type of junction.
const CepsVector< GeomCell * > & get1dcells() const
Connected 1d cells.
Abstract class for geometrical cell. On top of index and attributes managament, the cell has informat...
Definition: GeomCell.hpp:48
const CepsUInt & getDimension() const
Get the dimension of the object.
CepsBool isNullPtr(_Type *ptr)
Tells if passed pointer is null.
Definition: CepsMemory.hpp:45