Commit b866e066 authored by sjplimp's avatar sjplimp Committed by GitHub
Browse files

Merge pull request #24 from rbberger/info_command_styles

Info command extensions
parents 5d0da95a 1f901c9b
Loading
Loading
Loading
Loading
+26 −4
Original line number Diff line number Diff line
@@ -131,10 +131,11 @@
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">info</span> <span class="n">args</span>
</pre></div>
</div>
<dl class="docutils">
<dt>args = one or more of the following keywords: <em>out</em>, <em>all</em>, <em>system</em>, <em>communication</em>, <em>computes</em>, <em>dumps</em>, <em>fixes</em>, <em>groups</em>, <em>regions</em>, <em>variables</em>, <em>time</em>, or <em>configuration</em></dt>
<dd><em>out</em> values = <em>screen</em>, <em>log</em>, <em>append</em> filename, <em>overwrite</em> filename:ul</dd>
</dl>
<ul class="simple">
<li>args = one or more of the following keywords: <em>out</em>, <em>all</em>, <em>system</em>, <em>communication</em>, <em>computes</em>, <em>dumps</em>, <em>fixes</em>, <em>groups</em>, <em>regions</em>, <em>variables</em>, <em>styles</em>, <em>time</em>, or <em>configuration</em></li>
<li><em>out</em> values = <em>screen</em>, <em>log</em>, <em>append</em> filename, <em>overwrite</em> filename</li>
<li><em>styles</em> values = <em>all</em>, <em>angle</em>, <em>atom</em>, <em>bond</em>, <em>compute</em>, <em>command</em>, <em>dump</em>, <em>dihedral</em>, <em>fix</em>, <em>improper</em>, <em>integrate</em>, <em>kspace</em>, <em>minimize</em>, <em>region</em></li>
</ul>
</div>
<div class="section" id="examples">
<h2>Examples</h2>
@@ -142,6 +143,8 @@
<span class="n">info</span> <span class="n">groups</span> <span class="n">computes</span> <span class="n">variables</span>
<span class="n">info</span> <span class="nb">all</span> <span class="n">out</span> <span class="n">log</span>
<span class="n">info</span> <span class="nb">all</span> <span class="n">out</span> <span class="n">append</span> <span class="n">info</span><span class="o">.</span><span class="n">txt</span>
<span class="n">info</span> <span class="n">styles</span> <span class="nb">all</span>
<span class="n">info</span> <span class="n">styles</span> <span class="n">atom</span>
</pre></div>
</div>
</div>
@@ -179,6 +182,24 @@ selected.</p>
<p>The <em>variables</em> category prints a list of all currently defined
variables, their names, styles, definition and last computed value, if
available.</p>
<p>The <em>styles</em> category prints the list of styles available in LAMMPS. It
supports one of the following options to control what is printed out:</p>
<ul class="simple">
<li>all</li>
<li>angle</li>
<li>atom</li>
<li>bond</li>
<li>compute</li>
<li>command</li>
<li>dump</li>
<li>dihedral</li>
<li>fix</li>
<li>improper</li>
<li>integrate</li>
<li>kspace</li>
<li>minimize</li>
<li>region</li>
</ul>
<p>The <em>time</em> category prints the accumulated CPU and wall time for the
process that writes output (usually MPI rank 0).</p>
<p>The <em>configuration</em> command prints some information about the LAMMPS
@@ -198,6 +219,7 @@ reported.</p>
<div class="section" id="default">
<h2>Default</h2>
<p>The <em>out</em> option has the default <em>screen</em>.</p>
<p>The <em>styles</em> option has the default <em>all</em>.</p>
</div>
</div>

+26 −3
Original line number Diff line number Diff line
@@ -12,15 +12,18 @@ info command :h3

info args :pre

args = one or more of the following keywords: {out}, {all}, {system}, {communication}, {computes}, {dumps}, {fixes}, {groups}, {regions}, {variables}, {time}, or {configuration}
     {out} values = {screen}, {log}, {append} filename, {overwrite} filename:ul
