forked from dftfeDevelopers/dftfe
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuadDataCompositeWrite.cpp
More file actions
43 lines (38 loc) · 1.06 KB
/
QuadDataCompositeWrite.cpp
File metadata and controls
43 lines (38 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "QuadDataCompositeWrite.h"
#include <cstdio>
namespace dftfe
{
namespace dftUtils
{
QuadDataCompositeWrite::QuadDataCompositeWrite(
const std::vector<double> &vals)
: d_vals(vals)
, d_charspernum(20)
{}
void
QuadDataCompositeWrite::getCharArray(char *data)
{
const char *doubleFmt = "%19.12e ";
const char *doubleEndFmt = "%19.12e\n";
int count = 0;
for (int i = 0; i < d_vals.size() - 1; ++i)
{
sprintf(&data[count], doubleFmt, d_vals[i]);
count += d_charspernum;
}
sprintf(&data[count], doubleEndFmt, d_vals[d_vals.size() - 1]);
}
void
QuadDataCompositeWrite::getMPIDataType(MPI_Datatype *mpi_datatype)
{
int numberChars = getNumberCharsPerCompositeData();
MPI_Type_contiguous(numberChars, MPI_CHAR, mpi_datatype);
MPI_Type_commit(mpi_datatype);
}
int
QuadDataCompositeWrite::getNumberCharsPerCompositeData()
{
return d_charspernum * d_vals.size();
}
} // namespace dftUtils
} // namespace dftfe