@@ -87,14 +87,17 @@ model::DEMModel::DEMModel(inp::Input *deck) : ModelData(deck) {
8787 d_outputDeck_p->d_path + " log.txt" );
8888}
8989
90- void model::DEMModel::log (std::ostringstream &oss, int priority,
90+ void model::DEMModel::log (std::ostringstream &oss, int priority, bool check_condition, int override_priority,
9191 bool screen_out) {
92- if (d_outputDeck_p->d_debug > priority)
92+ int op = override_priority == -1 ? priority : override_priority;
93+ // if (d_outputDeck_p->d_debug > priority)
94+ if ((check_condition and d_outputDeck_p->d_debug > priority) or d_outputDeck_p->d_debug > op)
9395 util::io::log (oss, screen_out);
9496}
95- void model::DEMModel::log (const std::string &str, int priority,
97+ void model::DEMModel::log (const std::string &str, int priority, bool check_condition, int override_priority,
9698 bool screen_out) {
97- if (d_outputDeck_p->d_debug > priority)
99+ int op = override_priority == -1 ? priority : override_priority;
100+ if ((check_condition and d_outputDeck_p->d_debug > priority) or d_outputDeck_p->d_debug > op)
98101 util::io::log (str, screen_out);
99102}
100103
@@ -190,7 +193,7 @@ void model::DEMModel::init() {
190193 // setup tree
191194 double set_tree_time = d_nsearch_p->updatePointCloud (d_x, true );
192195 set_tree_time += d_nsearch_p->setInputCloud ();
193- log (fmt::format (" DEMModel: Tree setup time (ms) = {} \n " , set_tree_time));
196+ log (fmt::format (" DEMModel: Tree setup time (ms) = {}. \n " , set_tree_time));
194197
195198 // create neighborlists
196199 log (" DEMModel: Creating neighborlist for peridynamics.\n " );
@@ -229,11 +232,11 @@ void model::DEMModel::init() {
229232 if (d_pDeck_p->d_testName == " two_particle" )
230233 d_particles[0 ]->d_computeForce = false ;
231234
232- log (fmt::format (" DEMModel: Total particles = {} \n " , d_particles.size ()));
235+ log (fmt::format (" DEMModel: Total particles = {}. \n " , d_particles.size ()));
233236
234237 for (const auto &w : d_walls)
235238 if (!w->d_computeForce )
236- log (fmt::format (" DEMModel: force OFF in Wall i = {} \n " , w->getTypeId ()));
239+ log (fmt::format (" DEMModel: force OFF in Wall i = {}. \n " , w->getTypeId ()));
237240
238241 log (" DEMModel: Creating list of nodes on which force is to be computed.\n " );
239242 // TODO for now we simply look at particle/wall and check if we compute
@@ -254,7 +257,7 @@ void model::DEMModel::init() {
254257 d_Z = std::vector<float >(d_x.size (), 0 .);
255258
256259 auto t2 = steady_clock::now ();
257- log (fmt::format (" DEMModel: Total setup time (ms) = {} \n " ,
260+ log (fmt::format (" DEMModel: Total setup time (ms) = {}. \n " ,
258261 util::methods::timeDiff (t1, t2)));
259262
260263 // compute complexity information
@@ -267,7 +270,7 @@ void model::DEMModel::init() {
267270 log (fmt::format (" DEMModel: Computational complexity information \n "
268271 " Number of "
269272 " particles = {}, number of walls = {}, number of dofs = {},"
270- " number of free dofs = {}\n " ,
273+ " number of free dofs = {}. \n " ,
271274 d_particles.size (), d_walls.size (), 3 * d_x.size (),
272275 free_dofs));
273276}
@@ -288,29 +291,26 @@ void model::DEMModel::integrate() {
288291
289292 for (size_t i = d_n; i < d_modelDeck_p->d_Nt ; i++) {
290293
291- if (d_n % d_infoN == 0 )
292- log (fmt::format (" DEMModel: Time step: {}, time: {:.6f}\n " , i, d_time), 2 );
293-
294+ log (fmt::format (" DEMModel: Time step: {}, time: {:.6f}\n " , i, d_time), 2 , d_n % d_infoN == 0 , 3 );
295+
294296 clock_begin = steady_clock::now ();
297+ log (" Integrating\n " , false , 0 , 3 );
295298 integrateStep ();
296299 double integrate_time =
297300 util::methods::timeDiff (clock_begin, steady_clock::now ());
298301 integrate_compute_time += integrate_time;
299302
300- if (d_n % d_infoN == 0 )
301- log (fmt::format (" Integration time (ms) = {}\n " , integrate_time), 2 );
303+ log (fmt::format (" Integration time (ms) = {}\n " , integrate_time), 2 , d_n % d_infoN == 0 , 3 );
302304
303305 if (d_pDeck_p->d_testName == " two_particle" ) {
304306
305307 // compute location of maximum shear stress and also compute
306308 // penetration length
307309 auto msg = ppTwoParticleTest ();
308- if (d_n % d_infoN == 0 )
309- log (msg, 2 );
310+ log (msg, 2 , d_n % d_infoN == 0 , 3 );
310311 } else if (d_pDeck_p->d_testName == " compressive_test" ) {
311312 auto msg = ppCompressiveTest ();
312- if (d_n % d_infoN == 0 )
313- log (msg, 2 );
313+ log (msg, 2 , d_n % d_infoN == 0 , 3 );
314314 }
315315
316316 // handle general output
@@ -331,8 +331,7 @@ void model::DEMModel::integrate() {
331331 " Tree update = {:.6f}, External force = {:.6f}\n " ,
332332 integrate_compute_time * 1 .e -6 , pd_compute_time * 1 .e -6 ,
333333 contact_compute_time * 1 .e -6 , tree_compute_time * 1 .e -6 ,
334- extf_compute_time * 1 .e -6 ),
335- 1 );
334+ extf_compute_time * 1 .e -6 ), 1 );
336335}
337336
338337void model::DEMModel::integrateStep () {
@@ -433,56 +432,52 @@ void model::DEMModel::integrateVerlet() {
433432
434433void model::DEMModel::computeForces () {
435434
436- if (d_n % d_infoN == 0 )
437- log (" Compute forces \n " , 2 );
435+ bool dbg_condition = d_n % d_infoN == 0 ;
436+
437+ log (" Compute forces \n " , 2 , dbg_condition, 3 );
438438
439439 // update the point cloud (make sure that d_x is updated along with
440440 // displacment)
441441 auto pt_cloud_update_time = d_nsearch_p->updatePointCloud (d_x, true );
442442 pt_cloud_update_time += d_nsearch_p->setInputCloud ();
443443 tree_compute_time += pt_cloud_update_time;
444- if (d_n % d_infoN == 0 )
445- log (fmt::format (" Point cloud update time (ms) = {} \n " ,
446- pt_cloud_update_time),
447- 2 );
444+ log (fmt::format (" Point cloud update time (ms) = {} \n " ,
445+ pt_cloud_update_time), 2 , dbg_condition, 3 );
448446
449447 // reset force
450448 auto t1 = steady_clock::now ();
451449 hpx::parallel::for_loop (
452450 hpx::parallel::execution::par, 0 , d_x.size (),
453451 [this ](boost::uint64_t i) { this ->d_f [i] = util::Point (); });
454- if (d_n % d_infoN == 0 )
455- log (fmt::format (" Force reset time (ms) = {} \n " ,
456- util::methods::timeDiff (t1, steady_clock::now ())),
457- 2 );
452+ log (fmt::format (" Force reset time (ms) = {} \n " ,
453+ util::methods::timeDiff (t1, steady_clock::now ())), 2 , dbg_condition, 3 );
458454
459455 // compute peridynamic forces
460456 t1 = steady_clock::now ();
461457 computePeridynamicForces ();
462458 auto pd_time = util::methods::timeDiff (t1, steady_clock::now ());
463459 pd_compute_time += pd_time;
464- if (d_n % d_infoN == 0 )
465- log (fmt::format (" Peridynamics force time (ms) = {} \n " , pd_time), 2 );
460+ log (fmt::format (" Peridynamics force time (ms) = {} \n " , pd_time), 2 , dbg_condition, 3 );
466461
467462 // compute contact forces between particles
468463 t1 = steady_clock::now ();
469464 computeContactForces ();
470465 auto contact_time = util::methods::timeDiff (t1, steady_clock::now ());
471466 contact_compute_time += contact_time;
472- if (d_n % d_infoN == 0 )
473- log (fmt::format (" Contact force time (ms) = {} \n " , contact_time), 2 );
467+ log (fmt::format (" Contact force time (ms) = {} \n " , contact_time), 2 , dbg_condition, 3 );
474468
475469 // Compute external forces
476470 t1 = steady_clock::now ();
477471 computeExternalForces ();
478472 auto extf_time = util::methods::timeDiff (t1, steady_clock::now ());
479473 extf_compute_time += extf_time;
480- if (d_n % d_infoN == 0 )
481- log (fmt::format (" External force time (ms) = {} \n " , extf_time), 2 );
474+ log (fmt::format (" External force time (ms) = {} \n " , extf_time), 2 , dbg_condition, 3 );
482475}
483476
484477void model::DEMModel::computePeridynamicForces () {
485478
479+ log (" Computing peridynamic force \n " , 3 );
480+
486481 const auto dim = d_modelDeck_p->d_dim ;
487482 const bool is_state = d_allParticles[0 ]->getMaterial ()->isStateActive ();
488483
@@ -664,6 +659,8 @@ void model::DEMModel::computePeridynamicForces() {
664659
665660void model::DEMModel::computeExternalForces () {
666661
662+ log (" Computing external force \n " , 3 );
663+
667664 auto gravity = d_pDeck_p->d_gravity ;
668665
669666 if (gravity.length () > 1.0E-8 ) {
@@ -683,12 +680,15 @@ void model::DEMModel::computeExternalForces() {
683680}
684681
685682void model::DEMModel::computeExternalDisplacementBC () {
683+ log (" Computing external displacement bc \n " , 3 );
686684 for (auto &p : d_allParticles)
687685 d_uLoading_p->apply (d_time, p); // applied in parallel
688686}
689687
690688void model::DEMModel::computeContactForces () {
691689
690+ log (" Computing normal contact force \n " , 3 );
691+
692692 // Description:
693693 // 1. Normal contact is applied between nodes of particles and walls
694694 // 2. Normal damping is applied between particle centers
@@ -795,6 +795,7 @@ void model::DEMModel::computeContactForces() {
795795 });
796796
797797 // damping force
798+ log (" Computing normal damping force \n " , 3 );
798799 for (auto &pi : d_particles) {
799800
800801 double Ri = pi->d_geom_p ->boundingRadius ();
@@ -924,7 +925,7 @@ void model::DEMModel::computeContactForces() {
924925
925926void model::DEMModel::applyInitialCondition () {
926927
927- // std::cout << "applying initial condition\n";
928+ log ( " Applying initial condition \n " , 3 ) ;
928929
929930 if (!d_pDeck_p->d_icDeck .d_icActive )
930931 return ;
@@ -973,13 +974,13 @@ void model::DEMModel::createParticles() {
973974 auto rep_p_params = pz.d_params ;
974975
975976 // read mesh data
976- util::io:: log (" DEMModel: Creating mesh for reference particle in zone = " +
977+ log (" DEMModel: Creating mesh for reference particle in zone = " +
977978 std::to_string (z_id) + " \n " );
978979 auto *mesh = new fe::Mesh (&pz.d_meshDeck );
979980 // mesh->print();
980981
981982 // create the reference particle
982- util::io:: log (" DEMModel: Creating reference particle in zone = " +
983+ log (" DEMModel: Creating reference particle in zone = " +
983984 std::to_string (z_id) + " \n " );
984985
985986 auto ref_p = std::make_shared<particle::RefParticle>(&pz, mesh);
@@ -1006,7 +1007,7 @@ void model::DEMModel::createParticles() {
10061007 // mdeck.print();
10071008
10081009 // check the particle generation method
1009- util::io:: log (" DEMModel: Creating particles in zone = " +
1010+ log (" DEMModel: Creating particles in zone = " +
10101011 std::to_string (z_id) + " \n " );
10111012
10121013 if (pz.d_genMethod == " From_File" )
@@ -1059,10 +1060,9 @@ void model::DEMModel::createParticlesFromFile(
10591060 &rads, &orients, z_id);
10601061 }
10611062
1062- if (d_outputDeck_p->d_debug > 2 )
1063- log (fmt::format (" zone_id: {}, rads: {}, orients: {}, centers: {} \n " , z_id,
1063+ log (fmt::format (" zone_id: {}, rads: {}, orients: {}, centers: {} \n " , z_id,
10641064 util::io::printStr (rads), util::io::printStr (orients),
1065- util::io::printStr (centers)));
1065+ util::io::printStr (centers)), 2 );
10661066
10671067 // get representative particle for this zone
10681068 const auto &rep_p = pz.d_particle_p ;
@@ -1155,7 +1155,7 @@ void model::DEMModel::createWalls() {
11551155 // read and create mesh data
11561156 fe::Mesh *mesh;
11571157 if (wz.d_meshFlag ) {
1158- util::io:: log (" DEMModel: Creating mesh for wall in zone = " +
1158+ log (" DEMModel: Creating mesh for wall in zone = " +
11591159 std::to_string (z_id) + " \n " );
11601160 // wz.d_meshDeck.print();
11611161 mesh = new fe::Mesh (&wz.d_meshDeck );
@@ -1187,7 +1187,7 @@ void model::DEMModel::createWalls() {
11871187 mdeck.d_horizon = horizon;
11881188
11891189 // create wall
1190- util::io:: log (" DEMModel: Creating wall in zone = " + std::to_string (z_id) +
1190+ log (" DEMModel: Creating wall in zone = " + std::to_string (z_id) +
11911191 " \n " );
11921192 auto wall =
11931193 new particle::Wall (z + wall_id_begin, z, wz, z_id, mesh,
@@ -1218,8 +1218,7 @@ void model::DEMModel::setupContact() {
12181218 d_hMax = h;
12191219 }
12201220
1221- log (" DEMModel: Contact setup" );
1222- log (fmt::format (" hmin = {:.6f}, hmax = {:.6f} \n " , d_hMin, d_hMax));
1221+ log (fmt::format (" DEMModel: Contact setup\n hmin = {:.6f}, hmax = {:.6f} \n " , d_hMin, d_hMax), 1 );
12231222
12241223 d_maxContactR = 0 .;
12251224 // precompute bulk modulus of all zones
@@ -1283,7 +1282,7 @@ void model::DEMModel::setupContact() {
12831282 " Vmax = {:5.3e}, "
12841283 " betan = {:7.5f}, mu = {:.4f}, kappa = {:5.3e}\n " ,
12851284 deck->d_contactR , d_hMin, deck->d_Kn , deck->d_vMax ,
1286- deck->d_betan , deck->d_mu , deck->d_kappa ));
1285+ deck->d_betan , deck->d_mu , deck->d_kappa ), 1 );
12871286 }
12881287 }
12891288}
@@ -1311,8 +1310,7 @@ void model::DEMModel::updatePeridynamicNeighborlist() {
13111310 });
13121311 auto t2 = steady_clock::now ();
13131312 log (fmt::format (" DEMModel: Peridynamics neighbor update time = {}\n " ,
1314- util::methods::timeDiff (t1, t2)),
1315- 2 );
1313+ util::methods::timeDiff (t1, t2)), 2 );
13161314}
13171315
13181316void model::DEMModel::updateContactNeighborlist () {
@@ -1336,8 +1334,7 @@ void model::DEMModel::updateContactNeighborlist() {
13361334 });
13371335 auto t2 = steady_clock::now ();
13381336 log (fmt::format (" DEMModel: Contact neighbor update time = {}\n " ,
1339- util::methods::timeDiff (t1, t2)),
1340- 2 );
1337+ util::methods::timeDiff (t1, t2)), 2 );
13411338}
13421339
13431340void model::DEMModel::updateNeighborlistCombine () {
@@ -1380,8 +1377,7 @@ void model::DEMModel::updateNeighborlistCombine() {
13801377 });
13811378 auto t2 = steady_clock::now ();
13821379 log (fmt::format (" DEMModel: Peridynamics+Contact neighbor update time = {}\n " ,
1383- util::methods::timeDiff (t1, t2)),
1384- 2 );
1380+ util::methods::timeDiff (t1, t2)), 2 );
13851381}
13861382
13871383void model::DEMModel::output () {
@@ -1632,4 +1628,4 @@ std::string model::DEMModel::ppCompressiveTest() {
16321628 " .6f}, "
16331629 " reaction force = {:5.3e} \n " ,
16341630 wall_penetration, tot_reaction_force);
1635- }
1631+ }
0 commit comments