sphere_scattering.cc File Reference
#include <complex>
#include <cmath>
#include "generic.h"
#include "fourier_decomposed_helmholtz.h"
#include "meshes/simple_rectangular_quadmesh.h"
#include "oomph_crbond_bessel.h"

Classes

class  AnnularQuadMesh< ELEMENT >
 
class  FourierDecomposedHelmholtzProblem< ELEMENT >
 Problem class. More...
 

Namespaces

 PlanarWave
 
 ProblemParameters
 Namespace for exact solution and problem parameters.
 

Functions

std::complex< doublePlanarWave::I (0.0, 1.0)
 Imaginary unit. More...
 
void PlanarWave::get_exact_u (const Vector< double > &x, Vector< double > &u)
 Exact solution as a Vector of size 2, containing real and imag parts. More...
 
void PlanarWave::plot ()
 Plot. More...
 
std::complex< doubleProblemParameters::I (0.0, 1.0)
 Imaginary unit. More...
 
void ProblemParameters::get_exact_u (const Vector< double > &x, Vector< double > &u)
 Exact solution as a Vector of size 2, containing real and imag parts. More...
 
void ProblemParameters::exact_minus_dudr (const Vector< double > &x, std::complex< double > &flux)
 
int main (int argc, char **argv)
 Driver code for Fourier decomposed Helmholtz problem. More...
 

Variables

unsigned PlanarWave::N_terms =100
 Number of terms in series. More...
 
double PlanarWave::K =3.0*MathematicalConstants::Pi
 Wave number. More...
 
double ProblemParameters::K_squared =10.0
 Square of the wavenumber. More...
 
int ProblemParameters::N_fourier =3
 Fourier wave number. More...
 
unsigned ProblemParameters::Nterms_for_DtN =6
 Number of terms in computation of DtN boundary condition. More...
 
unsigned ProblemParameters::N_terms =6
 Number of terms in the exact solution. More...
 
Vector< doubleProblemParameters::Coeff (N_terms, 1.0)
 Coefficients in the exact solution. More...
 
unsigned ProblemParameters::El_multiplier =1
 Multiplier for number of elements. More...
 

Function Documentation

◆ main()

int main ( int argc  ,
char **  argv 
)

Driver code for Fourier decomposed Helmholtz problem.

