multigrid/helmholtz_multigrid/unstructured_two_d_helmholtz.cc File Reference
#include <fenv.h>
#include "math.h"
#include <complex>
#include "generic.h"
#include "helmholtz.h"
#include "pml_helmholtz.h"
#include "meshes/quad_from_triangle_mesh.h"

Classes

class  GlobalParameters::TestPMLMapping
 
class  PMLHelmholtzMGProblem< ELEMENT >
 

Namespaces

 GlobalParameters
 Global parameters.
 
 Smoother_Factory_Function_Helper
 Returns a pointer to a smoother of the appropriate type.
 

Functions

void GlobalParameters::update_parameters ()
 Update parameters. More...
 
void GlobalParameters::get_exact_u (const Vector< double > &x, Vector< double > &u, const double &alpha=0.25 *MathematicalConstants::Pi)
 
void GlobalParameters::get_exact_u_bessel (const Vector< double > &x, Vector< double > &u)
 
void GlobalParameters::default_get_exact_u (const Vector< double > &x, Vector< double > &u)
 
HelmholtzSmootherSmoother_Factory_Function_Helper::set_pre_smoother ()
 
HelmholtzSmootherSmoother_Factory_Function_Helper::set_post_smoother ()
 
int main (int argc, char **argv)
 Solve 2D Helmholtz problem. More...
 

Variables

unsigned GlobalParameters::N_pml_element =1
 The number of elements in the PML layer. More...
 
unsigned GlobalParameters::Disable_pml_flag =0
 
unsigned GlobalParameters::N_boundary_segment =6
 The number of segments used to define the circular boundary. More...
 

Function Documentation

◆ main()

int main ( int argc  ,
char **  argv 
)

Solve 2D Helmholtz problem.

