1 // ATC transfer headers 2 #include "TimeIntegrator.h" 3 #include "ATC_Coupling.h" 4 #include "ATC_Error.h" 5 6 namespace ATC { 7 8 //-------------------------------------------------------- 9 //-------------------------------------------------------- 10 // Class AtomTimeIntegratorType 11 //-------------------------------------------------------- 12 //-------------------------------------------------------- 13 14 //-------------------------------------------------------- 15 // Constructor 16 //-------------------------------------------------------- AtomTimeIntegratorType(ATC_Method * atc,AtomType atomType)17 AtomTimeIntegratorType::AtomTimeIntegratorType(ATC_Method * atc, AtomType atomType) : 18 atc_(atc), 19 atomType_(atomType), 20 mass_(nullptr), 21 position_(nullptr), 22 velocity_(nullptr), 23 force_(nullptr) 24 { 25 // do nothing 26 } 27 28 //-------------------------------------------------------- 29 // construct_transfers 30 // sets/constructs all required dependency managed data 31 //-------------------------------------------------------- construct_transfers()32 void AtomTimeIntegratorType::construct_transfers() 33 { 34 InterscaleManager & interscaleManager(atc_->interscale_manager()); 35 mass_ = interscaleManager.fundamental_atom_quantity(LammpsInterface::ATOM_MASS,atomType_); 36 position_ = interscaleManager.fundamental_atom_quantity(LammpsInterface::ATOM_POSITION,atomType_); 37 velocity_ = interscaleManager.fundamental_atom_quantity(LammpsInterface::ATOM_VELOCITY,atomType_); 38 force_ = interscaleManager.fundamental_atom_quantity(LammpsInterface::ATOM_FORCE,atomType_); 39 } 40 41 //-------------------------------------------------------- 42 // initial_integrate_velocity 43 // velocity update in first part of velocity-verlet 44 //-------------------------------------------------------- init_integrate_velocity(double dt)45 void AtomTimeIntegratorType::init_integrate_velocity(double dt) 46 { 47 const DENS_MAT & m(mass_->quantity()); 48 49 _deltaQuantity_ = force_->quantity(); 50 _deltaQuantity_ /= m; 51 _deltaQuantity_ *= 0.5*dt; 52 53 (*velocity_) += _deltaQuantity_; 54 } 55 56 //-------------------------------------------------------- 57 // initial_integrate_position 58 // position update in first part of velocity-verlet 59 //-------------------------------------------------------- init_integrate_position(double dt)60 void AtomTimeIntegratorType::init_integrate_position(double dt) 61 { 62 _deltaQuantity_ = velocity_->quantity(); 63 _deltaQuantity_ *= dt; 64 (*position_) += _deltaQuantity_; 65 } 66 67 //-------------------------------------------------------- 68 // final_integrate 69 // velocity update in second part of velocity-verlet 70 //-------------------------------------------------------- final_integrate(double dt)71 void AtomTimeIntegratorType::final_integrate(double dt) 72 { 73 const DENS_MAT & m(mass_->quantity()); 74 75 _deltaQuantity_ = force_->quantity(); 76 _deltaQuantity_ /= m; 77 _deltaQuantity_ *= 0.5*dt; 78 79 (*velocity_) += _deltaQuantity_; 80 } 81 82 //-------------------------------------------------------- 83 //-------------------------------------------------------- 84 // Class TimeIntegrator 85 //-------------------------------------------------------- 86 //-------------------------------------------------------- 87 88 //-------------------------------------------------------- 89 // Constructor 90 //-------------------------------------------------------- TimeIntegrator(ATC_Coupling * atc,TimeIntegrationType timeIntegrationType)91 TimeIntegrator::TimeIntegrator(ATC_Coupling * atc, 92 TimeIntegrationType timeIntegrationType) : 93 timeIntegrationMethod_(nullptr), 94 atc_(atc), 95 timeFilter_(nullptr), 96 timeFilterManager_(atc_->time_filter_manager()), 97 timeIntegrationType_(timeIntegrationType), 98 needReset_(true) 99 { 100 // do nothing 101 } 102 103 //-------------------------------------------------------- 104 // Destructor 105 //-------------------------------------------------------- ~TimeIntegrator()106 TimeIntegrator::~TimeIntegrator() 107 { 108 if (timeIntegrationMethod_) 109 delete timeIntegrationMethod_; 110 } 111 112 //-------------------------------------------------------- 113 // construct_transfers 114 // sets/constructs all required dependency managed data 115 //-------------------------------------------------------- construct_transfers()116 void TimeIntegrator::construct_transfers() 117 { 118 timeIntegrationMethod_->construct_transfers(); 119 } 120 121 //-------------------------------------------------------- 122 // initialize 123 // initialize all data and variables before a run 124 //-------------------------------------------------------- initialize()125 void TimeIntegrator::initialize() 126 { 127 timeIntegrationMethod_->initialize(); 128 needReset_ = false; 129 } 130 131 //-------------------------------------------------------- 132 // pre_initial_integrate1 133 // first time integration computations 134 // before Verlet step 1 135 //-------------------------------------------------------- pre_initial_integrate1(double dt)136 void TimeIntegrator::pre_initial_integrate1(double dt) 137 { 138 timeIntegrationMethod_->pre_initial_integrate1(dt); 139 } 140 141 //-------------------------------------------------------- 142 // pre_initial_integrate2 143 // second time integration computations 144 // before Verlet step 1 145 //-------------------------------------------------------- pre_initial_integrate2(double dt)146 void TimeIntegrator::pre_initial_integrate2(double dt) 147 { 148 timeIntegrationMethod_->pre_initial_integrate2(dt); 149 } 150 151 //-------------------------------------------------------- 152 // post_initial_integrate1 153 // first time integration computations 154 // after Verlet step 1 155 //-------------------------------------------------------- post_initial_integrate1(double dt)156 void TimeIntegrator::post_initial_integrate1(double dt) 157 { 158 timeIntegrationMethod_->post_initial_integrate1(dt); 159 } 160 161 //-------------------------------------------------------- 162 // post_initial_integrate2 163 // second time integration computations 164 // after Verlet step 1 165 //-------------------------------------------------------- post_initial_integrate2(double dt)166 void TimeIntegrator::post_initial_integrate2(double dt) 167 { 168 timeIntegrationMethod_->post_initial_integrate2(dt); 169 } 170 171 //-------------------------------------------------------- 172 // pre_final_integrate1 173 // first time integration computations 174 // before Verlet step 2 175 //-------------------------------------------------------- pre_final_integrate1(double dt)176 void TimeIntegrator::pre_final_integrate1(double dt) 177 { 178 timeIntegrationMethod_->pre_final_integrate1(dt); 179 } 180 181 //-------------------------------------------------------- 182 // pre_final_integrate2 183 // second time integration computations 184 // before Verlet step 2 185 //-------------------------------------------------------- pre_final_integrate2(double dt)186 void TimeIntegrator::pre_final_integrate2(double dt) 187 { 188 timeIntegrationMethod_->pre_final_integrate2(dt); 189 } 190 191 //-------------------------------------------------------- 192 // post_final_integrate1 193 // first time integration computations 194 // after Verlet step 2 195 //-------------------------------------------------------- post_final_integrate1(double dt)196 void TimeIntegrator::post_final_integrate1(double dt) 197 { 198 timeIntegrationMethod_->post_final_integrate1(dt); 199 } 200 201 //-------------------------------------------------------- 202 // post_final_integrate2 203 // second time integration computations 204 // after Verlet step 2 205 //-------------------------------------------------------- post_final_integrate2(double dt)206 void TimeIntegrator::post_final_integrate2(double dt) 207 { 208 timeIntegrationMethod_->post_final_integrate2(dt); 209 } 210 211 //-------------------------------------------------------- 212 // post_final_integrate3 213 // third time integration computations 214 // after Verlet step 2 215 //-------------------------------------------------------- post_final_integrate3(double dt)216 void TimeIntegrator::post_final_integrate3(double dt) 217 { 218 timeIntegrationMethod_->post_final_integrate3(dt); 219 } 220 221 //-------------------------------------------------------- 222 // has_final_predictor 223 // checks to see if first RHS computation is needed 224 //-------------------------------------------------------- has_final_predictor()225 bool TimeIntegrator::has_final_predictor() 226 { 227 return timeIntegrationMethod_->has_final_predictor(); 228 } 229 230 //-------------------------------------------------------- 231 // has_final_corrector 232 // checks to see if second RHS computation is needed 233 //-------------------------------------------------------- has_final_corrector()234 bool TimeIntegrator::has_final_corrector() 235 { 236 return timeIntegrationMethod_->has_final_corrector(); 237 } 238 239 //-------------------------------------------------------- 240 // add_to_rhs 241 // add any needed contributions to RHS 242 //-------------------------------------------------------- add_to_rhs()243 void TimeIntegrator::add_to_rhs() 244 { 245 timeIntegrationMethod_->add_to_rhs(); 246 } 247 248 //-------------------------------------------------------- 249 // post_process 250 // perform any post processing calculations 251 //-------------------------------------------------------- post_process()252 void TimeIntegrator::post_process() 253 { 254 timeIntegrationMethod_->post_process(); 255 } 256 257 //-------------------------------------------------------- 258 // output 259 // add variables to output list 260 //-------------------------------------------------------- output(OUTPUT_LIST & outputData)261 void TimeIntegrator::output(OUTPUT_LIST & outputData) 262 { 263 timeIntegrationMethod_->output(outputData); 264 } 265 266 //-------------------------------------------------------- 267 // pack_fields 268 // add persistent variables to data list 269 //-------------------------------------------------------- pack_fields(RESTART_LIST & data)270 void TimeIntegrator::pack_fields(RESTART_LIST & data) 271 { 272 timeIntegrationMethod_->pack_fields(data); 273 274 //timeFilter_->pack_fields(data); 275 } 276 277 //-------------------------------------------------------- 278 // finish 279 // perform any final state setting 280 //-------------------------------------------------------- finish()281 void TimeIntegrator::finish() 282 { 283 timeIntegrationMethod_->finish(); 284 } 285 286 //-------------------------------------------------------- 287 //-------------------------------------------------------- 288 // Class TimeIntegrationMethod 289 //-------------------------------------------------------- 290 //-------------------------------------------------------- 291 292 //-------------------------------------------------------- 293 // Constructor 294 // Grab data from ATC 295 //-------------------------------------------------------- TimeIntegrationMethod(TimeIntegrator * timeIntegrator)296 TimeIntegrationMethod::TimeIntegrationMethod(TimeIntegrator * timeIntegrator) : 297 timeIntegrator_(timeIntegrator), 298 atc_(timeIntegrator_->atc()) 299 { 300 // do nothing 301 } 302 303 }; 304