mpi/multi_domain/fsi_collapsible_channel/fsi_collapsible_channel_adapt.cc File Reference
#include <iostream>
#include "generic.h"
#include "navier_stokes.h"
#include "beam.h"
#include "meshes/one_d_lagrangian_mesh.h"
#include "meshes/collapsible_channel_mesh.h"
#include <fenv.h>

Classes

class  UndeformedWall
 
class  FSICollapsibleChannelProblem< ELEMENT >
 Problem class. More...
 

Namespaces

 BL_Squash
 
 Global_Physical_Variables
 Global variables.
 

Functions

double BL_Squash::squash_fct (const double &s)
 
void Global_Physical_Variables::prescribed_traction (const double &t, const Vector< double > &x, const Vector< double > &n, Vector< double > &traction)
 Traction applied on the fluid at the left (inflow) boundary. More...
 
void Global_Physical_Variables::load (const Vector< double > &xi, const Vector< double > &x, const Vector< double > &N, Vector< double > &load)
 Load function: Apply a constant external pressure to the beam. More...
 
int main (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int argc  ,
char argv[] 
)

Driver code for a collapsible channel problem with FSI. Presence of command line arguments indicates validation run with coarse resolution and small number of timesteps.

965 {
966 
967 // feenableexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW);
968 
969 #ifdef OOMPH_HAS_MPI
970  MPI_Helpers::init(argc,argv);
971 #endif
972 
973  // Store command line arguments
974  CommandLineArgs::setup(argc,argv);
975 
976  // Reduction in resolution for validation run
977  unsigned coarsening_factor=4;
978  if (CommandLineArgs::Argc>1)
979  {
980  coarsening_factor=4;
981  }
982 
983 
984  // Switch off output modifier
986 
987  // Define processor-labeled output file for all on-screen stuff
988  std::ofstream output_stream;
989  char filename[100];
990  sprintf(filename,"OUTPUT.%i",MPI_Helpers::communicator_pt()->my_rank());
991  output_stream.open(filename);
992  oomph_info.stream_pt() = &output_stream;
993  OomphLibWarning::set_stream_pt(&output_stream);
994  OomphLibError::set_stream_pt(&output_stream);
995 
996  // Number of elements in the domain
997  unsigned nup=20/coarsening_factor;
998  unsigned ncollapsible=40/coarsening_factor;
999  unsigned ndown=40/coarsening_factor;
1000  unsigned ny=16/coarsening_factor;
1001 
1002  // Length of the domain
1003  double lup=5.0;
1004  double lcollapsible=10.0;
1005  double ldown=10.0;
1006  double ly=1.0;
1007 
1008  // Set external pressure (on the wall stiffness scale).
1010 
1011  // Pressure on the left boundary: This is consistent with steady
1012  // Poiseuille flow
1013  Global_Physical_Variables::P_up=12.0*(lup+lcollapsible+ldown);
1014 
1015 
1016 #ifdef MACRO_ELEMENT_NODE_UPDATE
1017 
1018 #ifdef TAYLOR_HOOD
1019 
1020  // Build the problem with QTaylorHoodElements
1023  problem(nup, ncollapsible, ndown, ny,
1024  lup, lcollapsible, ldown, ly);
1025 
1026 #else
1027 
1028  // Build the problem with QCrouzeixRaviartElements
1031  problem(nup, ncollapsible, ndown, ny,
1032  lup, lcollapsible, ldown, ly);
1033 
1034 #endif
1035 
1036 #else
1037 
1038 #ifdef TAYLOR_HOOD
1039 
1040  // Build the problem with QTaylorHoodElements
1043  problem(nup, ncollapsible, ndown, ny,
1044  lup, lcollapsible, ldown, ly);
1045 
1046 #else
1047 
1048  // Build the problem with QCrouzeixRaviartElements
1051  problem(nup, ncollapsible, ndown, ny,
1052  lup, lcollapsible, ldown, ly);
1053 
1054 #endif
1055 
1056 #endif
1057 
1058 
1059  // Timestep. Note: Preliminary runs indicate that the period of
1060  // the oscillation is about 1 so this gives us 40 steps per period.
1061  double dt=1.0/40.0;
1062 
1063  // Initial time for the simulation
1064  double t_min=0.0;
1065 
1066  // Maximum time for simulation
1067  double t_max=3.5;
1068 
1069  // Initialise timestep
1070  problem.time_pt()->time()=t_min;
1071  problem.initialise_dt(dt);
1072 
1073  // Apply initial condition
1074  problem.set_initial_condition();
1075 
1076  //Set output directory
1077  DocInfo doc_info;
1078 #ifdef MACRO_ELEMENT_NODE_UPDATE
1079  doc_info.set_directory("RESLT");
1080 #else
1081  doc_info.set_directory("RESLT_ALG");
1082 #endif
1083 
1084  // Open a trace file
1085  ofstream trace_file;
1086  sprintf(filename,"%s/trace.dat",doc_info.directory().c_str());
1087  trace_file.open(filename);
1088 
1089  // Output the initial condition
1090  problem.doc_solution(doc_info, trace_file);
1091 
1092  // Increment step number
1093  doc_info.number()++;
1094 
1095  // Find number of timesteps (reduced for validation)
1096  unsigned nstep = unsigned((t_max-t_min)/dt);
1097 // unsigned nstep=10;
1098  if (CommandLineArgs::Argc>1)
1099  {
1100  nstep=3;
1101  }
1102 
1103 
1104  // Set targets for spatial adaptivity
1105  problem.bulk_mesh_pt()->max_permitted_error()=1.0e-3;
1106  problem.bulk_mesh_pt()->min_permitted_error()=1.0e-5;
1107 
1108 
1109 #ifdef OOMPH_HAS_MPI
1110  // Distribute the problem
1111  std::ifstream input_file;
1112 
1114  unsigned n_partition=problem.mesh_pt()->nelement();
1115 
1116  // Get partition from file
1117  Vector<unsigned> element_partition(n_partition,0);
1118  sprintf(filename,"fsi_collapsible_channel_partition.dat");
1119  input_file.open(filename);
1120  std::string input_string;
1121  for (unsigned e=0;e<n_partition;e++)
1122  {
1123  getline(input_file,input_string,'\n');
1124  element_partition[e]=atoi(input_string.c_str());
1125  }
1126 
1127  bool report_stats=false;
1128  DocInfo mesh_doc_info;
1129  mesh_doc_info.disable_doc();
1130  problem.distribute(element_partition,mesh_doc_info,report_stats);
1131 
1132  // Check halo schemes (on submeshes)
1133  problem.check_halo_schemes();
1134 #endif
1135 
1136  // When performing the first timestep, we can adapt the mesh as many times
1137  // as we want because the initial condition can be re-set
1138  unsigned max_adapt=3; // 1
1139  bool first=true;
1140 
1141  // Timestepping loop
1142  for (unsigned istep=0;istep<nstep;istep++)
1143  {
1144  // Solve the problem
1145  problem.unsteady_newton_solve(dt,max_adapt,first);
1146 
1147  // Outpt the solution
1148  problem.doc_solution(doc_info, trace_file);
1149 
1150  // Step number
1151  doc_info.number()++;
1152 
1153  // We've done the first step
1154  first=false;
1155  max_adapt=1;
1156  }
1157 
1158  // Close trace file.
1159  trace_file.close();
1160 
1161 #ifdef OOMPH_HAS_MPI
1162  MPI_Helpers::finalize();
1163 #endif
1164 
1165 }//end of main
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Problem class.
Definition: fsi_chan_problem.h:315
Definition: algebraic_elements.h:540
Definition: oomph_utilities.h:499
void disable_doc()
Disable documentation.
Definition: oomph_utilities.h:542
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
Definition: macro_element_node_update_element.h:265
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
void setup(Time *time_pt)
Create all GeomObjects needed to define the cylinder and the flag.
Definition: turek_flag_non_fsi.cc:277
double P_ext
External pressure.
Definition: fibre.cc:64
double P_up
Default pressure on the left boundary.
Definition: fsi_collapsible_channel.cc:183
string filename
Definition: MergeRestartFiles.py:39
const double ly
Definition: ConstraintElementsUnitTest.cpp:34
const unsigned ny
Definition: ConstraintElementsUnitTest.cpp:31
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::default_output_modifier, oomph::DocInfo::directory(), oomph::DocInfo::disable_doc(), e(), MergeRestartFiles::filename, Mesh_Parameters::ly, oomph::DocInfo::number(), Mesh_Parameters::ny, oomph::oomph_info, oomph::OomphInfo::output_modifier_pt(), Global_Physical_Variables::P_ext, Global_Physical_Variables::P_up, problem, oomph::DocInfo::set_directory(), Flag_definition::setup(), oomph::OomphInfo::stream_pt(), and oomph::Global_string_for_annotation::string().