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 {
iarg = 4;
iarg = model->add_submodel(arg, iarg, narg, NORMAL);
iarg = model->add_sub_model(arg, iarg, narg, NORMAL);
while (iarg < narg) {
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) {
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) {
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) {
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) {
iarg = model->add_submodel(arg, iarg + 1, narg, HEAT);
iarg = model->add_sub_model(arg, iarg + 1, narg, HEAT);
heat_flag = 1;
} else if (strcmp(arg[iarg], "xplane") == 0 ||
strcmp(arg[iarg], "yplane") == 0 ||
@ -115,9 +115,9 @@ FixWallGran::FixWallGran(LAMMPS *lmp, int narg, char **arg) :
}
}
// Define default damping submodel if unspecified, takes no args
// Define default damping sub model if unspecified, takes no args
if (!model->damping_model)
model->construct_submodel("viscoelastic", DAMPING);
model->construct_sub_model("viscoelastic", DAMPING);
model->init();
size_history = model->size_history;

View File

@ -13,7 +13,7 @@
------------------------------------------------------------------------- */
/* ----------------------------------------------------------------------
This class contains a framework for granular submodels (GranSubMod):
This class contains a framework for granular sub models (GranSubMod):
normal, damping, tangential, rolling, twisting, and heat
These are used to calculate forces/torques/etc based on contact geometry
@ -29,7 +29,7 @@ using namespace LAMMPS_NS;
using namespace Granular_NS;
/* ----------------------------------------------------------------------
Parent class for all types of granular submodels
Parent class for all types of granular sub models
------------------------------------------------------------------------- */
GranSubMod::GranSubMod(class GranularModel *gm, LAMMPS *lmp) : Pointers(lmp)
@ -79,10 +79,10 @@ void GranSubMod::mix_coeffs(double* icoeffs, double* jcoeffs)
------------------------------------------------------------------------- */
double GranSubMod::mix_stiffnessE(double E1, double E2,
double pois1, double pois2)
double poiss1, double poiss2)
{
double factor1 = (1 - pois1 * pois1) / E1;
double factor2 = (1 - pois2 * pois2) / E2;
double factor1 = (1 - poiss1 * poiss1) / E1;
double factor2 = (1 - poiss2 * poiss2) / E2;
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 pois1, double pois2)
double poiss1, double poiss2)
{
double factor1 = 2 * (2 - pois1) * (1 + pois1) / E1;
double factor2 = 2 * (2 - pois2) * (1 + pois2) / E2;
double factor1 = 2 * (2 - poiss1) * (1 + poiss1) / E1;
double factor2 = 2 * (2 - poiss2) * (1 + poiss2) / E2;
return 1 / (factor1 + factor2);
}
@ -102,9 +102,9 @@ double GranSubMod::mix_stiffnessG(double E1, double E2,
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;
}
@ -112,9 +112,9 @@ double GranSubMod::mix_stiffnessE_wall(double E, double pois)
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;
}

View File

