sync with GH
git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@15561 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
356
src/info.cpp
356
src/info.cpp
@ -1,4 +1,5 @@
|
||||
/* ----------------------------------------------------------------------
|
||||
fputs
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, Sandia National Laboratories
|
||||
Steve Plimpton, sjplimp@sandia.gov
|
||||
@ -12,7 +13,8 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing author: Axel Kohlmeyer (Temple U)
|
||||
Contributing authors: Axel Kohlmeyer (Temple U),
|
||||
Richard Berger (Temple U)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include <string.h>
|
||||
@ -39,6 +41,9 @@
|
||||
#include "error.h"
|
||||
|
||||
#include <time.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
|
||||
#ifdef _WIN32
|
||||
#define PSAPI_VERSION=1
|
||||
@ -70,9 +75,29 @@ enum {COMPUTES=1<<0,
|
||||
VARIABLES=1<<7,
|
||||
SYSTEM=1<<8,
|
||||
COMM=1<<9,
|
||||
ATOM_STYLES=1<<10,
|
||||
INTEGRATE_STYLES=1<<11,
|
||||
MINIMIZE_STYLES=1<<12,
|
||||
PAIR_STYLES=1<<13,
|
||||
BOND_STYLES=1<<14,
|
||||
ANGLE_STYLES=1<<15,
|
||||
DIHEDRAL_STYLES=1<<16,
|
||||
IMPROPER_STYLES=1<<17,
|
||||
KSPACE_STYLES=1<<18,
|
||||
FIX_STYLES=1<<19,
|
||||
COMPUTE_STYLES=1<<20,
|
||||
REGION_STYLES=1<<21,
|
||||
DUMP_STYLES=1<<22,
|
||||
COMMAND_STYLES=1<<23,
|
||||
ALL=~0};
|
||||
|
||||
static const int STYLES = ATOM_STYLES | INTEGRATE_STYLES | MINIMIZE_STYLES | PAIR_STYLES | BOND_STYLES | \
|
||||
ANGLE_STYLES | DIHEDRAL_STYLES | IMPROPER_STYLES | KSPACE_STYLES | FIX_STYLES | \
|
||||
COMPUTE_STYLES | REGION_STYLES | DUMP_STYLES | COMMAND_STYLES;
|
||||
|
||||
}
|
||||
|
||||
|
||||
static const char *varstyles[] = {
|
||||
"index", "loop", "world", "universe", "uloop", "string", "getenv",
|
||||
"file", "atomfile", "format", "equal", "atom", "python", "(unknown)"};
|
||||
@ -85,6 +110,9 @@ static const char *commlayout[] = { "uniform", "nonuniform", "irregular" };
|
||||
static const char bstyles[] = "pfsm";
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace std;
|
||||
|
||||
static void print_columns(FILE* fp, vector<string> & styles);
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -122,16 +150,16 @@ void Info::command(int narg, char **arg)
|
||||
if ((out != screen) && (out != logfile)) fclose(out);
|
||||
out = fopen(arg[idx+2],"w");
|
||||
idx += 3;
|
||||
} else if (strncmp(arg[idx],"communication",4) == 0) {
|
||||
} else if (strncmp(arg[idx],"communication",5) == 0) {
|
||||
flags |= COMM;
|
||||
++idx;
|
||||
} else if (strncmp(arg[idx],"computes",4) == 0) {
|
||||
} else if (strncmp(arg[idx],"computes",5) == 0) {
|
||||
flags |= COMPUTES;
|
||||
++idx;
|
||||
} else if (strncmp(arg[idx],"dumps",3) == 0) {
|
||||
} else if (strncmp(arg[idx],"dumps",5) == 0) {
|
||||
flags |= DUMPS;
|
||||
++idx;
|
||||
} else if (strncmp(arg[idx],"fixes",3) == 0) {
|
||||
} else if (strncmp(arg[idx],"fixes",5) == 0) {
|
||||
flags |= FIXES;
|
||||
++idx;
|
||||
} else if (strncmp(arg[idx],"groups",3) == 0) {
|
||||
@ -152,6 +180,61 @@ void Info::command(int narg, char **arg)
|
||||
} else if (strncmp(arg[idx],"system",3) == 0) {
|
||||
flags |= SYSTEM;
|
||||
++idx;
|
||||
} else if (strncmp(arg[idx],"styles",3) == 0) {
|
||||
if (idx+1 < narg) {
|
||||
++idx;
|
||||
if (strncmp(arg[idx],"all",3) == 0) {
|
||||
flags |= STYLES;
|
||||
++idx;
|
||||
} else if (strncmp(arg[idx],"atom",3) == 0) {
|
||||
flags |= ATOM_STYLES;
|
||||
++idx;
|
||||
} else if (strncmp(arg[idx],"integrate",3) == 0) {
|
||||
flags |= INTEGRATE_STYLES;
|
||||
++idx;
|
||||
} else if (strncmp(arg[idx],"minimize",3) == 0) {
|
||||
flags |= MINIMIZE_STYLES;
|
||||
++idx;
|
||||
} else if (strncmp(arg[idx],"pair",3) == 0) {
|
||||
flags |= PAIR_STYLES;
|
||||
++idx;
|
||||
} else if (strncmp(arg[idx],"bond",3) == 0) {
|
||||
flags |= BOND_STYLES;
|
||||
++idx;
|
||||
} else if (strncmp(arg[idx],"angle",3) == 0) {
|
||||
flags |= ANGLE_STYLES;
|
||||
++idx;
|
||||
} else if (strncmp(arg[idx],"dihedral",3) == 0) {
|
||||
flags |= DIHEDRAL_STYLES;
|
||||
++idx;
|
||||
} else if (strncmp(arg[idx],"improper",3) == 0) {
|
||||
flags |= IMPROPER_STYLES;
|
||||
++idx;
|
||||
} else if (strncmp(arg[idx],"kspace",3) == 0) {
|
||||
flags |= KSPACE_STYLES;
|
||||
++idx;
|
||||
} else if (strncmp(arg[idx],"fix",3) == 0) {
|
||||
flags |= FIX_STYLES;
|
||||
++idx;
|
||||
} else if (strncmp(arg[idx],"compute",4) == 0) {
|
||||
flags |= COMPUTE_STYLES;
|
||||
++idx;
|
||||
} else if (strncmp(arg[idx],"region",3) == 0) {
|
||||
flags |= REGION_STYLES;
|
||||
++idx;
|
||||
} else if (strncmp(arg[idx],"dump",3) == 0) {
|
||||
flags |= DUMP_STYLES;
|
||||
++idx;
|
||||
} else if (strncmp(arg[idx],"command",4) == 0) {
|
||||
flags |= COMMAND_STYLES;
|
||||
++idx;
|
||||
} else {
|
||||
flags |= STYLES;
|
||||
}
|
||||
} else {
|
||||
flags |= STYLES;
|
||||
++idx;
|
||||
}
|
||||
} else {
|
||||
error->warning(FLERR,"Ignoring unknown or incorrect info command flag");
|
||||
++idx;
|
||||
@ -457,6 +540,10 @@ void Info::command(int narg, char **arg)
|
||||
cpuh,cpum,cpus,wallh,wallm,walls);
|
||||
}
|
||||
|
||||
if (flags & STYLES) {
|
||||
available_styles(out, flags);
|
||||
}
|
||||
|
||||
fputs("\nInfo-Info-Info-Info-Info-Info-Info-Info-Info-Info-Info\n\n",out);
|
||||
|
||||
// close output file pointer if opened locally thus forcing a hard sync.
|
||||
@ -464,6 +551,225 @@ void Info::command(int narg, char **arg)
|
||||
fclose(out);
|
||||
}
|
||||
|
||||
|
||||
void Info::available_styles(FILE * out, int flags)
|
||||
{
|
||||
|
||||
fprintf(out,"\nStyles information:\n");
|
||||
|
||||
if(flags & ATOM_STYLES) atom_styles(out);
|
||||
if(flags & INTEGRATE_STYLES) integrate_styles(out);
|
||||
if(flags & MINIMIZE_STYLES) minimize_styles(out);
|
||||
if(flags & PAIR_STYLES) pair_styles(out);
|
||||
if(flags & BOND_STYLES) bond_styles(out);
|
||||
if(flags & ANGLE_STYLES) angle_styles(out);
|
||||
if(flags & DIHEDRAL_STYLES) dihedral_styles(out);
|
||||
if(flags & IMPROPER_STYLES) improper_styles(out);
|
||||
if(flags & KSPACE_STYLES) kspace_styles(out);
|
||||
if(flags & FIX_STYLES) fix_styles(out);
|
||||
if(flags & COMPUTE_STYLES) compute_styles(out);
|
||||
if(flags & REGION_STYLES) region_styles(out);
|
||||
if(flags & DUMP_STYLES) dump_styles(out);
|
||||
if(flags & COMMAND_STYLES) command_styles(out);
|
||||
}
|
||||
|
||||
void Info::atom_styles(FILE * out)
|
||||
{
|
||||
fprintf(out, "\nAtom styles:\n");
|
||||
|
||||
vector<string> styles;
|
||||
|
||||
for(Atom::AtomVecCreatorMap::iterator it = atom->avec_map->begin(); it != atom->avec_map->end(); ++it) {
|
||||
styles.push_back(it->first);
|
||||
}
|
||||
|
||||
print_columns(out, styles);
|
||||
fprintf(out, "\n\n\n");
|
||||
}
|
||||
|
||||
void Info::integrate_styles(FILE * out)
|
||||
{
|
||||
fprintf(out, "\nIntegrate styles:\n");
|
||||
|
||||
vector<string> styles;
|
||||
|
||||
for(Update::IntegrateCreatorMap::iterator it = update->integrate_map->begin(); it != update->integrate_map->end(); ++it) {
|
||||
styles.push_back(it->first);
|
||||
}
|
||||
|
||||
print_columns(out, styles);
|
||||
fprintf(out, "\n\n\n");
|
||||
}
|
||||
|
||||
void Info::minimize_styles(FILE * out)
|
||||
{
|
||||
fprintf(out, "\nMinimize styles:\n");
|
||||
|
||||
vector<string> styles;
|
||||
|
||||
for(Update::MinimizeCreatorMap::iterator it = update->minimize_map->begin(); it != update->minimize_map->end(); ++it) {
|
||||
styles.push_back(it->first);
|
||||
}
|
||||
|
||||
print_columns(out, styles);
|
||||
fprintf(out, "\n\n\n");
|
||||
}
|
||||
|
||||
void Info::pair_styles(FILE * out)
|
||||
{
|
||||
fprintf(out, "\nPair styles:\n");
|
||||
|
||||
vector<string> styles;
|
||||
|
||||
for(Force::PairCreatorMap::iterator it = force->pair_map->begin(); it != force->pair_map->end(); ++it) {
|
||||
styles.push_back(it->first);
|
||||
}
|
||||
|
||||
print_columns(out, styles);
|
||||
fprintf(out, "\n\n\n");
|
||||
}
|
||||
|
||||
void Info::bond_styles(FILE * out)
|
||||
{
|
||||
fprintf(out, "\nBond styles:\n");
|
||||
|
||||
vector<string> styles;
|
||||
|
||||
for(Force::BondCreatorMap::iterator it = force->bond_map->begin(); it != force->bond_map->end(); ++it) {
|
||||
styles.push_back(it->first);
|
||||
}
|
||||
|
||||
print_columns(out, styles);
|
||||
fprintf(out, "\n\n\n");
|
||||
}
|
||||
|
||||
void Info::angle_styles(FILE * out)
|
||||
{
|
||||
fprintf(out, "\nAngle styles:\n");
|
||||
|
||||
vector<string> styles;
|
||||
|
||||
for(Force::AngleCreatorMap::iterator it = force->angle_map->begin(); it != force->angle_map->end(); ++it) {
|
||||
styles.push_back(it->first);
|
||||
}
|
||||
|
||||
print_columns(out, styles);
|
||||
fprintf(out, "\n\n\n");
|
||||
}
|
||||
|
||||
void Info::dihedral_styles(FILE * out)
|
||||
{
|
||||
fprintf(out, "\nDihedral styles:\n");
|
||||
|
||||
vector<string> styles;
|
||||
|
||||
for(Force::DihedralCreatorMap::iterator it = force->dihedral_map->begin(); it != force->dihedral_map->end(); ++it) {
|
||||
styles.push_back(it->first);
|
||||
}
|
||||
|
||||
print_columns(out, styles);
|
||||
fprintf(out, "\n\n\n");
|
||||
}
|
||||
|
||||
void Info::improper_styles(FILE * out)
|
||||
{
|
||||
fprintf(out, "\nImproper styles:\n");
|
||||
|
||||
vector<string> styles;
|
||||
|
||||
for(Force::ImproperCreatorMap::iterator it = force->improper_map->begin(); it != force->improper_map->end(); ++it) {
|
||||
styles.push_back(it->first);
|
||||
}
|
||||
|
||||
print_columns(out, styles);
|
||||
fprintf(out, "\n\n\n");
|
||||
}
|
||||
|
||||
void Info::kspace_styles(FILE * out)
|
||||
{
|
||||
fprintf(out, "\nKSpace styles:\n");
|
||||
|
||||
vector<string> styles;
|
||||
|
||||
for(Force::KSpaceCreatorMap::iterator it = force->kspace_map->begin(); it != force->kspace_map->end(); ++it) {
|
||||
styles.push_back(it->first);
|
||||
}
|
||||
|
||||
print_columns(out, styles);
|
||||
fprintf(out, "\n\n\n");
|
||||
}
|
||||
|
||||
void Info::fix_styles(FILE * out)
|
||||
{
|
||||
fprintf(out, "\nFix styles:\n");
|
||||
|
||||
vector<string> styles;
|
||||
|
||||
for(Modify::FixCreatorMap::iterator it = modify->fix_map->begin(); it != modify->fix_map->end(); ++it) {
|
||||
styles.push_back(it->first);
|
||||
}
|
||||
|
||||
print_columns(out, styles);
|
||||
fprintf(out, "\n\n\n");
|
||||
}
|
||||
|
||||
void Info::compute_styles(FILE * out)
|
||||
{
|
||||
fprintf(out, "\nCompute styles:\n");
|
||||
|
||||
vector<string> styles;
|
||||
|
||||
for(Modify::ComputeCreatorMap::iterator it = modify->compute_map->begin(); it != modify->compute_map->end(); ++it) {
|
||||
styles.push_back(it->first);
|
||||
}
|
||||
|
||||
print_columns(out, styles);
|
||||
fprintf(out, "\n\n\n");
|
||||
}
|
||||
|
||||
void Info::region_styles(FILE * out)
|
||||
{
|
||||
fprintf(out, "\nRegion styles:\n");
|
||||
|
||||
vector<string> styles;
|
||||
|
||||
for(Domain::RegionCreatorMap::iterator it = domain->region_map->begin(); it != domain->region_map->end(); ++it) {
|
||||
styles.push_back(it->first);
|
||||
}
|
||||
|
||||
print_columns(out, styles);
|
||||
fprintf(out, "\n\n\n");
|
||||
}
|
||||
|
||||
void Info::dump_styles(FILE * out)
|
||||
{
|
||||
fprintf(out, "\nDump styles:\n");
|
||||
|
||||
vector<string> styles;
|
||||
|
||||
for(Output::DumpCreatorMap::iterator it = output->dump_map->begin(); it != output->dump_map->end(); ++it) {
|
||||
styles.push_back(it->first);
|
||||
}
|
||||
|
||||
print_columns(out, styles);
|
||||
fprintf(out, "\n\n\n");
|
||||
}
|
||||
|
||||
void Info::command_styles(FILE * out)
|
||||
{
|
||||
fprintf(out, "\nCommand styles (add-on input script commands):\n");
|
||||
|
||||
vector<string> styles;
|
||||
|
||||
for(Input::CommandCreatorMap::iterator it = input->command_map->begin(); it != input->command_map->end(); ++it) {
|
||||
styles.push_back(it->first);
|
||||
}
|
||||
|
||||
print_columns(out, styles);
|
||||
fprintf(out, "\n\n\n");
|
||||
}
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
// the is_active() function returns true if the selected style or name
|
||||
@ -681,3 +987,43 @@ bool Info::is_defined(const char *category, const char *name)
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void print_columns(FILE* fp, vector<string> & styles)
|
||||
{
|
||||
if (styles.size() == 0) {
|
||||
fprintf(fp, "\nNone");
|
||||
return;
|
||||
}
|
||||
|
||||
std::sort(styles.begin(), styles.end());
|
||||
|
||||
int pos = 80;
|
||||
for (int i = 0; i < styles.size(); ++i) {
|
||||
|
||||
// skip "secret" styles
|
||||
if (isupper(styles[i][0])) continue;
|
||||
|
||||
int len = styles[i].length();
|
||||
if (pos + len > 80) {
|
||||
fprintf(fp,"\n");
|
||||
pos = 0;
|
||||
}
|
||||
|
||||
if (len < 16) {
|
||||
fprintf(fp,"%-16s",styles[i].c_str());
|
||||
pos += 16;
|
||||
} else if (len < 32) {
|
||||
fprintf(fp,"%-32s",styles[i].c_str());
|
||||
pos += 32;
|
||||
} else if (len < 48) {
|
||||
fprintf(fp,"%-48s",styles[i].c_str());
|
||||
pos += 48;
|
||||
} else if (len < 64) {
|
||||
fprintf(fp,"%-64s",styles[i].c_str());
|
||||
pos += 64;
|
||||
} else {
|
||||
fprintf(fp,"%-80s",styles[i].c_str());
|
||||
pos += 80;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user