CEPS  24.01
Cardiac ElectroPhysiology Simulator
SolVecSAFunc.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 
32 // =============================================================================
33 // SAFunc with data extracted from distributed vector
34 
37 {
38  setDataPointer(sol);
39  checkLocation(location);
40 }
41 
42 void
44 {
46  "Cannot initialize functor dependant on distributed vector, as passed ptr to vector is null"
47  );
48  m_sol = sol;
49 }
50 
53 {
55 }
56 
59 {
60  return f->getFlags();
61 }
62 
63 void
65 {
66  m_sol->get()->getLocalData();
67 }
68 
69 void
71 {
72  m_sol->get()->releaseLocalData();
73 }
74 
75 void
77 {
79  and location != CepsFunctionFlag::NodeIndex
80  and location != CepsFunctionFlag::DofIndex,
81  "Cannot initialize a functor on distributed vector with a flag that is not DofIndex, CellIndex or NodeIndex"
82  );
83  m_location = location;
84 }
85 
86 void
88 {
89  args.u = 0.;
91  args.u = (**m_sol)[args.cellId];
93  args.u = (**m_sol)[args.nodeId];
94  else
95  args.u = (**m_sol)[args.dofId];
96 }
CepsFunctionFlag
Enum for CepsStandardArgs functions.
Definition: CepsEnums.hpp:137
@ CellIndex
Use cell index to determine position.
@ NodeIndex
Use node index to determine position.
@ Solution
Depends on the content of a solution vector with values at dofs.
@ DofIndex
Use dof index to determine position.
#define CEPS_ABORT_IF(condition, message)
Stops the execution with a message if condition is true. If testing is enabled, only throws a runtime...
CepsScalar CepsMathScalar
Real numbers.
Definition: CepsTypes.hpp:133
int CepsEnum
Enum type.
Definition: CepsTypes.hpp:216
std::shared_ptr< DistributedHaloVector > DHVecPtr
Typedef for pointer on Distributed Halo CepsVector.
A SAFunc is a ceps::Function that uses CepsStandardArgs as argument of call operator (),...
Definition: SAFunc.hpp:100
A SAFunc which gets its values from a distributed vector of values on degrees of freedom.
void setDataPointer(DHVecPtr *sol)
Sets the link to data.
virtual void releaseLocalData() final
Authorize access to data for solvecSAFunc, other derived classes : nothing.
void checkLocation(const CepsFunctionFlag &loc)
Determines if flag passed in constructor is valid (cells or nodes ID)
CepsFunctionFlag m_location
To get the correct index in the vector.
DHVecPtr * m_sol
Pointed data.
SolVecSAFunc(DHVecPtr *sol, CepsFunctionFlag loc)
Default constructor. Vector is passed as pointer on pointer in order to pass a U^n,...
CepsEnum getFlags() const final
Return the vector dependance flag + location, does not mean that the content of the vector can not ch...
void setArgsFromLocation(CepsStandardArgs &args) const
Sets args.u from the location flag.
virtual void getLocalData() final
Authorize access to data for solvecSAFunc, other derived classes : nothing.
constexpr auto toIntegral(_Enum e) -> typename std::underlying_type< _Enum >::type
Converts an enum type variable to an integer.
Definition: CepsEnums.hpp:42
CepsEnum getFlagsOf(ArraySAFunc< _Result > *f)
get functor options
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
CepsNodeGlobalIndex nodeId
node index
Definition: CepsTypes.hpp:246
CepsReal u
solution u
Definition: CepsTypes.hpp:242
CepsCellGlobalIndex cellId
cell index
Definition: CepsTypes.hpp:245
CepsDofGlobalIndex dofId
dof index
Definition: CepsTypes.hpp:244