void TIME_STEPPER::time_loop() { if (first_step) { REAL OmRMax = 0.0, MaxRadius = 0.0; if (globalSystem->useBodies) { for (int i = 0; i < BODY::AllBodyFaces.size(); ++i) { Vect3 Pos = BODY::AllBodyFaces[i]->CollocationPoint - BODY::AllBodyFaces[i]->Owner->CG; // Get point kinematic velocity - rotational part first Vect3 Vrot = BODY::AllBodyFaces[i]->Owner->BodyRates.Cross(Pos); // Add to translational velocity.... Vect3 Vkin = BODY::AllBodyFaces[i]->Owner->Velocity + Vrot; OmRMax = max(Vkin.Mag(), OmRMax); MaxRadius = max(MaxRadius, Pos.Mag()); } } dt = globalSystem->dtInit;// = cfl_lim/OmRMax; dt_prev = cfl_lim/OmRMax; if (globalSystem->useBodies) { BODY::BodySubStep(globalSystem->dtInit, globalSystem->NumSubSteps); globalSystem->PutWakesInTree(); } globalOctree->Reset(); globalOctree->GetVels(); // if (globalSystem->useFMM) { //#pragma omp parallel for // for (int i = 0; i < FVMCell::AllCells.size(); ++i) // for (int j = 0; j < FVMCell::AllCells.size(); ++j) // FVMCell::AllCells[i]->Velocity += UTIL::globalDirectVel(FVMCell::AllCells[j]->Position - FVMCell::AllCells[i]->Position, FVMCell::AllCells[j]->Omega); // } first_step = false; } else { #ifdef TIME_STEPS long unsigned int t1 = ticks(); #endif TimeAdvance(); // Produce Output if (globalTimeStepper->dump_next) { globalSystem->WriteData(); } #ifdef TIME_STEPS long unsigned int t13 = ticks(); stringstream tmp; tmp << "Total....................: " << double(t13 - t1) / 1000.0 << endl; globalIO->step_data += tmp.str(); #endif // Display Status globalIO->stat_step(); } }
void TIME_STEPPER::time_step() { #ifdef TIME_STEPS long unsigned int t7 = ticks(); #endif // Need a sensible way to figure out how long to make the global Eulerian time step // and then the number and length of the Lagrangian time steps // First off calculate the Eulerian time-step length srad = 0.0; globalOctree->GetSRad(); REAL dt_euler = cfl_lim / srad.Mag(); //(srad.x + srad.y + srad.z); if (srad.Mag() == 0.0) dt_euler = globalSystem->dtInit; dt = dt_euler; // Calculate timestep length such that no body travels further than a single cell REAL OmRMax = 0.0, MaxRadius = 0.0; if (globalSystem->useBodies) { for (int i = 0; i < BODY::AllBodyFaces.size(); ++i) { Vect3 Pos = BODY::AllBodyFaces[i]->CollocationPoint - BODY::AllBodyFaces[i]->Owner->CG; // Get point kinematic velocity - rotational part first Vect3 Vrot = BODY::AllBodyFaces[i]->Owner->BodyRates.Cross(Pos); // Add to translational velocity.... Vect3 Vkin = BODY::AllBodyFaces[i]->Owner->Velocity + Vrot; OmRMax = max(Vkin.Mag(), OmRMax); MaxRadius = max(MaxRadius, Pos.Mag()); } } if (fabs((dt - dt_prev)/dt_prev) > 0.05) { if ((dt - dt_prev) > 0.) dt = 1.05 * dt_prev; } dt_euler = dt; // dt = min(dt_euler,4.*cfl_lim/OmRMax); // the maximum distance allowable by any body part is 4 cells... // dt = min(dt_euler,cfl_lim/OmRMax); // Check to see if this takes us over a time when we should be writing some output dump_next = false; if ((TIME_STEPPER::SimTime + dt >= t_out) || (TIME_STEPPER::SimTime + dt >= TIME_STEPPER::MaxTime)) { if (TIME_STEPPER::SimTime + dt >= TIME_STEPPER::MaxTime) last_step = true; dump_next = true; //dt = dt_euler = min(t_out - TIME_STEPPER::SimTime, TIME_STEPPER::MaxTime - TIME_STEPPER::SimTime); t_out += TIME_STEPPER::dt_out; } if (globalSystem->useBodies) { // If Lagrangian time-step is infinite (ie body is not moving) use a sensible number of sub-steps REAL dt_lagrange = min(dt_euler / globalSystem->NumSubSteps, cfl_lim / (OmRMax)); // int nss = (int) ceil(dt_euler / dt_lagrange); //cout << dt_lagrange << " " << nss << " " << dt_euler << " " << cfl_lim << " " << OmRMax << endl; globalSystem->NumSubSteps = nss; } CFL = srad * dt; // if (n == 0) dump_next = true; if (n > 0) { dt_prev = dt; t += dt; } // if ((ChangeOver == false) && (t >= 1)) // { // // for (int i = 0; i < globalSystem->NumBodies; ++i) // globalSystem->Bodies[i]->CG.vV = - globalSystem->Vinf; // // globalSystem->Vinf.x = 0; // globalSystem->Vinf.y = 0; // globalSystem->Vinf.z = 0; // globalSystem->Vinf = 0; // ChangeOver = true; // } n++; #ifdef TIME_STEPS long unsigned int t8 = ticks(); stringstream tmp; tmp << "time_step() : " << double(t8 - t7) / 1000.0 << endl; globalIO->step_data += tmp.str(); #endif }