two_d_unsteady_heat_t_adapt.cc File Reference
#include "generic.h"
#include "unsteady_heat.h"
#include "meshes/rectangular_quadmesh.h"

Classes

class  UnsteadyHeatProblem< ELEMENT >
 UnsteadyHeat problem. More...
 

Namespaces

 ExactSolnForUnsteadyHeat
 Namespace for unforced exact solution for UnsteadyHeat equation.
 

Functions

void ExactSolnForUnsteadyHeat::get_exact_u (const double &time, const Vector< double > &x, Vector< double > &u)
 Exact solution as a Vector. More...
 
void ExactSolnForUnsteadyHeat::get_exact_u (const double &time, const Vector< double > &x, double &u)
 Exact solution as a scalar. More...
 
void ExactSolnForUnsteadyHeat::get_source (const double &time, const Vector< double > &x, double &source)
 Source function to make it an exact solution. More...
 
int main (int argc, char *argv[])
 

Variables

double ExactSolnForUnsteadyHeat::Gamma =10.0
 Factor controlling the rate of change. More...
 

Function Documentation

◆ main()

int main ( int argc  ,
char argv[] 
)

///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// Driver code for the adaptive solution of an unsteady heat equation with option for restart from disk: Only a single command line argument is allowed. If specified it is interpreted as the name of the restart file.

613 {
614 
615  // Store command line arguments
616  CommandLineArgs::setup(argc,argv);
617 
618  // Build problem
621 
622  // Setup labels for output
623  DocInfo doc_info;
624 
625  // Output directory
626  doc_info.set_directory("RESLT");
627 
628  // Output number
629  doc_info.number()=0;
630 
631  // Open a trace file
632  ofstream trace_file;
633  char filename[100];
634  sprintf(filename,"%s/trace.dat",doc_info.directory().c_str());
635  trace_file.open(filename);
636  trace_file << "VARIABLES=\"time\",\"dt\",\"u<SUB>FE</SUB>\","
637  << "\"u<SUB>exact</SUB>\",\"norm of error\",\"norm of solution\""
638  << std::endl;
639 
640  // Choose simulation interval
641  double t_max=0.18; // 2.0;
642 
643  // Set IC
644  problem.set_initial_condition();
645 
646 
647  // Initial timestep: Use the one used when setting up the initial
648  // condition
649  double dt=problem.time_pt()->dt();
650 
651  //Output initial condition
652  problem.doc_solution(doc_info,trace_file);
653 
654  //Increment counter for solutions
655  doc_info.number()++;
656 
657  // Target error for adaptive timestepping
658  double epsilon_t=1.0e-4;
659 
660  // Timestepping loop: Don't know how many steps we're going to take
661  // in advance
662  while (problem.time_pt()->time()<t_max)
663  {
664 
665  // Take an adaptive timestep -- the input dt is the suggested timestep.
666  // The adaptive timestepper will adjust dt until the required error
667  // tolerance is satisfied. The function returns a suggestion
668  // for the timestep that should be taken for the next step. This
669  // is either the actual timestep taken this time or a larger
670  // value if the solution was found to be "too accurate".
671  double dt_next=problem.adaptive_unsteady_newton_solve(dt,epsilon_t);
672 
673  // Use dt_next as suggestion for the next timestep
674  dt=dt_next;
675 
676  //Output solution
677  problem.doc_solution(doc_info,trace_file);
678 
679  //Increment counter for solutions
680  doc_info.number()++;
681 
682  } // end of timestepping loop
683 
684  // Close trace file
685  trace_file.close();
686 
687 
688 }; // end of main
UnsteadyHeat problem.
Definition: pretend_melt.cc:80
Definition: oomph_utilities.h:499
std::string directory() const
Output directory.
Definition: oomph_utilities.h:524
void set_directory(const std::string &directory)
Definition: oomph_utilities.cc:298
unsigned & number()
Number used (e.g.) for labeling output files.
Definition: oomph_utilities.h:554
void get_source(const double &time, const Vector< double > &x, double &source)
Source function to make it an exact solution.
Definition: heat_transfer_and_melting/two_d_unsteady_heat_melt/two_d_unsteady_heat.cc:79
void setup(Time *time_pt)
Create all GeomObjects needed to define the cylinder and the flag.
Definition: turek_flag_non_fsi.cc:277
string filename
Definition: MergeRestartFiles.py:39
Constructor for SteadyAxisymAdvectionDiffusion problem
Definition: steady_axisym_advection_diffusion.cc:213

References oomph::DocInfo::directory(), MergeRestartFiles::filename, ExactSolnForUnsteadyHeat::get_source(), oomph::DocInfo::number(), problem, oomph::DocInfo::set_directory(), and Flag_definition::setup().