macro_rules! compute_styles {
($(($variant:tt, $lit:literal, $nargs:literal) ),+) => {
#[allow(non_camel_case_types)]
#[derive(Debug,Default,Eq,PartialEq,Clone,Copy,Hash)]
pub enum ComputeStyle {
$($variant,)+
#[default] #[allow(clippy::enum_variant_names)]
InvalidComputeStyle,
}
impl ComputeStyle {
pub const fn n_positional_args(&self) -> usize {
match self {
$(ComputeStyle::$variant => $nargs,)+
ComputeStyle::InvalidComputeStyle => 0,
}
}
}
impl From<&str> for ComputeStyle {
fn from(value: &str) -> Self {
match value {
$($lit => ComputeStyle::$variant,)+
_ => ComputeStyle::InvalidComputeStyle,
}
}
}
impl std::fmt::Display for ComputeStyle {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
$(ComputeStyle::$variant => write!(f, $lit),)+
ComputeStyle::InvalidComputeStyle => write!(f, "Invalid Compute Style"),
}
}
}
};
}
compute_styles!(
(AcklandAtom, "ackland/atom", 0),
(Adf, "adf", 1),
(Angle, "angle", 0),
(AngleLocal, "angle/local", 1), (AngmomChunk, "angmom/chunk", 1),
(AveSphereAtom, "ave/sphere/atom", 0),
(BasalAtom, "basal/atom", 0),
(BodyLocal, "body/local", 1),
(Bond, "bond", 0),
(BondLocal, "bond/local", 1),
(BornMatrix, "born/matrix", 0),
(CentroAtom, "centro/atom", 1),
(ChunkAtom, "chunk/atom", 1), (ChunkSpreadAtom, "chunk/spread/atom", 1), (ClusterAtom, "cluster/atom", 1), (FragmentAtom, "fragment/atom", 0),
(AggregateAtom, "aggregate/atom", 1), (CnaAtom, "cna/atom", 1), (CnpAtom, "cnp/atom", 1), (Com, "com", 0),
(ComChunk, "com/chunk", 1), (ContactAtom, "contact/atom", 0),
(CompositionAtom, "composition/atom", 0), (CoordAtom, "coord/atom", 1), (CountType, "count/type", 1),
(DamageAtom, "damage/atom", 0),
(Dihedral, "dihedral", 0),
(DihedralLocal, "dihedral/local", 1),
(DilatationAtom, "dilatation/atom", 0),
(Dipole, "dipole", 0),
(DipoleTip4p, "dipole/tip4p", 0),
(DipoleChunk, "dipole/chunk", 1), (DipoleTip4pChunk, "dipole/tip4p/chunk", 1), (DisplaceAtom, "displace/atom", 0),
(Dpd, "dpd", 0),
(DpdAtom, "dpd/atom", 0),
(EdpdTempAtom, "edpd/temp/atom", 0),
(EfieldAtom, "efield/atom", 0),
(EfieldWolfAtom, "efield/wolf/atom", 1), (EntropyAtom, "entropy/atom", 2), (ErotateAsphere, "erotate/asphere", 0),
(ErotateRigid, "erotate/rigid", 1), (ErotateSphere, "erotate/sphere", 0),
(ErotateSphereAtom, "erotate/sphere/atom", 0),
(EventDisplace, "event/displace", 1), (Fabric, "fabric", 1), (Fep, "fep", 1), (FepTa, "fep/ta", 3), (GlobalAtom, "global/atom", 2),
(GroupGroup, "group/group", 1), (Gyration, "gyration", 0),
(GyrationChunk, "gyration/chunk", 1), (GyrationShape, "gyration/shape", 1), (GyrationShapeChunk, "gyration/shape/chunk", 1), (HeatFlux, "heat/flux", 3), (HexorderAtom, "hexorder/atom", 0),
(Hma, "hma", 1), (Improper, "improper", 0),
(ImproperLocal, "improper/local", 0), (InertiaChunk, "inertia/chunk", 1), (Ke, "ke", 0),
(KeAtom, "ke/atom", 0),
(KeAtomEff, "ke/atom/eff", 0),
(KeEff, "ke/eff", 0),
(KeRigid, "ke/rigid", 1), (Mliap, "mliap", 4), (Momentum, "momentum", 0),
(Msd, "msd", 0),
(MsdChunk, "msd/chunk", 1), (MsdNongauss, "msd/nongauss", 0),
(NbondAtom, "nbond/atom", 0),
(OmegaChunk, "omega/chunk", 1),
(OrientorderAtom, "orientorder/atom", 0),
(Pace, "pace", 1), (Pair, "pair", 1), (PairLocal, "pair/local", 1),
(Pe, "pe", 0),
(PeAtom, "pe/atom", 0),
(PlasticityAtom, "plasticity/atom", 0),
(Pressure, "pressure", 1), (PressureAlchemy, "pressure/alchemy", 1), (PressureUef, "pressure/uef", 1), (PropertyAtom, "property/atom", 1), (PropertyChunk, "property/chunk", 2), (PropertyGrid, "property/grid", 4), (PropertyLocal, "property/local", 1), (PtmAtom, "ptm/atom", 3), (RattlersAtom, "rattlers/atom", 3), (Rdf, "rdf", 1), (ReaxffAtom, "reaxff/atom", 1), (Reduce, "reduce", 0),
(ReduceRegion, "reduce/region", 1), (ReduceChunk, "reduce/chunk", 2), (RigidLocal, "rigid/local", 2), (Saed, "saed", 2), (SlcsaAtom, "slcsa/atom", 7),
(Slice, "slice", 4), (SmdContactRadius, "smd/contact/radius", 0),
(SmdDamage, "smd/damage", 0),
(SmdHourglassError, "smd/hourglass/error", 0),
(SmdInternalEnergy, "smd/internal/energy", 0),
(SmdPlasticStrain, "smd/plastic/strain", 0),
(SmdPlasticStrainRate, "smd/plastic/strain/rate", 0),
(SmdRho, "smd/rho", 0),
(SmdTlsphDefgrad, "smd/tlsph/defgrad", 0),
(SmdTlsphDt, "smd/tlsph/dt", 0),
(SmdTlsphNumNeighs, "smd/tlsph/num/neighs", 0),
(SmdTlsphShape, "smd/tlsph/shape", 0),
(SmdTlsphStrain, "smd/tlsph/strain", 0),
(SmdTlsphStrainRate, "smd/tlsph/strain/rate", 0),
(SmdTlsphStress, "smd/tlsph/stress", 0),
(SmdTriangleVertices, "smd/triangle/vertices", 0),
(SmdUlsphEffm, "smd/ulsph/effm", 0),
(SmdUlsphNumNeighs, "smd/ulsph/num/neighs", 0),
(SmdUlsphStrain, "smd/ulsph/strain", 0),
(SmdUlsphStrainRate, "smd/ulsph/strain/rate", 0),
(SmdUlsphStress, "smd/ulsph/stress", 0),
(SmdVol, "smd/vol", 2),
(SnaAtom, "sna/atom", 2),
(SnadAtom, "snad/atom", 2),
(SnavAtom, "snav/atom", 2),
(Snap, "snap", 2),
(SnaGrid, "sna/grid", 3),
(SnaGridLocal, "sna/grid/local", 3),
(SphEAtom, "sph/e/atom", 0),
(SphRhoAtom, "sph/rho/atom", 0),
(SphTAtom, "sph/t/atom", 0),
(Spin, "spin", 0),
(StressAtom, "stress/atom", 1), (CentroidStressAtom, "centroid/stress/atom", 1), (StressCartesian, "stress/cartesian", 4), (StressCylinder, "stress/cylinder", 4),
(StressSpherical, "stress/spherical", 5),
(StressMop, "stress/mop", 2),
(StressMopProfile, "stress/mop/profile", 3),
(ForceTally, "force/tally", 1),
(HeatFluxTally, "heat/flux/tally", 1),
(HeatFluxVirialTally, "heat/flux/virial/tally", 1),
(PeTally, "pe/tally", 1),
(PeMolTally, "pe/mol/tally", 1),
(StressTally, "stress/tally", 1),
(TdpdCcAtom, "tdpd/cc/atom", 1), (Temp, "temp", 0),
(TempAsphere, "temp/asphere", 0),
(TempBody, "temp/body", 0),
(TempChunk, "temp/chunk", 1),
(TempCom, "temp/com", 0),
(TempCs, "temp/cs", 2),
(TempDeform, "temp/deform", 0),
(TempDeformEff, "temp/deform/eff", 0),
(TempDrude, "temp/drude", 0),
(TempEff, "temp/eff", 0),
(TempPartial, "temp/partial", 3), (TempProfile, "temp/profile", 5), (TempRamp, "temp/ramp", 6),
(TempRegion, "temp/region", 1), (TempRegionEff, "temp/region/eff", 1), (TempRotate, "temp/rotate", 0),
(TempSphere, "temp/sphere", 0),
(TempUef, "temp/uef", 0),
(Ti, "ti", 0),
(TorqueChunk, "torque/chunk", 1), (Vacf, "vacf", 0),
(VcmChunk, "vcm/chunk", 1),
(ViscosityCos, "viscosity/cos", 0),
(VoronoiAtom, "voronoi/atom", 0),
(Xrd, "xrd", 2) );
impl ComputeStyle {
pub fn is_invalid(&self) -> bool {
matches!(self, ComputeStyle::InvalidComputeStyle)
}
}
#[cfg(test)]
mod tests {
use crate::styles::ComputeStyle;
#[test]
fn all_computes_defined() {
let computes = include_str!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/docs_extract/computes.txt"
));
for compute in computes.lines() {
dbg!(compute);
assert_ne!(
ComputeStyle::from(compute),
ComputeStyle::InvalidComputeStyle
)
}
}
}