From c780768e91e4a45c06f9997b9853992afbc7fefc Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 21 Dec 2021 13:16:23 -0500 Subject: [PATCH] put contents of netcdf_units into NetCDFUnits namespace --- src/NETCDF/dump_netcdf.cpp | 2 ++ src/NETCDF/dump_netcdf.h | 4 ++-- src/NETCDF/dump_netcdf_mpiio.cpp | 2 ++ src/NETCDF/dump_netcdf_mpiio.h | 4 ++-- src/NETCDF/netcdf_units.cpp | 4 +++- src/NETCDF/netcdf_units.h | 5 +++-- 6 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/NETCDF/dump_netcdf.cpp b/src/NETCDF/dump_netcdf.cpp index f67bf8c2ff..605b480da0 100644 --- a/src/NETCDF/dump_netcdf.cpp +++ b/src/NETCDF/dump_netcdf.cpp @@ -44,6 +44,8 @@ using namespace LAMMPS_NS; using namespace MathConst; +using NetCDFUnits::Quantity; +using NetCDFUnits::get_unit_for; static const char NC_FRAME_STR[] = "frame"; static const char NC_SPATIAL_STR[] = "spatial"; diff --git a/src/NETCDF/dump_netcdf.h b/src/NETCDF/dump_netcdf.h index 619aad9138..2e0a275425 100644 --- a/src/NETCDF/dump_netcdf.h +++ b/src/NETCDF/dump_netcdf.h @@ -29,7 +29,7 @@ DumpStyle(netcdf,DumpNetCDF); #include "dump_custom.h" namespace LAMMPS_NS { -enum class Quantity; +namespace NetCDFUnits {enum Quantity : int;} // forward declaration const int NC_FIELD_NAME_MAX = 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. char name[NC_FIELD_NAME_MAX]; // field name 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) int ndumped; // number of enties written for this prop. diff --git a/src/NETCDF/dump_netcdf_mpiio.cpp b/src/NETCDF/dump_netcdf_mpiio.cpp index ba16b8c0e6..eb117e1dc0 100644 --- a/src/NETCDF/dump_netcdf_mpiio.cpp +++ b/src/NETCDF/dump_netcdf_mpiio.cpp @@ -44,6 +44,8 @@ using namespace LAMMPS_NS; using namespace MathConst; +using NetCDFUnits::Quantity; +using NetCDFUnits::get_unit_for; static const char NC_FRAME_STR[] = "frame"; static const char NC_SPATIAL_STR[] = "spatial"; diff --git a/src/NETCDF/dump_netcdf_mpiio.h b/src/NETCDF/dump_netcdf_mpiio.h index 97fad9b805..da45887b88 100644 --- a/src/NETCDF/dump_netcdf_mpiio.h +++ b/src/NETCDF/dump_netcdf_mpiio.h @@ -29,7 +29,7 @@ DumpStyle(netcdf/mpiio,DumpNetCDFMPIIO); #include "dump_custom.h" namespace LAMMPS_NS { -enum class Quantity; +namespace NetCDFUnits {enum Quantity : int;} // forward declaration const int NC_MPIIO_FIELD_NAME_MAX = 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. char name[NC_MPIIO_FIELD_NAME_MAX]; // field name int var; // NetCDF variable - Quantity quantity; // type of the quantity + NetCDFUnits::Quantity quantity; // type of the quantity }; typedef void (DumpNetCDFMPIIO::*funcptr_t)(void *); diff --git a/src/NETCDF/netcdf_units.cpp b/src/NETCDF/netcdf_units.cpp index 938512755a..907d0d7496 100644 --- a/src/NETCDF/netcdf_units.cpp +++ b/src/NETCDF/netcdf_units.cpp @@ -22,7 +22,9 @@ #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 (quantity == Quantity::UNKNOWN) { return ""; diff --git a/src/NETCDF/netcdf_units.h b/src/NETCDF/netcdf_units.h index bb83d983c8..8ec47a96bf 100644 --- a/src/NETCDF/netcdf_units.h +++ b/src/NETCDF/netcdf_units.h @@ -25,8 +25,9 @@ namespace LAMMPS_NS { class Error; +namespace NetCDFUnits { // type of quantity for per-atom values (used to get the unit) -enum class Quantity { +enum Quantity : int { UNKNOWN = 0, TIME, DISTANCE, @@ -38,7 +39,7 @@ enum class Quantity { // get the name of the unit for the given `quantity` in the given LAMMPS // `unit_style` any error will be reported through `error` std::string get_unit_for(const char* unit_style, Quantity quantity, Error* error); - +} } #endif