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#include <cstdint>
30// commonly used typedefs used in dftfe go here
31namespace dftfe
32{
33 namespace dataTypes
34 {
35#ifdef USE_COMPLEX
36 typedef std::complex<double> number;
37 typedef std::complex<float> numberFP32;
38 typedef double numberValueType;
39 typedef float numberFP32ValueType;
40#else
41 typedef double number;
42 typedef float numberFP32;
43 typedef double numberValueType;
44 typedef float numberFP32ValueType;
45#endif
46
47 inline MPI_Datatype
48 mpi_type_id(const int *)
49 {
50 return MPI_INT;
51 }
52
53 inline MPI_Datatype
54 mpi_type_id(const long int *)
55 {
56 return MPI_LONG;
57 }
58
59 inline MPI_Datatype
60 mpi_type_id(const unsigned int *)
61 {
62 return MPI_UNSIGNED;
63 }
64
65 inline MPI_Datatype
66 mpi_type_id(const unsigned long int *)
67 {
68 return MPI_UNSIGNED_LONG;
69 }
70
71 inline MPI_Datatype
72 mpi_type_id(const unsigned long long int *)
73 {
74 return MPI_UNSIGNED_LONG_LONG;
75 }
76
77
78 inline MPI_Datatype
79 mpi_type_id(const float *)
80 {
81 return MPI_FLOAT;
82 }
83
84
85 inline MPI_Datatype
86 mpi_type_id(const double *)
87 {
88 return MPI_DOUBLE;
89 }
90
91 inline MPI_Datatype
92 mpi_type_id(const long double *)
93 {
94 return MPI_LONG_DOUBLE;
95 }
96
97 inline MPI_Datatype
98 mpi_type_id(const std::complex<float> *)
99 {
100 return MPI_COMPLEX;
101 }
102
103 inline MPI_Datatype
104 mpi_type_id(const std::complex<double> *)
105 {
106 return MPI_DOUBLE_COMPLEX;
107 }
108
109 template <typename T>
111 {
112 typedef T type;
113 };
114
115 template <>
116 struct singlePrecType<double>
117 {
118 typedef float type;
119 };
120
121 template <>
122 struct singlePrecType<std::complex<double>>
123 {
124 typedef std::complex<float> type;
125 };
126
127 template <typename T>
129 {
130 typedef T type;
131 };
132
133 template <>
134 struct halfPrecType<double>
135 {
136 typedef uint16_t type;
137 };
138
139 template <>
140 struct halfPrecType<std::complex<double>>
141 {
142 typedef std::complex<uint16_t> type;
143 };
144
145 template <>
146 struct halfPrecType<float>
147 {
148 typedef uint16_t type;
149 };
150
151 template <>
152 struct halfPrecType<std::complex<float>>
153 {
154 typedef std::complex<uint16_t> type;
155 };
156 } // namespace dataTypes
157} // namespace dftfe
158
159#endif
Definition dftfeDataTypes.h:34
double numberValueType
Definition dftfeDataTypes.h:43
float numberFP32ValueType
Definition dftfeDataTypes.h:44
double number
Definition dftfeDataTypes.h:41
MPI_Datatype mpi_type_id(const int *)
Definition dftfeDataTypes.h:48
float numberFP32
Definition dftfeDataTypes.h:42
Definition pseudoPotentialToDftfeConverter.cc:34
uint16_t type
Definition dftfeDataTypes.h:136
uint16_t type
Definition dftfeDataTypes.h:148
std::complex< uint16_t > type
Definition dftfeDataTypes.h:142
std::complex< uint16_t > type
Definition dftfeDataTypes.h:154
Definition dftfeDataTypes.h:129
T type
Definition dftfeDataTypes.h:130
float type
Definition dftfeDataTypes.h:118
std::complex< float > type
Definition dftfeDataTypes.h:124
Definition dftfeDataTypes.h:111
T type
Definition dftfeDataTypes.h:112