CArl
Code Arlequin / C++ implementation
CArl_FETI_setup_finish.cpp File Reference

Program responsible to finish the FETI setup and launch the iterations. More...

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Program responsible to finish the FETI setup and launch the iterations.

This program's input file description can be found at the documentation of the function carl::get_input_params(GetPot& field_parser, feti_setup_finish_params& input_params) .

It will use the following files ...

  • ... from the input_params.coupling_folder_path folder:
    • coupling matrices $C_1$, $C_2$ and $C_{\mbox{Med}}$ (the latter used for the preconditioner). Files:
      coupling_matrix_macro.petscmat
      coupling_matrix_micro.petscmat
      coupling_matrix_mediator.petscmat
      
  • ... from the input_params.scratch_folder_path folder:
    • solutions $u_0,1$ and $u_{0,2}$, from the system $K_l * u_{0,l} = F_l$. Files:
      ext_solver_u0_A_sys_sol_vec.petscvec
      ext_solver_u0_B_sys_sol_vec.petscvec
      
    • [RB] solutions $x_1(kkk)$ and $x_2(kkk)$, from the system $K_l * x_l(kkk) = C_l^t*\phi_0$. Files:
      ext_solver_A_sys_sol_vec.petscvec
      ext_solver_B_sys_sol_vec.petscvec
      
    • [RB] matrix $\mbox{inv}(R_I^t * R_I) = \mbox{inv}(R_2^t*C_2^t*C_2*R_2)$, used for the rigid body modes projections. Files:
      rb_inv_RITRI.petscmat
      
    • [RB] rigid body mode vectors multiplied by $C_2$. Files:
      rb_coupl_vector_[iii]_n_[nb. of vectors].petscvec
      
  • ... from the micro system folder (common vector path given by input_params.RB_vectors_base):
    • [RB] rigid body mode vectors. Files:
      [input_params.RB_vectors_base]_rb_vector_[iii]_n_[nb. of vectors].petscvec
      

The items marked with a [RB] are only needed if the rigid body modes projectors are used. In the last two cases, [nb. of vectors] is the number of rigid body mode vectors (given by input_params.nb_of_rb_vectors) and [iii] is an integer going from 0 to input_params.nb_of_rb_vectors - 1 (following C++ notation).

This program outputs a series of files, all inside the input_params.scratch_folder_path folder:

  • initial iteration vectors, $r(0)$, $z(0)$, $p(0)$. Files:
    FETI_iter__r__0.petscvec
    FETI_iter__p__0.petscvec
    
  • (overwrite) vectors used as the RHS for the external solvers. Files:
    ext_solver_A_rhs.petscvec
    ext_solver_B_rhs.petscvec
    
  • (create) scalar values (iteration, residual, RB mode corrections). Files:
    FETI_iter_scalar_data.dat

Definition in file CArl_FETI_setup_finish.cpp.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 61 of file CArl_FETI_setup_finish.cpp.

