/usr/include/liggghts/fix_wall_gran_base.h is in libliggghts-dev 3.7.0+repack1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 | /* ----------------------------------------------------------------------
This is the
██╗ ██╗ ██████╗ ██████╗ ██████╗ ██╗ ██╗████████╗███████╗
██║ ██║██╔════╝ ██╔════╝ ██╔════╝ ██║ ██║╚══██╔══╝██╔════╝
██║ ██║██║ ███╗██║ ███╗██║ ███╗███████║ ██║ ███████╗
██║ ██║██║ ██║██║ ██║██║ ██║██╔══██║ ██║ ╚════██║
███████╗██║╚██████╔╝╚██████╔╝╚██████╔╝██║ ██║ ██║ ███████║
╚══════╝╚═╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝®
DEM simulation engine, released by
DCS Computing Gmbh, Linz, Austria
http://www.dcs-computing.com, office@dcs-computing.com
LIGGGHTS® is part of CFDEM®project:
http://www.liggghts.com | http://www.cfdem.com
Core developer and main author:
Christoph Kloss, christoph.kloss@dcs-computing.com
LIGGGHTS® is open-source, distributed under the terms of the GNU Public
License, version 2 or later. It is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. You should have
received a copy of the GNU General Public License along with LIGGGHTS®.
If not, see http://www.gnu.org/licenses . See also top-level README
and LICENSE files.
LIGGGHTS® and CFDEM® are registered trade marks of DCS Computing GmbH,
the producer of the LIGGGHTS® software and the CFDEM®coupling software
See http://www.cfdem.com/terms-trademark-policy for details.
-------------------------------------------------------------------------
Contributing author and copyright for this file:
Christoph Kloss (DCS Computing GmbH, Linz)
Christoph Kloss (JKU Linz)
Richard Berger (JKU Linz)
Arno Mayrhofer (CFDEMresearch GmbH, Linz)
Copyright 2012- DCS Computing GmbH, Linz
Copyright 2009-2012 JKU Linz
Copyright 2016- CFDEMresearch GmbH, Linz
------------------------------------------------------------------------- */
#ifndef LMP_FIX_WALL_GRAN_BASE_H
#define LMP_FIX_WALL_GRAN_BASE_H
#include "fix_wall_gran.h"
#include "fix_contact_property_atom_wall.h"
#include "contact_interface.h"
#include "compute_pair_gran_local.h"
#include "tri_mesh.h"
#include "settings.h"
#include <string.h>
#include "force.h"
#include <stdlib.h>
#include "contact_models.h"
#include "granular_wall.h"
#include "fix_calculate_energy_wall.h"
#ifdef SUPERQUADRIC_ACTIVE_FLAG
#include "math_const.h"
#endif
namespace LIGGGHTS {
using namespace ContactModels;
namespace Walls {
template<typename ContactModel>
class Granular : private Pointers, public IGranularWall {
ContactModel cmodel;
FixWallGran * parent;
int dissipation_offset_;
FixCalculateWallEnergy *fix_dissipated_energy_;
public:
Granular(LAMMPS * lmp, FixWallGran * parent, const int64_t hash) :
Pointers(lmp),
cmodel(lmp, parent,true /*is_wall*/, hash),
parent(parent),
dissipation_offset_(-1),
fix_dissipated_energy_(NULL)
{
}
virtual ~Granular()
{
}
virtual void init_granular() {
cmodel.connectToProperties(force->registry);
#ifdef LIGGGHTS_DEBUG
if(comm->me == 0) {
fprintf(screen, "==== WALL %s GLOBAL PROPERTIES ====\n", parent->id);
force->registry.print_all(screen);
fprintf(screen, "==== WALL %s GLOBAL PROPERTIES ====\n", parent->id);
fprintf(logfile, "==== WALL %s GLOBAL PROPERTIES ====\n", parent->id);
force->registry.print_all(logfile);
fprintf(logfile, "==== WALL %s GLOBAL PROPERTIES ====\n", parent->id);
}
#endif
}
virtual void settings(int nargs, char ** args, IContactHistorySetup *hsetup) {
Settings settings(lmp);
cmodel.registerSettings(settings);
bool success = settings.parseArguments(nargs, args);
cmodel.postSettings(hsetup);
#ifdef LIGGGHTS_DEBUG
if(comm->me == 0) {
fprintf(screen, "==== WALL %s SETTINGS ====\n", parent->id);
settings.print_all(screen);
fprintf(screen, "==== WALL %s SETTINGS ====\n", parent->id);
fprintf(logfile, "==== WALL %s SETTINGS ====\n", parent->id);
settings.print_all(logfile);
fprintf(logfile, "==== WALL %s SETTINGS ====\n", parent->id);
}
#endif
dissipation_offset_ = get_history_offset("dissipation_force");
fix_dissipated_energy_ = static_cast<FixCalculateWallEnergy*>(modify->find_fix_style("calculate/wall_dissipated_energy", 0));
if (dissipation_offset_ >= 0 && !fix_dissipated_energy_)
error->one(FLERR, "Could not find fix calculate/wall_dissipated_energy");
if(!success) {
error->fix_error(FLERR, parent, settings.error_message.c_str());
}
}
inline void force_update(double * const f, double * const torque,
const ForceData & forces) {
for (int coord = 0; coord < 3; coord++) {
f[coord] += forces.delta_F[coord];
torque[coord] += forces.delta_torque[coord];
}
}
virtual bool checkSurfaceIntersect(SurfacesIntersectData & sidata)
{
return cmodel.checkSurfaceIntersect(sidata);
}
virtual void compute_force(FixWallGran * wg, SurfacesIntersectData & sidata, bool intersectflag,double *vwall, class FixMeshSurface * fix_mesh = 0, int iMesh = 0, class TriMesh *mesh = 0,int iTri = 0)
{
const int ip = sidata.i;
double *x = atom->x[ip];
double *f = atom->f[ip];
double *torque = atom->torque[ip];
double *v = atom->v[ip];
double *omega = atom->omega[ip];
double mass = atom->rmass[ip];
int *type = atom->type;
#ifdef LIGGGHTS_DEBUG
if(std::isnan(vectorMag3D(x)))
error->one(FLERR,"x is NaN!");
if(std::isnan(vectorMag3D(f)))
error->one(FLERR,"f is NaN!");
if(std::isnan(vectorMag3D(torque)))
error->one(FLERR,"torque is NaN!");
if(std::isnan(vectorMag3D(omega)))
error->one(FLERR,"omega is NaN!");
#endif
// copy collision data to struct (compiler can figure out a better way to
// interleave these stores with the double calculations above.
ForceData i_forces;
ForceData j_forces;
memset(&i_forces, 0, sizeof(ForceData));
memset(&j_forces, 0, sizeof(ForceData));
sidata.v_i = v;
sidata.v_j = vwall;
sidata.omega_i = omega;
sidata.r = sidata.radi - sidata.deltan; // sign corrected, because negative value is passed
sidata.rsq = sidata.r*sidata.r;
const double rinv = 1.0/sidata.r;
sidata.rinv = rinv;
sidata.area_ratio = 1.;
//store type here as negative in case of primitive wall!
sidata.j = mesh ? iTri : -wg->atom_type_wall();
sidata.contact_flags = NULL;
sidata.itype = type[ip];
if(wg->fix_rigid() && wg->body(ip) >= 0)
mass = wg->masstotal(wg->body(ip));
sidata.meff = mass;
sidata.mi = mass;
sidata.computeflag = wg->computeflag();
sidata.shearupdate = wg->shearupdate();
sidata.jtype = wg->atom_type_wall();
double force_old[3]={}, f_pw[3];
// if force should be stored - remember old force
if(wg->store_force() || fix_mesh)
vectorCopy3D(f,force_old);
// add to cwl
if(wg->compute_wall_gran_local() && wg->addflag())
{
double contactPoint[3];
vectorSubtract3D(x,sidata.delta,contactPoint);
#ifdef SUPERQUADRIC_ACTIVE_FLAG
if(atom->superquadric_flag) {
vectorCopy3D(sidata.contact_point, contactPoint);
}
#endif
wg->compute_wall_gran_local()->add_wall_1(iMesh,mesh->id(iTri),ip,contactPoint,vwall);
}
#ifdef SUPERQUADRIC_ACTIVE_FLAG
double enx, eny, enz;
if(atom->superquadric_flag) {
#ifdef LIGGGHTS_DEBUG
if(vectorMag3D(sidata.delta) == 0.0)
error->one(FLERR, "vectorMag3D(sidata.delta) == 0.0");
#endif
const double delta_inv = 1.0 / vectorMag3D(sidata.delta);
#ifdef LIGGGHTS_DEBUG
if(std::isnan(delta_inv))
error->one(FLERR, "delta_inv is NaN!");
#endif
enx = sidata.delta[0] * delta_inv;
eny = sidata.delta[1] * delta_inv;
enz = sidata.delta[2] * delta_inv;
sidata.radi = cbrt(0.75 * atom->volume[ip] / M_PI);
#ifdef LIGGGHTS_DEBUG
if(std::isnan(sidata.radi))
error->one(FLERR, "delta_inv is NaN!");
#endif
Superquadric particle(atom->x[ip], atom->quaternion[ip], atom->shape[ip], atom->roundness[ip]);
sidata.koefi = particle.calc_curvature_coefficient(sidata.contact_point);
} else { // sphere case
enx = sidata.delta[0] * rinv;
eny = sidata.delta[1] * rinv;
enz = sidata.delta[2] * rinv;
}
#else // sphere case
const double enx = sidata.delta[0] * rinv;
const double eny = sidata.delta[1] * rinv;
const double enz = sidata.delta[2] * rinv;
#endif
sidata.radsum = sidata.radi;
sidata.en[0] = enx;
sidata.en[1] = eny;
sidata.en[2] = enz;
double delta[3];
if (dissipation_offset_ >= 0 && sidata.computeflag && sidata.shearupdate)
{
sidata.fix_mesh->triMesh()->get_global_vel(delta);
vectorScalarMult3D(delta, update->dt);
// displacement force from the previous time step
double * const diss_force = &sidata.contact_history[dissipation_offset_];
// in the scalar product with the current mesh delta
const double dissipated_energy = vectorDot3D(delta, diss_force)*0.5;
fix_dissipated_energy_->dissipate_energy(dissipated_energy, true);
// reset the dissipation force
diss_force[0] = 0.0;
diss_force[1] = 0.0;
diss_force[2] = 0.0;
}
if (intersectflag)
{
cmodel.surfacesIntersect(sidata, i_forces, j_forces);
cmodel.endSurfacesIntersect(sidata, mesh, i_forces, j_forces);
// if there is a surface touch, there will always be a force
sidata.has_force_update = true;
}
// surfacesClose is not supported for convex particles
else if (!atom->shapetype_flag)
{
// apply force update only if selected contact models have requested it
sidata.has_force_update = false;
cmodel.surfacesClose(sidata, i_forces, j_forces);
}
if (sidata.is_wall && dissipation_offset_ >= 0 && sidata.computeflag && sidata.shearupdate)
{
// new displacement force from this time step
double * const diss_force = &sidata.contact_history[dissipation_offset_];
// in the scalar product with the mesh displacement from earlier on
const double dissipated_energy = vectorDot3D(delta, diss_force)*0.5;
//printf("pdis %e %e\n", update->get_cur_time(), dissipated_energy);
fix_dissipated_energy_->dissipate_energy(dissipated_energy, false);
}
if(sidata.computeflag)
{
if (sidata.has_force_update)
force_update(f, torque, i_forces);
// summation of f.n to compute a simplistic pressure
if (wg->store_sum_normal_force())
{
double * const iforce = wg->get_sum_normal_force_ptr(ip);
const double fDotN = vectorDot3D(i_forces.delta_F, sidata.en);
*iforce += fDotN;
}
}
if (wg->store_force_contact() && 0 == update->ntimestep % wg->store_force_contact_every())
{
wg->add_contactforce_wall(ip,i_forces,mesh?mesh->id(iTri):0);
}
if (wg->store_force_contact_stress())
wg->add_contactforce_stress_wall(ip, i_forces, sidata.delta, vwall, mesh?mesh->id(iTri):0);
if(wg->compute_wall_gran_local() && wg->addflag())
{
const double fx = i_forces.delta_F[0];
const double fy = i_forces.delta_F[1];
const double fz = i_forces.delta_F[2];
const double tor1 = i_forces.delta_torque[0]*sidata.area_ratio;
const double tor2 = i_forces.delta_torque[1]*sidata.area_ratio;
const double tor3 = i_forces.delta_torque[2]*sidata.area_ratio;
double normal[3];
vectorCopy3D(sidata.en, normal);
vectorNegate3D(normal);
wg->compute_wall_gran_local()->add_wall_2(sidata.i,fx,fy,fz,tor1,tor2,tor3,sidata.contact_history,sidata.rsq, normal);
}
// add heat flux
if(wg->heattransfer_flag())
wg->addHeatFlux(mesh,ip,sidata.radi,sidata.deltan,1.);
// if force should be stored or evaluated
if(sidata.has_force_update && (wg->store_force() || fix_mesh) )
{
vectorSubtract3D(f,force_old,f_pw);
if(wg->store_force())
vectorAdd3D (wg->fix_wallforce()->array_atom[ip], f_pw, wg->fix_wallforce()->array_atom[ip]);
if (fix_mesh)
{
double delta[3];
delta[0] = -sidata.delta[0];
delta[1] = -sidata.delta[1];
delta[2] = -sidata.delta[2];
fix_mesh->add_particle_contribution (ip,f_pw,delta,iTri,vwall);
}
}
}
int get_history_offset(const std::string hname)
{
return cmodel.get_history_offset(hname);
}
bool contact_match(const std::string mtype, const std::string model)
{
return cmodel.contact_match(mtype, model);
}
};
}
}
#endif
|