147 std::string rb_vec_filename = RB_vectors_base +
"_0_n_" + std::to_string(
m_null_nb_vecs) +
".petscvec";
160 rb_vec_filename = RB_vectors_base +
"_" + std::to_string(iii) +
"_n_" + std::to_string(m_null_nb_vecs) +
".petscvec";
164 rb_coupl_vec_filename =
m_scratch_folder_path +
"/rb_coupl_vector_" + std::to_string(iii) +
"_n_" + std::to_string(m_null_nb_vecs) +
".petscvec";
180 MatCreateSeqDense(PETSC_COMM_SELF,m_null_nb_vecs,m_null_nb_vecs,NULL,&
m_inv_RITRI_mat);
188 PetscScalar *dummy_array;
193 dummy_matrix_contents[iii] = dummy_array[iii];
201 m_comm.broadcast(dummy_matrix_contents);
205 std::vector<PetscInt> dummy_indexes(m_null_nb_vecs,0);
209 dummy_indexes[iii] = iii;
212 MatSetValues(
m_inv_RITRI_mat,m_null_nb_vecs,&dummy_indexes[0],m_null_nb_vecs,&dummy_indexes[0],&dummy_matrix_contents[0],INSERT_VALUES);
395 for(
int iii = 0; iii <
m_kkk+1; ++iii)
417 for(
int iii = 0; iii <
m_kkk; ++iii)
437 std::ifstream scalar_data;
465 std::ifstream scalar_data;
468 for(
int iii = 0; iii <
m_kkk; ++iii)
543 #ifdef PRINT_MATLAB_DEBUG
556 #ifdef PRINT_MATLAB_DEBUG
569 #ifdef PRINT_MATLAB_DEBUG
582 #ifdef PRINT_MATLAB_DEBUG
595 #ifdef PRINT_MATLAB_DEBUG
610 #ifdef PRINT_MATLAB_DEBUG
620 #ifdef PRINT_MATLAB_DEBUG
632 PetscScalar residual = 0;
633 PetscScalar RB_correct = 0;
658 std::ofstream scalar_data;
662 scalar_data.precision(15);
663 scalar_data <<
m_kkk <<
" " << residual <<
" " << residual;
667 scalar_data <<
" " << RB_correct;
670 scalar_data << std::endl;
676 scalar_data.precision(15);
677 scalar_data <<
m_kkk <<
" " << residual;
681 scalar_data <<
" " << RB_correct;
684 scalar_data << std::endl;
698 std::ofstream scalar_data;
702 scalar_data.precision(15);
710 scalar_data << std::endl;
716 scalar_data.precision(15);
723 scalar_data << std::endl;
735 scalar_data.precision(15);
773 #ifdef PRINT_MATLAB_DEBUG
781 std::cout << std::endl;
782 std::cout <<
" --> Iteration no. " <<
m_kkk + 1 <<
" : ";
786 std::cout <<
" > Abs. residual convergence : rho(kkk+1) < " <<
m_abs_residual_conv << std::endl;
790 std::cout <<
" > Rel. residual convergence : rho(kkk+1) < " <<
m_rel_residual_conv <<
" * rho(0) " << std::endl;
794 std::cout <<
" > Rel. residual DIVERGENCE : rho(kkk+1) > " <<
m_rel_residual_div <<
" * rho(0) " << std::endl;
798 std::cout <<
" > Negative residual DIVERGENCE" << std::endl;
802 std::cout <<
" > Iter. DIVERGENCE : kkk + 1 > " <<
m_max_iter_div << std::endl;
808 std::cout <<
" > Rel. RB mode correction convergence : abs( RB(kkk+1) - RB_(kkk) ) / RB(kkk+1) < " <<
m_rb_modes_conv << std::endl;
811 std::cout << std::endl;
813 std::cout <<
" --> Previous " << std::min(m_kkk+2,nb_of_iters) <<
" iterations convergence parameter : " << std::endl;
816 std::cout <<
"[ kkk ] [ rho(kkk) ] [ | RB_corr(kkk) | ]" << std::endl;
820 std::cout <<
"[ kkk ] [ rho(kkk) ]" << std::endl;
823 std::string command_string =
"tail -n " + std::to_string(nb_of_iters) +
" " +
m_scratch_folder_path +
"/FETI_convergence.dat";
830 std::cout <<
" --> Converged!" << std::endl;
832 std::cout <<
" --> DIVERGED!" << std::endl;
834 std::cout <<
" --> Iterating ..." << std::endl;
836 std::cout << std::endl;
double m_abs_residual_conv
Absolute residual convergence.
void export_inital_vecs()
Export the initial iteration vectors, r(0) and p(0)
Vec m_current_residual
Current residual vector, r(kkk+1) (r(0) for the initialization)
bool m_bC_RR_MatrixSet
Mediator - mediator coupling matrix has been set?
double m_rho_0
Double containing the initial rho(0)
PetscInt m_null_nb_vecs
Number of null space vectors.
bool m_bR_sizes_set
Have the mediator dimensions been set yet?
PetscInt m_null_vecs_N_local
bool m_bSet_u_0
Have the u_0 vectors been set?
PetscInt m_C_R_micro_M_local
bool m_bNullVecsDimensionsSet
Have the null space vectors' dimensions been set?
bool m_bConvResidualRel
The residual converged? (relative to initial value)
bool m_bSet_previous_residual
Have the previous r(kkk) vector been set?
PetscInt m_C_R_BIG_N_local
Vec m_previous_phi
Previous Lagrange multipliers / solution, phi(kkk)
std::string m_coupling_folder_path
Coupling matrices path.
void read_scalar_data()
Read the scalar data, rho(0 ... kkk), | RB_corr(0 ... kkk) | and p(0 ... kkk - 1).q(0 ... kkk - 1)
Mat m_C_RR
Mediator - mediator system coupling matrix.
double m_previous_RB_mode_corr
Double containing the previous RB_mode_corr(kkk)
bool m_binvRITRIMatSet
Have the inv(RI^T * RI) matrix been set?
void export_ext_solver_rhs(Vec vec_in)
Calculate and export the external solver RHS's.
void read_previous_phi()
Read the previous Lagrage multiplier / solution.
void read_all_previous_q()
Read all the previous q vectors.
Mat m_C_R_BIG
Mediator - macro system coupling matrix.
void write_PETSC_vector(libMesh::PetscVector< libMesh::Number > &input_vec, const std::string &filename, int dim=1)
bool m_bConv
Did the solver converge?
double m_rel_residual_conv
Relative residual convergence (relative to initial value)
Vec m_ext_solver_sol_micro
Micro model external solver solution.
void export_rb_correction_vector()
Export the rigid body modes correction.
std::string exec_command(const std::string &cmd)
void export_ext_solver_rhs_Ct_phi()
Calculate and export the external solver RHS's for the decoupled problem.
void set_coupling_matrix_R_micro()
Read the mediator - micro system coupling matrix.
void export_r()
Export the current r(kkk+1) residual vector.
Vec m_u_0_BIG
Solution of the decoupled macro model.
std::string m_scratch_folder_path
Scratch folder path.
void export_q()
Export the current q(kkk) vector.
Vec m_coupled_sol_micro
Coupled system solution for the micro model.
bool m_bC_R_BIG_MatrixSet
Mediator - macro coupling matrix has been set?
void read_previous_r()
Read the previous residual.
void read_rb_corr()
Read the rigid body modes correction vector.
Vec * m_previous_p_ptr
Pointer to the previous p vectors, p(0 ... kkk)
Mat m_inv_RITRI_mat
Matrix , used in some projectors.
int m_max_iter_div
Number of iterations divergence.
void export_p()
Export the current p(kkk+1) vector.
bool m_bSet_current_RB_correction
Have the RB modes correction RB_corr(kkk+1) vector been set?
PetscInt m_C_R_BIG_M_local
void read_null_space_vecs(const std::string &RB_vectors_base, int nb_of_rb_vectors)
Read the null space vectors.
bool m_bCalculatedScalar
Calculated the current iterations scalar data?
Vec m_u_0_micro
Solution of the decoupled micro model.
void set_coupling_matrix_RR()
Read the mediator - mediator system coupling matrix.
bool m_bDivResidualNeg
The residual is negative? (more usefull for debugging, really)
Vec m_current_z
Current z(kkk+1) (z(0) for the initialization)
bool m_bBIG_sizes_set
Have the macro dimensions been set yet?
void read_vector_data()
Read the vector data - essentially calls the "read_previous" and "read_all_previous" methods...
Vec m_current_rb_correction
Current rigid body modes correction, RB_corr(kkk+1) (RB_corr(0) for the initialization) ...
bool m_bScratchFolderSet
Have the scratch folder been set?
Mat m_C_R_micro
Mediator - micro system coupling matrix.
bool m_bSet_previous_p_ptr
Have the previous p vectors, p(0 ... kkk), been set?
void export_initial_scalar_data()
Export the initial iteration scalar data, rho(0) and | RB_corr(0) |
void export_phi()
Export the current Lagrange multiplier / solution.
bool m_bSet_current_z
Have the current z(kkk+1) vector been set?
double m_current_RB_mode_corr
Double containing the current RB_mode_corr(kkk+1)
double m_rb_modes_conv
Relative RB correction convergence (relative to previous value)
Vec * m_previous_q_ptr
Pointer to the previous q vectors, q(0 ... kkk)
double m_previous_rho
Double containing the previous rho(kkk)
bool m_bDiv
Did the solver diverge?
PetscInt m_C_R_micro_N_local
bool m_bSet_current_residual
Have the current r(kkk+1) vector been set?
void read_all_previous_p()
Read all the previous p vectors.
void read_PETSC_matrix(Mat input_mat, const std::string &filename, MPI_Comm comm=PETSC_COMM_WORLD)
Vec m_coupled_sol_BIG
Coupled system solution for the macro model.
std::vector< double > m_p_dot_q
Vector containing the p.q scalar products.
RBModesSystem m_RB_modes_system
Which model is associated to the RB modes? Default: RBModesSystem::MICRO.
void set_coupling_matrix_R_BIG()
Read the mediator - macro system coupling matrix.
bool m_bSet_previous_q_ptr
Have the previous q vectors, q(0 ... kkk), been set?
bool m_bReadPreviousScalar
Read the previous iterations scalar data?
bool m_bConvRBCorrRel
The RB correction converged? (relative to previous value)
libMesh::Parallel::Communicator & m_comm
Communicator.
bool m_bCouplingFolderSet
Have the Coupling matrices folder been set?
void read_null_space_inv_RITRI_mat()
Read the matrix.
void read_coupling_matrices()
Read all the coupling matrices.
Vec m_ext_solver_sol_BIG
Macro model external solver solution.
bool m_bConvResidualAbs
The residual converged? (absolute)
bool m_bCouplingMatricesSet
All coupling matrices has been set?
double m_rel_residual_div
Relative residual divergence (relative to initial value)
void export_coupled_solution(std::string output_base)
void read_decoupled_solutions()
Read the decoupled solutions, .
bool m_bSet_ext_solver_sol
Have the external solvers solutions been set vectors been set?
bool m_bC_R_micro_MatrixSet
Mediator - micro coupling matrix has been set?
bool m_bmicro_sizes_set
Have the micro dimensions been set yet?
bool m_bSet_current_p
Have the current p(kkk+1) vector been set?
Vec m_current_phi
Current Lagrange multipliers / solution, phi(kkk+1) (phi(0) for the initialization) ...
void read_ext_solver_output()
Read the latest external solver output.
BaseCGPrecondType m_precond_type
Preconditioner type. Default: BaseCGPrecondType::NO_PRECONDITIONER.
bool m_bSet_previous_phi
Have the previous Lagrange multipliers / solution phi(kkk) been set?
void print_previous_iters_conv(int nb_of_iters=5)
void export_scalar_data()
Export the iteration scalar data, rho(kkk+1), | RB_corr(kkk+1) | and p(kkk).q(kkk) ...
bool m_bCoupled_sols_set
Have the coupled solutions been set yet?
Vec m_null_coupled_vecs[maxVecLimit]
Null space vectors times the coupling matrix.
bool m_bDivResidualRel
The residual diverged? (relative to initial value)
Vec m_previous_residual
Previous residual vector, r(kkk)
void export_ext_solver_rhs_Ct_p()
Calculate and export the external solver RHS's for the next iteration.
int m_kkk
Current iteration index.
void read_PETSC_vector(libMesh::PetscVector< libMesh::Number > &input_vec, const std::string &filename)
bool m_bSet_current_phi
Have the current Lagrange multipliers / solution phi(kkk+1) been set?
void write_PETSC_vector_MATLAB(Vec input_vec, const std::string &filename, MPI_Comm comm=PETSC_COMM_WORLD)
Vec m_current_p
Current p(kkk+1) (p(0) for the initialization)
void export_ext_solver_rhs_initial()
Calculate and export the external solver RHS's for the first iteration.
Vec m_null_vecs[maxVecLimit]
Null space vectors.
double m_current_rho
Double containing the current rho(kkk+1)
bool m_bUsingNullVecs
Do we need to use the null space vectors?
bool m_bNullVecsSet
Have the null space vectors been set?