CEPS  24.01
Cardiac ElectroPhysiology Simulator
DegreeOfFreedom.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 
33  Unknown* unknown,
34  const CepsSet<CepsAttribute>& attrs,
35  CepsGlobalIndex geomId,
36  CepsIndex dofId,
37  CepsProcId procId,
39 ) :
40  ceps::HoldsGlobalIndex(dofId),
41  ceps::HoldsBoundary(false),
42  ceps::HoldsProcIds(procId),
43  ceps::HoldsAttributes(attrs),
44  m_unknown(unknown),
45  m_geomId(geomId),
46  m_discrId(geomId),
47  m_vertex(nullptr),
48  m_neigh(neighs)
49 {
51  "A degree of freedom must be defined with a valid unknown"
52  );
53 }
54 
55 void
57 {
58  m_unknown = unknown;
59  return;
60 }
61 
62 Unknown *
64 {
65  return m_unknown;
66 }
67 
68 const CepsLocationFlag &
70 {
71  return m_unknown->getLocation ();
72 }
73 
74 void
76 {
77  m_geomId = geomId;
78  return;
79 }
80 
81 const CepsGlobalIndex &
83 {
84  return m_geomId;
85 }
86 
87 void
89 {
90  m_discrId = discrId;
91  return;
92 }
93 
94 const CepsGlobalIndex &
96 {
97  return m_discrId;
98 }
99 
100 void
102 {
103  m_vertex = vertex;
104  return;
105 }
106 
107 CepsVertex *
109 {
110  return m_vertex;
111 }
112 
113 void
115 {
116  m_neigh.insert (x);
117  return;
118 }
119 
120 CepsUInt
122 {
123  return m_neigh.size ();
124 }
125 
128 {
129  return m_neigh;
130 }
131 
134 {
136  "Passed DegreeOfFreedom is nullptr"
137  );
138  CepsStandardArgs args;
139  if (dof->getLocation() != CepsLocationFlag::ZeroD)
140  args.x = dof->getVertex()->getCoordinates();
141  args.dofId = dof->getGlobalIndex();
142  args.attr = dof->getAttributes();
143  args.unknownId = dof->getUnknown()->getIdentifier();
144  if (dof->getLocation() == CepsLocationFlag::Point)
145  args.nodeId = dof->getGeomId();
146  else if (dof->getLocation() == CepsLocationFlag::Cell)
147  args.cellId = dof->getGeomId();
148  return args;
149 }
CepsLocationFlag
DataLocation: an enum that will be used by various elements of the code (pde, readers,...
Definition: CepsEnums.hpp:108
@ Cell
Data is defined at cell centers.
@ 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::set< _Type, _Compare, _Alloc > CepsSet
C++ set.
Definition: CepsTypes.hpp:209
CepsIndex CepsGlobalIndex
Many uses. Has to be signed for PETSc.
Definition: CepsTypes.hpp:218
std::make_unsigned_t< CepsInt > CepsUInt
Unsigned version on CepsInt.
Definition: CepsTypes.hpp:109
CepsUInt CepsProcId
For CPU indices.
Definition: CepsTypes.hpp:123
CepsInt CepsIndex
Index rowid etc.
Definition: CepsTypes.hpp:111
CepsStandardArgs getStandardArgsFrom(DegreeOfFreedom *dof)
Returns a standard args structure with data from a dof.
CepsReal3D & getCoordinates()
Get three coordinates, read & write.
Definition: CepsVertex.cpp:174
A degree of freedom for any kind of problem The dof can be associated to a geometrical element or not...
const CepsGlobalIndex & getGeomId() const
Get the Geom Identity for the dof (-1 means no geometric entity)
CepsGlobalIndex m_discrId
A global index used only for finite elements : it is the ID of the FE Node which may be different fro...
const CepsLocationFlag & getLocation() const
Shorcut from unknown to know the location.
CepsVertex * getVertex() const
Get the vertex pointer.
void setGeomId(CepsGlobalIndex geomId)
Set the geom id (replace the existing one)
CepsGlobalIndex m_geomId
Id of geometric entity on which the dof is defined.
Unknown * getUnknown() const
Get the unknow defined at this dof.
Unknown * m_unknown
Link to unknown defined at that dof.
const CepsGlobalIndex & getDiscrId() const
Get the spatial discretization ID (FEnode id for FE)
void setDiscrId(CepsGlobalIndex discrId)
Set the FE node id (replace the existing one)
void setVertex(CepsVertex *vertex)
Set the vertex pointer where is defined the dof.
void setUnknown(Unknown *unknown)
Set the unknown (replace the existing one)
CepsSet< DegreeOfFreedom * > m_neigh
Pointers on nieghboring dofs.
const CepsSet< DegreeOfFreedom * > & getNeighbors() const
Neighbor dofs.
CepsVertex * m_vertex
Geometrical location of the dof.
void addNeighbor(DegreeOfFreedom *x)
Add a neihboring dof.
CepsUInt getNumberOfNeighbors() const
Neighbor dofs #.
DegreeOfFreedom()=delete
Deleted default constructor.
A class used to defined an unknown of a PDE problem The unknown can be defined on a specific region,...
Definition: Unknown.hpp:45
const CepsLocationFlag & getLocation() const
Get the data location of the unknown.
Definition: Unknown.cpp:101
CepsUnknownIndex getIdentifier() const
Get the identifier of the unknown.
Definition: Unknown.cpp:82
CepsSet< CepsAttribute > & getAttributes()
Returns the attributes of the entity.
const CepsGlobalIndex & getGlobalIndex() const
Get the index
A namespace for all utility methods.
CepsBool isNullPtr(_Type *ptr)
Tells if passed pointer is null.
Definition: CepsMemory.hpp:45
Structure used to pass arguments to SAFunc (see pde directory) The flags of the SAFunc allows extract...
Definition: CepsTypes.hpp:239
CepsSet< CepsAttribute > attr
attributes
Definition: CepsTypes.hpp:243
CepsNodeGlobalIndex nodeId
node index
Definition: CepsTypes.hpp:246
CepsCellGlobalIndex cellId
cell index
Definition: CepsTypes.hpp:245
CepsReal3D x
space
Definition: CepsTypes.hpp:241
CepsDofGlobalIndex dofId
dof index
Definition: CepsTypes.hpp:244
CepsUnknownIndex unknownId
unknown index
Definition: CepsTypes.hpp:247