args = one or more of the following keywords: {out}, {all}, {system}, {communication}, {computes}, {dumps}, {fixes}, {groups}, {regions}, {variables}, {styles}, {time}, or {configuration}
     {out} values = {screen}, {log}, {append} filename, {overwrite} filename
     {styles} values = {all}, {angle}, {atom}, {bond}, {compute}, {command}, {dump}, {dihedral}, {fix}, {improper}, {integrate}, {kspace}, {minimize}, {region} :ul

[Examples:]

info system
info groups computes variables
info all out log
info all out append info.txt :pre
info all out append info.txt
info styles all
info styles atom :pre

[Description:]

@@ -67,6 +70,24 @@ The {variables} category prints a list of all currently defined
variables, their names, styles, definition and last computed value, if
available.

The {styles} category prints the list of styles available in LAMMPS. It
supports one of the following options to control what is printed out:

all
angle
atom
bond
compute
command
dump
dihedral
fix
improper
integrate
kspace
minimize
region :ul

The {time} category prints the accumulated CPU and wall time for the
process that writes output (usually MPI rank 0).

@@ -84,3 +105,5 @@ reported.
[Default:]

The {out} option has the default {screen}.

The {styles} option has the default {all}.
+33 −26
Original line number Diff line number Diff line
@@ -210,6 +210,15 @@ Atom::Atom(LAMMPS *lmp) : Pointers(lmp)

  datamask = ALL_MASK;
  datamask_ext = ALL_MASK;

  avec_map = new AtomVecCreatorMap();

#define ATOM_CLASS
#define AtomStyle(key,Class) \
  (*avec_map)[#key] = &avec_creator<Class>;
#include "style_atom.h"
#undef AtomStyle
#undef ATOM_CLASS
}