61  {
62 
63  // --- Initialize libMesh
64  libMesh::LibMeshInit init(argc, argv);
65 
66  // Do performance log?
67  libMesh::PerfLog perf_log("Main program");
68 
69  // libMesh's C++ / MPI communicator wrapper
70  libMesh::Parallel::Communicator& WorldComm = init.comm();
71 
72  // Number of processors and processor rank.
73  int rank = WorldComm.rank();
74  int nodes = WorldComm.size();
75 
76  // --- Set up inputs
77 
78  // Command line parser
79  GetPot command_line(argc, argv);
80 
81  // File parser
82  GetPot field_parser;
83 
84  // If there is an input file, parse it to get the parameters. Else, parse the command line
85  std::string input_filename;
86  if (command_line.search(2, "--inputfile", "-i")) {
87  input_filename = command_line.next(input_filename);
88  field_parser.parse_input_file(input_filename, "#", "\n", " \t\n");
89  } else {
90  field_parser = command_line;
91  }
92 
93  carl::feti_setup_finish_params input_params;
94  get_input_params(field_parser, input_params);
95 
96  // Object containing the FETI operations
97  carl::FETI_Operations feti_op(WorldComm,input_params.scratch_folder_path,input_params.coupling_folder_path);
98 
99  // --- Define if the rb modes will be used or not
100  feti_op.using_rb_modes(input_params.bUseRigidBodyModes);
101 
102  // --- Read the files!
103 
104  // Read up the coupling matricesconst std::string& filename)
105  feti_op.set_coupling_matrix_R_micro();
106  feti_op.set_coupling_matrix_R_BIG();
107 
108  // Read the decoupled solutions, K_i * u_0,i = F_i
109  feti_op.read_decoupled_solutions();
110 
111  // Read operations needed if we are using the rigid body modes
112  if(input_params.bUseRigidBodyModes)
113  {
114  // Read the solutions of K_i * x_i(0) = C_i^t * phi(0)
115  feti_op.read_ext_solver_output();
116 
117  // Read the RB-related vectors and matrices
118  feti_op.read_null_space_vecs(input_params.RB_vectors_base,input_params.nb_of_rb_vectors);
119  feti_op.read_null_space_inv_RITRI_mat();
120  }
121 
122  // --- Set up any matrices or vectors needed before calculating the outputs
123  // Set up the preconditioner
124  feti_op.set_preconditioner(input_params.CG_precond_type /*, initial_set = true */ );
125 
126  // --- Calculate the output vectors! All are saved internaly inside the object
127  // Calculate r(0)
128  feti_op.calculate_initial_r();
129 
130  // Calculate p(0)
131  feti_op.calculate_initial_p();
132 
133  // Calculations needed if we are using the rigid body modes
134  if(input_params.bUseRigidBodyModes)
135  {
136  // Calculate the rigid body modes correction RB_corr
137  feti_op.calculate_rb_correction();
138  }
139 
140  // --- Export output vectors!
141  // Export 'r(0)' and 'p(0)'
142  feti_op.export_inital_vecs();
143 
144  // Export the Ct_i * p(0) vectors
145  feti_op.export_ext_solver_rhs_initial();
146 
147  // Export the scalar data, rho(0) and, if pertinent, |RB_corr|
148  feti_op.export_initial_scalar_data();
149 
150  // --- Launch the "iter_script.sh" script --- ONLY ON THE FIRST PROC!
151  if(WorldComm.rank() == 0)
152  {
153  std::string iter_script_command = ". " + input_params.scratch_folder_path + "/FETI_iter_script.sh";
154  if(input_params.scheduler == carl::ClusterSchedulerType::LOCAL)
155  {
156  std::cout << " !!! LOCAL test: MPI commands cannot be launched recursivelly !!! " << std::endl;
157  std::cout << " Run the following program by hand: " << std::endl;
158  std::cout << iter_script_command << std::endl;
159  } else {
160  carl::exec_command(iter_script_command);
161  }
162  }
163 
164  return 0;
165 }
void get_input_params(GetPot &field_parser, feti_iterate_params &input_params)
Parser function for the coupled solver test programs.
carl::BaseCGPrecondType CG_precond_type
[CG] Type of preconditionner.
std::string exec_command(const std::string &cmd)
bool bUseRigidBodyModes
[RB] Use the rigid body modes for the micro system?
std::string scratch_folder_path
Path to the folder which will be used to save the temporary files during the solve operation...
ClusterSchedulerType scheduler
Cluster scheduler software type. Values: PBS, SLURM (code not implemented for the later yet)...
Class containing the operations needed for the FETI solver.
std::string RB_vectors_base
[RB] Common path base for the micro system's rigid body mode vectors.
int nb_of_rb_vectors
[RB] Number of RB mode vectors.
Structure containing the parameters for the setup initialization of the FETI solver.
std::string coupling_folder_path
Folder containing the coupling matrices.