Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,15 @@ class ResidualBasedBlockBuilderAndSolver
// Assemble all elements
const auto timer = BuiltinTimer();

KRATOS_PREPARE_CATCH_THREAD_EXCEPTION

#pragma omp parallel firstprivate(nelements,nconditions, LHS_Contribution, RHS_Contribution, EquationId )
{
# pragma omp for schedule(guided, 512) nowait
for (int k = 0; k < nelements; k++) {
auto it_elem = el_begin + k;
for (int i = 0; i < nelements; i++) {
KRATOS_TRY

auto it_elem = el_begin + i;

if (it_elem->IsActive()) {
// Calculate elemental contribution
Expand All @@ -237,11 +241,14 @@ class ResidualBasedBlockBuilderAndSolver
Assemble(A, b, LHS_Contribution, RHS_Contribution, EquationId);
}

KRATOS_CATCH_THREAD_EXCEPTION
}

#pragma omp for schedule(guided, 512)
for (int k = 0; k < nconditions; k++) {
auto it_cond = cond_begin + k;
for (int i = 0; i < nconditions; i++) {
KRATOS_TRY

auto it_cond = cond_begin + i;

if (it_cond->IsActive()) {
// Calculate elemental contribution
Expand All @@ -250,9 +257,13 @@ class ResidualBasedBlockBuilderAndSolver
// Assemble the elemental contribution
Assemble(A, b, LHS_Contribution, RHS_Contribution, EquationId);
}
KRATOS_CATCH_THREAD_EXCEPTION

}
}

KRATOS_CHECK_AND_THROW_THREAD_EXCEPTION

KRATOS_INFO_IF("ResidualBasedBlockBuilderAndSolver", this->GetEchoLevel() >= 1) << "Build time: " << timer << std::endl;

KRATOS_INFO_IF("ResidualBasedBlockBuilderAndSolver", this->GetEchoLevel() > 2) << "Finished parallel building" << std::endl;
Expand Down Expand Up @@ -297,11 +308,15 @@ class ResidualBasedBlockBuilderAndSolver
// Assemble all elements
const auto timer = BuiltinTimer();

KRATOS_PREPARE_CATCH_THREAD_EXCEPTION

#pragma omp parallel firstprivate(nelements, nconditions, lhs_contribution, equation_id )
{
# pragma omp for schedule(guided, 512) nowait
for (int k = 0; k < nelements; ++k) {
auto it_elem = it_elem_begin + k;
for (int i = 0; i < nelements; ++i) {
KRATOS_TRY

auto it_elem = it_elem_begin + i;

// Detect if the element is active or not. If the user did not make any choice the element is active by default
if (it_elem->IsActive()) {
Expand All @@ -311,11 +326,15 @@ class ResidualBasedBlockBuilderAndSolver
// Assemble the elemental contribution
AssembleLHS(rA, lhs_contribution, equation_id);
}

KRATOS_CATCH_THREAD_EXCEPTION
}

#pragma omp for schedule(guided, 512)
for (int k = 0; k < nconditions; ++k) {
auto it_cond = it_cond_begin + k;
for (int i = 0; i < nconditions; ++i) {
KRATOS_TRY

auto it_cond = it_cond_begin + i;

// Detect if the element is active or not. If the user did not make any choice the element is active by default
if (it_cond->IsActive()) {
Expand All @@ -325,9 +344,13 @@ class ResidualBasedBlockBuilderAndSolver
// Assemble the elemental contribution
AssembleLHS(rA, lhs_contribution, equation_id);
}

KRATOS_CATCH_THREAD_EXCEPTION
}
}

KRATOS_CHECK_AND_THROW_THREAD_EXCEPTION

KRATOS_INFO_IF("ResidualBasedBlockBuilderAndSolver", this->GetEchoLevel() >= 1) << "Build time LHS: " << timer << std::endl;

KRATOS_INFO_IF("ResidualBasedBlockBuilderAndSolver", this->GetEchoLevel() > 2) << "Finished parallel building LHS" << std::endl;
Expand Down Expand Up @@ -1239,21 +1262,27 @@ class ResidualBasedBlockBuilderAndSolver

std::vector<LockObject> lock_array(indices.size());

KRATOS_PREPARE_CATCH_THREAD_EXCEPTION

#pragma omp parallel
{
Element::EquationIdVectorType slave_ids(3);
Element::EquationIdVectorType master_ids(3);
std::unordered_map<IndexType, std::unordered_set<IndexType>> temp_indices;

#pragma omp for schedule(guided, 512) nowait
for (int i_const = 0; i_const < static_cast<int>(rModelPart.MasterSlaveConstraints().size()); ++i_const) {
auto it_const = it_const_begin + i_const;
for (int i = 0; i < static_cast<int>(rModelPart.MasterSlaveConstraints().size()); ++i) {
KRATOS_TRY

auto it_const = it_const_begin + i;
it_const->EquationIdVector(slave_ids, master_ids, r_current_process_info);

// Slave DoFs
for (auto &id_i : slave_ids) {
temp_indices[id_i].insert(master_ids.begin(), master_ids.end());
}

KRATOS_CATCH_THREAD_EXCEPTION
}

// Merging all the temporal indexes
Expand All @@ -1264,6 +1293,8 @@ class ResidualBasedBlockBuilderAndSolver
}
}

KRATOS_CHECK_AND_THROW_THREAD_EXCEPTION

mSlaveIds.clear();
mMasterIds.clear();
for (int i = 0; i < static_cast<int>(indices.size()); ++i) {
Expand Down Expand Up @@ -1337,13 +1368,17 @@ class ResidualBasedBlockBuilderAndSolver
// We clear the set
mInactiveSlaveDofs.clear();

KRATOS_PREPARE_CATCH_THREAD_EXCEPTION

#pragma omp parallel firstprivate(transformation_matrix, constant_vector, slave_equation_ids, master_equation_ids)
{
std::unordered_set<IndexType> auxiliar_inactive_slave_dofs;

#pragma omp for schedule(guided, 512)
for (int i_const = 0; i_const < number_of_constraints; ++i_const) {
auto it_const = rModelPart.MasterSlaveConstraints().begin() + i_const;
for (int i = 0; i < number_of_constraints; ++i) {
KRATOS_TRY

auto it_const = rModelPart.MasterSlaveConstraints().begin() + i;
it_const->EquationIdVector(slave_equation_ids, master_equation_ids, r_current_process_info);

// If the constraint is active
Expand All @@ -1364,6 +1399,8 @@ class ResidualBasedBlockBuilderAndSolver
} else { // Taking into account inactive constraints
auxiliar_inactive_slave_dofs.insert(slave_equation_ids.begin(), slave_equation_ids.end());
}

KRATOS_CATCH_THREAD_EXCEPTION
}

// We merge all the sets in one thread
Expand All @@ -1373,6 +1410,8 @@ class ResidualBasedBlockBuilderAndSolver
}
}

KRATOS_CHECK_AND_THROW_THREAD_EXCEPTION

// Setting the master dofs into the T and C system
for (auto eq_id : mMasterIds) {
mConstantVector[eq_id] = 0.0;
Expand Down
Loading