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
29namespace dftfe
30{
31 namespace dftUtils
32 {
33 /**
34 * @brief Read from file containing only double data in columns.
35 *
36 * @param[in] numColumns number of data columsn in the file to be read
37 * @param[out] data output double data in [rows][columns] format
38 * @param[in] fileName
39 */
40 void
41 readFile(const unsigned int numColumns,
42 std::vector<std::vector<double>> &data,
43 const std::string & fileName);
44
45 /**
46 * @brief Read from file containing only double data in columns.
47 *
48 * @param[out] data output double data in [rows][columns] format
49 * @param[in] fileName
50 */
51 void
52 readFile(std::vector<std::vector<double>> &data,
53 const std::string & fileName);
54 /**
55 * @brief Read from file containing only double data in columns.
56 */
57 int
58 readPsiFile(const unsigned int numColumns,
59 std::vector<std::vector<double>> &data,
60 const std::string & fileName);
61
62 /**
63 * @brief Write data into file containing only double data in rows and columns.
64 *
65 * @param[in] data input double data in [rows][columns] format
66 * @param[in] fileName
67 * @param[in] mpi_comm_parent parent communicator
68 */
69 void
70 writeDataIntoFile(const std::vector<std::vector<double>> &data,
71 const std::string & fileName,
72 const MPI_Comm & mpi_comm_parent);
73
74 /**
75 * @brief Write data into file containing only double data in rows and columns.
76 *
77 * @param[in] data input double data in [rows][columns] format
78 * @param[in] fileName
79 */
80 void
81 writeDataIntoFile(const std::vector<std::vector<double>> &data,
82 const std::string & fileName);
83
84 /**
85 * @brief Read from file containing only integer data in columns.
86 */
87 void
88 readRelaxationFlagsFile(const unsigned int numColumns,
89 std::vector<std::vector<int>> & data,
90 std::vector<std::vector<double>> &forceData,
91 const std::string & fileName);
92
93 /**
94 * @brief Move/rename checkpoint file.
95 */
96 void
97 moveFile(const std::string &old_name, const std::string &new_name);
98
99 /**
100 * @brief copy file.
101 */
102 void
103 copyFile(const std::string &pathold, const std::string &pathnew);
104
105 /**
106 * @brief Verify if checkpoint file exists.
107 */
108 void
109 verifyCheckpointFileExists(const std::string &filename);
110 }; // namespace dftUtils
111
112} // namespace dftfe
113#endif
Contains repeatedly used functions in the KSDFT calculations.
Definition CompositeData.h:29
void readFile(const unsigned int numColumns, std::vector< std::vector< double > > &data, const std::string &fileName)
Read from file containing only double data in columns.
int readPsiFile(const unsigned int numColumns, std::vector< std::vector< double > > &data, const std::string &fileName)
Read from file containing only double data in columns.
void readRelaxationFlagsFile(const unsigned int numColumns, std::vector< std::vector< int > > &data, std::vector< std::vector< double > > &forceData, const std::string &fileName)
Read from file containing only integer 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