CArl
Code Arlequin / C++ implementation
CArl_FETI_setup_finish.cpp
Go to the documentation of this file.
2 
61 int main(int argc, char** argv) {
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);
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
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 export_inital_vecs()
Export the initial iteration vectors, r(0) and p(0)
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)
void set_coupling_matrix_R_micro()
Read the mediator - micro system coupling matrix.
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)...
void calculate_initial_p()
Calculate the initial p(0) vector.
Class containing the operations needed for the FETI solver.
void read_null_space_vecs(const std::string &RB_vectors_base, int nb_of_rb_vectors)
Read the null space vectors.
std::string RB_vectors_base
[RB] Common path base for the micro system's rigid body mode vectors.
void calculate_rb_correction()
Calculate the rigid body modes corrections.
void export_initial_scalar_data()
Export the initial iteration scalar data, rho(0) and | RB_corr(0) |
int nb_of_rb_vectors
[RB] Number of RB mode vectors.
Structure containing the parameters for the setup initialization of the FETI solver.
void set_coupling_matrix_R_BIG()
Read the mediator - macro system coupling matrix.
void read_null_space_inv_RITRI_mat()
Read the matrix.
void using_rb_modes(bool bUseRigidBodyModes)
Set up the.
void read_decoupled_solutions()
Read the decoupled solutions, .
void read_ext_solver_output()
Read the latest external solver output.
int main(int argc, char **argv)
void calculate_initial_r()
Calculate the inital residual vector, r(0)
void export_ext_solver_rhs_initial()
Calculate and export the external solver RHS's for the first iteration.
void set_preconditioner(BaseCGPrecondType CG_precond_type, bool bInitialSet=true)
std::string coupling_folder_path
Folder containing the coupling matrices.