@ -30,7 +30,7 @@ class GranSubMod : protected Pointers {
void read_restart();
virtual void mix_coeffs(double*, double*);
virtual void coeffs_to_local() {};
virtual void init() {}; // called after all submodels + coeffs defined
virtual void init() {}; // called after all sub models + coeffs defined
void allocate_coeffs();
std::string name;
@ -40,9 +40,9 @@ class GranSubMod : protected Pointers {
double *transfer_history_factor;
int history_index;
int beyond_contact; // If the submodel contact extends beyond overlap
int allow_cohesion; // If the submodel works with a cohesive normal force
int area_flag; // If the submodel requires area
int beyond_contact; // If the sub model contact extends beyond overlap
int allow_cohesion; // If the sub model works with a cohesive normal force
int area_flag; // If the sub model requires area
GranularModel *gm;

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)
error->all(FLERR, "Must specify granular submodel name");
error->all(FLERR, "Must specify granular sub model name");
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;
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;
for (i = 0; i < nclass; i++) {
@ -148,7 +148,7 @@ void GranularModel::construct_submodel(std::string model_name, SubmodelType mode
sub_models[model_type]->name.assign(model_name);
sub_models[model_type]->allocate_coeffs();
// Assign specific submodel pointer
// Assign specific sub model pointer
if (model_type == NORMAL) normal_model = dynamic_cast<GranSubModNormal *> (sub_models[model_type]);
if (model_type == DAMPING) damping_model = dynamic_cast<GranSubModDamping *> (sub_models[model_type]);
if (model_type == TANGENTIAL) tangential_model = dynamic_cast<GranSubModTangential *> (sub_models[model_type]);
@ -185,26 +185,26 @@ int GranularModel::define_classic_model(char **arg, int iarg, int narg)
error->all(FLERR,"Illegal classic gran model command");
if (strcmp(arg[iarg],"hooke") == 0) {
construct_submodel("hooke", NORMAL);
construct_submodel("linear_nohistory", TANGENTIAL);
construct_submodel("mass_velocity", DAMPING);
construct_sub_model("hooke", NORMAL);
construct_sub_model("linear_nohistory", TANGENTIAL);
construct_sub_model("mass_velocity", DAMPING);
} else if (strcmp(arg[iarg],"hooke/history") == 0) {
construct_submodel("hooke", NORMAL);
construct_submodel("linear_history_classic", TANGENTIAL);
construct_submodel("mass_velocity", DAMPING);
construct_sub_model("hooke", NORMAL);
construct_sub_model("linear_history_classic", TANGENTIAL);
construct_sub_model("mass_velocity", DAMPING);
} else if (strcmp(arg[iarg],"hertz/history") == 0) {
// convert Kn and Kt from pressure units to force/distance^2 if Hertzian
kn /= force->nktv2p;
kt /= force->nktv2p;
construct_submodel("hertz", NORMAL);
construct_submodel("mindlin_classic", TANGENTIAL);
construct_submodel("viscoelastic", DAMPING);
construct_sub_model("hertz", NORMAL);
construct_sub_model("mindlin_classic", TANGENTIAL);
construct_sub_model("viscoelastic", DAMPING);
} else error->all(FLERR,"Invalid classic gran model");
// ensure additional models are undefined
construct_submodel("none", ROLLING);
construct_submodel("none", TWISTING);
construct_submodel("none", HEAT);
construct_sub_model("none", ROLLING);
construct_sub_model("none", TWISTING);
construct_sub_model("none", HEAT);
// manually parse coeffs
normal_model->coeffs[0] = kn;
@ -226,7 +226,7 @@ int GranularModel::define_classic_model(char **arg, int iarg, int narg)
void GranularModel::init()
{
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
if (normal_model->name == "none") error->all(FLERR, "Must specify normal granular model");
@ -262,14 +262,14 @@ void GranularModel::init()
int j;
for (int i = 0; i < size_history; i++) {
// Find which submodel owns this history value
// Find which sub model owns this history value
size_cumulative = 0;
for (j = 0; j < NSUBMODELS; j++) {
if ((size_cumulative + sub_models[j]->size_history) > i) break;
size_cumulative += sub_models[j]->size_history;
}
// Check if submodel has nondefault transfers, if so copy its array
// Check if sub model has nondefault transfers, if so copy its array
transfer_history_factor[i] = -1;
if (j != NSUBMODELS) {
if (sub_models[j]->nondefault_history_transfer) {
@ -289,7 +289,7 @@ int GranularModel::mix_coeffs(GranularModel *g1, GranularModel *g2)
for (int i = 0; i < NSUBMODELS; 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);
}
@ -331,7 +331,7 @@ void GranularModel::read_restart(FILE *fp)
if (comm->me == 0)
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);
construct_submodel(model_name, (SubmodelType) i);
construct_sub_model(model_name, (SubModelType) i);
if (comm->me == 0)
utils::sfread(FLERR, &num_coeff, sizeof(int), 1, fp, nullptr, error);

View File

@ -19,7 +19,7 @@
namespace LAMMPS_NS {
namespace Granular_NS {
enum SubmodelType {
enum SubModelType {
NORMAL = 0,
DAMPING,
TANGENTIAL,
@ -53,9 +53,9 @@ class GranularModel : protected Pointers {
void calculate_forces();
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);
void construct_submodel(std::string, SubmodelType);
void construct_sub_model(std::string, SubModelType);
int mix_coeffs(GranularModel*, GranularModel*);
void write_restart(FILE *);
@ -94,7 +94,7 @@ class GranularModel : protected Pointers {
bool touch;
protected:
int rolling_defined, twisting_defined, heat_defined; // Flag optional submodels
int rolling_defined, twisting_defined, heat_defined; // Flag optional sub models
int classic_model; // Flag original pair/gran calculations
int area_flag; // Flag whether area is needed

View File

@ -345,21 +345,21 @@ void PairGranular::coeff(int narg, char **arg)
//Parse mandatory specification
int iarg = 2;
iarg = model->add_submodel(arg, iarg, narg, NORMAL);
iarg = model->add_sub_model(arg, iarg, narg, NORMAL);
//Parse optional arguments
while (iarg < narg) {
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) {
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) {
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) {
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) {
iarg = model->add_submodel(arg, iarg + 1, narg, HEAT);
iarg = model->add_sub_model(arg, iarg + 1, narg, HEAT);
heat_flag = 1;
} else if (strcmp(arg[iarg], "cutoff") == 0) {
if (iarg + 1 >= narg)
@ -372,9 +372,9 @@ void PairGranular::coeff(int narg, char **arg)
} else error->all(FLERR, "Illegal pair_coeff command {}", arg[iarg]);
}
// Define default damping submodel if unspecified, has no coeffs
// Define default damping sub model if unspecified, has no coeffs
if (!model->damping_model)
model->construct_submodel("viscoelastic", DAMPING);
model->construct_sub_model("viscoelastic", DAMPING);
model->init();
int count = 0;
@ -551,7 +551,7 @@ double PairGranular::init_one(int i, int j)
if (error_code != -1)
error->all(FLERR,"Granular pair style functional forms are different, "
"cannot mix coefficients for types {} and {} \n"
"with submodels {} and {}. \n"
"with sub models {} and {}. \n"
"This combination must be set explicitly via a "
"pair_coeff command",i,j,
model1->sub_models[error_code]->name,
@ -834,11 +834,11 @@ void PairGranular::transfer_history(double* source, double* target, int itype, i
{
class GranularModel* model = models_list[types_indices[itype][jtype]];
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];
}
} else {
for (int i = 0; i < size_history; i++) {
for (int i = 0; i < model->size_history; i++) {
target[i] = -source[i];
}
}