CEPS  24.01
Cardiac ElectroPhysiology Simulator
Field.hpp
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 #pragma once
32 
33 #include "common/CepsCommon.hpp"
37 
38 // Forwrad declaration
39 template <class _Result, class _SupportType>
40 class Field;
41 
43 template <class _SupportType>
46 template <class _SupportType>
49 template <class _SupportType>
51 
78 template <class _Result, class _SupportType>
79 class Field
80 {
81 
82  public:
83 
90 
95  FunctionType* functor,
96  const _Domain* domain,
97  CepsBool bufferize = false
98  );
99 
101  virtual ~Field() = default;
102 
104  void
105  addDomain(const _Domain* domain);
106 
108  void
110 
112  FunctionType*
113  getFunctor() const;
114 
120  void
122 
128  void
129  setScaleFactor(CepsReal scaleFactor);
130 
132  CepsReal
133  getScaleFactor() const;
134 
136  CepsBool
137  isBuffered() const;
138 
140  CepsBool
142 
144  CepsEnum
146 
148  CepsBool
150 
152  CepsBool
154 
156  CepsBool
157  isTimeVariable() const;
158 
160  CepsBool
161  needsSolution() const;
162 
167  void
169  CepsVector<_Result>& values,
170  CepsReal t,
171  const CepsVector<_SupportType*>& points={}
172  );
173 
178  _Result
179  getValue(_SupportType* point, CepsReal t);
180 
188  void
189  computeSupport(AbstractSelector<_Iterator>* selector,CepsBool canStartEmpty=false);
190 
192  virtual void
194 
198 
202 
206 
210 
213  friend class SourceTermManager;
214 
215  protected:
216 
218  virtual void
220 
222  virtual void
224 
233 
235 
236 };
237 
238 // Interactions with distributed vectors, exclusive to Scalar Fields
239 
247 template<class _SupportType>
248 void
250  CepsReal t=0.);
251 
258 template<class _SupportType>
259 void
261  CepsReal t=0.);
262 
271 template<class _SupportType>
272 void
274  CepsReal t = 0.,
275  CepsBool divide = false);
276 
288 template<class _SupportType>
289 void
291  DistributedVector* vec,
293  const CepsSet<CepsAttribute>& attrs,
294  const CepsSet<Unknown*> unknowns,
295  CepsReal t = 0.,
296  CepsBool divide = false
297 );
298 
309 template<class _SupportType>
310 void
312  DistributedVector* vec,
314  std::function<CepsBool(_SupportType*)>* predicate,
315  CepsReal t = 0.,
316  CepsBool divide = false
317 );
318 
330 template<class _SupportType>
331 void
333  DistributedVector* vec,
335  std::function<CepsBool(_SupportType*)>* predicate,
336  CepsReal t,
337  CepsBool divide,
338  const CepsVector<_SupportType*>* domain,
339  CepsUInt offset = 0
340 );
341 
342 // Definitions of these last template functions
CepsFunctionFlag
Enum for CepsStandardArgs functions.
Definition: CepsEnums.hpp:137
int CepsEnum
Enum type.
Definition: CepsTypes.hpp:216
std::set< _Type, _Compare, _Alloc > CepsSet
C++ set.
Definition: CepsTypes.hpp:209
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
float CepsReal
Need single precision floating point.
Definition: CepsTypes.hpp:100
void scaleByField(DistributedVector *vec, ScalarField< _SupportType > &f, CepsReal t=0., CepsBool divide=false)
Multiplies or divides given vector by coeff value. (default behaviour)
void addFieldValuesTo(ScalarField< _SupportType > &f, DistributedVector *vec, CepsReal t=0.)
Add values to a distributed vector. Exclusive to scalar fields. Field data may be evaluated on the fl...
void setFieldValuesTo(ScalarField< _SupportType > &f, DistributedVector *vec, CepsReal t=0.)
Set values into a distributed vector. Exclusive to scalar fields.
void scaleByFieldInternal(DistributedVector *vec, ScalarField< _SupportType > &f, std::function< CepsBool(_SupportType *)> *predicate, CepsReal t, CepsBool divide, const CepsVector< _SupportType * > *domain, CepsUInt offset=0)
Multiplies or divides given vector by coeff value.
@ offset
Offset phase.
Boundary condition to manage Dirichlet, Neumann and Robin conditions.
Structure to hold spatially dependant data and distribute it between process.
A Field is an object wrapped around a SAFunc functor, defined on at least one domain.
Definition: Field.hpp:80
CepsVector< _SupportType * > m_support
List of "points" where the field applies.
Definition: Field.hpp:227
CepsBool isSpaceVariable() const
Knowing the behavior relating to the space variable.
const CepsVector< _SupportType * > & getSupport()
Get suppor.
CepsVector< CepsGlobalIndex > & getSupportIndices()
Get indices of support.
void addDomain(const _Domain *domain)
Add another domain of definition.
CepsBool isBuffered() const
Tells if field is bufferized.
void setFunctor(ceps::Function< _Result(CepsStandardArgs)> *functor)
Set the functor inside the object.
CepsReal m_scaleFactor
An optional scale factor.
Definition: Field.hpp:226
CepsBool m_isPrecomputed
Check if values were already evaluated.
Definition: Field.hpp:232
CepsVector< _Result > m_buffer
Get buffer with data evaluated.
Definition: Field.hpp:230
FunctionType * m_functor
doesn't belong to this object
Definition: Field.hpp:225
CepsVector< _SupportType * > _Domain
The objects on which is defined the support (GeomCell, GeomNode, DegreeOfFreedom)
Definition: Field.hpp:87
CepsBool needsSolution() const
Knowing the behavior relating to the solution vector.
CepsBool m_precompute
Do we bufferize data ?
Definition: Field.hpp:231
virtual void evaluateOn(const _Domain *domain, CepsReal t, CepsUInt offset, CepsVector< _Result > &results)
Precompute field data.
CepsBool isTimeVariable() const
Knowing the behavior relating to the time variable.
virtual void actualize(CepsReal t)
Precompute field data.
CepsVector< CepsGlobalIndex > m_supportIndices
List of "points" indices.
Definition: Field.hpp:228
CepsVector< const CepsVector< _SupportType * > * > m_domains
Ranges on which the field is defined.
Definition: Field.hpp:234
_Result getValue(_SupportType *point, CepsReal t)
Get single value for given row index. /!\ If not nullptr, the solution vector should HAVE ALREADY CAL...
CepsReal getScaleFactor() const
Get the scale factor used.
FunctionType * getFunctor() const
Get the functor inside the object.
void setScaleFactor(CepsReal scaleFactor)
Scale the result.
CepsVector< _Result > & getBufferedData()
Ref to buffered data.
void getValues(CepsVector< _Result > &values, CepsReal t, const CepsVector< _SupportType * > &points={})
Get the values for given row indices. If no support was given, simply call the functor for all dofs.
CepsBool hasFunctorOption(CepsFunctionFlag flag) const
Knowing the behavior relating to the time variable.
void computeSupport(AbstractSelector< _Iterator > *selector, CepsBool canStartEmpty=false)
Computes the support in the domains of definition, using the given selector.
virtual void evaluateAll(CepsReal t, CepsVector< _Result > &results)
Evaluate on all domain or support, put results in given vector.
CepsBool m_supportComputed
True if computeSupport has been called.
Definition: Field.hpp:229
CepsBool hasBufferedData() const
Tells if field is bufferized and data has already been computed.
void clearDomains()
Removes domains and support.
CepsEnum getFunctorFlags() const
Get flags of the function.
virtual ~Field()=default
Destructor.
Field(FunctionType *functor, const _Domain *domain, CepsBool bufferize=false)
Construct a new Field object, with a vector, functor cannot be null.
typename CepsVector< _SupportType * >::const_iterator _Iterator
The objects on which is defined the support (GeomCell, GeomNode, DegreeOfFreedom)
Definition: Field.hpp:89
const CepsVector< const CepsVector< _SupportType * > * > & getDomains()
Get the spans on which the field is defined.
A SAFunc is a ceps::Function that uses CepsStandardArgs as argument of call operator (),...
Definition: SAFunc.hpp:100
Source term manager to create and manage SourceTerm objects.
Structure used to pass arguments to SAFunc (see pde directory) The flags of the SAFunc allows extract...
Definition: CepsTypes.hpp:239
function caller : abstract base, only contains an variadic operator()