replace use of iostreams and stringstreams with stdio and fmtlib
This commit is contained in:
@ -31,12 +31,10 @@
|
|||||||
#include "modify.h"
|
#include "modify.h"
|
||||||
#include "random_mars.h"
|
#include "random_mars.h"
|
||||||
#include "update.h"
|
#include "update.h"
|
||||||
|
|
||||||
#include <cfloat>
|
#include <cfloat>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <fstream>
|
|
||||||
#include <iomanip>
|
|
||||||
#include <sstream>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "latboltz_const.h"
|
#include "latboltz_const.h"
|
||||||
@ -688,14 +686,8 @@ FixLbFluid::~FixLbFluid()
|
|||||||
" </Grid>\n"
|
" </Grid>\n"
|
||||||
" </Domain>\n"
|
" </Domain>\n"
|
||||||
"</Xdmf>\n");
|
"</Xdmf>\n");
|
||||||
if (fclose(dump_file_handle_xdmf) != 0) {
|
if (fclose(dump_file_handle_xdmf))
|
||||||
std::ostringstream combined;
|
error->one(FLERR, "Unable to close \"{}\": {}", dump_file_name_xdmf, utils::getsyserror());
|
||||||
|
|
||||||
// The message plus the status
|
|
||||||
combined << std::string("unable to close \"") + dump_file_name_xdmf + std::string("\"");
|
|
||||||
|
|
||||||
error->one(FLERR, combined.str().c_str());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
MPI_File_close(&dump_file_handle_raw);
|
MPI_File_close(&dump_file_handle_raw);
|
||||||
}
|
}
|
||||||
@ -732,8 +724,8 @@ FixLbFluid::~FixLbFluid()
|
|||||||
|
|
||||||
int FixLbFluid::setmask()
|
int FixLbFluid::setmask()
|
||||||
{
|
{
|
||||||
return FixConst::INITIAL_INTEGRATE | FixConst::PRE_FORCE | FixConst::POST_FORCE |
|
return FixConst::INITIAL_INTEGRATE | FixConst::POST_FORCE | FixConst::FINAL_INTEGRATE |
|
||||||
FixConst::FINAL_INTEGRATE | FixConst::END_OF_STEP;
|
FixConst::END_OF_STEP;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FixLbFluid::init(void)
|
void FixLbFluid::init(void)
|
||||||
@ -856,8 +848,6 @@ void FixLbFluid::initial_integrate(int /* vflag */)
|
|||||||
timePCalc += MPI_Wtime() - st;
|
timePCalc += MPI_Wtime() - st;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FixLbFluid::pre_force(int vflag) {}
|
|
||||||
|
|
||||||
void FixLbFluid::post_force(int /*vflag*/)
|
void FixLbFluid::post_force(int /*vflag*/)
|
||||||
{
|
{
|
||||||
if (fixviscouslb == 1) {
|
if (fixviscouslb == 1) {
|
||||||
@ -1042,7 +1032,7 @@ void FixLbFluid::InitializeFirstRun(void)
|
|||||||
// Output for t=0
|
// Output for t=0
|
||||||
dump(update->ntimestep);
|
dump(update->ntimestep);
|
||||||
|
|
||||||
if (me == 0) utils::logmesg(lmp,"First Run initialized\n");
|
if (me == 0) utils::logmesg(lmp, "First Run initialized\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
@ -2355,15 +2345,9 @@ void FixLbFluid::SetupBuffers(void)
|
|||||||
if (dump_interval) {
|
if (dump_interval) {
|
||||||
if (me == 0) {
|
if (me == 0) {
|
||||||
dump_file_handle_xdmf = fopen(dump_file_name_xdmf.c_str(), "w");
|
dump_file_handle_xdmf = fopen(dump_file_name_xdmf.c_str(), "w");
|
||||||
if (!dump_file_handle_xdmf) {
|
if (!dump_file_handle_xdmf)
|
||||||
std::ostringstream combined;
|
error->one(FLERR, "Unable to truncate/create \"{}\": {}", dump_file_name_xdmf,
|
||||||
|
utils::getsyserror());
|
||||||
// The message plus the status
|
|
||||||
combined << std::string("unable to truncate/create \"") + dump_file_name_xdmf +
|
|
||||||
std::string("\"");
|
|
||||||
|
|
||||||
error->one(FLERR, combined.str().c_str());
|
|
||||||
}
|
|
||||||
fprintf(dump_file_handle_xdmf,
|
fprintf(dump_file_handle_xdmf,
|
||||||
"<?xml version=\"1.0\" ?>\n"
|
"<?xml version=\"1.0\" ?>\n"
|
||||||
"<!DOCTYPE Xdmf SYSTEM \"Xdmf.dtd\" []>\n"
|
"<!DOCTYPE Xdmf SYSTEM \"Xdmf.dtd\" []>\n"
|
||||||
@ -2372,9 +2356,6 @@ void FixLbFluid::SetupBuffers(void)
|
|||||||
" <Grid Name=\"fluid\" GridType=\"Collection\" CollectionType=\"Temporal\">\n\n");
|
" <Grid Name=\"fluid\" GridType=\"Collection\" CollectionType=\"Temporal\">\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// MPI_File_open(world, const_cast<char*>(dump_file_name_raw.c_str()),
|
|
||||||
// MPI_MODE_CREATE|MPI_MODE_WRONLY|MPI_MODE_UNIQUE_OPEN,
|
|
||||||
// MPI_INFO_NULL, &dump_file_handle_raw);
|
|
||||||
MPI_File_open(world, const_cast<char *>(dump_file_name_raw.c_str()),
|
MPI_File_open(world, const_cast<char *>(dump_file_name_raw.c_str()),
|
||||||
MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, &dump_file_handle_raw);
|
MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, &dump_file_handle_raw);
|
||||||
|
|
||||||
@ -3796,62 +3777,57 @@ void FixLbFluid::initializeGeometry()
|
|||||||
// Output local geometry to data files labeled with processor number
|
// Output local geometry to data files labeled with processor number
|
||||||
// Type dump
|
// Type dump
|
||||||
if (geodump) {
|
if (geodump) {
|
||||||
char datfile[FILENAME_MAX];
|
auto datfile = fmt::format("subgeom_{}_end_type.dmp", me);
|
||||||
sprintf(datfile, "subgeom_%d_end_type.dmp", me);
|
FILE *outfile = fopen(datfile.c_str(), "w");
|
||||||
std::ofstream outFile(datfile);
|
if (!outfile)
|
||||||
|
|
||||||
if (!outFile.is_open()) {
|
|
||||||
error->one(FLERR, " file {} could not be opened: {}", datfile, utils::getsyserror());
|
error->one(FLERR, " file {} could not be opened: {}", datfile, utils::getsyserror());
|
||||||
}
|
|
||||||
outFile << std::endl;
|
fmt::print(outfile, "\n me: {} px: {} py: {} pz: {}\n", me, comm->myloc[0], comm->myloc[1],
|
||||||
outFile << "me: " << me << " px: " << comm->myloc[0] << " py: " << comm->myloc[1]
|
comm->myloc[2]);
|
||||||
<< " pz: " << comm->myloc[2] << std::endl;
|
|
||||||
for (i = 0; i < subNbx; i++) {
|
for (i = 0; i < subNbx; i++) {
|
||||||
outFile << "i=" << i << std::endl;
|
fmt::print(outfile, "i={}\n", i);
|
||||||
for (k = subNbz - 1; k > -1; k--) {
|
for (k = subNbz - 1; k > -1; k--) {
|
||||||
if (k == subNbz - 2 || k == 0) {
|
if (k == subNbz - 2 || k == 0) {
|
||||||
for (j = 0; j < subNby + 2; j++) outFile << "---";
|
for (j = 0; j < subNby + 2; j++) fputs("---", outfile);
|
||||||
outFile << std::endl;
|
fputs("\n", outfile);
|
||||||
}
|
}
|
||||||
for (j = 0; j < subNby; j++) {
|
for (j = 0; j < subNby; j++) {
|
||||||
outFile << " " << sublattice[i][j][k].type << " ";
|
fmt::print(outfile, " {} ", sublattice[i][j][k].type);
|
||||||
if (j == 0 || j == subNby - 2) outFile << " | ";
|
if (j == 0 || j == subNby - 2) fputs(" | ", outfile);
|
||||||
if (j == subNby - 1) outFile << std::endl;
|
if (j == subNby - 1) fputs("\n", outfile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
outFile << " " << std::endl;
|
fputs(" \n \n", outfile);
|
||||||
outFile << " " << std::endl;
|
|
||||||
}
|
}
|
||||||
outFile << std::endl;
|
fputs("\n", outfile);
|
||||||
outFile.close();
|
fclose(outfile);
|
||||||
|
|
||||||
// Orientation dump
|
// Orientation dump
|
||||||
sprintf(datfile, "subgeom_%d_end_ori.dmp", me);
|
datfile = fmt::format("subgeom_{}_end_ori.dmp", me);
|
||||||
outFile.open(datfile);
|
outfile = fopen(datfile.c_str(), "w");
|
||||||
|
|
||||||
if (!outFile.is_open()) {
|
if (!outfile)
|
||||||
error->one(FLERR, " file {} could not be opened: {}", datfile, utils::getsyserror());
|
error->one(FLERR, " file {} could not be opened: {}", datfile, utils::getsyserror());
|
||||||
}
|
|
||||||
outFile << std::endl;
|
fmt::print("\nme: {}\n", me);
|
||||||
outFile << "me: " << me << std::endl;
|
|
||||||
for (i = 0; i < subNbx; i++) {
|
for (i = 0; i < subNbx; i++) {
|
||||||
outFile << "i=" << i << std::endl;
|
fmt::print("i={}\n", i);
|
||||||
for (k = subNbz - 1; k > -1; k--) {
|
for (k = subNbz - 1; k > -1; k--) {
|
||||||
if (k == subNbz - 2 || k == 0) {
|
if (k == subNbz - 2 || k == 0) {
|
||||||
for (j = 0; j < subNby + 2; j++) outFile << "---";
|
for (j = 0; j < subNby + 2; j++) fputs("---", outfile);
|
||||||
outFile << std::endl;
|
fputs("\bn", outfile);
|
||||||
}
|
}
|
||||||
for (j = 0; j < subNby; j++) {
|
for (j = 0; j < subNby; j++) {
|
||||||
outFile << " " << sublattice[i][j][k].orientation << " ";
|
fmt::print(outfile, " {} ", sublattice[i][j][k].orientation);
|
||||||
if (j == 0 || j == subNby - 2) outFile << " | ";
|
if (j == 0 || j == subNby - 2) fputs(" | ", outfile);
|
||||||
if (j == subNby - 1) outFile << std::endl;
|
if (j == subNby - 1) fputs("\n", outfile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
outFile << " " << std::endl;
|
fputs(" \n \n", outfile);
|
||||||
outFile << " " << std::endl;
|
|
||||||
}
|
}
|
||||||
outFile << std::endl;
|
fputs("\n", outfile);
|
||||||
outFile.close();
|
fclose(outfile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user