/* ---------------------------------------------------------------------- */
@@ -218,6 +227,7 @@ Atom::~Atom()
{
  delete [] atom_style;
  delete avec;
  delete avec_map;

  delete [] firstgroupname;
  memory->destroy(binhead);
@@ -445,46 +455,43 @@ AtomVec *Atom::new_avec(const char *style, int trysuffix, int &sflag)
      sflag = 1;
      char estyle[256];
      sprintf(estyle,"%s/%s",style,lmp->suffix);

      if (0) return NULL;

#define ATOM_CLASS
#define AtomStyle(key,Class) \
      else if (strcmp(estyle,#key) == 0) return new Class(lmp);
#include "style_atom.h"
#undef AtomStyle
#undef ATOM_CLASS
      if (avec_map->find(estyle) != avec_map->end()) {
        AtomVecCreator avec_creator = (*avec_map)[estyle];
        return avec_creator(lmp);
      }
    }

    if (lmp->suffix2) {
      sflag = 2;
      char estyle[256];
      sprintf(estyle,"%s/%s",style,lmp->suffix2);

      if (0) return NULL;

#define ATOM_CLASS
#define AtomStyle(key,Class) \
      else if (strcmp(estyle,#key) == 0) return new Class(lmp);
#include "style_atom.h"
#undef AtomStyle
#undef ATOM_CLASS
      if (avec_map->find(estyle) != avec_map->end()) {
        AtomVecCreator avec_creator = (*avec_map)[estyle];
        return avec_creator(lmp);
      }
    }
  }

  sflag = 0;
  if (0) return NULL;

#define ATOM_CLASS
#define AtomStyle(key,Class) \
  else if (strcmp(style,#key) == 0) return new Class(lmp);
#include "style_atom.h"
#undef ATOM_CLASS
  if (avec_map->find(style) != avec_map->end()) {
    AtomVecCreator avec_creator = (*avec_map)[style];
    return avec_creator(lmp);
  }

  else error->all(FLERR,"Unknown atom style");
  error->all(FLERR,"Unknown atom style");
  return NULL;
}

/* ----------------------------------------------------------------------
   one instance per AtomVec style in style_atom.h
------------------------------------------------------------------------- */

template <typename T>
AtomVec *Atom::avec_creator(LAMMPS *lmp)
{
  return new T(lmp);
}

/* ---------------------------------------------------------------------- */

void Atom::init()
+11 −0
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@
#define LMP_ATOM_H

#include "pointers.h"
#include <map>
#include <string>

namespace LAMMPS_NS {

@@ -197,6 +199,12 @@ class Atom : protected Pointers {

  int *sametag;      // sametag[I] = next atom with same ID, -1 if no more

  // AtomVec factory types and map

  typedef AtomVec *(*AtomVecCreator)(LAMMPS *);
  typedef std::map<std::string,AtomVecCreator> AtomVecCreatorMap;
  AtomVecCreatorMap *avec_map;

  // functions

  Atom(class LAMMPS *);
@@ -322,6 +330,9 @@ class Atom : protected Pointers {

  void setup_sort_bins();
  int next_prime(int);

 private:
  template <typename T> static AtomVec *avec_creator(LAMMPS *);
};

}
+37 −34
Original line number Diff line number Diff line
@@ -105,6 +105,15 @@ Domain::Domain(LAMMPS *lmp) : Pointers(lmp)
  regions = NULL;

  copymode = 0;

  region_map = new RegionCreatorMap();

#define REGION_CLASS
#define RegionStyle(key,Class) \
  (*region_map)[#key] = &region_creator<Class>;
#include "style_region.h"
#undef RegionStyle
#undef REGION_CLASS
}

/* ---------------------------------------------------------------------- */
@@ -116,6 +125,8 @@ Domain::~Domain()
  delete lattice;
  for (int i = 0; i < nregion; i++) delete regions[i];
  memory->sfree(regions);

  delete region_map;
}

/* ---------------------------------------------------------------------- */
@@ -1524,51 +1535,33 @@ void Domain::add_region(int narg, char **arg)
    if (lmp->suffix) {
      char estyle[256];
      sprintf(estyle,"%s/%s",arg[1],lmp->suffix);

      if (0) return;

#define REGION_CLASS
#define RegionStyle(key,Class) \
      else if (strcmp(estyle,#key) == 0) { \
            regions[nregion] = new Class(lmp,narg,arg); \
            regions[nregion]->init(); \
            nregion++; \
            return; \
      if (region_map->find(estyle) != region_map->end()) {
        RegionCreator region_creator = (*region_map)[estyle];
        regions[nregion] = region_creator(lmp, narg, arg);
        regions[nregion]->init();
        nregion++;
        return;
      }
#include "style_region.h"
#undef RegionStyle
#undef REGION_CLASS
    }

    if (lmp->suffix2) {
      char estyle[256];
      sprintf(estyle,"%s/%s",arg[1],lmp->suffix2);

      if (0) return;

#define REGION_CLASS
#define RegionStyle(key,Class) \
      else if (strcmp(estyle,#key) == 0) { \
            regions[nregion] = new Class(lmp,narg,arg); \
            regions[nregion]->init(); \
            nregion++; \
            return; \
      if (region_map->find(estyle) != region_map->end()) {
        RegionCreator region_creator = (*region_map)[estyle];
        regions[nregion] = region_creator(lmp, narg, arg);
        regions[nregion]->init();
        nregion++;
        return;
      }
#include "style_region.h"
#undef RegionStyle
#undef REGION_CLASS
    }
  }

  if (strcmp(arg[1],"none") == 0) error->all(FLERR,"Unknown region style");

#define REGION_CLASS
#define RegionStyle(key,Class) \
  else if (strcmp(arg[1],#key) == 0) \
    regions[nregion] = new Class(lmp,narg,arg);
#include "style_region.h"
#undef REGION_CLASS

  if (region_map->find(arg[1]) != region_map->end()) {
    RegionCreator region_creator = (*region_map)[arg[1]];
    regions[nregion] = region_creator(lmp, narg, arg);
  }
  else error->all(FLERR,"Unknown region style");

  // initialize any region variables via init()
@@ -1578,6 +1571,16 @@ void Domain::add_region(int narg, char **arg)
  nregion++;
}

/* ----------------------------------------------------------------------
   one instance per region style in style_region.h
------------------------------------------------------------------------- */

template <typename T>
Region *Domain::region_creator(LAMMPS *lmp, int narg, char ** arg)
{
  return new T(lmp, narg, arg);
}

/* ----------------------------------------------------------------------
   delete a region
------------------------------------------------------------------------- */
Loading