17 #include <unordered_set>
22 #include <Epetra_FECrsGraph.h>
23 #include <Epetra_IntVector.h>
33 #if !defined(START_TIMER)
34 #define START_TIMER(label, rank) \
35 if (mrComm.MyPID() == rank) \
38 #if !defined(STOP_TIMER)
39 #define STOP_TIMER(label, rank) \
40 if (mrComm.MyPID() == rank) \
80 template <
class TSparseSpace,
139 typename TLinearSolver::Pointer pNewLinearSystemSolver)
151 typename TLinearSolver::Pointer pNewLinearSystemSolver,
153 ) :
BaseType(pNewLinearSystemSolver),
189 void Build(
typename TSchemeType::Pointer pScheme,
214 if ((*it)->IsActive()) {
216 pScheme->CalculateSystemContributions(**it, LHS_Contribution, RHS_Contribution, equation_ids_vector, r_current_process_info);
219 TSparseSpace::AssembleLHS(rA, LHS_Contribution, equation_ids_vector);
220 TSparseSpace::AssembleRHS(rb, RHS_Contribution, equation_ids_vector);
224 LHS_Contribution.resize(0, 0,
false);
225 RHS_Contribution.resize(0,
false);
228 for (
auto it = rModelPart.
Conditions().ptr_begin(); it < rModelPart.
Conditions().ptr_end(); it++) {
230 if ((*it)->IsActive()) {
232 pScheme->CalculateSystemContributions(**it, LHS_Contribution, RHS_Contribution, equation_ids_vector, r_current_process_info);
235 TSparseSpace::AssembleLHS(rA, LHS_Contribution, equation_ids_vector);
236 TSparseSpace::AssembleRHS(rb, RHS_Contribution, equation_ids_vector);
258 void BuildLHS(
typename TSchemeType::Pointer pScheme,
278 pScheme->CalculateLHSContribution(**it, LHS_Contribution, equation_ids_vector, r_current_process_info);
281 TSparseSpace::AssembleLHS(rA, LHS_Contribution, equation_ids_vector);
284 LHS_Contribution.resize(0, 0,
false);
287 for (
auto it = rModelPart.
Conditions().ptr_begin(); it < rModelPart.
Conditions().ptr_end(); it++) {
289 pScheme->CalculateLHSContribution(**it, LHS_Contribution, equation_ids_vector, r_current_process_info);
292 TSparseSpace::AssembleLHS(rA, LHS_Contribution, equation_ids_vector);
318 KRATOS_ERROR <<
"Method BuildLHS_CompleteOnFreeRows not implemented in "
319 "Trilinos Builder And Solver"
347 TSparseSpace::SetToZero(rDx);
388 TSparseSpace::SetToZero(Dxmodified);
424 if (norm_b != 0.00) {
431 TSparseSpace::SetToZero(rDx);
432 KRATOS_WARNING(
"TrilinosResidualBasedBlockBuilderAndSolver") <<
"ATTENTION! setting the RHS to zero!" << std::endl;
461 Build(pScheme, rModelPart, rA, rb);
477 <<
"\nBefore the solution of the system"
478 <<
"\nSystem Matrix = " << rA <<
"\nunknowns vector = " << rDx
479 <<
"\nRHS vector = " << rb << std::endl;
492 <<
"\nAfter the solution of the system"
493 <<
"\nSystem Matrix = " << rA <<
"\nUnknowns vector = " << rDx
494 <<
"\nRHS vector = " << rb << std::endl;
532 KRATOS_INFO_IF(
"TrilinosBlockBuilderAndSolver", ( this->
GetEchoLevel() == 3)) <<
"After the solution of the system" <<
"\nSystem Matrix = " << rA <<
"\nUnknowns vector = " << rDx <<
"\nRHS vector = " << rb << std::endl;
544 void BuildRHS(
typename TSchemeType::Pointer pScheme,
565 pScheme->CalculateRHSContribution(**it, RHS_Contribution, equation_ids_vector, r_current_process_info);
568 TSparseSpace::AssembleRHS(rb, RHS_Contribution, equation_ids_vector);
571 RHS_Contribution.resize(0,
false);
574 for (
auto it = rModelPart.
Conditions().ptr_begin(); it < rModelPart.
Conditions().ptr_end(); it++) {
576 pScheme->CalculateRHSContribution(**it, RHS_Contribution, equation_ids_vector, r_current_process_info);
579 TSparseSpace::AssembleRHS(rb, RHS_Contribution, equation_ids_vector);
599 typename TSchemeType::Pointer pScheme,
610 DofsVectorType dof_list, second_dof_list;
615 temp_dofs_array.
reserve(guess_num_dofs);
620 for (
auto& r_elem : r_elements_array) {
621 pScheme->GetDofList(r_elem, dof_list, r_current_process_info);
622 for (
auto i_dof = dof_list.begin(); i_dof != dof_list.end(); ++i_dof)
628 for (
auto& r_cond : r_conditions_array) {
629 pScheme->GetDofList(r_cond, dof_list, r_current_process_info);
630 for (
auto i_dof = dof_list.begin(); i_dof != dof_list.end(); ++i_dof)
636 for (
auto& r_const : r_constraints_array) {
637 r_const.GetDofList(dof_list, second_dof_list, r_current_process_info);
638 for (
auto i_dof = dof_list.begin(); i_dof != dof_list.end(); ++i_dof)
640 for (
auto i_dof = second_dof_list.begin(); i_dof != second_dof_list.end(); ++i_dof)
650 KRATOS_ERROR_IF(number_of_dofs == 0) <<
"No degrees of freedom!" << std::endl;
659 <<
"Reaction variable not set for the following : " << std::endl
660 <<
"Node : " << dof_iterator->Id() << std::endl
661 <<
"Dof : " << (*dof_iterator) << std::endl
662 <<
"Not possible to calculate reactions." << std::endl;
685 const int current_rank = r_data_comm.
Rank();
686 const int world_size = r_data_comm.Size();
690 if (r_dof.GetSolutionStepValue(PARTITION_INDEX) == current_rank) {
701 free_offset = r_data_comm.ScanSum(free_size);
704 global_size = r_data_comm.SumAll(free_size);
707 free_offset -= free_size;
711 if (r_dof.GetSolutionStepValue(PARTITION_INDEX) == current_rank) {
712 r_dof.SetEquationId(free_offset++);
721 <<
"\n free_offset = " << free_offset << std::endl;
727 if (r_comm.GlobalNumberOfMasterSlaveConstraints() > 0) {
729 std::vector<int> send_first_ids(1,
mFirstMyId);
730 r_data_comm.AllGather(send_first_ids,
mFirstMyIds);
734 r_comm.SynchronizeDofs();
748 typename TSchemeType::Pointer pScheme,
767 KRATOS_ERROR <<
"It should not come here resizing is not allowed this way!!!!!!!! ... " << std::endl;
785 typename TSchemeType::Pointer pScheme,
792 TSparseSpace::SetToZero(rb);
802 std::vector<int> index_array(number_of_dofs);
808 id =
dof.EquationId();
809 if (
id < system_size) {
814 std::sort(index_array.begin(), index_array.end());
815 std::vector<int>::iterator NewEnd = std::unique(index_array.begin(), index_array.end());
816 index_array.resize(NewEnd - index_array.begin());
819 int tot_update_dofs = index_array.size();
820 rb.Comm().SumAll(&tot_update_dofs, &check_size, 1);
822 <<
"Dof count is not correct. There are less dofs than expected.\n"
823 <<
"Expected number of active dofs = " << system_size
824 <<
" dofs found = " << check_size << std::endl;
827 Epetra_Map dof_update_map(-1, index_array.size(),
828 &(*(index_array.begin())), 0, rb.Comm());
834 Epetra_Vector temp_RHS(pDofImporter->TargetMap());
837 int ierr = temp_RHS.Import(rb, *pDofImporter, Insert);
838 KRATOS_ERROR_IF(ierr != 0) <<
"Epetra failure found - error code: " << ierr << std::endl;
840 double* temp_RHS_values;
841 temp_RHS.ExtractView(&temp_RHS_values);
850 for (
int k = 0;
k < ndofs;
k++) {
853 const int i = (dof_iterator)->EquationId();
855 const double react_val = temp_RHS[pDofImporter->TargetMap().LID(
i)];
856 (dof_iterator->GetSolutionStepReactionValue()) = -react_val;
873 typename TSchemeType::Pointer pScheme,
888 const int global_id =
dof.EquationId();
889 global_ids[
i] = global_id;
890 is_dirichlet[
i] =
dof.IsFixed();
895 Epetra_Map localmap(-1, global_ids.size(), global_ids.data(), 0, rA.Comm());
896 Epetra_IntVector fixed_local(Copy, localmap, is_dirichlet.data());
898 Epetra_Import dirichlet_importer(rA.ColMap(), fixed_local.Map());
901 Epetra_IntVector fixed(rA.ColMap());
908 int ierr = fixed.Import(fixed_local, dirichlet_importer, Insert);
911 for (
int i = 0;
i < rA.NumMyRows();
i++) {
915 rA.ExtractMyRowView(
i, numEntries, vals, cols);
917 const int row_gid = rA.RowMap().GID(
i);
918 const int row_lid = localmap.LID(row_gid);
920 if (fixed_local[row_lid] == 0) {
921 for (
int j = 0;
j < numEntries;
j++) {
922 if (fixed[cols[
j]] ==
true)
931 for (
int j = 0;
j < numEntries;
j++) {
932 int col_gid = rA.ColMap().GID(cols[
j]);
933 if (col_gid != row_gid)
949 typename TSchemeType::Pointer pScheme,
970 TrilinosAssemblingUtilities::SetGlobalValueWithoutGlobalAssembly(rb, slave_equation_id, 0.0);
989 typename TSchemeType::Pointer pScheme,
1005 TSparseSpace::BtDBProductOperation(rA, copy_A, r_T,
true,
false,
true);
1019 TrilinosAssemblingUtilities::SetGlobalValueWithoutGlobalAssembly(rA, slave_equation_id, slave_equation_id, mScaleFactor);
1020 TrilinosAssemblingUtilities::SetGlobalValueWithoutGlobalAssembly(rb, slave_equation_id, 0.0);
1025 rb.GlobalAssemble();
1026 rA.GlobalAssemble();
1042 TSparseSpace::Clear(
mpT);
1069 "name" : "trilinos_block_builder_and_solver",
1070 "guess_row_size" : 45,
1071 "block_builder" : true,
1072 "diagonal_values_for_dirichlet_dofs" : "use_max_diagonal",
1073 "silent_warnings" : false
1079 return default_parameters;
1088 return "trilinos_block_builder_and_solver";
1112 return r_constant_vector;
1146 return "TrilinosBlockBuilderAndSolver";
1211 START_TIMER(
"ConstraintsRelationMatrixStructure", 0)
1218 const int temp_size = (number_of_local_rows < 1000) ? 1000 : number_of_local_rows;
1219 std::vector<int> temp_primary(temp_size, 0);
1220 std::vector<int> temp_secondary(temp_size, 0);
1221 for (
IndexType i = 0;
i != number_of_local_rows;
i++) {
1224 Epetra_Map& r_map = GetEpetraMap();
1225 std::fill(temp_primary.begin(), temp_primary.begin() + number_of_local_rows, 0);
1232 int index_diagonal[1] = {0};
1235 ierr = Tgraph.InsertGlobalIndices(1, index_diagonal, 1, index_diagonal);
1236 KRATOS_ERROR_IF(ierr < 0) <<
": Epetra failure in Graph.InsertGlobalIndices. Error code: " << ierr << std::endl;
1240 std::unordered_set<std::size_t> indices;
1247 for (
auto& r_const : r_constraints_array) {
1248 r_const.EquationIdVector(slave_equation_ids_vector, master_equation_ids_vector, r_current_process_info);
1252 for (
auto& r_slave_id : slave_equation_ids_vector) {
1253 temp_primary[num_active_slave_indices] = r_slave_id;
1254 ++num_active_slave_indices;
1256 IndexType num_active_master_indices = 0;
1257 for (
auto& r_master_id : master_equation_ids_vector) {
1258 temp_secondary[num_active_master_indices] = r_master_id;
1259 ++num_active_master_indices;
1263 if (num_active_slave_indices > 0 && num_active_master_indices > 0) {
1264 int slave_index[1] = {0};
1265 for (
IndexType i = 0;
i < num_active_slave_indices; ++
i) {
1266 slave_index[0] = temp_primary[
i];
1267 indices.insert(temp_primary[
i]);
1268 ierr = Tgraph.InsertGlobalIndices(1, slave_index, num_active_master_indices, temp_secondary.data());
1269 KRATOS_ERROR_IF(ierr < 0) <<
": Epetra failure in Graph.InsertGlobalIndices. Error code: " << ierr << std::endl;
1272 std::fill(temp_primary.begin(), temp_primary.begin() + num_active_slave_indices, 0);
1273 std::fill(temp_secondary.begin(), temp_secondary.begin() + num_active_master_indices, 0);
1277 ierr = Tgraph.GlobalAssemble();
1278 KRATOS_ERROR_IF(ierr < 0) <<
": Epetra failure in Epetra_FECrsGraph.GlobalAssemble. Error code: " << ierr << std::endl;
1279 ierr = Tgraph.FillComplete();
1280 KRATOS_ERROR_IF(ierr < 0) <<
": Epetra failure in Epetra_FECrsGraph.FillComplete. Error code: " << ierr << std::endl;
1281 ierr = Tgraph.OptimizeStorage();
1282 KRATOS_ERROR_IF(ierr < 0) <<
": Epetra failure in Epetra_FECrsGraph.OptimizeStorage. Error code: " << ierr << std::endl;
1303 const int current_rank = r_data_comm.
Rank();
1304 const int world_size = r_data_comm.Size();
1307 std::vector<std::unordered_set<IndexType>> auxiliary_slave_ids(world_size);
1308 for (
auto index : indices) {
1309 const IndexType rank = DeterminePartitionIndex(index);
1310 auxiliary_slave_ids[rank].insert(index);
1312 const int tag_sync_slave_id = 0;
1313 for (
int i_rank = 0; i_rank < world_size; ++i_rank) {
1314 if (i_rank != current_rank) {
1315 std::vector<IndexType> receive_slave_ids_vector;
1316 r_data_comm.Recv(receive_slave_ids_vector, i_rank, tag_sync_slave_id);
1317 auxiliary_slave_ids[i_rank].insert(receive_slave_ids_vector.begin(), receive_slave_ids_vector.end());
1319 for (
int j_rank = 0; j_rank < world_size; ++j_rank) {
1320 if (j_rank != current_rank) {
1321 const auto& r_slave_ids = auxiliary_slave_ids[j_rank];
1322 std::vector<IndexType> send_slave_ids_vector(r_slave_ids.begin(), r_slave_ids.end());
1323 r_data_comm.Send(send_slave_ids_vector, j_rank, tag_sync_slave_id);
1328 mSlaveIds = std::vector<IndexType>(auxiliary_slave_ids[current_rank].begin(), auxiliary_slave_ids[current_rank].
end());
1331 std::unordered_set<IndexType> temp_master_ids;
1337 for (
auto id_slave_vector : auxiliary_slave_ids) {
1338 for (
auto id_slave : id_slave_vector) {
1339 temp_master_ids.erase(id_slave);
1342 mMasterIds = std::vector<IndexType>(temp_master_ids.begin(), temp_master_ids.end());
1344 STOP_TIMER(
"ConstraintsRelationMatrixStructure", 0)
1360 TSparseSpace::SetToZero(r_T);
1361 TSparseSpace::SetToZero(r_constant_vector);
1376 const int current_rank = r_data_comm.
Rank();
1377 const int world_size = r_data_comm.Size();
1380 std::vector<std::unordered_set<IndexType>> auxiliary_inactive_slave_ids(world_size);
1384 std::size_t num_inactive_slave_dofs_other_partitions = 0;
1388 r_const.EquationIdVector(slave_equation_ids, master_equation_ids, r_current_process_info);
1390 if (r_const.IsActive()) {
1391 r_const.CalculateLocalSystem(transformation_matrix, constant_vector, r_current_process_info);
1397 for (
auto slave_id : slave_equation_ids) {
1398 const int index_rank = DeterminePartitionIndex(slave_id);
1399 if (index_rank == current_rank) {
1402 auxiliary_inactive_slave_ids[index_rank].insert(slave_id);
1403 ++num_inactive_slave_dofs_other_partitions;
1410 num_inactive_slave_dofs_other_partitions = r_data_comm.SumAll(num_inactive_slave_dofs_other_partitions);
1413 if (num_inactive_slave_dofs_other_partitions > 0) {
1414 const int tag_sync_inactive_slave_id = 0;
1415 for (
int i_rank = 0; i_rank < world_size; ++i_rank) {
1416 if (i_rank != current_rank) {
1417 std::vector<IndexType> receive_inactive_slave_ids_vector;
1418 r_data_comm.Recv(receive_inactive_slave_ids_vector, i_rank, tag_sync_inactive_slave_id);
1419 mInactiveSlaveDofs.insert(receive_inactive_slave_ids_vector.begin(), receive_inactive_slave_ids_vector.end());
1421 for (
int j_rank = 0; j_rank < world_size; ++j_rank) {
1422 if (j_rank != current_rank) {
1423 const auto& r_inactive_slave_ids = auxiliary_inactive_slave_ids[j_rank];
1424 std::vector<IndexType> send_inactive_slave_ids_vector(r_inactive_slave_ids.begin(), r_inactive_slave_ids.end());
1425 r_data_comm.Send(send_inactive_slave_ids_vector, j_rank, tag_sync_inactive_slave_id);
1445 r_T.GlobalAssemble();
1446 r_constant_vector.GlobalAssemble();
1461 typename TSchemeType::Pointer pScheme,
1472 auto& r_elements_array = rModelPart.
Elements();
1473 auto& r_conditions_array = rModelPart.
Conditions();
1480 const int temp_size = (number_of_local_rows < 1000) ? 1000 : number_of_local_rows;
1481 std::vector<int> temp_primary(temp_size, 0);
1482 std::vector<int> temp_secondary(temp_size, 0);
1483 for (
IndexType i = 0;
i != number_of_local_rows;
i++) {
1486 Epetra_Map& r_map = GetEpetraMap();
1487 std::fill(temp_primary.begin(), temp_primary.begin() + number_of_local_rows, 0);
1499 for (
auto& r_elem : r_elements_array) {
1500 pScheme->EquationId(r_elem, equation_ids_vector, r_current_process_info);
1504 for (
auto& r_id : equation_ids_vector) {
1505 temp_primary[num_active_indices] = r_id;
1506 ++num_active_indices;
1509 if (num_active_indices != 0) {
1510 ierr = Agraph.InsertGlobalIndices(num_active_indices, temp_primary.data(), num_active_indices, temp_primary.data());
1511 KRATOS_ERROR_IF(ierr < 0) <<
": Epetra failure in Graph.InsertGlobalIndices. Error code: " << ierr << std::endl;
1513 std::fill(temp_primary.begin(), temp_primary.begin() + num_active_indices, 0);
1517 for (
auto& r_cond : r_conditions_array) {
1518 pScheme->EquationId(r_cond, equation_ids_vector, r_current_process_info);
1522 for (
auto& r_id : equation_ids_vector) {
1523 temp_primary[num_active_indices] = r_id;
1524 ++num_active_indices;
1527 if (num_active_indices != 0) {
1528 ierr = Agraph.InsertGlobalIndices(num_active_indices, temp_primary.data(), num_active_indices, temp_primary.data());
1529 KRATOS_ERROR_IF(ierr < 0) <<
": Epetra failure in Graph.InsertGlobalIndices. Error code: " << ierr << std::endl;
1531 std::fill(temp_primary.begin(), temp_primary.begin() + num_active_indices, 0);
1536 for (
auto& r_const : r_constraints_array) {
1537 r_const.EquationIdVector(slave_equation_ids_vector, master_equation_ids_vector, r_current_process_info);
1541 for (
auto& r_slave_id : slave_equation_ids_vector) {
1542 temp_primary[num_active_slave_indices] = r_slave_id;
1543 ++num_active_slave_indices;
1545 IndexType num_active_master_indices = 0;
1546 for (
auto& r_master_id : master_equation_ids_vector) {
1547 temp_secondary[num_active_master_indices] = r_master_id;
1548 ++num_active_master_indices;
1552 if (num_active_slave_indices > 0) {
1554 for (
IndexType i = 0;
i < num_active_slave_indices; ++
i) {
1555 index[0] = temp_primary[
i];
1556 ierr = Agraph.InsertGlobalIndices(1, index, 1, index);
1557 KRATOS_ERROR_IF(ierr < 0) <<
": Epetra failure in Graph.InsertGlobalIndices. Error code: " << ierr << std::endl;
1560 if (num_active_master_indices > 0) {
1561 ierr = Agraph.InsertGlobalIndices(num_active_slave_indices, temp_primary.data(), num_active_master_indices, temp_secondary.data());
1562 KRATOS_ERROR_IF(ierr < 0) <<
": Epetra failure in Graph.InsertGlobalIndices. Error code: " << ierr << std::endl;
1566 if (num_active_master_indices > 0) {
1568 for (
IndexType i = 0;
i < num_active_master_indices; ++
i) {
1569 index[0] = temp_secondary[
i];
1570 ierr = Agraph.InsertGlobalIndices(1, index, 1, index);
1571 KRATOS_ERROR_IF(ierr < 0) <<
": Epetra failure in Graph.InsertGlobalIndices. Error code: " << ierr << std::endl;
1574 std::fill(temp_primary.begin(), temp_primary.begin() + num_active_slave_indices, 0);
1575 std::fill(temp_secondary.begin(), temp_secondary.begin() + num_active_master_indices, 0);
1579 ierr = Agraph.GlobalAssemble();
1580 KRATOS_ERROR_IF(ierr < 0) <<
": Epetra failure in Epetra_FECrsGraph.GlobalAssemble. Error code: " << ierr << std::endl;
1581 ierr = Agraph.FillComplete();
1582 KRATOS_ERROR_IF(ierr < 0) <<
": Epetra failure in Epetra_FECrsGraph.FillComplete. Error code: " << ierr << std::endl;
1583 ierr = Agraph.OptimizeStorage();
1584 KRATOS_ERROR_IF(ierr < 0) <<
": Epetra failure in Epetra_FECrsGraph.OptimizeStorage. Error code: " << ierr << std::endl;
1597 rpDx.swap(p_new_Dx);
1620 const std::string& r_diagonal_values_for_dirichlet_dofs = ThisParameters[
"diagonal_values_for_dirichlet_dofs"].
GetString();
1622 const std::set<std::string> available_options_for_diagonal = {
"no_scaling",
"use_max_diagonal",
"use_diagonal_norm",
"defined_in_process_info"};
1624 if (available_options_for_diagonal.find(r_diagonal_values_for_dirichlet_dofs) == available_options_for_diagonal.end()) {
1625 std::stringstream msg;
1626 msg <<
"Currently prescribed diagonal values for dirichlet dofs : " << r_diagonal_values_for_dirichlet_dofs <<
"\n";
1627 msg <<
"Admissible values for the diagonal scaling are : 'no_scaling', 'use_max_diagonal', 'use_diagonal_norm', or 'defined_in_process_info'" <<
"\n";
1632 if (r_diagonal_values_for_dirichlet_dofs ==
"no_scaling") {
1634 }
else if (r_diagonal_values_for_dirichlet_dofs ==
"use_max_diagonal") {
1636 }
else if (r_diagonal_values_for_dirichlet_dofs ==
"use_diagonal_norm") {
1641 mOptions.
Set(SILENT_WARNINGS, ThisParameters[
"silent_warnings"].GetBool());
1677 Epetra_Map& GetEpetraMap()
1679 if (
mpMap ==
nullptr) {
1682 std::vector<int> temp_primary(temp_size, 0);
1700 for (index = 0; index <
mFirstMyIds.size() - 1; ++index) {
1712 KRATOS_ERROR <<
"This method is not implemented for Trilinos";
1736 template<
class TSparseSpace,
class TDenseSpace,
class TLinearSolver>
Current class provides an implementation for the base builder and solving operations.
Definition: builder_and_solver.h:64
std::size_t IndexType
Definition of the index type.
Definition: builder_and_solver.h:76
bool mDofSetIsInitialized
If the matrix is reshaped each step.
Definition: builder_and_solver.h:743
TSparseSpace::VectorType TSystemVectorType
Definition of the vector size.
Definition: builder_and_solver.h:85
bool GetCalculateReactionsFlag() const
This method returns the flag mCalculateReactionsFlag.
Definition: builder_and_solver.h:184
TSparseSpace::MatrixType TSystemMatrixType
Definition of the sparse matrix.
Definition: builder_and_solver.h:82
virtual void AssignSettings(const Parameters ThisParameters)
This method assigns settings to member variables.
Definition: builder_and_solver.h:780
TSystemVectorPointerType mpReactionsVector
Definition: builder_and_solver.h:751
Scheme< TSparseSpace, TDenseSpace > TSchemeType
Definition of the scheme type.
Definition: builder_and_solver.h:100
virtual Parameters ValidateAndAssignParameters(Parameters ThisParameters, const Parameters DefaultParameters) const
This method validate and assign default parameters.
Definition: builder_and_solver.h:767
ModelPart::DofsArrayType DofsArrayType
Definition of the DoF array type.
Definition: builder_and_solver.h:106
virtual void Clear()
This function is intended to be called at the end of the solution step to clean up memory storage not...
Definition: builder_and_solver.h:600
bool GetReshapeMatrixFlag() const
This method returns the flag mReshapeMatrixFlag.
Definition: builder_and_solver.h:220
TDenseSpace::MatrixType LocalSystemMatrixType
The local matrix definition.
Definition: builder_and_solver.h:94
TSparseSpace::VectorPointerType TSystemVectorPointerType
Definition of the pointer to the vector.
Definition: builder_and_solver.h:91
TLinearSolver::Pointer mpLinearSystemSolver
Definition: builder_and_solver.h:737
DofsArrayType mDofSet
Pointer to the linear solver.
Definition: builder_and_solver.h:739
TDenseSpace::VectorType LocalSystemVectorType
The local vector definition.
Definition: builder_and_solver.h:97
TSparseSpace::MatrixPointerType TSystemMatrixPointerType
Definition of the pointer to the sparse matrix.
Definition: builder_and_solver.h:88
std::size_t SizeType
Definition of the size type.
Definition: builder_and_solver.h:73
bool mCalculateReactionsFlag
Flag taking care if the dof set was initialized ot not.
Definition: builder_and_solver.h:745
int GetEchoLevel() const
It returns the echo level.
Definition: builder_and_solver.h:674
virtual Parameters GetDefaultParameters() const
This method provides the defaults parameters to avoid conflicts between the different constructors.
Definition: builder_and_solver.h:628
unsigned int mEquationSystemSize
Flag taking in account if it is needed or not to calculate the reactions.
Definition: builder_and_solver.h:747
Definition: builtin_timer.h:26
SizeType GlobalNumberOfMasterSlaveConstraints() const
Definition: communicator.cpp:116
virtual const DataCommunicator & GetDataCommunicator() const
Definition: communicator.cpp:340
MeshType & LocalMesh()
Returns the reference to the mesh storing all local entities.
Definition: communicator.cpp:245
virtual int Rank() const
Get the parallel rank for this DataCommunicator.
Definition: data_communicator.h:587
std::vector< DofType::Pointer > DofsVectorType
Definition: element.h:100
std::vector< std::size_t > EquationIdVectorType
Definition: element.h:98
void Set(const Flags ThisFlag)
Definition: flags.cpp:33
static Flags Create(IndexType ThisPosition, bool Value=true)
Definition: flags.h:138
This class is useful for index iteration over containers.
Definition: parallel_utilities.h:451
void for_each(TUnaryFunction &&f)
Definition: parallel_utilities.h:514
SizeType NumberOfNodes() const
Definition: mesh.h:259
ConditionsContainerType & Conditions()
Definition: mesh.h:691
MasterSlaveConstraintContainerType & MasterSlaveConstraints()
Definition: mesh.h:802
ElementsContainerType & Elements()
Definition: mesh.h:568
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
MasterSlaveConstraintContainerType & MasterSlaveConstraints(IndexType ThisIndex=0)
Definition: model_part.h:654
Communicator & GetCommunicator()
Definition: model_part.h:1821
ConditionsContainerType & Conditions(IndexType ThisIndex=0)
Definition: model_part.h:1381
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
ElementsContainerType & Elements(IndexType ThisIndex=0)
Definition: model_part.h:1189
This class defines the node.
Definition: node.h:65
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
int GetInt() const
This method returns the integer contained in the current Parameter.
Definition: kratos_parameters.cpp:666
void RecursivelyAddMissingParameters(const Parameters &rDefaultParameters)
This function is designed to verify that the parameters under testing contain at least all parameters...
Definition: kratos_parameters.cpp:1457
std::string GetString() const
This method returns the string contained in the current Parameter.
Definition: kratos_parameters.cpp:684
A sorted associative container similar to an STL set, but uses a vector to store pointers to its data...
Definition: pointer_vector_set.h:72
void Unique()
Remove duplicate elements from the set.
Definition: pointer_vector_set.h:764
ptr_iterator ptr_end()
Returns an iterator pointing to the end of the underlying data container.
Definition: pointer_vector_set.h:404
ptr_iterator ptr_begin()
Returns an iterator pointing to the beginning of the underlying data container.
Definition: pointer_vector_set.h:386
size_type size() const
Returns the number of elements in the container.
Definition: pointer_vector_set.h:502
void push_back(TPointerType x)
Adds a pointer to the end of the set.
Definition: pointer_vector_set.h:544
iterator begin()
Returns an iterator pointing to the beginning of the container.
Definition: pointer_vector_set.h:278
void reserve(int reservedsize)
Reserves memory for a specified number of elements.
Definition: pointer_vector_set.h:733
iterator end()
Returns an iterator pointing to the end of the container.
Definition: pointer_vector_set.h:314
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
This class provides the implementation of the basic tasks that are needed by the solution strategy.
Definition: scheme.h:56
static void AssembleRelationMatrixT(MatrixType &rT, const Matrix &rTContribution, const std::vector< std::size_t > &rSlaveEquationId, const std::vector< std::size_t > &rMasterEquationId)
Assembles the relation matrix T of the system with MPC.
Definition: trilinos_assembling_utilities.h:96
static void AssembleConstantVector(VectorType &rC, const Vector &rConstantContribution, const std::vector< std::size_t > &rSlaveEquationId)
Assembles the Constant vector of the system with MPC.
Definition: trilinos_assembling_utilities.h:150
static void SetGlobalValueWithoutGlobalAssembly(VectorType &rX, IndexType i, const double Value)
Sets a value in a vector.
Definition: trilinos_assembling_utilities.h:213
Current class provides an implementation for trilinos builder and solving operations.
Definition: trilinos_block_builder_and_solver.h:85
Parameters GetDefaultParameters() const override
This method provides the defaults parameters to avoid conflicts between the different constructors.
Definition: trilinos_block_builder_and_solver.h:1065
TrilinosBlockBuilderAndSolver(EpetraCommunicatorType &rComm, typename TLinearSolver::Pointer pNewLinearSystemSolver, Parameters ThisParameters)
Default constructor. (with parameters)
Definition: trilinos_block_builder_and_solver.h:149
typename BaseType::TSystemMatrixPointerType TSystemMatrixPointerType
Definition of the pointer types.
Definition: trilinos_block_builder_and_solver.h:122
SCALING_DIAGONAL mScalingDiagonal
The manually set scale factor.
Definition: trilinos_block_builder_and_solver.h:1192
void SystemSolveWithPhysics(TSystemMatrixType &rA, TSystemVectorType &rDx, TSystemVectorType &rb, ModelPart &rModelPart)
This is a call to the linear system solver (taking into account some physical particularities of the ...
Definition: trilinos_block_builder_and_solver.h:375
std::vector< IndexType > mMasterIds
The equation ids of the slaves.
Definition: trilinos_block_builder_and_solver.h:1187
virtual void ConstructMatrixStructure(typename TSchemeType::Pointer pScheme, TSystemMatrixPointerType &rpA, TSystemVectorPointerType &rpDx, TSystemVectorPointerType &rpb, ModelPart &rModelPart)
Constructs the matrix structure for the given problem.
Definition: trilinos_block_builder_and_solver.h:1460
void Build(typename TSchemeType::Pointer pScheme, ModelPart &rModelPart, TSystemMatrixType &rA, TSystemVectorType &rb) override
Function to perform the build the system matrix and the residual vector.
Definition: trilinos_block_builder_and_solver.h:189
double GetScaleFactor()
Retrieves the current scale factor. This function returns the current scale factor value.
Definition: trilinos_block_builder_and_solver.h:1120
void CalculateReactions(typename TSchemeType::Pointer pScheme, ModelPart &rModelPart, TSystemMatrixType &rA, TSystemVectorType &rDx, TSystemVectorType &rb) override
It computes the reactions of the system.
Definition: trilinos_block_builder_and_solver.h:784
Epetra_MpiComm EpetraCommunicatorType
Epetra definitions.
Definition: trilinos_block_builder_and_solver.h:108
typename BaseType::TSystemMatrixType TSystemMatrixType
Defining the sparse matrices and vectors.
Definition: trilinos_block_builder_and_solver.h:114
std::string Info() const override
Turn back information as a string.
Definition: trilinos_block_builder_and_solver.h:1144
EpetraCommunicatorType & mrComm
Definition: trilinos_block_builder_and_solver.h:1175
Kratos::shared_ptr< Epetra_Map > mpMap
Auxiliary Id (the last row of the local system) // TODO: This can be removed as can be deduced from m...
Definition: trilinos_block_builder_and_solver.h:1180
TrilinosBlockBuilderAndSolver(const TrilinosBlockBuilderAndSolver &rOther)=delete
void ApplyRHSConstraints(typename TSchemeType::Pointer pScheme, ModelPart &rModelPart, TSystemVectorType &rb) override
Applies the constraints with master-slave relation matrix (RHS only)
Definition: trilinos_block_builder_and_solver.h:948
void BuildLHS_CompleteOnFreeRows(typename TSchemeType::Pointer pScheme, ModelPart &rModelPart, TSystemMatrixType &A) override
Build a rectangular matrix of size n*N where "n" is the number of unrestrained degrees of freedom and...
Definition: trilinos_block_builder_and_solver.h:314
void SetScaleFactor(const double ScaleFactor)
Sets the scale factor. This function sets a new value for the scale factor.
Definition: trilinos_block_builder_and_solver.h:1130
void SetUpDofSet(typename TSchemeType::Pointer pScheme, ModelPart &rModelPart) override
Builds the list of the DofSets involved in the problem by "asking" to each element and condition its ...
Definition: trilinos_block_builder_and_solver.h:598
void ApplyConstraints(typename TSchemeType::Pointer pScheme, ModelPart &rModelPart, TSystemMatrixType &rA, TSystemVectorType &rb) override
Applies the constraints with master-slave relation matrix.
Definition: trilinos_block_builder_and_solver.h:988
void AssignSettings(const Parameters ThisParameters) override
This method assigns settings to member variables.
Definition: trilinos_block_builder_and_solver.h:1612
void Clear() override
This function is intended to be called at the end of the solution step to clean up memory storage not...
Definition: trilinos_block_builder_and_solver.h:1035
TSystemVectorPointerType mpConstantVector
This is matrix containing the global relation for the constraints.
Definition: trilinos_block_builder_and_solver.h:1185
double mScaleFactor
The set containing the inactive slave dofs.
Definition: trilinos_block_builder_and_solver.h:1189
void BuildLHS(typename TSchemeType::Pointer pScheme, ModelPart &rModelPart, TSystemMatrixType &rA) override
Function to perform the building of the LHS.
Definition: trilinos_block_builder_and_solver.h:258
Flags mOptions
We identify the scaling considered for the dirichlet dofs.
Definition: trilinos_block_builder_and_solver.h:1193
int mFirstMyId
The local system size.
Definition: trilinos_block_builder_and_solver.h:1178
void BuildRHSAndSolve(typename TSchemeType::Pointer pScheme, ModelPart &rModelPart, TSystemMatrixType &rA, TSystemVectorType &rDx, TSystemVectorType &rb) override
Corresponds to the previous, but the System's matrix is considered already built and only the RHS is ...
Definition: trilinos_block_builder_and_solver.h:507
void BuildRHS(typename TSchemeType::Pointer pScheme, ModelPart &rModelPart, TSystemVectorType &rb) override
Function to perform the build of the RHS.
Definition: trilinos_block_builder_and_solver.h:544
virtual void ConstructMasterSlaveConstraintsStructure(ModelPart &rModelPart)
Constructs the master-slave constraints structure for the given model part.
Definition: trilinos_block_builder_and_solver.h:1208
TSparseSpace::VectorType & GetConstraintConstantVector() override
This method returns constraint constant vector.
Definition: trilinos_block_builder_and_solver.h:1109
typename BaseType::LocalSystemVectorType LocalSystemVectorType
Definition: trilinos_block_builder_and_solver.h:119
virtual void BuildMasterSlaveConstraints(ModelPart &rModelPart)
Builds the master-slave constraints for the given model part.
Definition: trilinos_block_builder_and_solver.h:1352
KRATOS_DEFINE_LOCAL_FLAG(SILENT_WARNINGS)
Definition of the flags.
void InternalSystemSolveWithPhysics(TSystemMatrixType &rA, TSystemVectorType &rDx, TSystemVectorType &rb, ModelPart &rModelPart)
This is a call to the linear system solver (taking into account some physical particularities of the ...
Definition: trilinos_block_builder_and_solver.h:411
IndexType mLocalSystemSize
The guess row size.
Definition: trilinos_block_builder_and_solver.h:1177
std::vector< int > mFirstMyIds
The map considered for the different vectors and matrices.
Definition: trilinos_block_builder_and_solver.h:1181
TrilinosBlockBuilderAndSolver & operator=(const TrilinosBlockBuilderAndSolver &rOther)=delete
typename BaseType::LocalSystemMatrixType LocalSystemMatrixType
Defining the local matrices and vectors.
Definition: trilinos_block_builder_and_solver.h:118
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: trilinos_block_builder_and_solver.h:1150
TSystemMatrixPointerType mpT
The ids corresponding to each partition (only used with MPC)
Definition: trilinos_block_builder_and_solver.h:1184
TSparseSpace::MatrixType & GetConstraintRelationMatrix() override
This method returns constraint relation (T) matrix.
Definition: trilinos_block_builder_and_solver.h:1099
int mGuessRowSize
The MPI communicator.
Definition: trilinos_block_builder_and_solver.h:1176
static std::string Name()
Returns the name of the class as used in the settings (snake_case format)
Definition: trilinos_block_builder_and_solver.h:1086
int mLastMyId
Auxiliary Id (the first row of the local system)
Definition: trilinos_block_builder_and_solver.h:1179
int Check(ModelPart &rModelPart) override
This function is designed to be called once to perform all the checks needed on the input provided....
Definition: trilinos_block_builder_and_solver.h:1053
typename BaseType::DofsArrayType DofsArrayType
Definition: trilinos_block_builder_and_solver.h:105
std::vector< IndexType > mSlaveIds
This is vector containing the rigid movement of the constraint.
Definition: trilinos_block_builder_and_solver.h:1186
TrilinosBlockBuilderAndSolver(EpetraCommunicatorType &rComm, int GuessRowSize, typename TLinearSolver::Pointer pNewLinearSystemSolver)
Default constructor.
Definition: trilinos_block_builder_and_solver.h:137
void BuildAndSolve(typename TSchemeType::Pointer pScheme, ModelPart &rModelPart, TSystemMatrixType &rA, TSystemVectorType &rDx, TSystemVectorType &rb) override
Function to perform the building and solving phase at the same time.
Definition: trilinos_block_builder_and_solver.h:451
void ResizeAndInitializeVectors(typename TSchemeType::Pointer pScheme, TSystemMatrixPointerType &rpA, TSystemVectorPointerType &rpDx, TSystemVectorPointerType &rpb, ModelPart &rModelPart) override
Resizes the system matrix and the vector according to the number of dos in the current rModelPart....
Definition: trilinos_block_builder_and_solver.h:747
typename BaseType::TSystemVectorPointerType TSystemVectorPointerType
Definition: trilinos_block_builder_and_solver.h:123
void SystemSolve(TSystemMatrixType &rA, TSystemVectorType &rDx, TSystemVectorType &rb) override
This is a call to the linear system solver.
Definition: trilinos_block_builder_and_solver.h:329
void ApplyDirichletConditions(typename TSchemeType::Pointer pScheme, ModelPart &rModelPart, TSystemMatrixType &rA, TSystemVectorType &rDx, TSystemVectorType &rb) override
Applies the dirichlet conditions. This operation may be very heavy or completely unexpensive dependin...
Definition: trilinos_block_builder_and_solver.h:872
void SetUpSystem(ModelPart &rModelPart) override
Organizes the DoF set in order to speed up the building phase Sets equation id for degrees of freedom...
Definition: trilinos_block_builder_and_solver.h:680
std::size_t IndexType
Definition: trilinos_block_builder_and_solver.h:101
std::unordered_set< IndexType > mInactiveSlaveDofs
The equation ids of the master.
Definition: trilinos_block_builder_and_solver.h:1188
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: trilinos_block_builder_and_solver.h:1156
typename BaseType::TSystemVectorType TSystemVectorType
Definition: trilinos_block_builder_and_solver.h:115
KRATOS_CLASS_POINTER_DEFINITION(TrilinosBlockBuilderAndSolver)
Definition of the pointer.
TrilinosBlockBuilderAndSolver()=default
Default constructor (empty)
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
std::size_t IndexType
The definition of the index type.
Definition: key_hash.h:35
#define KRATOS_ERROR
Definition: exception.h:161
#define KRATOS_ERROR_IF_NOT(conditional)
Definition: exception.h:163
#define KRATOS_ERROR_IF(conditional)
Definition: exception.h:162
#define KRATOS_INFO_IF(label, conditional)
Definition: logger.h:251
#define KRATOS_INFO_IF_ALL_RANKS(label, conditional)
Definition: logger.h:261
#define KRATOS_WARNING(label)
Definition: logger.h:265
end
Definition: DEM_benchmarks.py:180
TSpaceType::IndexType Size1(TSpaceType &dummy, typename TSpaceType::MatrixType const &rM)
Definition: add_strategies_to_python.cpp:117
void TransposeMult(SparseSpaceType &dummy, SparseSpaceType::MatrixType &rA, SparseSpaceType::VectorType &rX, SparseSpaceType::VectorType &rY)
Definition: add_strategies_to_python.cpp:104
TSpaceType::IndexType Size2(TSpaceType &dummy, typename TSpaceType::MatrixType const &rM)
Definition: add_strategies_to_python.cpp:123
double TwoNorm(SparseSpaceType &dummy, SparseSpaceType::VectorType &x)
Definition: add_strategies_to_python.cpp:164
TSpaceType::IndexType Size(TSpaceType &dummy, typename TSpaceType::VectorType const &rV)
Definition: add_strategies_to_python.cpp:111
void Mult(TSpaceType &dummy, typename TSpaceType::MatrixType &rA, typename TSpaceType::VectorType &rX, typename TSpaceType::VectorType &rY)
Definition: add_strategies_to_python.cpp:98
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::shared_ptr< T > shared_ptr
Definition: smart_pointers.h:27
SCALING_DIAGONAL
Definition: ublas_space.h:98
@ CONSIDER_PRESCRIBED_DIAGONAL
ScaleFactor
Definition: generate_frictional_mortar_condition.py:131
int dof
Definition: ode_solve.py:393
int k
Definition: quadrature.py:595
int j
Definition: quadrature.py:648
int counter
Definition: script_THERMAL_CORRECT.py:218
A
Definition: sensitivityMatrix.py:70
integer i
Definition: TensorModule.f:17
#define STOP_TIMER(label, rank)
Definition: trilinos_block_builder_and_solver.h:39
#define START_TIMER(label, rank)
Definition: trilinos_block_builder_and_solver.h:34