DFT-FE 1.1.0-pre
Density Functional Theory With Finite-Elements
Loading...
Searching...
No Matches
fileReaders.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/** @file fileReaders.h
18 * @brief Contains commonly used I/O file utils functions
19 *
20 * @author Shiva Rudraraju, Phani Motamarri, Sambit Das
21 */
22
23#ifndef fileReaders_H_
24#define fileReaders_H_
25#include <string>
26#include <vector>
27#include <mpi.h>
28#include <TypeConfig.h>
29
30namespace dftfe
31{
32 namespace dftUtils
33 {
34 /**
35 * @brief Read from file containing only double data in columns.
36 *
37 * @param[in] numColumns number of data columsn in the file to be read
38 * @param[out] data output double data in [rows][columns] format
39 * @param[in] fileName
40 */
41 void
42 readFile(const dftfe::uInt numColumns,
43 std::vector<std::vector<double>> &data,
44 const std::string &fileName);
45
46 /**
47 * @brief Read from file containing only double data in columns.
48 *
49 * @param[out] data output double data in [rows][columns] format
50 * @param[in] fileName
51 */
52 void
53 readFile(std::vector<std::vector<double>> &data,
54 const std::string &fileName);
55 /**
56 * @brief Read from file containing only double data in columns.
57 */
59 readPsiFile(const dftfe::uInt numColumns,
60 std::vector<std::vector<double>> &data,
61 const std::string &fileName);
62
63 /**
64 * @brief Write data into file containing only double data in rows and columns.
65 *
66 * @param[in] data input double data in [rows][columns] format
67 * @param[in] fileName
68 * @param[in] mpi_comm_parent parent communicator
69 */
70 void
71 writeDataIntoFile(const std::vector<std::vector<double>> &data,
72 const std::string &fileName,
73 const MPI_Comm &mpi_comm_parent);
74
75 /**
76 * @brief Write data into file containing only double data in rows and columns.
77 *
78 * @param[in] data input double data in [rows][columns] format
79 * @param[in] fileName
80 */
81 void
82 writeDataIntoFile(const std::vector<std::vector<double>> &data,
83 const std::string &fileName);
84
85 /**
86 * @brief Read from file containing only integer data in columns.
87 */
88 void
90 std::vector<std::vector<dftfe::Int>> &data,
91 std::vector<std::vector<double>> &forceData,
92 const std::string &fileName);
93
94 /**
95 * @brief Move/rename checkpoint file.
96 */
97 void
98 moveFile(const std::string &old_name, const std::string &new_name);
99
100 /**
101 * @brief copy file.
102 */
103 void
104 copyFile(const std::string &pathold, const std::string &pathnew);
105
106 /**
107 * @brief Verify if checkpoint file exists.
108 */
109 void
110 verifyCheckpointFileExists(const std::string &filename);
111 }; // namespace dftUtils
112
113} // namespace dftfe
114#endif
Contains repeatedly used functions in the KSDFT calculations.
Definition CompositeData.h:29
void readFile(const dftfe::uInt numColumns, std::vector< std::vector< double > > &data, const std::string &fileName)
Read from file containing only double data in columns.
void readRelaxationFlagsFile(const dftfe::uInt numColumns, std::vector< std::vector< dftfe::Int > > &data, std::vector< std::vector< double > > &forceData, const std::string &fileName)
Read from file containing only integer data in columns.
dftfe::Int readPsiFile(const dftfe::uInt numColumns, std::vector< std::vector< double > > &data, const std::string &fileName)
Read from file containing only double data in columns.
void moveFile(const std::string &old_name, const std::string &new_name)
Move/rename checkpoint file.
void writeDataIntoFile(const std::vector< std::vector< double > > &data, const std::string &fileName, const MPI_Comm &mpi_comm_parent)
Write data into file containing only double data in rows and columns.
void verifyCheckpointFileExists(const std::string &filename)
Verify if checkpoint file exists.
void copyFile(const std::string &pathold, const std::string &pathnew)
copy file.
Definition pseudoPotentialToDftfeConverter.cc:34
std::uint32_t uInt
Definition TypeConfig.h:10
std::int32_t Int
Definition TypeConfig.h:11