move error check to Compute::init() so they cannot be bypassed by input commands

This commit is contained in:
Axel Kohlmeyer
2024-10-23 21:08:07 -04:00
parent b682f52d11
commit fdd2fc4f5d
2 changed files with 23 additions and 23 deletions

View File

@ -144,17 +144,6 @@ ComputeStressMop::ComputeStressMop(LAMMPS *lmp, int narg, char **arg) : Compute(
iarg++;
}
// Error checks:
// 2D and pressure calculation in the Z coordinate
if (domain->dimension == 2 && dir == Z)
error->all(FLERR, "Compute stress/mop is incompatible with Z in 2d system");
// orthogonal simulation box
if (domain->triclinic != 0)
error->all(FLERR, "Compute stress/mop is incompatible with triclinic simulation box");
// Initialize some variables
values_local = values_global = vector = nullptr;
@ -203,6 +192,17 @@ ComputeStressMop::~ComputeStressMop()
void ComputeStressMop::init()
{
// Error checks:
// 2D and pressure calculation in the Z coordinate
if (domain->dimension == 2 && dir == Z)
error->all(FLERR, "Compute stress/mop is incompatible with Z in 2d system");
// orthogonal simulation box
if (domain->triclinic != 0)
error->all(FLERR, "Compute stress/mop is incompatible with triclinic simulation box");
// Conversion constants
nktv2p = force->nktv2p;

View File

@ -129,18 +129,6 @@ ComputeStressMopProfile::ComputeStressMopProfile(LAMMPS *lmp, int narg, char **a
iarg++;
}
// check domain related errors
// 3D only
if (domain->dimension == 2 && dir == Z)
error->all(FLERR, "Compute stress/mop/profile is incompatible with Z in 2d system");
// orthogonal simulation box
if (domain->triclinic != 0)
error->all(FLERR, "Compute stress/mop/profile is incompatible with triclinic simulation box");
// Initialize some variables
nbins = 0;
@ -192,6 +180,18 @@ ComputeStressMopProfile::~ComputeStressMopProfile()
void ComputeStressMopProfile::init()
{
// check domain related errors
// 3D only
if (domain->dimension == 2 && dir == Z)
error->all(FLERR, "Compute stress/mop/profile is incompatible with Z in 2d system");
// check for orthogonal simulation box
if (domain->triclinic != 0)
error->all(FLERR, "Compute stress/mop/profile is incompatible with triclinic simulation box");
// Conversion constants
nktv2p = force->nktv2p;