226 if ((mOutputDirectory==
"") || (mFilenamePrefix==
""))
228 EXCEPTION(
"Output directory or filename prefix has not been set");
232 mpHdf5Writer =
new Hdf5DataWriter(*(this->mpMesh)->GetDistributedVectorFactory(),
237 mpHdf5Writer->DefineFixedDimension((this->mpMesh)->GetNumNodes());
240 unsigned estimated_num_printing_timesteps = 1u + (
unsigned)((mTend - mTstart)/(mIdealTimeStep*mPrintingTimestepMultiple));
248 assert(mVariableColumnIds.empty());
249 for (
unsigned i=0; i<PROBLEM_DIM; i++)
251 std::stringstream variable_name;
252 variable_name <<
"Variable_" << i;
253 mVariableColumnIds.push_back(mpHdf5Writer->DefineVariable(variable_name.str(),
"undefined"));
255 mpHdf5Writer->DefineUnlimitedDimension(
"Time",
"undefined", estimated_num_printing_timesteps);
258 mpHdf5Writer->EndDefineMode();
265 mInitialCondition(nullptr),
266 mMatrixIsAssembled(false),
267 mMatrixIsConstant(false),
268 mIdealTimeStep(-1.0),
269 mLastWorkingTimeStep(-1),
270 mpTimeAdaptivityController(nullptr),
272 mOutputToParallelVtk(false),
274 mOutputDirectory(
""),
276 mPrintingTimestepMultiple(1),
277 mpHdf5Writer(nullptr)
333 EXCEPTION(
"SetTimes() has not been called");
335 if ((mIdealTimeStep <= 0.0) && (mpTimeAdaptivityController==
nullptr))
337 EXCEPTION(
"SetTimeStep() has not been called");
339 if (mInitialCondition ==
nullptr)
341 EXCEPTION(
"SetInitialCondition() has not been called");
345 bool print_output = (mOutputToVtk || mOutputToParallelVtk || mOutputToTxt);
348 InitialiseHdf5Writer();
349 WriteOneStep(mTstart, mInitialCondition);
350 mpHdf5Writer->AdvanceAlongUnlimitedDimension();
353 this->InitialiseForSolve(mInitialCondition);
355 if (mIdealTimeStep < 0)
357 mIdealTimeStep = mpTimeAdaptivityController->GetNextTimeStep(mTstart, mInitialCondition);
367 TimeStepper stepper(mTstart, mTend, mIdealTimeStep, mMatrixIsConstant);
369 Vec solution = mInitialCondition;
374 bool timestep_changed =
false;
380 if (mpTimeAdaptivityController)
383 mIdealTimeStep = mpTimeAdaptivityController->GetNextTimeStep(stepper.
GetTime(), solution);
392 timestep_changed = (fabs(new_dt/mLastWorkingTimeStep - 1.0) > 1e-5);
400 if (mMatrixIsConstant && fabs(new_dt/mIdealTimeStep - 1.0) > 1e-5)
410 mLastWorkingTimeStep = new_dt;
417 this->PrepareForSetupLinearSystem(solution);
423 if (solution != mInitialCondition)
432 bool compute_matrix = (!mMatrixIsConstant || !mMatrixIsAssembled || timestep_changed);
434 this->SetupLinearSystem(solution, compute_matrix);
436 this->FinaliseLinearSystem(solution);
440 this->mpLinearSystem->ResetKspSolver();
443 next_solution = this->mpLinearSystem->Solve(solution);
445 if (mMatrixIsConstant)
447 mMatrixIsAssembled =
true;
450 this->FollowingSolveLinearSystem(next_solution);
455 if (solution != mInitialCondition)
461 solution = next_solution;
466 WriteOneStep(stepper.
GetTime(), solution);
467 mpHdf5Writer->AdvanceAlongUnlimitedDimension();
472 if (mpHdf5Writer !=
nullptr)
475 mpHdf5Writer =
nullptr;
483 mFilenamePrefix, this->mpMesh,
false,
false);
485 if (mOutputToParallelVtk)
488 mFilenamePrefix, this->mpMesh,
true,
false);
493 mFilenamePrefix, this->mpMesh);