CEPS  24.01
Cardiac ElectroPhysiology Simulator
Unknown.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 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
30 #include "pde/common/Unknown.hpp"
31 
33  const CepsUnknownIndex& identifier,
34  const CepsString& name,
35  const CepsString& unit
36 ) :
37  m_identifier (identifier),
38  m_name (name),
39  m_unit (unit),
40  m_location (CepsLocationFlag::Point),
41  m_interactsWith({})
42 {
43 }
44 
45 Unknown::Unknown(const Unknown& that) :
46  m_identifier (that.m_identifier),
47  m_name (that.m_name),
48  m_unit (that.m_unit),
49  m_location (that.m_location),
50  m_interactsWith({})
51 {
52 }
53 
54 Unknown&
56 {
57  if (ceps::isDifferentPtr(this, &that))
58  {
60  m_name = that.m_name;
61  m_unit = that.m_unit;
62  m_location = that.m_location;
64  }
65  return *this;
66 }
67 
68 const CepsString&
70 {
71  return m_name;
72 }
73 
74 void
76 {
77  m_name = name;
78  return;
79 }
80 
83 {
84  return m_identifier;
85 }
86 
87 const CepsString&
89 {
90  return m_unit;
91 }
92 
93 void
95 {
96  m_unit = unit;
97  return;
98 }
99 
100 const CepsLocationFlag&
102 {
103  return m_location;
104 }
105 
106 CepsBool
108 {
109  return m_location == flag;
110 }
111 
112 void
114 {
115  m_location = location;
116  return;
117 }
118 
119 CepsBool
121 {
123 }
124 
125 void
127 {
129  "Cannot add interaction with nullptr"
130  );
131  m_interactsWith.insert(u);
132  if (addReciprocal)
133  u->addUnknownInteraction(this,false);
134 }
135 
136 CepsBool
138 {
139  return u==this or m_interactsWith.contains(u);
140 }
141 
142 const CepsSet<Unknown*>&
144 {
145  return m_interactsWith;
146 }
CepsLocationFlag
DataLocation: an enum that will be used by various elements of the code (pde, readers,...
Definition: CepsEnums.hpp:108
@ Point
Data is defined on each point.
@ ZeroD
Data is defined once.
#define CEPS_ABORT_IF(condition, message)
Stops the execution with a message if condition is true. If testing is enabled, only throws a runtime...
std::basic_string< CepsChar > CepsString
C++ format string.
Definition: CepsTypes.hpp:128
CepsIndex CepsUnknownIndex
For unknowns.
Definition: CepsTypes.hpp:217
std::set< _Type, _Compare, _Alloc > CepsSet
C++ set.
Definition: CepsTypes.hpp:209
bool CepsBool
Booleans.
Definition: CepsTypes.hpp:124
A class used to defined an unknown of a PDE problem The unknown can be defined on a specific region,...
Definition: Unknown.hpp:45
CepsBool interactsWith(Unknown *u) const
Tells if unknowns interacts with another, true if self.
Definition: Unknown.cpp:137
const CepsSet< Unknown * > & getUnknownsInInteraction() const
Get the set of unknowns with whom there are interactions.
Definition: Unknown.cpp:143
Unknown & operator=(const Unknown &that)
Copy assignement.
Definition: Unknown.cpp:55
const CepsLocationFlag & getLocation() const
Get the data location of the unknown.
Definition: Unknown.cpp:101
CepsBool isOnLocation(const CepsLocationFlag &flag) const
Detect if the unknown is appliable on this location.
Definition: Unknown.cpp:107
void setUnit(const CepsString &unit)
Set the unit of the unknown.
Definition: Unknown.cpp:94
CepsString m_unit
Unit of the unknown.
Definition: Unknown.hpp:118
void setName(const CepsString &name)
Get the name of the unknown.
Definition: Unknown.cpp:75
CepsString m_name
Name of the unknown.
Definition: Unknown.hpp:117
void addUnknownInteraction(Unknown *u, CepsBool addReciprocal=true)
Add an unknown this one interacts with.
Definition: Unknown.cpp:126
CepsLocationFlag m_location
Unknown location.
Definition: Unknown.hpp:119
const CepsString & getName() const
Get the name of the unknown.
Definition: Unknown.cpp:69
Unknown()=delete
Default constructor.
CepsBool isSpatial() const
Tells if unknown is defined on geometrical elements.
Definition: Unknown.cpp:120
void setLocation(const CepsLocationFlag &location)
Set the data location of the unknown.
Definition: Unknown.cpp:113
const CepsString & getUnit() const
Get the unit of the unknown.
Definition: Unknown.cpp:88
CepsUnknownIndex getIdentifier() const
Get the identifier of the unknown.
Definition: Unknown.cpp:82
CepsUnknownIndex m_identifier
Identifier.
Definition: Unknown.hpp:116
CepsSet< Unknown * > m_interactsWith
Other unknowns in interaction.
Definition: Unknown.hpp:120
CepsBool isNullPtr(_Type *ptr)
Tells if passed pointer is null.
Definition: CepsMemory.hpp:45
CepsBool isDifferentPtr(_Type *xptr, U *yptr)
Tells if two pointers designate two different addresses.
Definition: CepsMemory.hpp:86