turek_flag_load_balance.cc File Reference
#include "generic.h"
#include "solid.h"
#include "navier_stokes.h"
#include "multi_physics.h"
#include "meshes/cylinder_with_flag_mesh.h"
#include "meshes/rectangular_quadmesh.h"

Classes

class  TurekProblem< FLUID_ELEMENT, SOLID_ELEMENT >
 Problem class. More...
 

Namespaces

 Global_Parameters
 Namespace for global parameters.
 

Functions

void Global_Parameters::gravity (const double &time, const Vector< double > &xi, Vector< double > &b)
 Non-dimensional gravity as body force. More...
 
double Global_Parameters::flux (const double &t)
 Flux: Pulsatile flow. More...
 
void Global_Parameters::set_parameters (const string &case_id)
 Set parameters for the various test cases. More...
 
int main (int argc, char *argv[])
 Driver. More...
 

Function Documentation

◆ main()

int main ( int argc  ,
char argv[] 
)

Driver.

1300 {
1301 
1302 #ifdef OOMPH_HAS_MPI
1303  MPI_Helpers::init(argc,argv);
1304 #endif
1305 
1306  // Switch off output modifier
1308 
1309  // Define processor-labeled output file for all on-screen stuff
1310  std::ofstream output_stream;
1311  char filename[100];
1312  sprintf(filename,"RESLT_TUREK_LOAD_BALANCE/OUTPUT.%i",
1313  MPI_Helpers::communicator_pt()->my_rank());
1314  output_stream.open(filename);
1315  oomph_info.stream_pt() = &output_stream;
1316  OomphLibWarning::set_stream_pt(&output_stream);
1317  OomphLibError::set_stream_pt(&output_stream);
1318 
1319  // Store command line arguments
1320  CommandLineArgs::setup(argc,argv);
1321 
1322  // Get case id as string
1323  string case_id="FSI1";
1324  if (CommandLineArgs::Argc==1)
1325  {
1326  oomph_info << "No command line arguments; running self-test FSI1"
1327  << std::endl;
1328  }
1329  else if (CommandLineArgs::Argc==2)
1330  {
1331  case_id=CommandLineArgs::Argv[1];
1332  }
1333  else
1334  {
1335  oomph_info << "Wrong number of command line arguments" << std::endl;
1336  oomph_info << "Enter none (for default) or one (namely the case id"
1337  << std::endl;
1338  oomph_info << "which should be one of: FSI1, FSI2, FSI3, CSM1"
1339  << std::endl;
1340  }
1341  std::cout << "Running case " << case_id << std::endl;
1342 
1343  // Setup parameters for case identified by command line
1344  // argument
1346 
1347  // Length and height of domain
1348  double length=25.0;
1349  double height=4.1;
1350 
1351  //Set up the problem
1354 
1355  // Prepare output
1356  DocInfo doc_info;
1357  ofstream trace_file;
1358  doc_info.set_directory("RESLT_TUREK_LOAD_BALANCE");
1359  sprintf(filename,"%s/trace_on_proc%i.dat",doc_info.directory().c_str(),
1360  problem.communicator_pt()->my_rank());
1361  trace_file.open(filename);
1362 
1363  // Default number of timesteps
1364  unsigned nstep=4000;
1365  if (Global_Parameters::Case_ID=="FSI1")
1366  {
1367  std::cout << "Reducing number of steps for FSI1 " << std::endl;
1368  nstep=400;
1369  }
1370 
1371  if (CommandLineArgs::Argc==1)
1372  {
1373  std::cout << "Reducing number of steps for validation " << std::endl;
1374  nstep=2;
1375  }
1376 
1377  //Timestep:
1378  double dt=Global_Parameters::Dt;
1379 
1380  // Initialise timestep
1381  problem.initialise_dt(dt);
1382 
1383  // Impulsive start
1384  problem.assign_initial_values_impulsive(dt);
1385 
1386  // Doc the initial condition
1387  problem.doc_solution(doc_info,trace_file);
1388  doc_info.number()++;
1389 
1390 #ifdef OOMPH_HAS_MPI
1391 
1392  // Distribute the problem
1393  bool report_stats=true;
1394 
1395  // Are there command-line arguments?
1396  if (CommandLineArgs::Argc==1)
1397  {
1398  // No arguments, so it's a validation run
1399  std::ifstream input_file;
1400 
1401  // All meshes are partitioned
1402  unsigned n_partition=problem.mesh_pt()->nelement();
1403  Vector<unsigned> in_element_partition(n_partition,0);
1404 
1405  // Get partition from file
1406  sprintf(filename,"turek_flag_partition.dat");
1407  input_file.open(filename);
1408  std::string input_string;
1409  for (unsigned e=0;e<n_partition;e++)
1410  {
1411  getline(input_file,input_string,'\n');
1412  in_element_partition[e]=atoi(input_string.c_str());
1413  }
1414 
1415  // Now distribute the (still uniformly refined) problem
1416  problem.distribute(in_element_partition,report_stats);
1417 
1418  // This is a validation run, so use the default partition in load_balance()
1419  problem.set_default_partition_in_load_balance();
1420  }
1421  else
1422  {
1423  // There were command-line arguments, so distribute without
1424  // reference to any partition vector
1425  problem.distribute(report_stats);
1426  }
1427 
1428 
1429 #endif
1430 
1431  // Don't re-set the initial conditions when adapting during first
1432  // timestep
1433  bool first = false;
1434 
1435  // Max number of adaptation for time-stepping
1436  unsigned max_adapt=1;
1437 
1438  // Start of timestepping loop
1439  for(unsigned i=0;i<nstep;i++)
1440  {
1441  // Solve the problem
1442  problem.unsteady_newton_solve(dt,max_adapt,first);
1443 
1444  // Output the solution
1445  problem.doc_solution(doc_info,trace_file);
1446 
1447  // Step number
1448  doc_info.number()++;
1449 
1450  // Load balance the problem
1451  DocInfo load_doc_info;
1452  problem.load_balance(load_doc_info,report_stats);
1453 
1454  } // end of timestepping loop
1455 
1456  trace_file.close();
1457 
1458 
1459 
1460  oomph_info << "Done\n";
1461 
1462 #ifdef OOMPH_HAS_MPI
1463  MPI_Helpers::finalize();
1464 #endif
1465 
1466 }//end of main
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Problem class.
Definition: interaction/turek_flag/turek_flag.cc:371
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
std::ostream *& stream_pt()
Access function for the stream pointer.
Definition: oomph_definitions.h:464
OutputModifier *& output_modifier_pt()
Access function for the output modifier pointer.
Definition: oomph_definitions.h:476
Class for refineable QPVDElement elements.
Definition: refineable_solid_elements.h:181
void setup(Time *time_pt)
Create all GeomObjects needed to define the cylinder and the flag.
Definition: turek_flag_non_fsi.cc:277
string Case_ID
Default case ID.
Definition: interaction/turek_flag/turek_flag.cc:55
void set_parameters(const string &case_id)
Set parameters for the various test cases.
Definition: interaction/turek_flag/turek_flag.cc:143
double Dt
Timestep.
Definition: interaction/pseudo_solid_collapsible_tube/pseudo_solid_collapsible_tube.cc:415
double height(const double &x)
Height of domain.
Definition: simple_spine_channel.cc:429
string filename
Definition: MergeRestartFiles.py:39
char ** Argv
Arguments themselves.
Definition: oomph_utilities.cc:410
int Argc
Number of arguments + 1.
Definition: oomph_utilities.cc:407
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286
OutputModifier default_output_modifier
Single global instatiation of the default output modifier.
Definition: oomph_definitions.cc:325
OomphInfo oomph_info
Definition: oomph_definitions.cc:319
Constructor for SteadyAxisymAdvectionDiffusion problem
Definition: steady_axisym_advection_diffusion.cc:213

References oomph::CommandLineArgs::Argc, oomph::CommandLineArgs::Argv, Global_Parameters::Case_ID, oomph::default_output_modifier, oomph::DocInfo::directory(), Global_Parameters::Dt, e(), MergeRestartFiles::filename, Global_Physical_Variables::height(), i, oomph::DocInfo::number(), oomph::oomph_info, oomph::OomphInfo::output_modifier_pt(), problem, oomph::DocInfo::set_directory(), Global_Parameters::set_parameters(), Flag_definition::setup(), oomph::OomphInfo::stream_pt(), and oomph::Global_string_for_annotation::string().