52 #include <unordered_map>
57 #include <vtkPointLocator.h>
61 #include <Eigen/Dense>
69 #if not (PETSC_VERSION_MAJOR >= 3 && PETSC_VERSION_MINOR >= 2)
70 #error "Ceps need a Petsc version higher or equal than 3.2."
75 sizeof (PetscReal) ==
sizeof (PetscScalar),
76 "You need to compile Petsc with option '--with-scalar-type=real'"
81 using CepsUInt = std::make_unsigned_t<CepsInt>;
86 #if defined(PETSC_USE_REAL_DOUBLE) && not defined(CEPS_WITH_DOUBLE_PRECISION)
87 #define CEPS_WITH_DOUBLE_PRECISION
88 #elif defined(PETSC_USE_REAL_SINGLE) && defined(CEPS_WITH_DOUBLE_PRECISION)
89 #undef CEPS_WITH_DOUBLE_PRECISION
95 #include <type_traits>
97 #ifdef CEPS_WITH_DOUBLE_PRECISION
103 #ifdef CEPS_WITH_64_BIT_INTEGERS
114 #ifdef CEPS_WITH_DOUBLE_PRECISION
115 #define FLOATING_POINT_EPSILON 1E-15
117 #define FLOATING_POINT_EPSILON 1E-6
144 template<
typename _Result>
154 template <
class _Type,
class _Alloc = std::allocator<_Type>>
158 template <
class _Type, CepsSize _N>
161 template <
class _Type>
164 template <
class _Type>
167 template <
class _Type>
170 template <
class _Type>
187 template <
class... _Args>
194 typename _Compare = std::less<_Key>,
195 typename _Alloc = std::allocator<std::pair<const _Key, _Tp>>>
196 using CepsMap = std::map<_Key, _Tp, _Compare, _Alloc>;
202 typename _Hash = std::hash<_Key>,
203 typename _KeyEqual = std::equal_to<_Key>,
204 typename _Alloc = std::allocator<std::pair<const _Key, _Tp>>>
205 using CepsMultiMap = std::unordered_multimap<_Key, _Tp, _Hash, _KeyEqual, _Alloc>;
208 template <
class _Type,
class _Compare = std::less<_Type>,
class _Alloc = std::allocator<_Type>>
209 using CepsSet = std::set<_Type, _Compare, _Alloc>;
261 template <
typename _Type>
265 #define CEPS_DECL_PARALLEL_TYPE(_type, _mpi_type) \
267 struct MpiType<_type> \
270 static MPI_Datatype \
273 return static_cast<MPI_Datatype>(static_cast<void *>(&_mpi_type)); \
315 #define CEPS_MPI_REAL MpiType<CepsReal>::getType()
320 #define CEPS_MPI_INT MpiType<CepsInt>::getType ()
325 #define CEPS_MPI_UINT MpiType<CepsUInt>::getType ()
330 #define CEPS_MPI_SHORT MpiType<CepsShort>::getType ()
335 #define CEPS_MPI_INDEX MpiType<CepsIndex>::getType ()
340 #define CEPS_MPI_GEOM_INDEX MpiType<CepsIndex>::getType ()
345 #define CEPS_MPI_GLOBAL_INDEX MpiType<CepsGlobalIndex>::getType ()
350 #define CEPS_MPI_LOCAL_INDEX MpiType<CepsLocalIndex>::getType ()
355 #define CEPS_MPI_ELEMENT_INDEX MpiType<CepsIndex>::getType ()
360 #define CEPS_MPI_HASH MpiType<CepsHash>::getType ()
365 #define CEPS_MPI_SHASH MpiType<CepsSHash>::getType()
368 #undef CEPS_DECL_PARALLEL_TYPE
374 #define CEPS_MAKE_ALIGNED_OP_NEW EIGEN_MAKE_ALIGNED_OPERATOR_NEW
std::basic_string< CepsChar > CepsString
C++ format string.
Eigen::Matrix< CepsScalar, Eigen::Dynamic, 1 > CepsMathDynamic1D
Dynamic 1D array, eigen format.
CepsIndex CepsUnknownIndex
For unknowns.
std::array< _Type, _N > CepsArray
C++ arrays.
constexpr const CepsChar CepsNoName[]
Default string for things without defined name.
CepsArray2< CepsReal > CepsReal2D
Two real scalars, used like this for compatibility in polynomials.
CepsScalar CepsMathScalar
Real numbers.
CepsGlobalIndex CepsCellGlobalIndex
Indices of cells.
std::map< _Key, _Tp, _Compare, _Alloc > CepsMap
C++ map.
constexpr CepsReal2D CepsZero2D
Zero of CepsReal2D.
CepsSize CepsHash
Hashes for distributed data.
std::set< _Type, _Compare, _Alloc > CepsSet
C++ set.
std::tuple< _Args... > CepsTuple
C++ tuple.
CepsLocalIndex CepsDofLocalIndex
Indices of degrees of freedom.
CepsArray< CepsReal, 1u > CepsReal1D
A real scalar, used like this for compatibility in polynomials.
CepsReal CepsScalar
Real numbers.
Eigen::Matrix< CepsScalar, 3, 3 > CepsMathTensor
Tensor, eigen format.
CepsArray< _Type, 2U > CepsArray2
C++ array, 2 elements.
short CepsShort
Short type for custom purposes.
std::vector< _Type, _Alloc > CepsVector
C++ vector.
const CepsChar * CepsCString
C format string.
Eigen::Matrix< CepsScalar, 3, Eigen::Dynamic > CepsMathTensors
Array of tensors, eigen format.
#define CEPS_DECL_PARALLEL_TYPE(_type, _mpi_type)
size_t CepsSize
Size unsigned.
CepsGlobalIndex CepsDofGlobalIndex
Indices of degrees of freedom.
CepsInt CepsAttribute
Used to define regions.
CepsIndex CepsGlobalIndex
Many uses. Has to be signed for PETSc.
std::make_unsigned_t< CepsInt > CepsUInt
Unsigned version on CepsInt.
float CepsReal
Need single precision floating point.
Eigen::Matrix< CepsScalar, 3, 1 > CepsMathVertex
Vertex, eigen format.
CepsGlobalIndex CepsNodeGlobalIndex
Indices of nodes.
int64_t CepsSHash
Hashes for coordinates.
CepsIndex CepsLocalIndex
To use when the indexing is only on one process.
constexpr CepsReal1D CepsZero1D
Zero of CepsReal1D.
CepsArray< _Type, 3U > CepsArray3
C++ array, 3 elements.
CepsUInt CepsProcId
For CPU indices.
CepsArray< _Type, 9U > CepsArray9
C++ array, 9 elements.
constexpr const CepsChar CepsNoUnit[]
Default string for things without defined unit.
Eigen::Matrix< CepsScalar, 3, Eigen::Dynamic > CepsMathVertices
Array of vertices, eigen format.
Eigen::Matrix< CepsScalar, 1, Eigen::Dynamic > CepsMathScalars
Array of reals, eigen format.
CepsLocalIndex CepsCellLocalIndex
Indices of cells.
CepsArray3< CepsReal > CepsReal3D
Three real scalars, used like this for compatibility in polynomials.
constexpr CepsReal3D CepsZero3D
Zero of CepsReal3D.
int32_t CepsInt
Need 32 bit integer.
CepsArray< _Type, 4U > CepsArray4
C++ array, 4 elements.
constexpr CepsAttribute CepsUniversal
This attribute means "everywhere".
Eigen::Matrix< CepsScalar, Eigen::Dynamic, Eigen::Dynamic > CepsMathDynamic2D
Dynamic 2D array, eigen format.
CepsInt CepsIndex
Index rowid etc.
std::unordered_multimap< _Key, _Tp, _Hash, _KeyEqual, _Alloc > CepsMultiMap
C++ multimap.
CepsLocalIndex CepsNodeLocalIndex
Indices of nodes.
A namespace for all utility methods.
_Result convertReal(CepsReal *data)
A small utility to convert a vector of reals into the appropriate (scalar,vector,tensor)
Structure used to pass arguments to SAFunc (see pde directory) The flags of the SAFunc allows extract...
CepsSet< CepsAttribute > attr
attributes
CepsNodeGlobalIndex nodeId
node index
CepsCellGlobalIndex cellId
cell index
CepsDofGlobalIndex dofId
dof index
CepsUnknownIndex unknownId
unknown index
Used to retrieve the MPI "type" in function of the true type.