1116 {
1117  //------------------------
1118  // Command line arguments
1119  //------------------------
1120  // Store command line arguments
1121  CommandLineArgs::setup(argc,argv);
1122 
1123  // Choose the number of nodes in one direction of an element;
1124  // Values of nnode_1d:
1125  // 2: Bilinear interpolation
1126  // 3: Biquadratic interpolation
1127  // 4: Bicubic interpolation
1129  "--nnode_1d",&GlobalParameters::Nnode_1d);
1130 
1131  // Set the number of elements in the PML layer
1133  "--npml_element",&GlobalParameters::N_pml_element);
1134 
1135  // Set the thickness of the pml
1137  "--pml_thickness",&GlobalParameters::Pml_thickness);
1138 
1139  // Decide whether or not to display convergence information
1141  "--nboundary_segment",&GlobalParameters::N_boundary_segment);
1142 
1143  // Choose the minimum level of uniform refinement
1146 
1147  // Choose the additional levels of uniform refinement
1150 
1151  // Choose the maximum number of adaptive refinements
1153  "--n_adapt",&GlobalParameters::N_adaptations);
1154 
1155  // Choose how many additional levels of uniform refinement to use
1157  "--use_adapt",&GlobalParameters::Use_adaptation_flag);
1158 
1159  // Choose the value of k^2
1161  "--k_sq",&GlobalParameters::K_squared);
1162 
1163  // Choose the value of the shift in the CSLP
1165  "--alpha",&GlobalParameters::Alpha_shift);
1166 
1167  // Choose the value of the damping factor in the damped Jacobi solver
1170 
1171  // Choose the pre-smoother
1173  "--presmoother",&GlobalParameters::Pre_smoother_flag);
1174 
1175  // Choose the post-smoother
1177  "--postsmoother",&GlobalParameters::Post_smoother_flag);
1178 
1179  // Choose the linear solver
1181  "--linear_solver",&GlobalParameters::Linear_solver_flag);
1182 
1183  // Decide whether or not to suppress all or some of the MG solver output
1185  "--output_flag",&GlobalParameters::Output_management_flag);
1186 
1187  // Decide whether or not to display convergence information
1189  "--conv_flag",&GlobalParameters::Doc_convergence_flag);
1190 
1191  // Decide whether or not to display convergence information
1193  "--test_pml_mapping",&GlobalParameters::Enable_test_pml_mapping_flag);
1194 
1195  // Decide whether or not to display convergence information
1197  "--disable_pml",&GlobalParameters::Disable_pml_flag);
1198 
1199  // Parse command line
1201 
1202  // Document what has been specified on the command line
1204 
1205  // Update parameters
1207 
1208  //--------------------------------
1209  // Set the documentation directory
1210  //--------------------------------
1211  // Set output directory
1213 
1214  //-------------------
1215  // Set up the problem
1216  //-------------------
1217  // Initialise a null pointer to the class Problem
1218  Problem* problem_pt=0;
1219 
1220  // Set the problem pointer depending on the input (defaulted to nnode_1d=2)
1222  {
1223  // Set up the problem with refineable 2D four-node elements from the
1224  // QPMLHelmholtzElement family
1225  typedef RefineableQPMLHelmholtzElement<2,2> ELEMENT;
1226 
1227  // Set the problem pointer
1228  problem_pt=new PMLHelmholtzMGProblem<ELEMENT>;
1229  }
1230  else if (GlobalParameters::Nnode_1d==3)
1231  {
1232  // Set up the problem with refineable 2D nine-node elements from the
1233  // QPMLHelmholtzElement family
1234  typedef RefineableQPMLHelmholtzElement<2,3> ELEMENT;
1235 
1236  // Set the problem pointer
1237  problem_pt=new PMLHelmholtzMGProblem<ELEMENT>;
1238  }
1239  else if (GlobalParameters::Nnode_1d==4)
1240  {
1241  // Set up the problem with refineable 2D sixteen-node elements from the
1242  // QPMLHelmholtzElement family
1243  typedef RefineableQPMLHelmholtzElement<2,4> ELEMENT;
1244 
1245  // Set the problem pointer
1246  problem_pt=new PMLHelmholtzMGProblem<ELEMENT>;
1247  }
1248  else
1249  {
1250  // Throw an error otherwise
1251  throw OomphLibError("nnode_1d can only be 2,3 or 4.",
1254  }
1255 
1256  //------------------
1257  // Solve the problem
1258  //------------------
1259  // If the user wishes to use adaptive refinement then we use the Newton
1260  // solver with a given argument to indicate how many adaptations to use
1262  {
1263  // If the user wishes to silence everything
1265  {
1266  // Store the output stream pointer
1268 
1269  // Now set the oomph_info stream pointer to the null stream to
1270  // disable all possible output
1272  }
1273 
1274  // Keep refining until the minimum refinement level is reached
1275  for (unsigned i=0;i<GlobalParameters::Min_refinement_level;i++)
1276  {
1277  oomph_info << "\n===================="
1278  << "Initial Refinement"
1279  << "===================="
1280  << std::endl;
1281 
1282  // Add additional refinement
1283  problem_pt->refine_uniformly();
1284  }
1285 
1286  // If we silenced the adaptation, allow output again
1288  {
1289  // Now set the oomph_info stream pointer to the null stream to
1290  // disable all possible output
1292  }
1293 
1294  // Solve the problem
1295  problem_pt->newton_solve();
1296 
1297  // Keep refining until the minimum refinement level is reached
1298  for (unsigned i=0;i<GlobalParameters::N_adaptations;i++)
1299  {
1300  // If the user wishes to silence everything
1302  {
1303  // Store the output stream pointer
1305 
1306  // Now set the oomph_info stream pointer to the null stream to
1307  // disable all possible output
1309  }
1310 
1311  // Adapt the problem
1312  problem_pt->adapt();
1313 
1314  // If we silenced the adaptation, allow output again
1316  {
1317  // Now set the oomph_info stream pointer to the null stream to
1318  // disable all possible output
1320  }
1321 
1322  // Solve the problem
1323  problem_pt->newton_solve();
1324  }
1325  }
1326  // If the user instead wishes to use uniform refinement
1327  else
1328  {
1329  // If the user wishes to silence everything
1331  {
1332  // Store the output stream pointer
1334 
1335  // Now set the oomph_info stream pointer to the null stream to
1336  // disable all possible output
1338  }
1339 
1340  // Keep refining until the minimum refinement level is reached
1341  for (unsigned i=0;i<GlobalParameters::Min_refinement_level;i++)
1342  {
1343  oomph_info << "\n===================="
1344  << "Initial Refinement"
1345  << "===================="
1346  << std::endl;
1347 
1348  // Add additional refinement
1349  problem_pt->refine_uniformly();
1350  }
1351 
1352  // If we silenced the adaptation, allow output again
1354  {
1355  // Now set the oomph_info stream pointer to the null stream to
1356  // disable all possible output
1358  }
1359 
1360  // Solve the problem
1361  problem_pt->newton_solve();
1362 
1363  // Refine and solve until the additional refinements have been completed
1364  for (unsigned i=0;i<GlobalParameters::Add_refinement_level;i++)
1365  {
1366  // If the user wishes to silence everything
1368  {
1369  // Store the output stream pointer
1371 
1372  // Now set the oomph_info stream pointer to the null stream to
1373  // disable all possible output
1375  }
1376 
1377  oomph_info << "==================="
1378  << "Additional Refinement"
1379  << "=================="
1380  << std::endl;
1381 
1382  // Add additional refinement
1383  problem_pt->refine_uniformly();
1384 
1385  // If we silenced the adaptation, allow output again
1387  {
1388  // Now set the oomph_info stream pointer to the null stream to
1389  // disable all possible output
1391  }
1392 
1393  // Solve the problem
1394  problem_pt->newton_solve();
1395  }
1396  } // if (GlobalParameters::Use_adaptation_flag)
1397 
1398  // Delete the problem pointer
1399  delete problem_pt;
1400 
1401  // Make it a null pointer
1402  problem_pt=0;
1403 } // End of main
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Definition: multigrid/helmholtz_multigrid/unstructured_two_d_helmholtz.cc:321
void set_directory(const std::string &directory)
Definition: oomph_utilities.cc:298
std::ostream *& stream_pt()
Access function for the stream pointer.
Definition: oomph_definitions.h:464
Definition: oomph_definitions.h:222
Definition: problem.h:151
void refine_uniformly(const Vector< unsigned > &nrefine_for_mesh)
Definition: problem.h:2575
void newton_solve()
Use Newton method to solve the problem.
Definition: problem.cc:8783
void adapt(unsigned &n_refined, unsigned &n_unrefined)
Definition: problem.cc:13666
Definition: refineable_pml_helmholtz_elements.h:199
void setup(Time *time_pt)
Create all GeomObjects needed to define the cylinder and the flag.
Definition: turek_flag_non_fsi.cc:277
unsigned Enable_test_pml_mapping_flag
Definition: structured_cubic_point_source.cc:215
unsigned Use_adaptation_flag
Definition: structured_cubic_point_source.cc:70
unsigned Min_refinement_level
The minimum level of uniform refinement.
Definition: structured_cubic_point_source.cc:59
double Alpha_shift
Definition: structured_cubic_point_source.cc:129
unsigned Output_management_flag
Definition: structured_cubic_point_source.cc:92
unsigned N_pml_element
The number of elements in the PML layer.
Definition: multigrid/helmholtz_multigrid/unstructured_two_d_helmholtz.cc:68
unsigned Doc_convergence_flag
Definition: structured_cubic_point_source.cc:98
unsigned Disable_pml_flag
Definition: multigrid/helmholtz_multigrid/unstructured_two_d_helmholtz.cc:78
unsigned Pre_smoother_flag
Definition: structured_cubic_point_source.cc:75
unsigned Add_refinement_level
The additional levels of uniform refinement.
Definition: structured_cubic_point_source.cc:62
unsigned Nnode_1d
The number of nodes in one direction (default=2)
Definition: structured_cubic_point_source.cc:56
double K_squared
Square of the wavenumber.
Definition: helmholtz_point_source.cc:60
unsigned Post_smoother_flag
Definition: structured_cubic_point_source.cc:80
unsigned Linear_solver_flag
Definition: structured_cubic_point_source.cc:85
void update_parameters()
Update parameters.
Definition: extrude_with_macro_element_representation.cc:274
unsigned N_adaptations
The number of adaptations allowed by the Newton solver.
Definition: structured_cubic_point_source.cc:65
DocInfo Doc_info
Helper for documenting.
Definition: extrude_triangle_generated_mesh.cc:57
double Pml_thickness
Length of cube in each direction.
Definition: structured_cubic_point_source.cc:122
unsigned N_boundary_segment
The number of segments used to define the circular boundary.
Definition: multigrid/helmholtz_multigrid/unstructured_two_d_helmholtz.cc:196
std::ostream * Stream_pt
Definition: structured_cubic_point_source.cc:104
double Omega
The value of the damping factor for the damped Jacobi smoother.
Definition: structured_cubic_point_source.cc:244
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
Nullstream oomph_nullstream
Single (global) instantiation of the Nullstream.
Definition: oomph_definitions.cc:313
OomphInfo oomph_info
Definition: oomph_definitions.cc:319
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86

