// // this assumes that the user has set appropriate initial // conditions on each level // void run() { for (int nstep=0; nstep<this->nsteps; nstep++) { time t = nstep * this->dt; // predictor: sweep and interpolate to finest level for (auto leviter=this->coarsest(); leviter<this->finest(); ++leviter) { auto* sweeper = leviter.current(); auto* transfer = leviter.transfer(); if (leviter.level == 0) { sweeper->predict(t, this->dt); for (int s=1; s<nsweeps[leviter.level]; s++) sweeper->sweep(t, this->dt); } else { for (int s=0; s<nsweeps[leviter.level]; s++) sweeper->sweep(t, this->dt); } if (leviter < this->finest()) transfer->interpolate(leviter.fine(), leviter.current(), true); } // iterate by performing v-cycles for (int niter=0; niter<this->niters; niter++) cycle_v(this->finest(), t, this->dt); // advance each level for (auto lev=this->coarsest(); lev<=this->finest(); ++lev) lev.current()->advance(); } }
Vertex* intermediate_cycle_ATTLC(char gtype, const Graph& g) { tcwbool_ATTLC found_cycle = FALS; Vertex* v; Vis_v_ticket vt = Vertex::get_vis_v_ticket(); Set_of_p<Vertex> spv = g.vertices(); Set_of_piter<Vertex> vset_iter(spv); Vertex* next_v; while (next_v = vset_iter.next()) { if (!next_v->visited(vt)) { next_v->set_visited(vt); stat_v_pset.insert(next_v); if (cycle_v(gtype, next_v, 2, &v, g, vt)) { found_cycle = TRU; break; } else stat_v_pset.remove_all(); //clear for next try } } stat_v_pset.remove_all(); //clear reset_visited(vt, (Set_of_p<Vertex>&)g.vertices()); Vertex::free_vis_v_ticket(vt); return(found_cycle ? v : 0); }
LevelIter cycle_v(LevelIter leviter, double t, double dt) { if (leviter.level == 0) { leviter = cycle_bottom(leviter, t, dt); } else { leviter = cycle_down(leviter, t, dt); leviter = cycle_v(leviter, t, dt); leviter = cycle_up(leviter, t, dt); } return leviter; }
int intermediate_cycle_v_ATTLC(char gtype, const Graph& g, const Vertex* v) { tcwbool_ATTLC found_cycle = FALS; Vertex* vp; if (v) { Vis_v_ticket vt = Vertex::get_vis_v_ticket(); ((Vertex*)v)->set_visited(vt); stat_v_pset.insert((Vertex*)v); found_cycle = cycle_v(gtype, v, 1, &vp, g, vt); reset_visited(vt, (Set_of_p<Vertex>&)g.vertices()); Vertex::free_vis_v_ticket(vt); stat_v_pset.remove_all(); //clear } return(found_cycle); }