1 /* ---------------------------------------------------------------------- 2 This is the 3 4 ██╗ ██╗ ██████╗ ██████╗ ██████╗ ██╗ ██╗████████╗███████╗ 5 ██║ ██║██╔════╝ ██╔════╝ ██╔════╝ ██║ ██║╚══██╔══╝██╔════╝ 6 ██║ ██║██║ ███╗██║ ███╗██║ ███╗███████║ ██║ ███████╗ 7 ██║ ██║██║ ██║██║ ██║██║ ██║██╔══██║ ██║ ╚════██║ 8 ███████╗██║╚██████╔╝╚██████╔╝╚██████╔╝██║ ██║ ██║ ███████║ 9 ╚══════╝╚═╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝® 10 11 DEM simulation engine, released by 12 DCS Computing Gmbh, Linz, Austria 13 http://www.dcs-computing.com, office@dcs-computing.com 14 15 LIGGGHTS® is part of CFDEM®project: 16 http://www.liggghts.com | http://www.cfdem.com 17 18 Core developer and main author: 19 Christoph Kloss, christoph.kloss@dcs-computing.com 20 21 LIGGGHTS® is open-source, distributed under the terms of the GNU Public 22 License, version 2 or later. It is distributed in the hope that it will 23 be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 24 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. You should have 25 received a copy of the GNU General Public License along with LIGGGHTS®. 26 If not, see http://www.gnu.org/licenses . See also top-level README 27 and LICENSE files. 28 29 LIGGGHTS® and CFDEM® are registered trade marks of DCS Computing GmbH, 30 the producer of the LIGGGHTS® software and the CFDEM®coupling software 31 See http://www.cfdem.com/terms-trademark-policy for details. 32 33 ------------------------------------------------------------------------- 34 Contributing author and copyright for this file: 35 Philippe Seil (JKU Linz) 36 37 Copyright 2004- JKU Linz 38 ------------------------------------------------------------------------- */ 39 40 #include "fix_lb_coupling_onetoone.h" 41 42 #include "lammps.h" 43 #include "modify.h" 44 #include "error.h" 45 #include "atom.h" 46 #include "comm.h" 47 48 #include "fix_property_atom.h" 49 50 #include <iomanip> 51 #include <iostream> 52 53 namespace LAMMPS_NS { FixLbCouplingOnetoone(LAMMPS * lmp,int narg,char ** arg)54 FixLbCouplingOnetoone::FixLbCouplingOnetoone(LAMMPS *lmp, int narg, char **arg) 55 : Fix(lmp,narg,arg), fix_dragforce_(0), fix_hdtorque_(0) 56 { 57 } 58 ~FixLbCouplingOnetoone()59 FixLbCouplingOnetoone::~FixLbCouplingOnetoone() 60 { 61 62 } 63 setmask()64 int FixLbCouplingOnetoone::setmask() 65 { 66 int mask = 0; 67 mask |= FixConst::POST_FORCE; 68 return mask; 69 } 70 init()71 void FixLbCouplingOnetoone::init() 72 { 73 // make sure there is only one fix of this style 74 if(modify->n_fixes_style(style) != 1) 75 error->fix_error(FLERR,this,"More than one fix of this style is not allowed"); 76 77 } 78 post_create()79 void FixLbCouplingOnetoone::post_create() 80 { 81 // register dragforce 82 if(!fix_dragforce_) 83 { 84 const char *fixarg[] = { 85 "dragforce", // fix id 86 "all", // fix group 87 "property/atom", // fix style: property/atom 88 "dragforce", // property name 89 "vector", // 1 vector per particle 90 "yes", // restart 91 "no", // communicate ghost 92 "yes", // communicate rev 93 "0.","0.","0." // default values 94 }; 95 fix_dragforce_ = modify->add_fix_property_atom(11,const_cast<char**>(fixarg),style); 96 } 97 98 // register hydrodynamic torque 99 if(!fix_hdtorque_) 100 { 101 const char *fixarg[] = { 102 "hdtorque", // fix id 103 "all", // fix group 104 "property/atom", // fix style: property/atom 105 "hdtorque", // property name 106 "vector", // 1 vector per particle 107 "yes", // restart 108 "no", // communicate ghost 109 "yes", // communicate rev 110 "0.","0.","0." 111 }; 112 fix_hdtorque_ = modify->add_fix_property_atom(11,const_cast<char**>(fixarg),style); 113 } 114 } 115 pre_delete(bool unfixflag)116 void FixLbCouplingOnetoone::pre_delete(bool unfixflag) 117 { 118 if(!unfixflag) return; 119 120 if(fix_dragforce_) 121 modify->delete_fix(fix_dragforce_->id); 122 if(fix_hdtorque_) 123 modify->delete_fix(fix_hdtorque_->id); 124 } 125 post_force(int)126 void FixLbCouplingOnetoone::post_force(int) 127 { 128 double **f_ext = fix_dragforce_->array_atom; 129 //double **t_ext = fix_hdtorque_->array_atom; 130 double **t_ext = fix_hdtorque_->array_atom; 131 double **f = atom->f; 132 //double **t = atom->torque; 133 134 // for(int i=0;i<atom->nlocal;i++) 135 // std::cout << comm->me << " force_liggghts " 136 // << std::setprecision(12) << f_ext[i][2] << std::endl; 137 138 // std::cout << "before" << std::endl; 139 // fix_dragforce_->do_reverse_comm(); 140 // fix_hdtorque_->do_reverse_comm(); 141 // std::cout << "after" << std::endl; 142 143 // for(int i=0;i<atom->nlocal;i++) 144 // std::cout << comm->me << " force_liggghts_after " 145 // << std::setprecision(12) << f_ext[i][2] << " x " << atom->x[0][2] << std::endl; 146 double **t = atom->torque; 147 148 for(int i=0;i<atom->nlocal;i++){ 149 for(int j=0;j<3;j++){ 150 f[i][j] += f_ext[i][j]; 151 // t[i][j] += t_ext[i][j]; 152 t[i][j] += t_ext[i][j]; 153 } 154 } 155 156 } 157 get_force_ptr()158 double **FixLbCouplingOnetoone::get_force_ptr() 159 { 160 return fix_dragforce_->array_atom; 161 } get_torque_ptr()162 double **FixLbCouplingOnetoone::get_torque_ptr() 163 { 164 return fix_hdtorque_->array_atom; 165 } comm_force_torque()166 void FixLbCouplingOnetoone::comm_force_torque() 167 { 168 fix_dragforce_->do_reverse_comm(); 169 fix_hdtorque_->do_reverse_comm(); 170 } 171 172 }; /* LAMMPS_NS */ 173