References oomph::Problem::adapt(), GlobalParameters::Add_refinement_level, GlobalParameters::Alpha_shift, GlobalParameters::Disable_pml_flag, GlobalParameters::Doc_convergence_flag, GlobalParameters::Doc_info, oomph::CommandLineArgs::doc_specified_flags(), GlobalParameters::Enable_test_pml_mapping_flag, i, GlobalParameters::K_squared, GlobalParameters::Linear_solver_flag, GlobalParameters::Min_refinement_level, GlobalParameters::N_adaptations, GlobalParameters::N_boundary_segment, GlobalParameters::N_pml_element, oomph::Problem::newton_solve(), GlobalParameters::Nnode_1d, Smoother_Factory_Function_Helper::Omega, OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, oomph::oomph_info, oomph::oomph_nullstream, GlobalParameters::Output_management_flag, oomph::CommandLineArgs::parse_and_assign(), GlobalParameters::Pml_thickness, GlobalParameters::Post_smoother_flag, GlobalParameters::Pre_smoother_flag, oomph::Problem::refine_uniformly(), oomph::DocInfo::set_directory(), oomph::CommandLineArgs::setup(), oomph::CommandLineArgs::specify_command_line_flag(), GlobalParameters::Stream_pt, oomph::OomphInfo::stream_pt(), GlobalParameters::update_parameters(), and GlobalParameters::Use_adaptation_flag.