put contents of netcdf_units into NetCDFUnits namespace

This commit is contained in:
Axel Kohlmeyer
2021-12-21 13:16:23 -05:00
parent 1c25c96aaa
commit c780768e91
6 changed files with 14 additions and 7 deletions

View File

@ -44,6 +44,8 @@
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace MathConst; using namespace MathConst;
using NetCDFUnits::Quantity;
using NetCDFUnits::get_unit_for;
static const char NC_FRAME_STR[] = "frame"; static const char NC_FRAME_STR[] = "frame";
static const char NC_SPATIAL_STR[] = "spatial"; static const char NC_SPATIAL_STR[] = "spatial";

View File

@ -29,7 +29,7 @@ DumpStyle(netcdf,DumpNetCDF);
#include "dump_custom.h" #include "dump_custom.h"
namespace LAMMPS_NS { namespace LAMMPS_NS {
enum class Quantity; namespace NetCDFUnits {enum Quantity : int;} // forward declaration
const int NC_FIELD_NAME_MAX = 100; const int NC_FIELD_NAME_MAX = 100;
const int DUMP_NC_MAX_DIMS = 100; const int DUMP_NC_MAX_DIMS = 100;
@ -47,7 +47,7 @@ class DumpNetCDF : public DumpCustom {
int field[DUMP_NC_MAX_DIMS]; // field indices corresponding to the dim. int field[DUMP_NC_MAX_DIMS]; // field indices corresponding to the dim.
char name[NC_FIELD_NAME_MAX]; // field name char name[NC_FIELD_NAME_MAX]; // field name
int var; // NetCDF variable int var; // NetCDF variable
Quantity quantity; // type of the quantity NetCDFUnits::Quantity quantity; // type of the quantity
bool constant; // is this property per file (not per frame) bool constant; // is this property per file (not per frame)
int ndumped; // number of enties written for this prop. int ndumped; // number of enties written for this prop.

View File

@ -44,6 +44,8 @@
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace MathConst; using namespace MathConst;
using NetCDFUnits::Quantity;
using NetCDFUnits::get_unit_for;
static const char NC_FRAME_STR[] = "frame"; static const char NC_FRAME_STR[] = "frame";
static const char NC_SPATIAL_STR[] = "spatial"; static const char NC_SPATIAL_STR[] = "spatial";

View File

@ -29,7 +29,7 @@ DumpStyle(netcdf/mpiio,DumpNetCDFMPIIO);
#include "dump_custom.h" #include "dump_custom.h"
namespace LAMMPS_NS { namespace LAMMPS_NS {
enum class Quantity; namespace NetCDFUnits {enum Quantity : int;} // forward declaration
const int NC_MPIIO_FIELD_NAME_MAX = 100; const int NC_MPIIO_FIELD_NAME_MAX = 100;
const int DUMP_NC_MPIIO_MAX_DIMS = 100; const int DUMP_NC_MPIIO_MAX_DIMS = 100;
@ -47,7 +47,7 @@ class DumpNetCDFMPIIO : public DumpCustom {
int field[DUMP_NC_MPIIO_MAX_DIMS]; // field indices corresponding to the dim. int field[DUMP_NC_MPIIO_MAX_DIMS]; // field indices corresponding to the dim.
char name[NC_MPIIO_FIELD_NAME_MAX]; // field name char name[NC_MPIIO_FIELD_NAME_MAX]; // field name
int var; // NetCDF variable int var; // NetCDF variable
Quantity quantity; // type of the quantity NetCDFUnits::Quantity quantity; // type of the quantity
}; };
typedef void (DumpNetCDFMPIIO::*funcptr_t)(void *); typedef void (DumpNetCDFMPIIO::*funcptr_t)(void *);

View File

@ -22,7 +22,9 @@
#include "error.h" #include "error.h"
std::string LAMMPS_NS::get_unit_for(const char* unit_style, Quantity quantity, Error* error) { using namespace LAMMPS_NS;
std::string NetCDFUnits::get_unit_for(const char* unit_style, Quantity quantity, Error* error) {
if (!strcmp(unit_style, "lj")) { if (!strcmp(unit_style, "lj")) {
if (quantity == Quantity::UNKNOWN) { if (quantity == Quantity::UNKNOWN) {
return ""; return "";

View File

@ -25,8 +25,9 @@
namespace LAMMPS_NS { namespace LAMMPS_NS {
class Error; class Error;
namespace NetCDFUnits {
// type of quantity for per-atom values (used to get the unit) // type of quantity for per-atom values (used to get the unit)
enum class Quantity { enum Quantity : int {
UNKNOWN = 0, UNKNOWN = 0,
TIME, TIME,
DISTANCE, DISTANCE,
@ -38,7 +39,7 @@ enum class Quantity {
// get the name of the unit for the given `quantity` in the given LAMMPS // get the name of the unit for the given `quantity` in the given LAMMPS
// `unit_style` any error will be reported through `error` // `unit_style` any error will be reported through `error`
std::string get_unit_for(const char* unit_style, Quantity quantity, Error* error); std::string get_unit_for(const char* unit_style, Quantity quantity, Error* error);
}
} }
#endif #endif