adding examples, fixing wall algebra, updating labels

This commit is contained in:
jtclemm
2022-11-29 12:24:43 -07:00
parent f51ab2c440
commit 1a467233fb
6 changed files with 61 additions and 61 deletions

View File

@ -86,19 +86,19 @@ FixWallGran::FixWallGran(LAMMPS *lmp, int narg, char **arg) :
} else { } else {
iarg = 4; iarg = 4;
iarg = model->add_submodel(arg, iarg, narg, NORMAL); iarg = model->add_sub_model(arg, iarg, narg, NORMAL);
while (iarg < narg) { while (iarg < narg) {
if (strcmp(arg[iarg], "damping") == 0) { if (strcmp(arg[iarg], "damping") == 0) {
iarg = model->add_submodel(arg, iarg + 1, narg, DAMPING); iarg = model->add_sub_model(arg, iarg + 1, narg, DAMPING);
} else if (strcmp(arg[iarg], "tangential") == 0) { } else if (strcmp(arg[iarg], "tangential") == 0) {
iarg = model->add_submodel(arg, iarg + 1, narg, TANGENTIAL); iarg = model->add_sub_model(arg, iarg + 1, narg, TANGENTIAL);
} else if (strcmp(arg[iarg], "rolling") == 0) { } else if (strcmp(arg[iarg], "rolling") == 0) {
iarg = model->add_submodel(arg, iarg + 1, narg, ROLLING); iarg = model->add_sub_model(arg, iarg + 1, narg, ROLLING);
} else if (strcmp(arg[iarg], "twisting") == 0) { } else if (strcmp(arg[iarg], "twisting") == 0) {
iarg = model->add_submodel(arg, iarg + 1, narg, TWISTING); iarg = model->add_sub_model(arg, iarg + 1, narg, TWISTING);
} else if (strcmp(arg[iarg], "heat") == 0) { } else if (strcmp(arg[iarg], "heat") == 0) {
iarg = model->add_submodel(arg, iarg + 1, narg, HEAT); iarg = model->add_sub_model(arg, iarg + 1, narg, HEAT);
heat_flag = 1; heat_flag = 1;
} else if (strcmp(arg[iarg], "xplane") == 0 || } else if (strcmp(arg[iarg], "xplane") == 0 ||
strcmp(arg[iarg], "yplane") == 0 || strcmp(arg[iarg], "yplane") == 0 ||
@ -117,7 +117,7 @@ FixWallGran::FixWallGran(LAMMPS *lmp, int narg, char **arg) :
// Define default damping sub model if unspecified, takes no args // Define default damping sub model if unspecified, takes no args
if (!model->damping_model) if (!model->damping_model)
model->construct_submodel("viscoelastic", DAMPING); model->construct_sub_model("viscoelastic", DAMPING);
model->init(); model->init();
size_history = model->size_history; size_history = model->size_history;

View File

@ -79,10 +79,10 @@ void GranSubMod::mix_coeffs(double* icoeffs, double* jcoeffs)
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
double GranSubMod::mix_stiffnessE(double E1, double E2, double GranSubMod::mix_stiffnessE(double E1, double E2,
double pois1, double pois2) double poiss1, double poiss2)
{ {
double factor1 = (1 - pois1 * pois1) / E1; double factor1 = (1 - poiss1 * poiss1) / E1;
double factor2 = (1 - pois2 * pois2) / E2; double factor2 = (1 - poiss2 * poiss2) / E2;
return 1 / (factor1 + factor2); return 1 / (factor1 + factor2);
} }
@ -91,10 +91,10 @@ double GranSubMod::mix_stiffnessE(double E1, double E2,
------------------------------------------------------------------------ */ ------------------------------------------------------------------------ */
double GranSubMod::mix_stiffnessG(double E1, double E2, double GranSubMod::mix_stiffnessG(double E1, double E2,
double pois1, double pois2) double poiss1, double poiss2)
{ {
double factor1 = 2 * (2 - pois1) * (1 + pois1) / E1; double factor1 = 2 * (2 - poiss1) * (1 + poiss1) / E1;
double factor2 = 2 * (2 - pois2) * (1 + pois2) / E2; double factor2 = 2 * (2 - poiss2) * (1 + poiss2) / E2;
return 1 / (factor1 + factor2); return 1 / (factor1 + factor2);
} }
@ -102,9 +102,9 @@ double GranSubMod::mix_stiffnessG(double E1, double E2,
mixing of Young's modulus (E) for walls mixing of Young's modulus (E) for walls
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
double GranSubMod::mix_stiffnessE_wall(double E, double pois) double GranSubMod::mix_stiffnessE_wall(double E, double poiss)
{ {
double factor = 2 * (1 - pois); double factor = 2 * (1 - poiss * poiss);
return E / factor; return E / factor;
} }
@ -112,9 +112,9 @@ double GranSubMod::mix_stiffnessE_wall(double E, double pois)
mixing of shear modulus (G) for walls mixing of shear modulus (G) for walls
------------------------------------------------------------------------ */ ------------------------------------------------------------------------ */
double GranSubMod::mix_stiffnessG_wall(double E, double pois) double GranSubMod::mix_stiffnessG_wall(double E, double poiss)
{ {
double factor = 32.0 * (2 - pois) * (1 + pois); double factor = 4.0 * (2 - poiss) * (1 + poiss);
return E / factor; return E / factor;
} }

View File

@ -103,13 +103,13 @@ GranularModel::~GranularModel()
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
int GranularModel::add_submodel(char **arg, int iarg, int narg, SubmodelType model_type) int GranularModel::add_sub_model(char **arg, int iarg, int narg, SubModelType model_type)
{ {
if (iarg >= narg) if (iarg >= narg)
error->all(FLERR, "Must specify granular sub model name"); error->all(FLERR, "Must specify granular sub model name");
std::string model_name = std::string(arg[iarg++]); std::string model_name = std::string(arg[iarg++]);
construct_submodel(model_name, model_type); construct_sub_model(model_name, model_type);
int num_coeffs = sub_models[model_type]->num_coeffs; int num_coeffs = sub_models[model_type]->num_coeffs;
if (iarg + num_coeffs > narg) if (iarg + num_coeffs > narg)
@ -128,7 +128,7 @@ int GranularModel::add_submodel(char **arg, int iarg, int narg, SubmodelType mod
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void GranularModel::construct_submodel(std::string model_name, SubmodelType model_type) void GranularModel::construct_sub_model(std::string model_name, SubModelType model_type)
{ {
int i; int i;
for (i = 0; i < nclass; i++) { for (i = 0; i < nclass; i++) {
@ -185,26 +185,26 @@ int GranularModel::define_classic_model(char **arg, int iarg, int narg)
error->all(FLERR,"Illegal classic gran model command"); error->all(FLERR,"Illegal classic gran model command");
if (strcmp(arg[iarg],"hooke") == 0) { if (strcmp(arg[iarg],"hooke") == 0) {
construct_submodel("hooke", NORMAL); construct_sub_model("hooke", NORMAL);
construct_submodel("linear_nohistory", TANGENTIAL); construct_sub_model("linear_nohistory", TANGENTIAL);
construct_submodel("mass_velocity", DAMPING); construct_sub_model("mass_velocity", DAMPING);
} else if (strcmp(arg[iarg],"hooke/history") == 0) { } else if (strcmp(arg[iarg],"hooke/history") == 0) {
construct_submodel("hooke", NORMAL); construct_sub_model("hooke", NORMAL);
construct_submodel("linear_history_classic", TANGENTIAL); construct_sub_model("linear_history_classic", TANGENTIAL);
construct_submodel("mass_velocity", DAMPING); construct_sub_model("mass_velocity", DAMPING);
} else if (strcmp(arg[iarg],"hertz/history") == 0) { } else if (strcmp(arg[iarg],"hertz/history") == 0) {
// convert Kn and Kt from pressure units to force/distance^2 if Hertzian // convert Kn and Kt from pressure units to force/distance^2 if Hertzian
kn /= force->nktv2p; kn /= force->nktv2p;
kt /= force->nktv2p; kt /= force->nktv2p;
construct_submodel("hertz", NORMAL); construct_sub_model("hertz", NORMAL);
construct_submodel("mindlin_classic", TANGENTIAL); construct_sub_model("mindlin_classic", TANGENTIAL);
construct_submodel("viscoelastic", DAMPING); construct_sub_model("viscoelastic", DAMPING);
} else error->all(FLERR,"Invalid classic gran model"); } else error->all(FLERR,"Invalid classic gran model");
// ensure additional models are undefined // ensure additional models are undefined
construct_submodel("none", ROLLING); construct_sub_model("none", ROLLING);
construct_submodel("none", TWISTING); construct_sub_model("none", TWISTING);
construct_submodel("none", HEAT); construct_sub_model("none", HEAT);
// manually parse coeffs // manually parse coeffs
normal_model->coeffs[0] = kn; normal_model->coeffs[0] = kn;
@ -226,7 +226,7 @@ int GranularModel::define_classic_model(char **arg, int iarg, int narg)
void GranularModel::init() void GranularModel::init()
{ {
for (int i = 0; i < NSUBMODELS; i++) for (int i = 0; i < NSUBMODELS; i++)
if (!sub_models[i]) construct_submodel("none", (SubmodelType) i); if (!sub_models[i]) construct_sub_model("none", (SubModelType) i);
// Must have valid normal, damping, and tangential models // Must have valid normal, damping, and tangential models
if (normal_model->name == "none") error->all(FLERR, "Must specify normal granular model"); if (normal_model->name == "none") error->all(FLERR, "Must specify normal granular model");
@ -289,7 +289,7 @@ int GranularModel::mix_coeffs(GranularModel *g1, GranularModel *g2)
for (int i = 0; i < NSUBMODELS; i++) { for (int i = 0; i < NSUBMODELS; i++) {
if (g1->sub_models[i]->name != g2->sub_models[i]->name) return i; if (g1->sub_models[i]->name != g2->sub_models[i]->name) return i;
construct_submodel(g1->sub_models[i]->name, (SubmodelType) i); construct_sub_model(g1->sub_models[i]->name, (SubModelType) i);
sub_models[i]->mix_coeffs(g1->sub_models[i]->coeffs, g2->sub_models[i]->coeffs); sub_models[i]->mix_coeffs(g1->sub_models[i]->coeffs, g2->sub_models[i]->coeffs);
} }
@ -331,7 +331,7 @@ void GranularModel::read_restart(FILE *fp)
if (comm->me == 0) if (comm->me == 0)
utils::sfread(FLERR, const_cast<char*>(model_name.data()), sizeof(char),num_char, fp, nullptr, error); utils::sfread(FLERR, const_cast<char*>(model_name.data()), sizeof(char),num_char, fp, nullptr, error);
MPI_Bcast(const_cast<char*>(model_name.data()), num_char, MPI_CHAR, 0, world); MPI_Bcast(const_cast<char*>(model_name.data()), num_char, MPI_CHAR, 0, world);
construct_submodel(model_name, (SubmodelType) i); construct_sub_model(model_name, (SubModelType) i);
if (comm->me == 0) if (comm->me == 0)
utils::sfread(FLERR, &num_coeff, sizeof(int), 1, fp, nullptr, error); utils::sfread(FLERR, &num_coeff, sizeof(int), 1, fp, nullptr, error);

View File

@ -19,7 +19,7 @@
namespace LAMMPS_NS { namespace LAMMPS_NS {
namespace Granular_NS { namespace Granular_NS {
enum SubmodelType { enum SubModelType {
NORMAL = 0, NORMAL = 0,
DAMPING, DAMPING,
TANGENTIAL, TANGENTIAL,
@ -53,9 +53,9 @@ class GranularModel : protected Pointers {
void calculate_forces(); void calculate_forces();
double pulloff_distance(double, double); double pulloff_distance(double, double);
int add_submodel(char **, int, int, SubmodelType); int add_sub_model(char **, int, int, SubModelType);
int define_classic_model(char **, int, int); int define_classic_model(char **, int, int);
void construct_submodel(std::string, SubmodelType); void construct_sub_model(std::string, SubModelType);
int mix_coeffs(GranularModel*, GranularModel*); int mix_coeffs(GranularModel*, GranularModel*);
void write_restart(FILE *); void write_restart(FILE *);

View File

@ -345,21 +345,21 @@ void PairGranular::coeff(int narg, char **arg)
//Parse mandatory specification //Parse mandatory specification
int iarg = 2; int iarg = 2;
iarg = model->add_submodel(arg, iarg, narg, NORMAL); iarg = model->add_sub_model(arg, iarg, narg, NORMAL);
//Parse optional arguments //Parse optional arguments
while (iarg < narg) { while (iarg < narg) {
if (strcmp(arg[iarg], "tangential") == 0) { if (strcmp(arg[iarg], "tangential") == 0) {
iarg = model->add_submodel(arg, iarg + 1, narg, TANGENTIAL); iarg = model->add_sub_model(arg, iarg + 1, narg, TANGENTIAL);
} else if (strcmp(arg[iarg], "damping") == 0) { } else if (strcmp(arg[iarg], "damping") == 0) {
iarg = model->add_submodel(arg, iarg + 1, narg, DAMPING); iarg = model->add_sub_model(arg, iarg + 1, narg, DAMPING);
} else if (strcmp(arg[iarg], "rolling") == 0) { } else if (strcmp(arg[iarg], "rolling") == 0) {
iarg = model->add_submodel(arg, iarg + 1, narg, ROLLING); iarg = model->add_sub_model(arg, iarg + 1, narg, ROLLING);
} else if (strcmp(arg[iarg], "twisting") == 0) { } else if (strcmp(arg[iarg], "twisting") == 0) {
iarg = model->add_submodel(arg, iarg + 1, narg, TWISTING); iarg = model->add_sub_model(arg, iarg + 1, narg, TWISTING);
} else if (strcmp(arg[iarg], "heat") == 0) { } else if (strcmp(arg[iarg], "heat") == 0) {
iarg = model->add_submodel(arg, iarg + 1, narg, HEAT); iarg = model->add_sub_model(arg, iarg + 1, narg, HEAT);
heat_flag = 1; heat_flag = 1;
} else if (strcmp(arg[iarg], "cutoff") == 0) { } else if (strcmp(arg[iarg], "cutoff") == 0) {
if (iarg + 1 >= narg) if (iarg + 1 >= narg)
@ -374,7 +374,7 @@ void PairGranular::coeff(int narg, char **arg)
// Define default damping sub model if unspecified, has no coeffs // Define default damping sub model if unspecified, has no coeffs
if (!model->damping_model) if (!model->damping_model)
model->construct_submodel("viscoelastic", DAMPING); model->construct_sub_model("viscoelastic", DAMPING);
model->init(); model->init();
int count = 0; int count = 0;
@ -834,11 +834,11 @@ void PairGranular::transfer_history(double* source, double* target, int itype, i
{ {
class GranularModel* model = models_list[types_indices[itype][jtype]]; class GranularModel* model = models_list[types_indices[itype][jtype]];
if (model->nondefault_history_transfer) { if (model->nondefault_history_transfer) {
for (int i = 0; i < size_history; i++) { for (int i = 0; i < model->size_history; i++) {
target[i] = model->transfer_history_factor[i] * source[i]; target[i] = model->transfer_history_factor[i] * source[i];
} }
} else { } else {
for (int i = 0; i < size_history; i++) { for (int i = 0; i < model->size_history; i++) {
target[i] = -source[i]; target[i] = -source[i];
} }
} }