DFT-FE 1.3.0-pre
Density Functional Theory With Finite-Elements
Loading...
Searching...
No Matches
dftfeDataTypes.h
Go to the documentation of this file.
1// ---------------------------------------------------------------------
2//
3// Copyright (c) 2017-2025 The Regents of the University of Michigan and DFT-FE
4// authors.
5//
6// This file is part of the DFT-FE code.
7//
8// The DFT-FE code is free software; you can use it, redistribute
9// it, and/or modify it under the terms of the GNU Lesser General
10// Public License as published by the Free Software Foundation; either
11// version 2.1 of the License, or (at your option) any later version.
12// The full text of the license can be found in the file LICENSE at
13// the top level of the DFT-FE distribution.
14//
15// ---------------------------------------------------------------------
16//
17// @author Sambit Das
18//
19
20#ifndef dftfeDataTypes_H_
21#define dftfeDataTypes_H_
22
23// Include generic C++ headers
24#include <fstream>
25#include <iostream>
26#include <fenv.h>
27#include <complex>
28#include <mpi.h>
29// commonly used typedefs used in dftfe go here
30namespace dftfe
31{
32 namespace dataTypes
33 {
34#ifdef USE_COMPLEX
35 typedef std::complex<double> number;
36 typedef std::complex<float> numberFP32;
37 typedef double numberValueType;
38 typedef float numberFP32ValueType;
39#else
40 typedef double number;
41 typedef float numberFP32;
42 typedef double numberValueType;
43 typedef float numberFP32ValueType;
44#endif
45
46 inline MPI_Datatype
47 mpi_type_id(const int *)
48 {
49 return MPI_INT;
50 }
51
52 inline MPI_Datatype
53 mpi_type_id(const long int *)
54 {
55 return MPI_LONG;
56 }
57
58 inline MPI_Datatype
59 mpi_type_id(const unsigned int *)
60 {
61 return MPI_UNSIGNED;
62 }
63
64 inline MPI_Datatype
65 mpi_type_id(const unsigned long int *)
66 {
67 return MPI_UNSIGNED_LONG;
68 }
69
70 inline MPI_Datatype
71 mpi_type_id(const unsigned long long int *)
72 {
73 return MPI_UNSIGNED_LONG_LONG;
74 }
75
76
77 inline MPI_Datatype
78 mpi_type_id(const float *)
79 {
80 return MPI_FLOAT;
81 }
82
83
84 inline MPI_Datatype
85 mpi_type_id(const double *)
86 {
87 return MPI_DOUBLE;
88 }
89
90 inline MPI_Datatype
91 mpi_type_id(const long double *)
92 {
93 return MPI_LONG_DOUBLE;
94 }
95
96 inline MPI_Datatype
97 mpi_type_id(const std::complex<float> *)
98 {
99 return MPI_COMPLEX;
100 }
101
102 inline MPI_Datatype
103 mpi_type_id(const std::complex<double> *)
104 {
105 return MPI_DOUBLE_COMPLEX;
106 }
107
108 template <typename T>
110 {
111 typedef T type;
112 };
113
114 template <>
115 struct singlePrecType<double>
116 {
117 typedef float type;
118 };
119
120 template <>
121 struct singlePrecType<std::complex<double>>
122 {
123 typedef std::complex<float> type;
124 };
125
126 } // namespace dataTypes
127} // namespace dftfe
128
129#endif
Definition dftfeDataTypes.h:33
double numberValueType
Definition dftfeDataTypes.h:42
float numberFP32ValueType
Definition dftfeDataTypes.h:43
double number
Definition dftfeDataTypes.h:40
MPI_Datatype mpi_type_id(const int *)
Definition dftfeDataTypes.h:47
float numberFP32
Definition dftfeDataTypes.h:41
Definition pseudoPotentialToDftfeConverter.cc:34
float type
Definition dftfeDataTypes.h:117
std::complex< float > type
Definition dftfeDataTypes.h:123
Definition dftfeDataTypes.h:110
T type
Definition dftfeDataTypes.h:111