adaptive_hopf_with_separate_meshes.cc File Reference
#include <iostream>
#include <fstream>
#include <cstdio>
#include "generic.h"
#include "navier_stokes.h"
#include "linearised_navier_stokes.h"
#include "assert.h"

Classes

class  GeneralEllipse
 My own Ellipse class. More...
 
class  RectangleWithHoleDomain
 Rectangular domain with circular whole. More...
 
class  RectangleWithHoleMesh< ELEMENT >
 Domain-based mesh for rectangular mesh with circular hole. More...
 
class  RefineableRectangleWithHoleMesh< ELEMENT >
 
class  MyNavierStokesElement
 
class  FlowAroundCylinderProblem< ELEMENT >
 Flow around a cylinder in rectangular domain. More...
 

Namespaces

 Global_Parameters
 Namespace for global parameters.
 

Functions

std::complex< doubleGlobal_Parameters::Eigenfunction_normalisation (1.0, 0.0)
 
int main ()
 Driver. More...
 

Function Documentation

◆ main()

int main ( )

Driver.

//////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////

1809 {
1810  // Length and height of domain
1811  double length = 14.0;
1812  double height = 1.0/Global_Parameters::B;
1813 
1814  //Create a new ellipse object with equal semi-minor and semi-major axes
1815  //to be the central cylinder
1816  GeneralEllipse* cylinder_pt =
1817  new GeneralEllipse(4.5,0.0,0.5,0.5);
1818 
1819  // Create Problem
1821  <MyNavierStokesElement/*RefineableQCrouzeixRaviartElement<2>*/,
1823  problem(cylinder_pt,length,height);
1824 
1825  //Refine the problem uniformly a couple of times
1826  problem.refine_uniformly(); problem.refine_uniformly();
1827 
1828  // Solve adaptively with up to two rounds of refinement
1829  problem.newton_solve(2);
1830 
1831  //Now increase the Reynolds number to 90 in steps of 5
1832  //without any further adaptation
1833  for(unsigned i=0;i<3;i++)
1834  {
1835  Global_Parameters::Re += 5.0;
1836  problem.newton_solve();
1837  }
1838 
1839  //Assign memory for the eigenvalues and eigenvectors
1840  Vector<DoubleVector> eigenvectors;
1841  double frequency = 0.0;
1842 
1843  //If we are reading in from the disk
1845  {
1846  //Read in the eigenvalue from the data file
1847  std::ifstream input("eigen.dat");
1848  input >> frequency;
1849 
1850  //Read in the eigenvector from the data file
1851  const unsigned n_dof = problem.ndof();
1852  eigenvectors.resize(2);
1853  LinearAlgebraDistribution dist(problem.communicator_pt(),n_dof,false);
1854  //Rebuild the vector
1855  eigenvectors[0].build(&dist,0.0);
1856  eigenvectors[1].build(&dist,0.0);
1857 
1858  for(unsigned n=0;n<n_dof;n++)
1859  {
1860  input >> eigenvectors[0][n];
1861  input >> eigenvectors[1][n];
1862  }
1863  input.close();
1864  }
1865  //Otherwise solve the eigenproblem
1866  else
1867  {
1868  Vector<std::complex<double> > eigenvalues;
1869  //Now solve the eigenproblem
1870  problem.solve_eigenproblem(6,eigenvalues,eigenvectors);
1871  frequency = eigenvalues[0].imag();
1872  }
1873 
1874 
1875  //Create the perturbation problem and solve the eigenproblem on it
1876  //FlowAroundCylinderLinPertProblem
1877  // <RefineableQCrouzeixRaviartElement<2>,RefineableLinearisedQCrouzeixRaviartMu//ltiDomainElement
1878  // > pert_problem(problem.mesh_pt());
1879 
1880  problem.add_eigenproblem();
1881 
1882  //Transfer eigenfunction across to perturbation mesh
1883  problem.transfer_eigenfunction_as_initial_condition(eigenvectors[0],
1884  eigenvectors[1]);
1885 
1886  problem.set_eigenvalue(0.0,frequency);
1887 
1888  problem.newton_solve(2); //Slow!
1889 
1890  problem.doc_solution();
1891 
1892 
1893  exit(1);
1894  //Try to find the Hopf exactly by using the initial
1895  //guesses for the eigenvalue and eigenvector from
1896  //the data file
1897  problem.activate_hopf_tracking(&Global_Parameters::Re,
1898  frequency,
1899  eigenvectors[0],
1900  eigenvectors[1]);
1901  //Solve the problem
1902  problem.newton_solve();
1903  //Report the value of the bifurcation
1904  std::cout << "Hopf bifurcation found at " << Global_Parameters::Re << " " <<
1905  problem.dof(problem.ndof()-1) << std::endl;
1906 
1907  //Solve it again with three rounds of adaptation
1908  problem.newton_solve(2);
1909 
1910  std::cout << "Hopf bifurcation found at " << Global_Parameters::Re << " " <<
1911  problem.dof(problem.ndof()-1) << std::endl;
1912  problem.mesh_pt()->output("bif_soln.dat");
1913 
1914  //Output the value of the critical Reynolds number into a data file
1915  std::ofstream trace("trace.dat");
1916  trace << Global_Parameters::Re << " " <<
1917  problem.dof(problem.ndof()-1) << "\n";
1918  trace.close();
1919 }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
Flow around a cylinder in rectangular domain.
Definition: adaptive_hopf.cc:1042
My own Ellipse class.
Definition: adaptive_hopf.cc:80
Definition: adaptive_hopf_with_separate_meshes.cc:1057
Definition: multi_domain_linearised_navier_stokes_elements.h:410
Definition: linear_algebra_distribution.h:64
Definition: oomph-lib/src/generic/Vector.h:58
bool Read_in_eigenfunction_from_disk
Definition: adaptive_hopf.cc:65
double Re
reynolds number
Definition: adaptive_hopf.cc:54
double B
Definition: adaptive_hopf.cc:57
double height(const double &x)
Height of domain.
Definition: simple_spine_channel.cc:429
Constructor for SteadyAxisymAdvectionDiffusion problem
Definition: steady_axisym_advection_diffusion.cc:213

References Global_Parameters::B, Global_Physical_Variables::height(), i, n, problem, Global_Parameters::Re, and Global_Parameters::Read_in_eigenfunction_from_disk.