62 template<
class TSparseSpaceType,
class TDenseSpaceType,
63 class TPreconditionerType = Preconditioner<TSparseSpaceType, TDenseSpaceType>,
64 class TReordererType = Reorderer<TSparseSpaceType, TDenseSpaceType> >
66 public IterativeSolver<TSparseSpaceType, TDenseSpaceType,TPreconditionerType, TReordererType>
143 static constexpr
double ZeroTolerance = std::numeric_limits<double>::epsilon();
157 const double MaxTolerance,
158 const std::size_t MaxIterationNumber
159 ) :
BaseType (MaxTolerance, MaxIterationNumber),
160 mpSolverDispBlock(pSolverDispBlock)
163 mOptions.
Set(BLOCKS_ARE_ALLOCATED,
false);
164 mOptions.
Set(IS_INITIALIZED,
false);
177 mpSolverDispBlock(pSolverDispBlock)
183 Parameters default_parameters = GetDefaultParameters();
184 ThisParameters.ValidateAndAssignDefaults(default_parameters);
187 this->
SetTolerance( ThisParameters[
"tolerance"].GetDouble() );
189 mEchoLevel = ThisParameters[
"echo_level"].GetInt();
190 mOptions.
Set(BLOCKS_ARE_ALLOCATED,
false);
191 mOptions.
Set(IS_INITIALIZED,
false);
200 mpSolverDispBlock(rOther.mpSolverDispBlock),
201 mOptions(rOther.mOptions),
202 mDisplacementDofs(rOther.mDisplacementDofs),
203 mMasterIndices(rOther.mMasterIndices),
204 mSlaveInactiveIndices(rOther.mSlaveInactiveIndices),
205 mSlaveActiveIndices(rOther.mSlaveActiveIndices),
206 mLMInactiveIndices(rOther.mLMInactiveIndices),
207 mLMActiveIndices(rOther.mLMActiveIndices),
208 mOtherIndices(rOther.mOtherIndices),
209 mGlobalToLocalIndexing(rOther.mGlobalToLocalIndexing),
210 mWhichBlockType(rOther.mWhichBlockType),
211 mKDispModified(rOther.mKDispModified),
212 mKLMAModified(rOther.mKLMAModified),
213 mKLMIModified(rOther.mKLMIModified),
216 mKSASI(rOther.mKSASI),
217 mKSASA(rOther.mKSASA),
218 mPOperator(rOther.mPOperator),
219 mCOperator(rOther.mCOperator),
220 mResidualLMActive(rOther.mResidualLMActive),
221 mResidualLMInactive(rOther.mResidualLMInactive),
222 mResidualDisp(rOther.mResidualDisp),
223 mLMActive(rOther.mLMActive),
224 mLMInactive(rOther.mLMInactive),
226 mEchoLevel(rOther.mEchoLevel),
227 mFileCreated(rOther.mFileCreated)
263 if (mOptions.
Is(BLOCKS_ARE_ALLOCATED)) {
264 mpSolverDispBlock->Initialize(mKDispModified, mDisp, mResidualDisp);
265 mOptions.
Set(IS_INITIALIZED,
true);
267 KRATOS_DETAIL(
"MixedULM Initialize") <<
"Linear solver intialization is deferred to the moment at which blocks are available" << std::endl;
286 if (mOptions.
IsNot(BLOCKS_ARE_ALLOCATED)) {
288 mOptions.
Set(BLOCKS_ARE_ALLOCATED,
true);
291 mOptions.
Set(BLOCKS_ARE_ALLOCATED,
true);
294 if(mOptions.
IsNot(IS_INITIALIZED))
297 mpSolverDispBlock->InitializeSolutionStep(mKDispModified, mDisp, mResidualDisp);
314 const SizeType lm_active_size = mLMActiveIndices.size();
315 const SizeType lm_inactive_size = mLMInactiveIndices.size();
316 const SizeType total_disp_size = mOtherIndices.size() + mMasterIndices.size() + mSlaveInactiveIndices.size() + mSlaveActiveIndices.size();
319 GetUPart (rB, mResidualDisp);
322 if (mDisp.size() != total_disp_size)
323 mDisp.resize(total_disp_size,
false);
324 mpSolverDispBlock->Solve (mKDispModified, mDisp, mResidualDisp);
330 if (lm_active_size > 0) {
332 GetLMAPart (rB, mResidualLMActive);
335 if (mLMActive.size() != lm_active_size)
336 mLMActive.resize(lm_active_size,
false);
340 SetLMAPart(rX, mLMActive);
343 if (lm_inactive_size > 0) {
345 GetLMIPart (rB, mResidualLMInactive);
348 if (mLMInactive.size() != lm_inactive_size)
349 mLMInactive.resize(lm_inactive_size,
false);
353 SetLMIPart(rX, mLMInactive);
370 mpSolverDispBlock->FinalizeSolutionStep(mKDispModified, mDisp, mResidualDisp);
379 mOptions.
Set(BLOCKS_ARE_ALLOCATED,
false);
380 mpSolverDispBlock->Clear();
383 auto& r_data_dofs = mDisplacementDofs.GetContainer();
385 delete r_data_dofs[
i];
390 mKDispModified.clear();
391 mKLMAModified.clear();
392 mKLMIModified.clear();
402 mResidualLMActive.clear();
403 mResidualLMInactive.clear();
404 mResidualDisp.clear();
410 mOptions.
Set(IS_INITIALIZED,
false);
427 if (mEchoLevel == 2) {
428 KRATOS_INFO(
"RHS BEFORE CONDENSATION") <<
"RHS = " << rB << std::endl;
429 }
else if (mEchoLevel == 3) {
430 KRATOS_INFO(
"LHS BEFORE CONDENSATION") <<
"SystemMatrix = " << rA << std::endl;
431 KRATOS_INFO(
"RHS BEFORE CONDENSATION") <<
"RHS = " << rB << std::endl;
432 }
else if (mEchoLevel >= 4) {
433 const std::string matrix_market_name =
"before_condensation_A_" + std::to_string(mFileCreated) +
".mm";
436 const std::string matrix_market_vectname =
"before_condensation_b_" + std::to_string(mFileCreated) +
".mm.rhs";
440 if (mOptions.
IsNot(IS_INITIALIZED))
450 if (mEchoLevel == 2) {
451 KRATOS_INFO(
"Dx") <<
"Solution obtained = " << mDisp << std::endl;
452 KRATOS_INFO(
"RHS") <<
"RHS = " << mResidualDisp << std::endl;
453 }
else if (mEchoLevel == 3) {
454 KRATOS_INFO(
"LHS") <<
"SystemMatrix = " << mKDispModified << std::endl;
455 KRATOS_INFO(
"Dx") <<
"Solution obtained = " << mDisp << std::endl;
456 KRATOS_INFO(
"RHS") <<
"RHS = " << mResidualDisp << std::endl;
457 }
else if (mEchoLevel >= 4) {
458 const std::string matrix_market_name =
"A_" + std::to_string(mFileCreated) +
".mm";
461 const std::string matrix_market_vectname =
"b_" + std::to_string(mFileCreated) +
".mm.rhs";
518 SizeType n_lm_inactive_dofs = 0, n_lm_active_dofs = 0;
520 SizeType n_slave_inactive_dofs = 0, n_slave_active_dofs = 0;
524 if (rModelPart.
IsNot(TO_SPLIT)) {
526 for (
auto& i_dof : rDofSet) {
529 if (i_dof.EquationId() < rA.size1()) {
531 if (IsLMDof(i_dof)) {
535 ++n_lm_inactive_dofs;
536 }
else if (
node.Is(INTERFACE) && IsDisplacementDof(i_dof)) {
537 if (
node.Is(MASTER)) {
539 }
else if (
node.Is(SLAVE)) {
541 ++n_slave_active_dofs;
543 ++n_slave_inactive_dofs;
550 for (
auto& i_dof : rDofSet) {
554 if (IsLMDof(i_dof)) {
558 ++n_lm_inactive_dofs;
559 }
else if (
node.Is(INTERFACE) && IsDisplacementDof(i_dof)) {
560 if (
node.Is(MASTER)) {
562 }
else if (
node.Is(SLAVE)) {
564 ++n_slave_active_dofs;
566 ++n_slave_inactive_dofs;
572 KRATOS_ERROR_IF(tot_active_dofs != rA.size1()) <<
"Total system size does not coincide with the free dof map: " << tot_active_dofs <<
" vs " << rA.size1() << std::endl;
575 if (mMasterIndices.size() != n_master_dofs)
576 mMasterIndices.
resize (n_master_dofs,
false);
577 if (mSlaveInactiveIndices.size() != n_slave_inactive_dofs)
578 mSlaveInactiveIndices.
resize (n_slave_inactive_dofs,
false);
579 if (mSlaveActiveIndices.size() != n_slave_active_dofs)
580 mSlaveActiveIndices.
resize (n_slave_active_dofs,
false);
581 if (mLMInactiveIndices.size() != n_lm_inactive_dofs)
582 mLMInactiveIndices.
resize (n_lm_inactive_dofs,
false);
583 if (mLMActiveIndices.size() != n_lm_active_dofs)
584 mLMActiveIndices.
resize (n_lm_active_dofs,
false);
586 const SizeType n_other_dofs = tot_active_dofs - n_lm_inactive_dofs - n_lm_active_dofs - n_master_dofs - n_slave_inactive_dofs - n_slave_active_dofs;
587 if (mOtherIndices.size() != n_other_dofs)
588 mOtherIndices.
resize (n_other_dofs,
false);
589 if (mGlobalToLocalIndexing.size() != tot_active_dofs)
590 mGlobalToLocalIndexing.
resize (tot_active_dofs,
false);
591 if (mWhichBlockType.size() != tot_active_dofs)
592 mWhichBlockType.
resize(tot_active_dofs,
false);
595 KRATOS_ERROR_IF_NOT(n_lm_active_dofs == n_slave_active_dofs) <<
"The number of active LM dofs: " << n_lm_active_dofs <<
" and active slave nodes dofs: " << n_slave_active_dofs <<
" does not coincide" << std::endl;
603 SizeType lm_inactive_counter = 0, lm_active_counter = 0;
605 SizeType slave_inactive_counter = 0, slave_active_counter = 0;
610 if (rModelPart.
IsNot(TO_SPLIT)) {
612 for (
auto& i_dof : rDofSet) {
615 if (i_dof.EquationId() < rA.size1()) {
616 if (IsLMDof(i_dof)) {
617 if (r_node.
Is(ACTIVE)) {
618 mLMActiveIndices[lm_active_counter] = global_pos;
619 mGlobalToLocalIndexing[global_pos] = lm_active_counter;
623 mLMInactiveIndices[lm_inactive_counter] = global_pos;
624 mGlobalToLocalIndexing[global_pos] = lm_inactive_counter;
626 ++lm_inactive_counter;
628 }
else if ( r_node.
Is(INTERFACE) && IsDisplacementDof(i_dof)) {
629 if (r_node.
Is(MASTER)) {
630 mMasterIndices[master_counter] = global_pos;
631 mGlobalToLocalIndexing[global_pos] = master_counter;
634 }
else if (r_node.
Is(SLAVE)) {
635 if (r_node.
Is(ACTIVE)) {
636 mSlaveActiveIndices[slave_active_counter] = global_pos;
637 mGlobalToLocalIndexing[global_pos] = slave_active_counter;
639 ++slave_active_counter;
641 mSlaveInactiveIndices[slave_inactive_counter] = global_pos;
642 mGlobalToLocalIndexing[global_pos] = slave_inactive_counter;
644 ++slave_inactive_counter;
647 mOtherIndices[other_counter] = global_pos;
648 mGlobalToLocalIndexing[global_pos] = other_counter;
653 mOtherIndices[other_counter] = global_pos;
654 mGlobalToLocalIndexing[global_pos] = other_counter;
663 for (
auto& i_dof : rDofSet) {
666 if (IsLMDof(i_dof)) {
667 if (r_node.
Is(ACTIVE)) {
668 mLMActiveIndices[lm_active_counter] = global_pos;
669 mGlobalToLocalIndexing[global_pos] = lm_active_counter;
673 mLMInactiveIndices[lm_inactive_counter] = global_pos;
674 mGlobalToLocalIndexing[global_pos] = lm_inactive_counter;
676 ++lm_inactive_counter;
678 }
else if ( r_node.
Is(INTERFACE) && IsDisplacementDof(i_dof)) {
679 if (r_node.
Is(MASTER)) {
680 mMasterIndices[master_counter] = global_pos;
681 mGlobalToLocalIndexing[global_pos] = master_counter;
684 }
else if (r_node.
Is(SLAVE)) {
685 if (r_node.
Is(ACTIVE)) {
686 mSlaveActiveIndices[slave_active_counter] = global_pos;
687 mGlobalToLocalIndexing[global_pos] = slave_active_counter;
689 ++slave_active_counter;
691 mSlaveInactiveIndices[slave_inactive_counter] = global_pos;
692 mGlobalToLocalIndexing[global_pos] = slave_inactive_counter;
694 ++slave_inactive_counter;
697 mOtherIndices[other_counter] = global_pos;
698 mGlobalToLocalIndexing[global_pos] = other_counter;
703 mOtherIndices[other_counter] = global_pos;
704 mGlobalToLocalIndexing[global_pos] = other_counter;
712 KRATOS_DEBUG_ERROR_IF(master_counter != n_master_dofs) <<
"The number of active slave dofs counter : " << master_counter <<
"is higher than the expected: " << n_master_dofs << std::endl;
713 KRATOS_DEBUG_ERROR_IF(slave_active_counter != n_slave_active_dofs) <<
"The number of active slave dofs counter : " << slave_active_counter <<
"is higher than the expected: " << n_slave_active_dofs << std::endl;
714 KRATOS_DEBUG_ERROR_IF(slave_inactive_counter != n_slave_inactive_dofs) <<
"The number of inactive slave dofs counter : " << slave_inactive_counter <<
"is higher than the expected: " << n_slave_inactive_dofs << std::endl;
715 KRATOS_DEBUG_ERROR_IF(lm_active_counter != n_lm_active_dofs) <<
"The number of active LM dofs counter : " << lm_active_counter <<
"is higher than the expected: " << n_lm_active_dofs << std::endl;
716 KRATOS_DEBUG_ERROR_IF(lm_inactive_counter != n_lm_inactive_dofs) <<
"The number of inactive LM dofs counter : " << lm_inactive_counter <<
"is higher than the expected: " << n_lm_inactive_dofs << std::endl;
717 KRATOS_DEBUG_ERROR_IF(other_counter != n_other_dofs) <<
"The number of other dofs counter : " << other_counter <<
"is higher than the expected: " << n_other_dofs << std::endl;
721 const auto it_dof_begin = rDofSet.begin();
722 mDisplacementDofs.reserve(mOtherIndices.size() + mMasterIndices.size() + mSlaveActiveIndices.size() + mSlaveInactiveIndices.size() + mLMInactiveIndices.size() + mLMActiveIndices.size());
726 for (
auto& r_index : mOtherIndices) {
727 auto it_dof = it_dof_begin + r_index;
728 auto* p_dof =
new DofType(*it_dof);
730 mDisplacementDofs.push_back(p_dof);
733 for (
auto& r_index : mMasterIndices) {
734 auto it_dof = it_dof_begin + r_index;
735 auto* p_dof =
new DofType(*it_dof);
737 mDisplacementDofs.push_back(p_dof);
740 for (
auto& r_index : mSlaveInactiveIndices) {
741 auto it_dof = it_dof_begin + r_index;
742 auto* p_dof =
new DofType(*it_dof);
744 mDisplacementDofs.push_back(p_dof);
747 for (
auto& r_index : mSlaveActiveIndices) {
748 auto it_dof = it_dof_begin + r_index;
749 auto* p_dof =
new DofType(*it_dof);
751 mDisplacementDofs.push_back(p_dof);
756 if(mpSolverDispBlock->AdditionalPhysicalDataIsNeeded() ) {
757 mpSolverDispBlock->ProvideAdditionalData(rA, rX, rB, mDisplacementDofs, rModelPart);
771 return mDisplacementDofs;
780 return mDisplacementDofs;
792 std::string
Info()
const override
794 return "Mixed displacement LM linear solver";
800 rOStream <<
"Mixed displacement LM linear solver";
849 const bool NeedAllocation,
858 const SizeType other_dof_size = mOtherIndices.size();
859 const SizeType master_size = mMasterIndices.size();
860 const SizeType slave_inactive_size = mSlaveInactiveIndices.size();
861 const SizeType slave_active_size = mSlaveActiveIndices.size();
862 const SizeType lm_active_size = mLMActiveIndices.size();
863 const SizeType lm_inactive_size = mLMInactiveIndices.size();
869 const IndexType* index1 = rA.index1_data().begin();
870 const IndexType* index2 = rA.index2_data().begin();
871 const double*
values = rA.value_data().begin();
909 const IndexType local_row_id = mGlobalToLocalIndexing[
i];
927 KRATOS_DEBUG_ERROR_IF(local_row_id > master_size) <<
"MASTER:: Local row ID: " << local_row_id <<
" is greater than the number of rows " << master_size << std::endl;
928 KMLMA_ptr[local_row_id + 1] = KMLMA_cols;
944 KRATOS_DEBUG_ERROR_IF(local_row_id > slave_active_size) <<
"SLAVE_ACTIVE:: Local row ID: " << local_row_id <<
" is greater than the number of rows " << slave_active_size << std::endl;
945 mKSAN_ptr[local_row_id + 1] = mKSAN_cols;
946 mKSAM_ptr[local_row_id + 1] = mKSAM_cols;
947 mKSASI_ptr[local_row_id + 1] = mKSASI_cols;
948 mKSASA_ptr[local_row_id + 1] = mKSASA_cols;
949 KSALMA_ptr[local_row_id + 1] = KSALMA_cols;
957 KRATOS_DEBUG_ERROR_IF(local_row_id > lm_inactive_size) <<
"LM_INACTIVE:: Local row ID: " << local_row_id <<
" is greater than the number of rows " << lm_inactive_size << std::endl;
958 KLMILMI_ptr[local_row_id + 1] = KLMILMI_cols;
966 KRATOS_DEBUG_ERROR_IF(local_row_id > lm_active_size) <<
"LM_ACTIVE:: Local row ID: " << local_row_id <<
" is greater than the number of rows " << lm_active_size << std::endl;
967 KLMALMA_ptr[local_row_id + 1] = KLMALMA_cols;
972 std::partial_sum(KMLMA_ptr, KMLMA_ptr + master_size + 1, KMLMA_ptr);
973 const std::size_t KMLMA_nonzero_values = KMLMA_ptr[master_size];
975 double* aux_val_KMLMA=
new double[KMLMA_nonzero_values];
977 std::partial_sum(mKSAN_ptr, mKSAN_ptr + slave_active_size + 1, mKSAN_ptr);
978 const std::size_t mKSAN_nonzero_values = mKSAN_ptr[slave_active_size];
980 double* aux_val_mKSAN=
new double[mKSAN_nonzero_values];
982 std::partial_sum(mKSAM_ptr, mKSAM_ptr + slave_active_size + 1, mKSAM_ptr);
983 const std::size_t mKSAM_nonzero_values = mKSAM_ptr[slave_active_size];
985 double* aux_val_mKSAM=
new double[mKSAM_nonzero_values];
987 std::partial_sum(mKSASI_ptr, mKSASI_ptr + slave_active_size + 1, mKSASI_ptr);
988 const std::size_t mKSASI_nonzero_values = mKSASI_ptr[slave_active_size];
990 double* aux_val_mKSASI=
new double[mKSASI_nonzero_values];
992 std::partial_sum(mKSASA_ptr, mKSASA_ptr + slave_active_size + 1, mKSASA_ptr);
993 const std::size_t mKSASA_nonzero_values = mKSASA_ptr[slave_active_size];
995 double* aux_val_mKSASA =
new double[mKSASA_nonzero_values];
997 std::partial_sum(KSALMA_ptr, KSALMA_ptr + slave_active_size + 1, KSALMA_ptr);
998 const std::size_t KSALMA_nonzero_values = KSALMA_ptr[slave_active_size];
1000 double* aux_val_KSALMA =
new double[KSALMA_nonzero_values];
1002 std::partial_sum(KLMILMI_ptr, KLMILMI_ptr + lm_inactive_size + 1, KLMILMI_ptr);
1003 const std::size_t KLMILMI_nonzero_values = KLMILMI_ptr[lm_inactive_size];
1005 double* aux_val_KLMILMI =
new double[KLMILMI_nonzero_values];
1007 std::partial_sum(KLMALMA_ptr, KLMALMA_ptr + lm_active_size + 1, KLMALMA_ptr);
1008 const std::size_t KLMALMA_nonzero_values = KLMALMA_ptr[lm_active_size];
1010 double* aux_val_KLMALMA =
new double[KLMALMA_nonzero_values];
1016 const IndexType local_row_id = mGlobalToLocalIndexing[
i];
1019 IndexType KMLMA_row_beg = KMLMA_ptr[local_row_id];
1020 IndexType KMLMA_row_end = KMLMA_row_beg;
1024 const double value =
values[
j];
1025 const IndexType local_col_id = mGlobalToLocalIndexing[col_index];
1026 aux_index2_KMLMA[KMLMA_row_end] = local_col_id;
1027 aux_val_KMLMA[KMLMA_row_end] = value;
1032 IndexType mKSAN_row_beg = mKSAN_ptr[local_row_id];
1033 IndexType mKSAN_row_end = mKSAN_row_beg;
1034 IndexType mKSAM_row_beg = mKSAM_ptr[local_row_id];
1035 IndexType mKSAM_row_end = mKSAM_row_beg;
1036 IndexType mKSASI_row_beg = mKSASI_ptr[local_row_id];
1037 IndexType mKSASI_row_end = mKSASI_row_beg;
1038 IndexType mKSASA_row_beg = mKSASA_ptr[local_row_id];
1039 IndexType mKSASA_row_end = mKSASA_row_beg;
1040 IndexType KSALMA_row_beg = KSALMA_ptr[local_row_id];
1041 IndexType KSALMA_row_end = KSALMA_row_beg;
1044 const double value =
values[
j];
1045 const IndexType local_col_id = mGlobalToLocalIndexing[col_index];
1047 aux_index2_mKSAN[mKSAN_row_end] = local_col_id;
1048 aux_val_mKSAN[mKSAN_row_end] = value;
1051 aux_index2_mKSAM[mKSAM_row_end] = local_col_id;
1052 aux_val_mKSAM[mKSAM_row_end] = value;
1055 aux_index2_mKSASI[mKSASI_row_end] = local_col_id;
1056 aux_val_mKSASI[mKSASI_row_end] = value;
1059 aux_index2_mKSASA[mKSASA_row_end] = local_col_id;
1060 aux_val_mKSASA[mKSASA_row_end] = value;
1063 aux_index2_KSALMA[KSALMA_row_end] = local_col_id;
1064 aux_val_KSALMA[KSALMA_row_end] = value;
1069 IndexType KLMILMI_row_beg = KLMILMI_ptr[local_row_id];
1070 IndexType KLMILMI_row_end = KLMILMI_row_beg;
1074 const double value =
values[
j];
1075 const IndexType local_col_id = mGlobalToLocalIndexing[col_index];
1076 aux_index2_KLMILMI[KLMILMI_row_end] = local_col_id;
1077 aux_val_KLMILMI[KLMILMI_row_end] = value;
1082 IndexType KLMALMA_row_beg = KLMALMA_ptr[local_row_id];
1083 IndexType KLMALMA_row_end = KLMALMA_row_beg;
1087 const double value =
values[
j];
1088 const IndexType local_col_id = mGlobalToLocalIndexing[col_index];
1089 aux_index2_KLMALMA[KLMALMA_row_end] = local_col_id;
1090 aux_val_KLMALMA[KLMALMA_row_end] = value;
1097 CreateMatrix(KMLMA, master_size, lm_active_size, KMLMA_ptr, aux_index2_KMLMA, aux_val_KMLMA);
1098 CreateMatrix(mKSAN, slave_active_size, other_dof_size, mKSAN_ptr, aux_index2_mKSAN, aux_val_mKSAN);
1099 CreateMatrix(mKSAM, slave_active_size, master_size, mKSAM_ptr, aux_index2_mKSAM, aux_val_mKSAM);
1100 CreateMatrix(mKSASI, slave_active_size, slave_inactive_size, mKSASI_ptr, aux_index2_mKSASI, aux_val_mKSASI);
1101 CreateMatrix(mKSASA, slave_active_size, slave_active_size, mKSASA_ptr, aux_index2_mKSASA, aux_val_mKSASA);
1102 CreateMatrix(KSALMA, slave_active_size, lm_active_size, KSALMA_ptr, aux_index2_KSALMA, aux_val_KSALMA);
1103 CreateMatrix(KLMILMI, lm_inactive_size, lm_inactive_size, KLMILMI_ptr, aux_index2_KLMILMI, aux_val_KLMILMI);
1104 CreateMatrix(KLMALMA, lm_active_size, lm_active_size, KLMALMA_ptr, aux_index2_KLMALMA, aux_val_KLMALMA);
1109 if (lm_active_size > 0) {
1110 ComputeDiagonalByLumping(KSALMA, mKLMAModified,
ZeroTolerance);
1116 if (lm_inactive_size > 0) {
1117 ComputeDiagonalByLumping(KLMILMI, mKLMIModified,
ZeroTolerance);
1121 if (slave_active_size > 0) {
1132 if (slave_active_size > 0) {
1135 if (slave_inactive_size > 0)
1146 if (slave_active_size > 0) {
1149 if (slave_inactive_size > 0)
1155 const SizeType other_dof_initial_index = 0;
1156 const SizeType master_dof_initial_index = other_dof_size;
1157 const SizeType slave_inactive_dof_initial_index = master_dof_initial_index + master_size;
1158 const SizeType assembling_slave_dof_initial_index = slave_inactive_dof_initial_index + slave_inactive_size;
1161 const SizeType nrows = mKDispModified.size1();
1164 K_disp_modified_ptr_aux1[0] = 0;
1168 ComputeNonZeroColumnsDispDoFs( index1, index2,
values,
i, other_dof_initial_index, K_disp_modified_ptr_aux1);
1170 ComputeNonZeroColumnsDispDoFs( index1, index2,
values,
i, master_dof_initial_index, K_disp_modified_ptr_aux1);
1172 ComputeNonZeroColumnsDispDoFs( index1, index2,
values,
i, slave_inactive_dof_initial_index, K_disp_modified_ptr_aux1);
1174 ComputeNonZeroColumnsPartialDispDoFs( index1, index2,
values,
i, assembling_slave_dof_initial_index, K_disp_modified_ptr_aux1);
1179 std::partial_sum(K_disp_modified_ptr_aux1, K_disp_modified_ptr_aux1 + nrows + 1, K_disp_modified_ptr_aux1);
1180 const SizeType nonzero_values_aux1 = K_disp_modified_ptr_aux1[nrows];
1182 double* aux_val_K_disp_modified_aux1 =
new double[nonzero_values_aux1];
1186 ComputeAuxiliaryValuesDispDoFs( index1, index2,
values,
i, other_dof_initial_index, K_disp_modified_ptr_aux1, aux_index2_K_disp_modified_aux1, aux_val_K_disp_modified_aux1);
1188 ComputeAuxiliaryValuesDispDoFs( index1, index2,
values,
i, master_dof_initial_index, K_disp_modified_ptr_aux1, aux_index2_K_disp_modified_aux1, aux_val_K_disp_modified_aux1);
1190 ComputeAuxiliaryValuesDispDoFs( index1, index2,
values,
i, slave_inactive_dof_initial_index, K_disp_modified_ptr_aux1, aux_index2_K_disp_modified_aux1, aux_val_K_disp_modified_aux1);
1192 ComputeAuxiliaryValuesPartialDispDoFs( index1, index2,
values,
i, assembling_slave_dof_initial_index, K_disp_modified_ptr_aux1, aux_index2_K_disp_modified_aux1, aux_val_K_disp_modified_aux1);
1197 CreateMatrix(mKDispModified, nrows,
ncols, K_disp_modified_ptr_aux1, aux_index2_K_disp_modified_aux1, aux_val_K_disp_modified_aux1);
1202 K_disp_modified_ptr_aux2[
i] = 0;
1206 IndexType K_disp_modified_cols_aux2 = 0;
1208 if (master_auxKSAN.nnz() > 0 && other_dof_size > 0) {
1209 SparseMatrixMultiplicationUtility::ComputeNonZeroBlocks(master_auxKSAN, i, K_disp_modified_cols_aux2);
1212 if (master_auxKSAM.nnz() > 0) {
1213 SparseMatrixMultiplicationUtility::ComputeNonZeroBlocks(master_auxKSAM, i, K_disp_modified_cols_aux2);
1216 if (master_auxKSASI.nnz() > 0 && slave_inactive_size > 0) {
1217 SparseMatrixMultiplicationUtility::ComputeNonZeroBlocks(master_auxKSASI, i, K_disp_modified_cols_aux2);
1220 if (master_auxKSASA.nnz() > 0 && slave_active_size > 0) {
1221 SparseMatrixMultiplicationUtility::ComputeNonZeroBlocks(master_auxKSASA, i, K_disp_modified_cols_aux2);
1223 K_disp_modified_ptr_aux2[master_dof_initial_index +
i + 1] = K_disp_modified_cols_aux2;
1227 IndexType K_disp_modified_cols_aux2 = 0;
1229 if (aslave_auxKSAN.nnz() > 0 && other_dof_size > 0) {
1230 SparseMatrixMultiplicationUtility::ComputeNonZeroBlocks(aslave_auxKSAN, i, K_disp_modified_cols_aux2);
1233 if (aslave_auxKSAM.nnz() > 0 && master_size > 0) {
1234 SparseMatrixMultiplicationUtility::ComputeNonZeroBlocks(aslave_auxKSAM, i, K_disp_modified_cols_aux2);
1237 if (aslave_auxKSASI.nnz() > 0 && slave_inactive_size > 0) {
1238 SparseMatrixMultiplicationUtility::ComputeNonZeroBlocks(aslave_auxKSASI, i, K_disp_modified_cols_aux2);
1241 if (aslave_auxKSASA.nnz() > 0) {
1242 SparseMatrixMultiplicationUtility::ComputeNonZeroBlocks(aslave_auxKSASA, i, K_disp_modified_cols_aux2);
1244 K_disp_modified_ptr_aux2[assembling_slave_dof_initial_index +
i + 1] = K_disp_modified_cols_aux2;
1248 std::partial_sum(K_disp_modified_ptr_aux2, K_disp_modified_ptr_aux2 + nrows + 1, K_disp_modified_ptr_aux2);
1249 const SizeType nonzero_values_aux2 = K_disp_modified_ptr_aux2[nrows];
1251 double* aux_val_K_disp_modified_aux2 =
new double[nonzero_values_aux2];
1254 const IndexType row_beg = K_disp_modified_ptr_aux2[master_dof_initial_index +
i];
1257 if (master_auxKSAN.nnz() > 0 && other_dof_size > 0) {
1258 SparseMatrixMultiplicationUtility::ComputeAuxiliarValuesBlocks(master_auxKSAN, aux_index2_K_disp_modified_aux2, aux_val_K_disp_modified_aux2, i, row_end, other_dof_initial_index);
1261 if (master_auxKSAM.nnz() > 0) {
1262 SparseMatrixMultiplicationUtility::ComputeAuxiliarValuesBlocks(master_auxKSAM, aux_index2_K_disp_modified_aux2, aux_val_K_disp_modified_aux2, i, row_end, master_dof_initial_index);
1265 if (master_auxKSASI.nnz() > 0 && slave_inactive_size > 0) {
1266 SparseMatrixMultiplicationUtility::ComputeAuxiliarValuesBlocks(master_auxKSASI, aux_index2_K_disp_modified_aux2, aux_val_K_disp_modified_aux2, i, row_end, slave_inactive_dof_initial_index);
1269 if (master_auxKSASA.nnz() > 0 && slave_active_size > 0) {
1270 SparseMatrixMultiplicationUtility::ComputeAuxiliarValuesBlocks(master_auxKSASA, aux_index2_K_disp_modified_aux2, aux_val_K_disp_modified_aux2, i, row_end, assembling_slave_dof_initial_index);
1275 const IndexType row_beg = K_disp_modified_ptr_aux2[assembling_slave_dof_initial_index +
i];
1278 if (aslave_auxKSAN.nnz() > 0 && other_dof_size > 0) {
1279 SparseMatrixMultiplicationUtility::ComputeAuxiliarValuesBlocks(aslave_auxKSAN, aux_index2_K_disp_modified_aux2, aux_val_K_disp_modified_aux2, i, row_end, other_dof_initial_index);
1282 if (aslave_auxKSAM.nnz() > 0 && master_size > 0) {
1283 SparseMatrixMultiplicationUtility::ComputeAuxiliarValuesBlocks(aslave_auxKSAM, aux_index2_K_disp_modified_aux2, aux_val_K_disp_modified_aux2, i, row_end, master_dof_initial_index);
1286 if (aslave_auxKSASI.nnz() > 0 && slave_inactive_size > 0) {
1287 SparseMatrixMultiplicationUtility::ComputeAuxiliarValuesBlocks(aslave_auxKSASI, aux_index2_K_disp_modified_aux2, aux_val_K_disp_modified_aux2, i, row_end, slave_inactive_dof_initial_index);
1290 if (aslave_auxKSASA.nnz() > 0) {
1291 SparseMatrixMultiplicationUtility::ComputeAuxiliarValuesBlocks(aslave_auxKSASA, aux_index2_K_disp_modified_aux2, aux_val_K_disp_modified_aux2, i, row_end, assembling_slave_dof_initial_index);
1297 CreateMatrix(K_disp_modified_aux2, nrows,
ncols, K_disp_modified_ptr_aux2, aux_index2_K_disp_modified_aux2, aux_val_K_disp_modified_aux2);
1300 SparseMatrixMultiplicationUtility::MatrixAdd<SparseMatrixType, SparseMatrixType>(mKDispModified, K_disp_modified_aux2, - 1.0);
1303 EnsureStructuralSymmetryMatrix(mKDispModified);
1306 CheckMatrix(mKDispModified);
1388 inline void ComputeNonZeroColumnsDispDoFs(
1391 const double* Values,
1392 const int CurrentRow,
1397 const IndexType row_begin = Index1[CurrentRow];
1398 const IndexType row_end = Index1[CurrentRow + 1];
1402 const IndexType local_row_id = mGlobalToLocalIndexing[CurrentRow] + InitialIndex;
1415 Ptr[local_row_id + 1] = cols;
1428 inline void ComputeNonZeroColumnsPartialDispDoFs(
1431 const double* Values,
1432 const int CurrentRow,
1437 const IndexType row_begin = Index1[CurrentRow];
1438 const IndexType row_end = Index1[CurrentRow + 1];
1442 const IndexType local_row_id = mGlobalToLocalIndexing[CurrentRow] + InitialIndex;
1453 Ptr[local_row_id + 1] = cols;
1467 inline void ComputeAuxiliaryValuesDispDoFs(
1470 const double* Values,
1471 const int CurrentRow,
1479 const SizeType other_dof_size = mOtherIndices.size();
1480 const SizeType master_size = mMasterIndices.size();
1481 const SizeType slave_inactive_size = mSlaveInactiveIndices.size();
1484 const SizeType other_dof_initial_index = 0;
1485 const SizeType master_dof_initial_index = other_dof_size;
1486 const SizeType slave_inactive_dof_initial_index = master_dof_initial_index + master_size;
1487 const SizeType assembling_slave_dof_initial_index = slave_inactive_dof_initial_index + slave_inactive_size;
1490 const IndexType local_row_id = mGlobalToLocalIndexing[CurrentRow] + InitialIndex;
1492 const IndexType row_begin_A = Index1[CurrentRow];
1493 const IndexType row_end_A = Index1[CurrentRow + 1];
1495 const IndexType row_beg = Ptr[local_row_id];
1500 const IndexType local_col_id = mGlobalToLocalIndexing[col_index];
1501 const double value = Values[
j];
1503 AuxIndex2[row_end] = local_col_id + other_dof_initial_index;
1504 AuxVals[row_end] = value;
1507 AuxIndex2[row_end] = local_col_id + master_dof_initial_index;
1508 AuxVals[row_end] = value;
1511 AuxIndex2[row_end] = local_col_id + slave_inactive_dof_initial_index;
1512 AuxVals[row_end] = value;
1515 AuxIndex2[row_end] = local_col_id + assembling_slave_dof_initial_index;
1516 AuxVals[row_end] = value;
1534 inline void ComputeAuxiliaryValuesPartialDispDoFs(
1537 const double* Values,
1538 const int CurrentRow,
1546 const SizeType other_dof_size = mOtherIndices.size();
1547 const SizeType master_size = mMasterIndices.size();
1548 const SizeType slave_inactive_size = mSlaveInactiveIndices.size();
1551 const SizeType master_dof_initial_index = other_dof_size;
1552 const SizeType slave_inactive_dof_initial_index = master_dof_initial_index + master_size;
1553 const SizeType assembling_slave_dof_initial_index = slave_inactive_dof_initial_index + slave_inactive_size;
1556 const IndexType local_row_id = mGlobalToLocalIndexing[CurrentRow] + InitialIndex;
1558 const IndexType row_begin_A = Index1[CurrentRow];
1559 const IndexType row_end_A = Index1[CurrentRow + 1];
1561 const IndexType row_beg = Ptr[local_row_id];
1566 const IndexType local_col_id = mGlobalToLocalIndexing[col_index];
1567 const double value = Values[
j];
1569 AuxIndex2[row_end] = local_col_id + master_dof_initial_index;
1570 AuxVals[row_end] = value;
1573 AuxIndex2[row_end] = local_col_id + slave_inactive_dof_initial_index;
1574 AuxVals[row_end] = value;
1577 AuxIndex2[row_end] = local_col_id + assembling_slave_dof_initial_index;
1578 AuxVals[row_end] = value;
1587 inline void AllocateBlocks()
1590 auto& r_data_dofs = mDisplacementDofs.GetContainer();
1592 delete r_data_dofs[
i];
1594 r_data_dofs.clear();
1597 mKDispModified.clear();
1598 mKLMAModified.clear();
1599 mKLMIModified.clear();
1609 mResidualLMActive.
clear();
1610 mResidualLMInactive.
clear();
1611 mResidualDisp.
clear();
1614 mLMInactive.
clear();
1618 const SizeType other_dof_size = mOtherIndices.size();
1619 const SizeType master_size = mMasterIndices.size();
1620 const SizeType slave_inactive_size = mSlaveInactiveIndices.size();
1621 const SizeType slave_active_size = mSlaveActiveIndices.size();
1622 const SizeType lm_active_size = mLMActiveIndices.size();
1623 const SizeType lm_inactive_size = mLMInactiveIndices.size();
1624 const SizeType total_size = other_dof_size + master_size + slave_inactive_size + slave_active_size;
1627 mKDispModified.resize(total_size, total_size,
false);
1628 mKLMAModified.resize(lm_active_size, lm_active_size,
false);
1629 mKLMAModified.reserve(lm_active_size);
1630 mKLMIModified.resize(lm_inactive_size, lm_inactive_size,
false);
1631 mKLMIModified.reserve(lm_inactive_size);
1633 mKSAN.resize(slave_active_size, other_dof_size,
false);
1634 mKSAM.resize(slave_active_size, master_size,
false);
1635 mKSASI.resize(slave_active_size, slave_inactive_size,
false);
1636 mKSASA.resize(slave_active_size, slave_active_size,
false);
1638 mPOperator.resize(master_size, slave_active_size,
false);
1639 mCOperator.resize(lm_active_size, slave_active_size,
false);
1641 mResidualLMActive.
resize(lm_active_size,
false );
1642 mResidualLMInactive.
resize(lm_inactive_size,
false );
1643 mResidualDisp.
resize(total_size );
1645 mLMActive.
resize(lm_active_size,
false);
1646 mLMInactive.
resize(lm_inactive_size,
false);
1647 mDisp.
resize(total_size,
false);
1655 inline void GetUPart (
1661 const SizeType other_dof_size = mOtherIndices.size();
1662 const SizeType master_size = mMasterIndices.size();
1663 const SizeType slave_inactive_size = mSlaveInactiveIndices.size();
1664 const SizeType slave_active_size = mSlaveActiveIndices.size();
1665 const SizeType lm_active_size = mLMActiveIndices.size();
1666 const SizeType total_size = other_dof_size + master_size + slave_inactive_size + slave_active_size;
1669 if (ResidualU.size() != total_size )
1670 ResidualU.resize (total_size,
false);
1672 IndexPartition<std::size_t>(other_dof_size).for_each([&](std::size_t
i) {
1673 ResidualU[
i] = rTotalResidual[mOtherIndices[
i]];
1677 VectorType aux_res_active_slave(slave_active_size);
1678 IndexPartition<std::size_t>(slave_active_size).for_each([&](std::size_t
i) {
1679 aux_res_active_slave[
i] = rTotalResidual[mSlaveActiveIndices[
i]];
1682 if (slave_active_size > 0) {
1684 VectorType aux_complement_master_residual(master_size);
1687 IndexPartition<std::size_t>(master_size).for_each([&](std::size_t
i) {
1688 ResidualU[other_dof_size +
i] = rTotalResidual[mMasterIndices[
i]] - aux_complement_master_residual[
i];
1691 IndexPartition<std::size_t>(master_size).for_each([&](std::size_t
i) {
1692 ResidualU[other_dof_size +
i] = rTotalResidual[mMasterIndices[
i]];
1696 IndexPartition<std::size_t>(slave_inactive_size).for_each([&](std::size_t
i) {
1697 ResidualU[other_dof_size + master_size +
i] = rTotalResidual[mSlaveInactiveIndices[
i]];
1700 if (slave_active_size > 0) {
1702 VectorType aux_complement_active_lm_residual(lm_active_size);
1705 IndexPartition<std::size_t>(lm_active_size).for_each([&](std::size_t
i) {
1706 ResidualU[other_dof_size + master_size + slave_inactive_size +
i] = rTotalResidual[mLMActiveIndices[
i]] - aux_complement_active_lm_residual[
i];
1709 IndexPartition<std::size_t>(lm_active_size).for_each([&](std::size_t
i) {
1710 ResidualU[other_dof_size + master_size + slave_inactive_size +
i] = rTotalResidual[mLMActiveIndices[
i]];
1720 inline void GetLMAPart(
1726 const SizeType other_dof_size = mOtherIndices.size();
1727 const SizeType master_size = mMasterIndices.size();
1728 const SizeType slave_inactive_size = mSlaveInactiveIndices.size();
1729 const SizeType slave_active_size = mSlaveActiveIndices.size();
1732 if (slave_active_size > 0) {
1735 if (rResidualLMA.size() != slave_active_size )
1736 rResidualLMA.resize (slave_active_size,
false);
1738 IndexPartition<std::size_t>(rResidualLMA.size()).for_each([&](std::size_t
i) {
1739 rResidualLMA[
i] = rTotalResidual[mSlaveActiveIndices[
i]];
1748 IndexPartition<std::size_t>(other_dof_size).for_each([&](std::size_t
i) {
1749 disp_N[
i] = mDisp[
i];
1752 IndexPartition<std::size_t>(master_size).for_each([&](std::size_t
i) {
1753 disp_M[
i] = mDisp[other_dof_size +
i];
1756 IndexPartition<std::size_t>(slave_inactive_size).for_each([&](std::size_t
i) {
1757 disp_SI[
i] = mDisp[other_dof_size + master_size +
i];
1760 IndexPartition<std::size_t>(slave_active_size).for_each([&](std::size_t
i) {
1761 disp_SA[
i] = mDisp[other_dof_size + master_size + slave_inactive_size +
i];
1769 if (slave_inactive_size > 0) {
1783 inline void GetLMIPart (
1789 const SizeType lm_inactive_size = mLMInactiveIndices.size();
1792 if (rResidualLMI.size() != lm_inactive_size )
1793 rResidualLMI.resize (lm_inactive_size,
false);
1795 IndexPartition<std::size_t>(lm_inactive_size).for_each([&](std::size_t
i) {
1796 rResidualLMI[
i] = rTotalResidual[mLMInactiveIndices[
i]];
1805 inline void SetUPart (
1810 const SizeType other_indexes_size = mOtherIndices.size();
1811 const SizeType master_indexes_size = mMasterIndices.size();
1812 const SizeType slave_inactive_indexes_size = mSlaveInactiveIndices.size();
1813 const SizeType slave_active_indexes_size = mSlaveActiveIndices.size();
1815 IndexPartition<std::size_t>(other_indexes_size).for_each([&](std::size_t
i) {
1816 rTotalResidual[mOtherIndices[
i]] = ResidualU[
i];
1818 IndexPartition<std::size_t>(master_indexes_size).for_each([&](std::size_t
i) {
1819 rTotalResidual[mMasterIndices[
i]] = ResidualU[other_indexes_size +
i];
1821 IndexPartition<std::size_t>(slave_inactive_indexes_size).for_each([&](std::size_t
i) {
1822 rTotalResidual[mSlaveInactiveIndices[
i]] = ResidualU[other_indexes_size + master_indexes_size +
i];
1824 IndexPartition<std::size_t>(slave_active_indexes_size).for_each([&](std::size_t
i) {
1825 rTotalResidual[mSlaveActiveIndices[
i]] = ResidualU[other_indexes_size + master_indexes_size + slave_inactive_indexes_size +
i];
1834 inline void SetLMAPart (
1839 IndexPartition<std::size_t>(ResidualLMA.size()).for_each([&](std::size_t
i) {
1840 rTotalResidual[mLMActiveIndices[
i]] = ResidualLMA[
i];
1849 inline void SetLMIPart (
1854 IndexPartition<std::size_t>(ResidualLMI.size()).for_each([&](std::size_t
i) {
1855 rTotalResidual[mLMInactiveIndices[
i]] = ResidualLMI[
i];
1866 const SizeType size_system_1 = rA.size1();
1867 const SizeType size_system_2 = rA.size2();
1870 SparseMatrixMultiplicationUtility::TransposeMatrix<SparseMatrixType, SparseMatrixType>(transpose, rA, 0.0);
1873 SparseMatrixMultiplicationUtility::MatrixAdd<SparseMatrixType, SparseMatrixType>(rA, transpose, 1.0);
1883 const std::size_t* index1 = rA.index1_data().begin();
1884 const std::size_t* index2 = rA.index2_data().begin();
1885 const double*
values = rA.value_data().begin();
1887 for (std::size_t
i=0;
i<rA.size1(); ++
i) {
1888 std::size_t row_begin = index1[
i];
1889 std::size_t row_end = index1[
i+1];
1890 if (row_end - row_begin == 0)
1891 KRATOS_WARNING(
"Checking sparse matrix") <<
"Line " <<
i <<
" has no elements" << std::endl;
1893 for (std::size_t
j=row_begin;
j<row_end;
j++) {
1894 KRATOS_ERROR_IF( index2[
j] > rA.size2() ) <<
"Array above size of A" << std::endl;
1899 return std::sqrt (norm);
1940 void ComputeDiagonalByLumping (
1947 const std::size_t size_A = rA.size1();
1974 double* aux_val =
new double[size_A];
1976 IndexPartition<std::size_t>(size_A).for_each([&](std::size_t
i) {
1979 const double value = rA(
i,
i);
1981 if (std::abs(value) > Tolerance)
1982 aux_val[
i] = 1.0/value;
1990 delete[] aux_index2;
1999 static inline bool IsDisplacementDof(
const DofType& rDoF)
2001 const auto& r_variable = rDoF.GetVariable();
2002 if (r_variable == DISPLACEMENT_X ||
2003 r_variable == DISPLACEMENT_Y ||
2004 r_variable == DISPLACEMENT_Z) {
2016 static inline bool IsLMDof(
const DofType& rDoF)
2018 const auto& r_variable = rDoF.GetVariable();
2019 if (r_variable == VECTOR_LAGRANGE_MULTIPLIER_X ||
2020 r_variable == VECTOR_LAGRANGE_MULTIPLIER_Y ||
2021 r_variable == VECTOR_LAGRANGE_MULTIPLIER_Z) {
2033 Parameters GetDefaultParameters()
2035 Parameters default_parameters( R
"(
2037 "solver_type" : "mixed_ulm_linear_solver",
2038 "tolerance" : 1.0e-6,
2039 "max_iteration_number" : 200,
2043 return default_parameters;
2062 template<
class TSparseSpaceType,
class TDenseSpaceType,
class TPreconditionerType,
class TReordererType>
2064 template<
class TSparseSpaceType,
class TDenseSpaceType,
class TPreconditionerType,
class TReordererType>
2071 template<
class TSparseSpaceType,
class TDenseSpaceType,
class TPreconditionerType,
class TReordererType>
2078 template<
class TSparseSpaceType,
class TDenseSpaceType,
class TPreconditionerType,
class TReordererType>
2083 rOStream << std::endl;
void Set(const Flags ThisFlag)
Definition: flags.cpp:33
bool Is(Flags const &rOther) const
Definition: flags.h:274
static Flags Create(IndexType ThisPosition, bool Value=true)
Definition: flags.h:138
bool IsNot(Flags const &rOther) const
Definition: flags.h:291
This class is useful for index iteration over containers.
Definition: parallel_utilities.h:451
void for_each(TUnaryFunction &&f)
Definition: parallel_utilities.h:514
Definition: amatrix_interface.h:41
void resize(std::size_t NewSize1, std::size_t NewSize2, bool preserve=0)
Definition: amatrix_interface.h:224
Base class for all the iterative solvers in Kratos.
Definition: iterative_solver.h:68
void SetTolerance(double NewTolerance) override
Definition: iterative_solver.h:305
virtual void SetMaxIterationsNumber(unsigned int NewMaxIterationsNumber)
Definition: iterative_solver.h:285
Base class for all the linear solvers in Kratos.
Definition: linear_solver.h:65
This solver is designed for the solution of mixed U-LM problems (this solver in particular is optimiz...
Definition: mixedulm_linear_solver.h:67
MixedULMLinearSolver(LinearSolverPointerType pSolverDispBlock, Parameters ThisParameters=Parameters(R"({})"))
Second constructor, it uses a Kratos parameters as input instead of direct input.
Definition: mixedulm_linear_solver.h:173
KRATOS_DEFINE_LOCAL_FLAG(IS_INITIALIZED)
The flag that indicates if the solution is initialized.
std::size_t SizeType
The size type.
Definition: mixedulm_linear_solver.h:131
~MixedULMLinearSolver() override
Destructor.
Definition: mixedulm_linear_solver.h:232
typename ModelPart::ConditionsContainerType ConditionsArrayType
An array of conditions.
Definition: mixedulm_linear_solver.h:125
static constexpr double ZeroTolerance
The zero tolerance considerered.
Definition: mixedulm_linear_solver.h:143
typename TSparseSpaceType::MatrixType SparseMatrixType
The sparse matrix type.
Definition: mixedulm_linear_solver.h:107
typename ModelPart::DofsArrayType DofsArrayType
The array containing the dofs.
Definition: mixedulm_linear_solver.h:122
MixedULMLinearSolver(LinearSolverPointerType pSolverDispBlock, const double MaxTolerance, const std::size_t MaxIterationNumber)
Default constructor.
Definition: mixedulm_linear_solver.h:155
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: mixedulm_linear_solver.h:798
typename ModelPart::NodesContainerType NodesArrayType
An array of nodes.
Definition: mixedulm_linear_solver.h:128
void PerformSolutionStep(SparseMatrixType &rA, VectorType &rX, VectorType &rB) override
This function actually performs the solution work, eventually taking advantage of what was done befor...
Definition: mixedulm_linear_solver.h:307
typename TSparseSpaceType::VectorType VectorType
The vector type.
Definition: mixedulm_linear_solver.h:110
typename TDenseSpaceType::VectorType DenseVectorType
The dense vector type.
Definition: mixedulm_linear_solver.h:116
void Clear() override
This function is designed to clean up all internal data in the solver.
Definition: mixedulm_linear_solver.h:377
BlockType
An enumeration of the different types of blocks used in the mixed Uzawa-LM linear solver.
Definition: mixedulm_linear_solver.h:76
@ OTHER
A block of another type.
@ LM_ACTIVE
An active Lagrange multiplier block.
@ LM_INACTIVE
An inactive Lagrange multiplier block.
@ SLAVE_INACTIVE
An inactive slave block.
@ SLAVE_ACTIVE
An active slave block.
const DofsArrayType & GetDisplacementDofs() const
This method retrieves the displacement DoFs of the system ordered according to the resolution order.
Definition: mixedulm_linear_solver.h:778
bool Solve(SparseMatrixType &rA, VectorType &rX, VectorType &rB) override
Normal solve method.
Definition: mixedulm_linear_solver.h:420
bool AdditionalPhysicalDataIsNeeded() override
Some solvers may require a minimum degree of knowledge of the structure of the matrix....
Definition: mixedulm_linear_solver.h:492
KRATOS_CLASS_POINTER_DEFINITION(MixedULMLinearSolver)
Pointer definition of MixedULMLinearSolver.
void ProvideAdditionalData(SparseMatrixType &rA, VectorType &rX, VectorType &rB, DofsArrayType &rDofSet, ModelPart &rModelPart) override
Some solvers may require a minimum degree of knowledge of the structure of the matrix.
Definition: mixedulm_linear_solver.h:506
DenseVector< BlockType > BlockTypeVectorType
A vector of types.
Definition: mixedulm_linear_solver.h:140
MixedULMLinearSolver & operator=(const MixedULMLinearSolver &Other)
Assignment operator.
Definition: mixedulm_linear_solver.h:239
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: mixedulm_linear_solver.h:804
KRATOS_DEFINE_LOCAL_FLAG(BLOCKS_ARE_ALLOCATED)
The flag that indicates if the blocks are allocated.
void Initialize(SparseMatrixType &rA, VectorType &rX, VectorType &rB) override
This function is designed to be called as few times as possible. It creates the data structures that ...
Definition: mixedulm_linear_solver.h:257
void FillBlockMatrices(const bool NeedAllocation, SparseMatrixType &rA, VectorType &rX, VectorType &rB)
T his function generates the subblocks of matrix A.
Definition: mixedulm_linear_solver.h:848
DofsArrayType & GetDisplacementDofs()
This method retrieves the displacement DoFs of the system ordered according to the resolution order.
Definition: mixedulm_linear_solver.h:769
typename TDenseSpaceType::MatrixType DenseMatrixType
The dense matrix type.
Definition: mixedulm_linear_solver.h:113
void InitializeSolutionStep(SparseMatrixType &rA, VectorType &rX, VectorType &rB) override
This function is designed to be called every time the coefficients change in the system that is,...
Definition: mixedulm_linear_solver.h:279
bool Solve(SparseMatrixType &rA, DenseMatrixType &rX, DenseMatrixType &rB) override
Multi solve method for solving a set of linear systems with same coefficient matrix.
Definition: mixedulm_linear_solver.h:476
std::size_t IndexType
The index type.
Definition: mixedulm_linear_solver.h:134
MixedULMLinearSolver(const MixedULMLinearSolver &rOther)
Copy constructor.
Definition: mixedulm_linear_solver.h:198
std::string Info() const override
Turn back information as a string.
Definition: mixedulm_linear_solver.h:792
typename LinearSolverType::Pointer LinearSolverPointerType
The pointer to a linear solver.
Definition: mixedulm_linear_solver.h:104
typename ModelPart::DofType DofType
The definition of the dof type.
Definition: mixedulm_linear_solver.h:119
void FinalizeSolutionStep(SparseMatrixType &rA, VectorType &rX, VectorType &rB) override
This function is designed to be called at the end of the solve step.
Definition: mixedulm_linear_solver.h:364
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
MeshType::ConditionsContainerType ConditionsContainerType
Condintions container. A vector set of Conditions with their Id's as key.
Definition: model_part.h:183
Dof< double > DofType
Definition: model_part.h:109
PointerVectorSet< DofType > DofsArrayType
Definition: model_part.h:115
MeshType::NodesContainerType NodesContainerType
Nodes container. Which is a vector set of nodes with their Id's as key.
Definition: model_part.h:128
NodeType & GetNode(IndexType NodeId, IndexType ThisIndex=0)
Definition: model_part.h:433
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
static void CreateSolutionMatrix(CMatrix &C, const TSize NRows, const TSize NCols, const Ptr *CPtr, const IndexType *AuxIndex2C, const ValueType *AuxValC)
This method is designed to create the final solution sparse matrix from the auxiliar values.
Definition: sparse_matrix_multiplication_utility.h:610
static void MatrixMultiplication(const AMatrix &rA, const BMatrix &rB, CMatrix &rC)
Matrix-matrix product C = A·B @detail This method uses a template for each matrix.
Definition: sparse_matrix_multiplication_utility.h:117
static void SortRows(const TIndexType *CPtr, const TSize NRows, const TSize NCols, Col *Columns, ValueType *Values)
This method is designed to reorder the rows by columns.
Definition: sparse_matrix_multiplication_utility.h:654
BOOST_UBLAS_INLINE void clear()
Definition: array_1d.h:325
BOOST_UBLAS_INLINE void resize(size_type array_size, bool preserve=true)
Definition: array_1d.h:242
#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_IF_NOT(conditional)
Definition: exception.h:163
#define KRATOS_ERROR_IF(conditional)
Definition: exception.h:162
#define KRATOS_DEBUG_ERROR_IF(conditional)
Definition: exception.h:171
#define KRATOS_DETAIL(label)
Definition: logger.h:280
#define KRATOS_INFO(label)
Definition: logger.h:250
#define KRATOS_WARNING(label)
Definition: logger.h:265
ncols
Definition: GenerateCN.py:97
void Mult(TSpaceType &dummy, typename TSpaceType::MatrixType &rA, typename TSpaceType::VectorType &rX, typename TSpaceType::VectorType &rY)
Definition: add_strategies_to_python.cpp:98
void UnaliasedAdd(TSpaceType &dummy, typename TSpaceType::VectorType &x, const double A, const typename TSpaceType::VectorType &rY)
Definition: add_strategies_to_python.cpp:170
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
bool WriteMatrixMarketVector(const char *FileName, VectorType &V)
Definition: matrix_market_interface.h:539
bool WriteMatrixMarketMatrix(const char *FileName, CompressedMatrixType &M, bool Symmetric)
Definition: matrix_market_interface.h:308
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
std::vector< IndexType > IndexVectorType
Index vector.
Definition: mmg_io.h:63
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
list values
Definition: bombardelli_test.py:42
int j
Definition: quadrature.py:648
int node_id
Definition: read_stl.py:12
int counter
Definition: script_THERMAL_CORRECT.py:218
integer i
Definition: TensorModule.f:17
Definition: mesh_converter.cpp:38