TBTK
FileReader.h
Go to the documentation of this file.
1 /* Copyright 2016 Kristofer Bj√∂rnson and Andreas Theiler
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
24 #ifndef COM_DAFER45_TBTK_FILE_READER
25 #define COM_DAFER45_TBTK_FILE_READER
26 
28 #include "TBTK/Geometry.h"
29 #include "TBTK/Model.h"
30 #include "TBTK/ParameterSet.h"
32 #include "TBTK/Property/DOS.h"
33 #include "TBTK/Property/Density.h"
35 #include "TBTK/Property/LDOS.h"
36 #include "TBTK/Property/SpectralFunction.h"
39 
40 #include <fstream>
41 #include <stdio.h>
42 
43 namespace TBTK{
44 
50 class FileReader{
51 public:
53  static Model* readModel(
54  std::string name = "Model",
55  std::string path = "/"
56  );
57 
60  std::string name = "HoppingAmplitudeSet",
61  std::string path = "/"
62  );
63 
65  static Geometry* readGeometry(
66  Model *model,
67  std::string name = "Geometry",
68  std::string path = "/"
69  );
70 
72  static IndexTree* readIndexTree(
73  std::string name = "IndexTree",
74  std::string path = "/"
75  );
76 
79  std::string name = "EigenValues",
80  std::string path = "/"
81  );
82 
85  std::string name = "WaveFunctions",
86  std::string pat = "/"
87  );
88 
90  static Property::DOS* readDOS(
91  std::string name = "DOS",
92  std::string path = "/"
93  );
94 
97  std::string name = "Density",
98  std::string path = "/"
99  );
100 
103  std::string name = "Magnetization",
104  std::string path = "/"
105  );
106 
108  static Property::LDOS* readLDOS(
109  std::string name = "LDOS",
110  std::string path = "/"
111  );
112 
115  std::string name = "SpectralFunction",
116  std::string path = "/"
117  );
118 
121  std::string name = "SpinPolarizedLDOS",
122  std::string path = "/"
123  );
124 
127  std::string name = "ParameterSet",
128  std::string path = "/"
129  );
130 
132  static void read(
133  int **data,
134  int *rank,
135  int **dims,
136  std::string name,
137  std::string path = "/"
138  );
139 
141  static void read(
142  double **data,
143  int *rank,
144  int **dims,
145  std::string name,
146  std::string path = "/"
147  );
148 
151  static void read(
152  std::complex<double> **data,
153  int *rank,
154  int **dims,
155  std::string name,
156  std::string path = "/"
157  );
158 
160  static void readAttributes(
161  int *attributes,
162  std::string *attribute_names,
163  int num,
164  std::string name,
165  std::string path = "/"
166  );
167 
169  static void readAttributes(
170  double *attributes,
171  std::string *attribute_names,
172  int num,
173  std::string name,
174  std::string path = "/"
175  );
176 
178  static void setFileName(std::string filename);
179 
182  static void clear();
183 
185  static bool exists();
186 private:
188  static bool isInitialized;
189 
191  static std::string filename;
192 };
193 
195  std::string name,
196  std::string path
197 ){
198  return reinterpret_cast<Property::SpectralFunction*>(readLDOS(name, path));
199 }
200 
201 inline void FileReader::setFileName(std::string filename){
202  FileReader::filename = filename;
203  isInitialized = false;
204 }
205 
206 inline void FileReader::clear(){
207  remove(filename.c_str());
208  isInitialized = false;
209 }
210 
211 }; //End of namespace TBTK
212 
213 #endif
214 
static void readAttributes(int *attributes, std::string *attribute_names, int num, std::string name, std::string path="/")
static Property::SpinPolarizedLDOS * readSpinPolarizedLDOS(std::string name="SpinPolarizedLDOS", std::string path="/")
Property container for local density of states (LDOS).
Definition: LDOS.h:33
Property container for eigen values..
Definition: EigenValues.h:32
static void setFileName(std::string filename)
Definition: FileReader.h:201
HoppingAmplitude container.
Definition: HoppingAmplitudeSet.h:49
Property container for magnetization.
Definition: Magnetization.h:35
Property container for spectral function.
Definition: SpectralFunction.h:32
Property container for eigen values.
Property container for local density of states (LDOS).
static Model * readModel(std::string name="Model", std::string path="/")
static bool exists()
Container of Model related information.
static Property::EigenValues * readEigenValues(std::string name="EigenValues", std::string path="/")
static Property::LDOS * readLDOS(std::string name="LDOS", std::string path="/")
static Geometry * readGeometry(Model *model, std::string name="Geometry", std::string path="/")
Set of parameters.
HoppingAmplitude container.
Definition: FileReader.h:50
Property container for spin-polarized local density of states (spin-polarized LDOS).
static ParameterSet * readParameterSet(std::string name="ParameterSet", std::string path="/")
Property container for density.
static Property::Density * readDensity(std::string name="Density", std::string path="/")
static IndexTree * readIndexTree(std::string name="IndexTree", std::string path="/")
Property container for magnetization.
static void clear()
Definition: FileReader.h:206
static HoppingAmplitudeSet * readHoppingAmplitudeSet(std::string name="HoppingAmplitudeSet", std::string path="/")
Data structure for mapping physical indices to a linear index.
Definition: IndexTree.h:34
static Property::SpectralFunction * readSpectralFunction(std::string name="SpectralFunction", std::string path="/")
Definition: FileReader.h:194
static Property::WaveFunctions * readWaveFunctions(std::string name="WaveFunctions", std::string pat="/")
Definition: ModelFactory.h:35
Definition: ParameterSet.h:34
Property container for wave function.
Definition: WaveFunctions.h:34
Property container for spin-polarized local density of states (spin-polarized LDOS).
Definition: SpinPolarizedLDOS.h:37
Property container for density.
Definition: Density.h:33
Property container for density of states (DOS).
Contains geometric information about a Model.
Definition: Geometry.h:35
static Property::DOS * readDOS(std::string name="DOS", std::string path="/")
static void read(int **data, int *rank, int **dims, std::string name, std::string path="/")
Property container for density of states (DOS).
Definition: DOS.h:32
Property container for wave functions.
Container of Model related information.
Definition: Model.h:52
static Property::Magnetization * readMagnetization(std::string name="Magnetization", std::string path="/")
Contains geometric inforamtion about a Model.