simplify Domain::print_box()

This commit is contained in:
Axel Kohlmeyer 2020-06-03 22:52:49 -04:00
parent fc216edf10
commit 00fd82016c
No known key found for this signature in database
GPG Key ID: D9B44E93BF0C375A
2 changed files with 13 additions and 25 deletions

View File

@ -39,6 +39,7 @@
#include "memory.h"
#include "error.h"
#include "utils.h"
#include "fmt/format.h"
using namespace LAMMPS_NS;
@ -1935,33 +1936,20 @@ void Domain::set_box(int narg, char **arg)
print box info, orthogonal or triclinic
------------------------------------------------------------------------- */
void Domain::print_box(const char *str)
void Domain::print_box(const std::string &prefix)
{
if (comm->me == 0) {
if (screen) {
if (triclinic == 0)
fprintf(screen,"%sorthogonal box = (%g %g %g) to (%g %g %g)\n",
str,boxlo[0],boxlo[1],boxlo[2],boxhi[0],boxhi[1],boxhi[2]);
else {
char *format = (char *)
"%striclinic box = (%g %g %g) to (%g %g %g) with tilt (%g %g %g)\n";
fprintf(screen,format,
str,boxlo[0],boxlo[1],boxlo[2],boxhi[0],boxhi[1],boxhi[2],
xy,xz,yz);
}
}
if (logfile) {
if (triclinic == 0)
fprintf(logfile,"%sorthogonal box = (%g %g %g) to (%g %g %g)\n",
str,boxlo[0],boxlo[1],boxlo[2],boxhi[0],boxhi[1],boxhi[2]);
else {
char *format = (char *)
"%striclinic box = (%g %g %g) to (%g %g %g) with tilt (%g %g %g)\n";
fprintf(logfile,format,
str,boxlo[0],boxlo[1],boxlo[2],boxhi[0],boxhi[1],boxhi[2],
xy,xz,yz);
}
std::string mesg = prefix;
if (triclinic == 0) {
mesg += fmt::format("orthogonal box = ({} {} {}) to ({} {} {})\n",
boxlo[0],boxlo[1],boxlo[2],
boxhi[0],boxhi[1],boxhi[2]);
} else {
mesg += fmt::format("triclinic box = ({} {} {}) to ({} {} {}) "
"with tilt ({} {} {})\n",boxlo[0],boxlo[1],
boxlo[2],boxhi[0],boxhi[1],boxhi[2],xy,xz,yz);
}
utils::logmesg(lmp,mesg);
}
}

View File

@ -131,7 +131,7 @@ class Domain : protected Pointers {
int find_region(char *);
void set_boundary(int, char **, int);
void set_box(int, char **);
void print_box(const char *);
void print_box(const std::string &);
void boundary_string(char *);
virtual void lamda2x(int);