733 {
734 
735  // Store command line arguments
736  CommandLineArgs::setup(argc,argv);
737 
738  // Define possible command line arguments and parse the ones that
739  // were actually specified
740 
741  // Multiplier for number of elements
744 
745  // Parse command line
747 
748  // Doc what has actually been specified on the command line
750 
751 
752  // Check if the claimed representation of a planar wave in
753  // the tutorial is correct -- of course it is!
754  //PlanarWave::plot();
755 
756  // Test Bessel/Hankel functions
757  //-----------------------------
758  {
759  // Number of Bessel functions to be computed
760  unsigned n=3;
761 
762  // Offset of Bessel function order (less than 1!)
763  double bessel_offset=0.5;
764 
765  ofstream bessely_file("besselY.dat");
766  ofstream bessely_deriv_file("dbesselY.dat");
767 
768  ofstream besselj_file("besselJ.dat");
769  ofstream besselj_deriv_file("dbesselJ.dat");
770 
771  // Evaluate Bessel/Hankel functions
772  Vector<double> jv(n+1);
773  Vector<double> yv(n+1);
774  Vector<double> djv(n+1);
775  Vector<double> dyv(n+1);
776  double x_min=0.5;
777  double x_max=5.0;
778  unsigned nplot=100;
779  for (unsigned i=0;i<nplot;i++)
780  {
781  double x=x_min+(x_max-x_min)*double(i)/double(nplot-1);
782  double order_max_in=double(n)+bessel_offset;
783  double order_max_out=0;
784 
785  // This function returns vectors containing
786  // J_k(x), Y_k(x) and their derivatives
787  // up to k=order_max, with k increasing in
788  // integer increments starting with smallest
789  // positive value. So, e.g. for order_max=3.5
790  // jv[0] contains J_{1/2}(x),
791  // jv[1] contains J_{3/2}(x),
792  // jv[2] contains J_{5/2}(x),
793  // jv[3] contains J_{7/2}(x).
794  CRBond_Bessel::bessjyv(order_max_in,x,
795  order_max_out,
796  &jv[0],&yv[0],
797  &djv[0],&dyv[0]);
798  bessely_file << x << " ";
799  for (unsigned j=0;j<=n;j++)
800  {
801  bessely_file << yv[j] << " ";
802  }
803  bessely_file << std::endl;
804 
805  besselj_file << x << " ";
806  for (unsigned j=0;j<=n;j++)
807  {
808  besselj_file << jv[j] << " ";
809  }
810  besselj_file << std::endl;
811 
812  bessely_deriv_file << x << " ";
813  for (unsigned j=0;j<=n;j++)
814  {
815  bessely_deriv_file << dyv[j] << " ";
816  }
817  bessely_deriv_file << std::endl;
818 
819  besselj_deriv_file << x << " ";
820  for (unsigned j=0;j<=n;j++)
821  {
822  besselj_deriv_file << djv[j] << " ";
823  }
824  besselj_deriv_file << std::endl;
825 
826  }
827  bessely_file.close();
828  besselj_file.close();
829  bessely_deriv_file.close();
830  besselj_deriv_file.close();
831  }
832 
833 
834  // Test Legendre Polynomials
835  //--------------------------
836  {
837  // Fourier wavenumber
838  unsigned n=3;
839 
840  ofstream some_file("legendre3.dat");
841  unsigned nplot=100;
842  for (unsigned i=0;i<nplot;i++)
843  {
844  double x=double(i)/double(nplot-1)*2.0*MathematicalConstants::Pi;
845 
846  some_file << x << " ";
847  for (unsigned j=n;j<=5;j++)
848  {
849  some_file << Legendre_functions_helper::plgndr2(j,n,cos(x)) << " ";
850  }
851  some_file << std::endl;
852  }
853  some_file.close();
854  }
855 
856 
857  {
858  ofstream some_file("legendre.dat");
859  unsigned nplot=100;
860  for (unsigned i=0;i<nplot;i++)
861  {
862  double x=double(i)/double(nplot-1);
863 
864  some_file << x << " ";
865  for (unsigned j=0;j<=3;j++)
866  {
867  some_file << Legendre_functions_helper::plgndr2(j,0,x) << " ";
868  }
869  some_file << std::endl;
870  }
871  some_file.close();
872  }
873 
874 
875 
876  // Create the problem with 2D nine-node elements from the
877  // QFourierDecomposedHelmholtzElement family.
879  problem;
880 
881  // Create label for output
882  DocInfo doc_info;
883 
884  // Set output directory
885  doc_info.set_directory("RESLT");
886 
887  // Solve for a few Fourier wavenumbers
890  {
891  // Step number
893 
894  // Solve the problem
895  problem.newton_solve();
896 
897  //Output the solution
898  problem.doc_solution(doc_info);
899  }
900 
901 } //end of main
AnnoyingScalar cos(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:136
int i
Definition: BiCGSTAB_step_by_step.cpp:9
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
Problem class.
Definition: sphere_scattering.cc:380
Definition: oomph_utilities.h:499
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
double Pi
Definition: two_d_biharmonic.cc:235
int bessjyv(double v, double x, double &vm, double *jv, double *yv, double *djv, double *dyv)
Definition: crbond_bessel.cc:1050
void setup(Time *time_pt)
Create all GeomObjects needed to define the cylinder and the flag.
Definition: turek_flag_non_fsi.cc:277
unsigned El_multiplier
Multiplier for number of elements.
Definition: sphere_scattering.cc:363
int N_fourier
Fourier wave number.
Definition: sphere_scattering.cc:228
void specify_command_line_flag(const std::string &command_line_flag, const std::string &doc)
Specify possible argument-free command line flag.
Definition: oomph_utilities.cc:451
void parse_and_assign(int argc, char *argv[], const bool &throw_on_unrecognised_args)
Definition: oomph_utilities.cc:760
void doc_specified_flags()
Document specified command line flags.
Definition: oomph_utilities.cc:610
double plgndr2(const unsigned &l, const unsigned &m, const double &x)
Legendre polynomials depending on two parameters.
Definition: fourier_decomposed_helmholtz_elements.cc:97
list x
Definition: plotDoE.py:28
Constructor for SteadyAxisymAdvectionDiffusion problem
Definition: steady_axisym_advection_diffusion.cc:213
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2

References CRBond_Bessel::bessjyv(), cos(), oomph::CommandLineArgs::doc_specified_flags(), ProblemParameters::El_multiplier, i, j, n, ProblemParameters::N_fourier, oomph::DocInfo::number(), oomph::CommandLineArgs::parse_and_assign(), oomph::MathematicalConstants::Pi, oomph::Legendre_functions_helper::plgndr2(), problem, oomph::DocInfo::set_directory(), oomph::CommandLineArgs::setup(), oomph::CommandLineArgs::specify_command_line_flag(), and plotDoE::x.