29 #if !defined(KRATOS_EDGEBASED_LEVELSET_SUBSTEP_FLUID_SOLVER_H_INCLUDED)
30 #define KRATOS_EDGEBASED_LEVELSET_SUBSTEP_FLUID_SOLVER_H_INCLUDED
44 #include "utilities/geometry_utilities.h"
51 template <
unsigned int TDim,
class MatrixContainer,
class TSparseSpace,
class TLinearSolver>
74 double stabdt_pressure_factor,
75 double stabdt_convection_factor,
77 bool assume_constant_dp)
78 : mr_matrix_container(mr_matrix_container),
79 mr_model_part(mr_model_part),
80 mstabdt_pressure_factor(stabdt_pressure_factor),
81 mstabdt_convection_factor(stabdt_convection_factor),
82 mtau2_factor(tau2_factor),
83 massume_constant_dp(assume_constant_dp)
85 for (ModelPart::NodesContainerType::iterator it = mr_model_part.
NodesBegin(); it != mr_model_part.
NodesEnd(); it++)
86 it->FastGetSolutionStepValue(VISCOSITY) =
viscosity;
89 mdelta_t_avg = 1000.0;
93 mWallLawIsActive =
false;
96 mcorner_coefficient = 30.0;
97 medge_coefficient = 2.0;
98 std::cout <<
"Edge based level set substep solver is created" << std::endl;
112 mr_matrix_container.
SetToZero(mBodyForce);
114 mr_matrix_container.
SetToZero(mViscosity);
130 mr_matrix_container.
SetToZero(mNodalFlag);
132 mr_matrix_container.
SetToZero(mdistances);
134 mr_matrix_container.
SetToZero(mTauPressure);
135 mTauConvection.resize(
n_nodes);
136 mr_matrix_container.
SetToZero(mTauConvection);
145 mEdgeDimensions.resize(n_edges);
146 mr_matrix_container.
SetToZero(mEdgeDimensions);
151 mr_matrix_container.
SetToZero(mPiConvection);
163 mr_matrix_container.
SetToZero(mdiv_error);
164 mWallReductionFactor.resize(
n_nodes);
165 mr_matrix_container.
SetToZero(mWallReductionFactor);
166 mdiag_stiffness.resize(
n_nodes);
167 mr_matrix_container.
SetToZero(mdiag_stiffness);
184 std::vector<unsigned int> tempFixedVelocities;
185 std::vector<array_1d<double, TDim>> tempFixedVelocitiesValues;
186 std::vector<unsigned int> tempPressureOutletList;
187 std::vector<unsigned int> tempDistanceList;
188 for (ModelPart::NodesContainerType::iterator inode = mr_model_part.
NodesBegin();
192 int index = inode->FastGetSolutionStepValue(AUX_INDEX);
194 if (inode->Is(INLET))
196 tempFixedVelocities.push_back(index);
197 tempFixedVelocitiesValues.push_back(mvel_n1[index]);
200 if (inode->IsFixed(DISTANCE))
202 tempDistanceList.push_back(index);
205 if (inode->Is(OUTLET) || inode->IsFixed(PRESSURE))
207 tempPressureOutletList.push_back(index);
210 mFixedVelocities.resize(tempFixedVelocities.size(),
false);
211 mFixedVelocitiesValues.resize(tempFixedVelocitiesValues.size(),
false);
212 mPressureOutletList.resize(tempPressureOutletList.size(),
false);
213 mDistanceBoundaryList.resize(tempDistanceList.size(),
false);
214 mDistanceValuesList.resize(tempDistanceList.size(),
false);
217 mFixedVelocities[
i] = tempFixedVelocities[
i];
218 mFixedVelocitiesValues[
i] = tempFixedVelocitiesValues[
i];
222 mPressureOutletList[
i] = tempPressureOutletList[
i];
225 for (
int i = 0; i < static_cast<int>(tempDistanceList.size());
i++)
227 mDistanceBoundaryList[
i] = tempDistanceList[
i];
232 if constexpr (TDim == 3)
236 unsigned int n_nonzero_entries = 2 * n_edges +
n_nodes;
240 std::vector<int> row_partition(number_of_threads);
242 for (
int k = 0;
k < number_of_threads;
k++)
247 for (
int i_node =
static_cast<int>(row_partition[
k]); i_node < static_cast<int>(row_partition[
k + 1]); i_node++)
256 unsigned int j_neighbour = mr_matrix_container.
GetColumnIndex()[csr_index];
258 if ((
static_cast<int>(j_neighbour) > i_node) && (flag == 0))
261 mL.push_back(i_node, i_node, 0.0);
265 mL.push_back(i_node, j_neighbour, 0.0);
269 mL.push_back(i_node, i_node, 0.0);
274 CalculateEdgeLengths(mr_model_part.
Nodes());
279 for (ModelPart::NodesContainerType::iterator inode = mr_model_part.
NodesBegin();
283 temp_body_force = mRho * inode->FastGetSolutionStepValue(BODY_FORCE);
284 inode->FastGetSolutionStepValue(PRESS_PROJ) = temp_body_force;
289 for (
unsigned int i_node = 0; i_node < mHmin.size(); i_node++)
291 KRATOS_ERROR_IF(mHmin[i_node] < 1.0e-15) <<
"hmin too small on node " << i_node + 1 << std::endl;
292 KRATOS_ERROR_IF(mHmin[i_node] < 1.0e-15) <<
"hmin too small on node " << i_node + 1 << std::endl;
293 KRATOS_ERROR_IF(mHmin[i_node] > 1.0e15) <<
"hmin too big on node " << i_node + 1 << std::endl;
294 KRATOS_ERROR_IF(mHmin[i_node] > 1.0e15) <<
"havg too big on node " << i_node + 1 << std::endl;
296 for (ModelPart::ElementsContainerType::iterator it = mr_model_part.
ElementsBegin(); it != mr_model_part.
ElementsEnd(); it++)
298 KRATOS_ERROR_IF(it->Id() < 1) <<
"Element found with Id 0 or negative" << std::endl;
300 double elem_vol = 0.0;
301 if constexpr (TDim == 2)
302 elem_vol = it->GetGeometry().Area();
304 elem_vol = it->GetGeometry().Volume();
306 KRATOS_ERROR_IF(elem_vol <= 0) <<
"error on element -> " << it->Id() <<
". Area can not be lesser than 0" << std::endl;
313 mshock_coeff =
coeff;
343 int n_nodes =
static_cast<int>(mvel_n1.size());
346 Vector dt_avg_vec(n_proc, 1e10);
347 Vector dt_vec(n_proc, 1e10);
348 Vector dt_avg_novisc_vec(n_proc, 1e10);
350 #pragma omp parallel for firstprivate(n_nodes)
351 for (
int i_node = 0; i_node <
n_nodes; i_node++)
354 double &
delta_t = dt_vec[my_id];
355 double &mdelta_t_avg = dt_avg_vec[my_id];
356 double &delta_t_avg_novisc = dt_avg_novisc_vec[my_id];
359 const double havg_i = mHavg[i_node];
360 const double hmin_i = mHmin[i_node];
361 const double eps_i = mEps[i_node];
362 double nu = mViscosity[i_node];
363 double vel_norm =
norm_2(v_i);
368 double delta_t_i = 1.0 / (vel_norm / hmin_i +
nu / (hmin_i * hmin_i));
369 const double delta_t_i_avg = 1.0 / (vel_norm / havg_i +
nu / (havg_i * havg_i));
370 double delta_t_i_avg_novisc = 1.0 / (2.0 * vel_norm / havg_i);
377 unsigned int j_neighbour = mr_matrix_container.
GetColumnIndex()[csr_index];
379 double v_diff_norm = 0.0;
380 for (
unsigned int l_comp = 0; l_comp < TDim; l_comp++)
382 double temp = v_i[l_comp] - v_j[l_comp];
385 v_diff_norm = sqrt(v_diff_norm);
386 v_diff_norm /= eps_i;
387 double delta_t_j = 1.0 / (v_diff_norm / havg_i + 4.0 *
nu / (havg_i * havg_i));
388 double delta_t_j_avg_novisc = 1.0 / (2.0 * v_diff_norm / havg_i);
389 if (delta_t_j < delta_t_i)
390 delta_t_i = delta_t_j;
391 if (delta_t_j_avg_novisc < delta_t_i_avg_novisc)
392 delta_t_i_avg_novisc = delta_t_j_avg_novisc;
397 if (delta_t_i_avg < mdelta_t_avg)
398 mdelta_t_avg = delta_t_i_avg;
399 if (delta_t_i_avg_novisc < delta_t_avg_novisc)
400 delta_t_avg_novisc = delta_t_i_avg_novisc;
405 mdelta_t_avg = dt_avg_vec[0];
406 double delta_t_avg_novisc = dt_avg_novisc_vec[0];
407 for (
unsigned int i = 1;
i < dt_vec.size();
i++)
411 if (mdelta_t_avg > dt_vec[
i])
412 mdelta_t_avg = dt_avg_vec[
i];
413 if (delta_t_avg_novisc > dt_vec[
i])
414 delta_t_avg_novisc = dt_avg_novisc_vec[
i];
417 delta_t_avg_novisc *= CFLNumber;
419 mnumsubsteps = ceil(delta_t_avg_novisc /
delta_t);
421 if (mnumsubsteps <= 1)
437 if constexpr (TDim == 3)
438 ApplySmagorinsky3D(MolecularViscosity, Cs);
448 int fixed_size = mFixedVelocities.size();
450 #pragma omp parallel for firstprivate(fixed_size)
451 for (
int i_velocity = 0; i_velocity < fixed_size; i_velocity++)
453 unsigned int i_node = mFixedVelocities[i_velocity];
456 for (
unsigned int comp = 0; comp < TDim; comp++)
457 u_i_fix[comp] = u_i[comp];
482 double delta_t = CurrentProcessInfo[DELTA_TIME];
485 double time_inv_avg = 1.0 / mdelta_t_avg;
487 double stabdt_pressure_factor = mstabdt_pressure_factor;
488 double stabdt_convection_factor = mstabdt_convection_factor;
490 #pragma omp parallel for firstprivate(time_inv_avg, stabdt_pressure_factor, stabdt_convection_factor)
491 for (
int i_node = 0; i_node <
n_nodes; i_node++)
493 double &h_avg_i = mHavg[i_node];
494 double &h_min_i = mHmin[i_node];
497 const double nu_i = mViscosity[i_node];
498 const double eps_i = mEps[i_node];
499 const double lindarcy_i = mA[i_node];
500 const double nonlindarcy_i = mB[i_node];
501 double vel_norm =
norm_2(a_i);
502 double porosity_coefficient = ComputePorosityCoefficient(vel_norm, eps_i, lindarcy_i, nonlindarcy_i);
504 double tau = 1.0 / (2.0 * vel_norm / h_min_i + stabdt_pressure_factor * time_inv_avg + (4.0 * nu_i) / (h_avg_i * h_avg_i) + porosity_coefficient);
505 double tau_conv = 1.0 / (2.0 * vel_norm / h_min_i + stabdt_convection_factor * time_inv_avg);
506 mTauPressure[i_node] =
tau;
507 mTauConvection[i_node] = tau_conv;
514 for (
unsigned int l_comp = 0; l_comp < TDim; l_comp++)
518 const double &eps_i = mEps[i_node];
523 unsigned int j_neighbour = mr_matrix_container.GetColumnIndex()[csr_index];
524 array_1d<double, TDim> a_j = mvel_n1[j_neighbour];
525 const array_1d<double, TDim> &U_j = mvel_n1[j_neighbour];
526 const double &eps_j = mEps[j_neighbour];
528 CSR_Tuple &edge_ij = mr_matrix_container.GetEdgeValues()[csr_index];
529 edge_ij.Add_ConvectiveContribution(pi_i, a_i, U_i, a_j, U_j);
533 int inout_size = mInOutBoundaryList.size();
535 for (
int i = 0;
i < inout_size;
i++)
537 unsigned int i_node = mInOutBoundaryList[
i];
540 double projection_length = 0.0;
541 for (
unsigned int comp = 0; comp < TDim; comp++)
543 projection_length += U_i[comp] * an_i[comp];
548 for (
unsigned int comp = 0; comp < TDim; comp++)
549 pi_i[comp] += projection_length * U_i[comp];
556 for (
unsigned int l_comp = 0; l_comp < TDim; l_comp++)
557 pi_i[l_comp] *= m_inv;
562 double n_substeps = mnumsubsteps + 1;
563 double reduced_it = 0;
565 std::vector<int> initial_data_vector(
n_nodes);
567 auto initial_assembled_vector = block_for_each<AccumReduction<int>>(initial_data_vector, [&](
int& i_node){
569 if (mdistances[i_node] <= 0.0)
576 double energy_initial = accumulate(initial_assembled_vector.begin(), initial_assembled_vector.end(), 0);
578 while (reduced_it++ < 2)
580 double delta_t_substep =
delta_t / n_substeps;
581 for (
unsigned int substep = 0; substep < n_substeps; substep++)
589 Add_Effective_Inverse_Multiply(mWork, mWork, delta_t_substep / 6.0, mr_matrix_container.
GetLumpedMass(), mdiag_stiffness,
rhs);
590 Add_Effective_Inverse_Multiply(mvel_n1, mvel_n, 0.5 * delta_t_substep, mr_matrix_container.
GetLumpedMass(), mdiag_stiffness,
rhs);
595 Add_Effective_Inverse_Multiply(mWork, mWork, delta_t_substep / 3.0, mr_matrix_container.
GetLumpedMass(), mdiag_stiffness,
rhs);
596 Add_Effective_Inverse_Multiply(mvel_n1, mvel_n, 0.5 * delta_t_substep, mr_matrix_container.
GetLumpedMass(), mdiag_stiffness,
rhs);
601 Add_Effective_Inverse_Multiply(mWork, mWork, delta_t_substep / 3.0, mr_matrix_container.
GetLumpedMass(), mdiag_stiffness,
rhs);
602 Add_Effective_Inverse_Multiply(mvel_n1, mvel_n, delta_t_substep, mr_matrix_container.
GetLumpedMass(), mdiag_stiffness,
rhs);
607 Add_Effective_Inverse_Multiply(mWork, mWork, delta_t_substep / 6.0, mr_matrix_container.
GetLumpedMass(), mdiag_stiffness,
rhs);
615 std::vector<int> final_data_vector(
n_nodes);
617 auto final_assembled_vector = block_for_each<AccumReduction<int>>(final_data_vector, [&](
int& i_node){
619 if (mdistances[i_node] <= 0.0)
626 double energy_final = accumulate(final_assembled_vector.begin(), final_assembled_vector.end(), 0);
631 if (energy_final < 1.5 * energy_initial)
661 double inverse_rho = 1.0 / mRho;
663 #pragma omp parallel for private(stab_low, stab_high)
664 for (
int i_node = 0; i_node <
n_nodes; i_node++)
666 double dist = mdistances[i_node];
669 const double nu_i = mViscosity[i_node];
670 const double nu_j = nu_i;
676 const double &p_i =
pressure[i_node];
677 const double &eps_i = mEps[i_node];
678 const double lindarcy_i = mA[i_node];
679 const double nonlindarcy_i = mB[i_node];
680 double edge_tau = mTauConvection[i_node];
684 for (
unsigned int comp = 0; comp < TDim; comp++)
685 rhs_i[comp] = m_i * eps_i * f_i[comp];
687 double porosity_coefficient = ComputePorosityCoefficient(
norm_2(U_i), eps_i, lindarcy_i, nonlindarcy_i);
688 diag_stiffness[i_node] = m_i * porosity_coefficient;
693 unsigned int j_neighbour = mr_matrix_container.
GetColumnIndex()[csr_index];
697 const double &p_j =
pressure[j_neighbour];
698 const double &eps_j = mEps[j_neighbour];
703 edge_ij.
Sub_grad_p(rhs_i, p_i * inverse_rho * eps_i, p_j * inverse_rho * eps_i);
714 int inout_size = mInOutBoundaryList.size();
715 for (
int i = 0;
i < inout_size;
i++)
717 unsigned int i_node = mInOutBoundaryList[
i];
720 double projection_length = 0.0;
722 for (
unsigned int comp = 0; comp < TDim; comp++)
724 projection_length += U_i[comp] * an_i[comp];
725 Ain += an_i[comp] * an_i[comp];
730 for (
unsigned int comp = 0; comp < TDim; comp++)
731 rhs_i[comp] += projection_length * U_i[comp];
735 if (mWallLawIsActive ==
true)
736 ComputeWallResistance(
vel, diag_stiffness);
742 int SolveStep2(
typename TLinearSolver::Pointer pLinearSolver)
747 mis_visited[i_node] = 0;
750 int layer_counter = -1;
751 boost::numeric::ublas::vector<int> layers(mr_model_part.
Nodes().size());
752 boost::numeric::ublas::vector<int> layer_limits(3);
757 #pragma omp parallel for
758 for (
int i_node = 0; i_node < static_cast<int>(mr_model_part.
Nodes().size()); i_node++)
760 if (mdistances[i_node] < 0.0)
765 unsigned int j_neighbour = mr_matrix_container.
GetColumnIndex()[csr_index];
766 if (mdistances[j_neighbour] >= 0.0 && mis_visited[i_node] == 0)
769 layers[++layer_counter] = i_node;
771 mis_visited[i_node] = 1;
779 layer_limits[1] = layer_counter;
781 for (
unsigned int i = 0; i < static_cast<unsigned int>(layer_limits[1]);
i++)
783 unsigned int i_node = layers[
i];
787 unsigned int j_neighbour = mr_matrix_container.
GetColumnIndex()[csr_index];
788 if (mdistances[j_neighbour] >= 0.0 && mis_visited[j_neighbour] == 0)
790 layers[layer_counter++] = j_neighbour;
791 mis_visited[j_neighbour] = 2;
795 layer_limits[2] = layer_counter;
797 int return_value = 0;
800 #pragma omp parallel for
801 for (
int iii =
static_cast<int>(layer_limits[1]); iii < static_cast<int>(layer_limits[2]); iii++)
803 unsigned int i_node = layers[iii];
805 for (
unsigned int comp = 0; comp < TDim; comp++)
807 double dist_i = mdistances[i_node];
811 unsigned int j_neighbour = mr_matrix_container.
GetColumnIndex()[csr_index];
812 const double &dist_j = mdistances[j_neighbour];
818 for (
unsigned int l_comp = 0; l_comp < TDim; l_comp++)
819 grad_d[l_comp] *= m_inv;
820 double norm_grad =
norm_2(grad_d);
823 if (dist_i < 0.01 * mHavg[i_node])
825 else if (dist_i > 2.0 * mHavg[i_node])
828 dist_i = 2.0 * mHavg[i_node];
831 if (norm_grad > 0.001)
843 double pestimate =
inner_prod(press_grad, grad_d);
844 mPn1[i_node] = pestimate;
848 std::cout <<
"attention gradient of distance much greater than 1 on node:" << i_node << std::endl;
851 double avg_number = 0.0;
855 unsigned int j_neighbour = mr_matrix_container.
GetColumnIndex()[csr_index];
856 if (mis_visited[j_neighbour] == 1)
858 pavg += mPn1[j_neighbour];
863 KRATOS_ERROR_IF(avg_number == 0) <<
"can not happen that the extrapolation node has no neighbours" << std::endl;
865 mPn1[i_node] = pavg / avg_number;
880 double delta_t = CurrentProcessInfo[DELTA_TIME];
883 double &rhs_i =
rhs[i_node];
885 const double &p_i = mPn1[i_node];
886 const double &p_old_i = mPn[i_node];
894 unsigned int j_neighbour = mr_matrix_container.GetColumnIndex()[csr_index];
895 const double &p_j = mPn1[j_neighbour];
896 const double &p_old_j = mPn[j_neighbour];
897 const array_1d<double, TDim> &U_j_curr = mvel_n1[j_neighbour];
898 const array_1d<double, TDim> &xi_j = mXi[j_neighbour];
900 CSR_Tuple &edge_ij = mr_matrix_container.GetEdgeValues()[csr_index];
903 double edge_tau = 0.25 * (mTauPressure[i_node] + mTauPressure[j_neighbour]);
905 double edge_tau = 0.5 * mTauPressure[i_node];
908 if (edge_tau < delta_t)
913 edge_ij.CalculateScalarLaplacian(sum_l_ikjk);
914 double sum_l_ikjk_onlydt = sum_l_ikjk * (delta_t);
915 sum_l_ikjk *= (delta_t + edge_tau);
919 rhs_i -= sum_l_ikjk * (p_j - p_i);
920 rhs_i += sum_l_ikjk_onlydt * (p_old_j - p_old_i);
923 edge_ij.Sub_D_v(rhs_i, U_i_curr * mRho, U_j_curr * mRho);
928 edge_ij.Add_div_v(temp, xi_i, xi_j);
929 rhs_i += edge_tau * temp;
931 mL(i_node, j_neighbour) = sum_l_ikjk;
935 mL(i_node, i_node) = l_ii;
938 if (muse_mass_correction ==
true)
941 double &rhs_i =
rhs[i_node];
942 rhs_i -= mdiv_error[i_node];
946 double max_diag = 0.0;
947 for (
int i_node = 0; i_node <
n_nodes; i_node++)
949 double L_diag = mL(i_node, i_node);
950 if (std::abs(L_diag) > std::abs(max_diag))
955 for (
unsigned int i_pressure = 0; i_pressure < mPressureOutletList.size(); i_pressure++)
957 unsigned int i_node = mPressureOutletList[i_pressure];
958 mL(i_node, i_node) = max_diag;
962 unsigned int j_neighbour = mr_matrix_container.
GetColumnIndex()[csr_index];
963 mL(i_node, j_neighbour) = 0.0;
968 if (mdistances[i_node] >= 0)
970 mL(i_node, i_node) = max_diag;
974 unsigned int j_neighbour = mr_matrix_container.
GetColumnIndex()[csr_index];
975 mL(i_node, j_neighbour) = 0.0;
982 unsigned int j_neighbour = mr_matrix_container.
GetColumnIndex()[csr_index];
983 if (mdistances[j_neighbour] >= 0)
984 mL(i_node, j_neighbour) = 0.0;
991 double *Lvalues = mL.value_data().begin();
992 SizeType *Lrow_indices = mL.index1_data().begin();
993 SizeType *Lcol_indices = mL.index2_data().begin();
1000 if (
static_cast<unsigned int>(Lcol_indices[
j]) ==
k)
1002 t = fabs(Lvalues[
j]);
1006 scaling_factors[
k] = 1.0 / sqrt(
t);
1012 double k_factor = scaling_factors[
k];
1016 Lvalues[
j] *= scaling_factors[Lcol_indices[
j]] * k_factor;
1026 pLinearSolver->Solve(mL, dp,
rhs);
1030 mPn1[i_node] += dp[i_node] * scaling_factors[i_node];
1037 #pragma omp parallel for private(work_array)
1038 for (
int i_node = 0; i_node <
n_nodes; i_node++)
1041 for (
unsigned int comp = 0; comp < TDim; comp++)
1043 double dist = mdistances[i_node];
1046 const double &p_i = mPn1[i_node];
1047 for (
unsigned int csr_index = mr_matrix_container.
GetRowStartIndex()[i_node]; csr_index != mr_matrix_container.
GetRowStartIndex()[i_node + 1]; csr_index++)
1050 unsigned int j_neighbour = mr_matrix_container.
GetColumnIndex()[csr_index];
1051 const double &p_j = mPn1[j_neighbour];
1057 for (
unsigned int l_comp = 0; l_comp < TDim; l_comp++)
1058 xi_i[l_comp] *= m_inv;
1063 return return_value;
1079 double delta_t = CurrentProcessInfo[DELTA_TIME];
1081 if (massume_constant_dp ==
true)
1084 double rho_inv = 1.0 / mRho;
1086 #pragma omp parallel for private(correction) firstprivate(delta_t, rho_inv, factor)
1087 for (
int i_node = 0; i_node <
n_nodes; i_node++)
1089 double dist = mdistances[i_node];
1093 double delta_p_i = (mPn1[i_node] - mPn[i_node]) * rho_inv *
factor;
1096 for (
unsigned int l_comp = 0; l_comp < TDim; l_comp++)
1097 correction[l_comp] = 0.0;
1099 for (
unsigned int csr_index = mr_matrix_container.
GetRowStartIndex()[i_node]; csr_index != mr_matrix_container.
GetRowStartIndex()[i_node + 1]; csr_index++)
1101 unsigned int j_neighbour = mr_matrix_container.
GetColumnIndex()[csr_index];
1102 double delta_p_j = (mPn1[j_neighbour] - mPn[j_neighbour]) * rho_inv *
factor;
1104 edge_ij.
Sub_grad_p(correction, delta_p_i, delta_p_j);
1109 const double &
d = mdiag_stiffness[i_node];
1112 for (
unsigned int comp = 0; comp < TDim; comp++)
1127 for (
unsigned int l_comp = 0; l_comp < TDim; l_comp++)
1128 acc[l_comp] = (v1[l_comp] -
v[l_comp]) /
delta_t;
1133 if (muse_mass_correction ==
true)
1135 #pragma omp parallel for private(correction) firstprivate(delta_t, rho_inv)
1136 for (
int i_node = 0; i_node <
n_nodes; i_node++)
1138 const double dist = mdistances[i_node];
1139 double &div_i_err = mdiv_error[i_node];
1145 for (
unsigned int csr_index = mr_matrix_container.
GetRowStartIndex()[i_node]; csr_index != mr_matrix_container.
GetRowStartIndex()[i_node + 1]; csr_index++)
1147 unsigned int j_neighbour = mr_matrix_container.
GetColumnIndex()[csr_index];
1150 edge_ij.
Add_D_v(div_i_err, U_i_curr * mRho, U_j_curr * mRho);
1164 int size = mDistanceBoundaryList.size();
1166 #pragma omp parallel for firstprivate(size)
1167 for (
int i_dist = 0; i_dist < size; i_dist++)
1169 unsigned int i_node = mDistanceBoundaryList[i_dist];
1170 double &
dist = mdistances[i_node];
1171 dist = mDistanceValuesList[i_dist];
1181 int corner_size = mcorner_nodes.size();
1182 for (
int i = 0;
i < corner_size;
i++)
1184 int i_node = mcorner_nodes[
i];
1189 for (
unsigned int comp = 0; comp < TDim; comp++)
1193 for (
unsigned int csr_index = mr_matrix_container.
GetRowStartIndex()[i_node]; csr_index != mr_matrix_container.
GetRowStartIndex()[i_node + 1]; csr_index++)
1196 unsigned int j_neighbour = mr_matrix_container.
GetColumnIndex()[csr_index];
1197 const double &dist_j = mdistances[j_neighbour];
1200 if (dist_j <= 0 && mis_slip[j_neighbour] ==
false)
1203 for (
unsigned int comp = 0; comp < TDim; comp++)
1204 aux[comp] += vj[comp];
1209 for (
unsigned int comp = 0; comp < TDim; comp++)
1210 U_i[comp] = aux[comp] /
counter;
1214 int slip_size = mSlipBoundaryList.size();
1216 #pragma omp parallel for firstprivate(slip_size)
1217 for (
int i_slip = 0; i_slip < slip_size; i_slip++)
1219 unsigned int i_node = mSlipBoundaryList[i_slip];
1220 double dist = mdistances[i_node];
1225 double projection_length = 0.0;
1226 double normalization = 0.0;
1227 for (
unsigned int comp = 0; comp < TDim; comp++)
1229 projection_length += U_i[comp] * an_i[comp];
1230 normalization += an_i[comp] * an_i[comp];
1232 projection_length /= normalization;
1234 for (
unsigned int comp = 0; comp < TDim; comp++)
1235 U_i[comp] -= projection_length * an_i[comp];
1240 int fixed_size = mFixedVelocities.size();
1242 #pragma omp parallel for firstprivate(fixed_size)
1243 for (
int i_velocity = 0; i_velocity < fixed_size; i_velocity++)
1245 unsigned int i_node = mFixedVelocities[i_velocity];
1246 double dist = mdistances[i_node];
1251 for (
unsigned int comp = 0; comp < TDim; comp++)
1252 u_i[comp] = u_i_fix[comp];
1267 mis_visited[i_node] = 0.0;
1270 boost::numeric::ublas::vector<int> layers(mr_model_part.
Nodes().size(), -1);
1273 layer_limits[0] = 0;
1274 int layer_counter = -1;
1276 #pragma omp parallel for
1277 for (
int i_node = 0; i_node < static_cast<int>(mr_model_part.
Nodes().size()); i_node++)
1279 if (mdistances[i_node] < 0.0)
1281 for (
unsigned int csr_index = mr_matrix_container.
GetRowStartIndex()[i_node]; csr_index != mr_matrix_container.
GetRowStartIndex()[i_node + 1]; csr_index++)
1284 unsigned int j_neighbour = mr_matrix_container.
GetColumnIndex()[csr_index];
1285 if (mdistances[j_neighbour] >= 0.0 && mis_visited[i_node] == 0)
1287 #pragma omp critical
1288 layers[++layer_counter] = i_node;
1290 mis_visited[i_node] = 1;
1304 layer_limits[1] = layer_counter;
1311 for (
unsigned int iii =
static_cast<unsigned int>(layer_limits[il]); iii < static_cast<unsigned int>(layer_limits[il + 1]); iii++)
1313 unsigned int i_node = layers[iii];
1314 for (
unsigned int csr_index = mr_matrix_container.
GetRowStartIndex()[i_node]; csr_index != mr_matrix_container.
GetRowStartIndex()[i_node + 1]; csr_index++)
1316 unsigned int j_neighbour = mr_matrix_container.
GetColumnIndex()[csr_index];
1317 if (mdistances[j_neighbour] >= 0.0 && mis_visited[j_neighbour] == 0)
1319 layers[layer_counter++] = j_neighbour;
1320 mis_visited[j_neighbour] = il + 2;
1324 layer_limits[il + 2] = layer_counter;
1331 #pragma omp parallel for
1332 for (
int i = layer_limits[0];
i < layer_limits[1];
i++)
1334 unsigned int i_node = layers[
i];
1336 double avg_number = 0.0;
1338 for (
unsigned int csr_index = mr_matrix_container.
GetRowStartIndex()[i_node]; csr_index != mr_matrix_container.
GetRowStartIndex()[i_node + 1]; csr_index++)
1340 unsigned int j_neighbour = mr_matrix_container.
GetColumnIndex()[csr_index];
1341 if (mis_visited[j_neighbour] == 0)
1344 noalias(aux_proj) += inside_press_grad;
1348 if (avg_number != 0.0)
1350 aux_proj /= avg_number;
1351 noalias(mXi[i_node]) = aux_proj;
1356 noalias(xi) = mRho * mBodyForce[i_node];
1357 noalias(xi) -= mRho * macc[i_node];
1364 for (
int iii = layer_limits[il]; iii < layer_limits[il + 1]; iii++)
1367 unsigned int i_node = layers[iii];
1370 double avg_number = 0.0;
1373 for (
unsigned int csr_index = mr_matrix_container.
GetRowStartIndex()[i_node]; csr_index != mr_matrix_container.
GetRowStartIndex()[i_node + 1]; csr_index++)
1375 unsigned int j_neighbour = mr_matrix_container.
GetColumnIndex()[csr_index];
1376 if (mis_visited[j_neighbour] < (il + 1) && mis_visited[j_neighbour] != 0)
1382 double pestimate = mPn[j_neighbour] +
temp;
1384 noalias(aux_proj) += press_grad;
1385 noalias(aux) += mvel_n1[j_neighbour];
1389 if (avg_number != 0.0)
1393 aux_proj /= avg_number;
1397 KRATOS_THROW_ERROR(std::runtime_error,
"error in extrapolation:: no neighbours find on a extrapolation layer -- impossible",
"");
1399 mvel_n1[i_node] = aux;
1400 mvel_n[i_node] = aux;
1402 mXi[i_node] = aux_proj;
1409 if (mdistances[i_node] <= 0.0)
1410 mis_visited[i_node] = 1.0;
1412 mis_visited[i_node] = 0.0;
1418 #pragma omp parallel for
1419 for (
int iii =
static_cast<int>(layer_limits[il]); iii < static_cast<int>(layer_limits[il + 1]); iii++)
1421 unsigned int i_node = layers[iii];
1422 mis_visited[i_node] = 1.0;
1430 for (
int i_node = 0; i_node < mvel_n1.size(); i_node++)
1431 aux_v +=
inner_prod(mvel_n1[i_node], mvel_n1[i_node]);
1432 double aux_xi = 0.0;
1433 for (
int i_node = 0; i_node < mvel_n1.size(); i_node++)
1434 aux_xi +=
inner_prod(mXi[i_node], mXi[i_node]);
1446 for (ModelPart::NodesContainerType::iterator inode = mr_model_part.
NodesBegin();
1450 double dist = inode->FastGetSolutionStepValue(DISTANCE);
1451 inode->FastGetSolutionStepValue(DISTANCE) = -
dist;
1460 double &
dist = mdistances[i_node];
1462 mis_visited[i_node] = 1.0;
1464 mis_visited[i_node] = 0.0;
1472 for (ModelPart::NodesContainerType::iterator inode = mr_model_part.
NodesBegin();
1476 inode->FastGetSolutionStepValue(rVar, 1) = inode->FastGetSolutionStepValue(rVar);
1485 mis_visited[i_node] = 0;
1488 for (
unsigned int i_node = 0; i_node < mr_model_part.
Nodes().size(); i_node++)
1490 if (mdistances[i_node] > 0.0)
1492 mis_visited[i_node] = 1;
1493 for (
unsigned int csr_index = mr_matrix_container.
GetRowStartIndex()[i_node]; csr_index != mr_matrix_container.
GetRowStartIndex()[i_node + 1]; csr_index++)
1495 unsigned int j_neighbour = mr_matrix_container.
GetColumnIndex()[csr_index];
1496 mis_visited[j_neighbour] = 1;
1508 mis_visited[i_node] = 0;
1511 for (
unsigned int i_node = 0; i_node < mr_model_part.
Nodes().size(); i_node++)
1513 if (mdistances[i_node] <= 0.0)
1515 mis_visited[i_node] = 1;
1516 for (
unsigned int csr_index = mr_matrix_container.
GetRowStartIndex()[i_node]; csr_index != mr_matrix_container.
GetRowStartIndex()[i_node + 1]; csr_index++)
1518 unsigned int j_neighbour = mr_matrix_container.
GetColumnIndex()[csr_index];
1519 mis_visited[j_neighbour] = 1;
1531 if (mdistances[i_node] <= 0.0)
1532 mis_visited[i_node] = 1;
1534 mis_visited[i_node] = 0;
1547 if constexpr (TDim == 2)
1549 for (ModelPart::ConditionsContainerType::iterator cond_it = rConditions.begin(); cond_it != rConditions.end(); cond_it++)
1550 CalculateNormal2D(cond_it, area_normal);
1552 else if constexpr (TDim == 3)
1557 for (ModelPart::ConditionsContainerType::iterator cond_it = rConditions.begin(); cond_it != rConditions.end(); cond_it++)
1558 CalculateNormal3D(cond_it, area_normal, v1, v2);
1562 unsigned int n_nodes = mNodalFlag.size();
1565 for (
unsigned int i_node = 0; i_node <
n_nodes; i_node++)
1568 mis_slip[i_node] =
false;
1572 const double node_factor = 1.0 / TDim;
1573 for (ModelPart::ConditionsContainerType::iterator cond_it = rConditions.begin(); cond_it != rConditions.end(); cond_it++)
1580 if (
static_cast<bool>(cond_it->Is(SLIP)))
1581 for (
unsigned int if_node = 0; if_node < TDim; if_node++)
1583 unsigned int i_node =
static_cast<unsigned int>(face_geometry[if_node].FastGetSolutionStepValue(AUX_INDEX));
1585 mis_slip[i_node] =
true;
1586 for (
unsigned int comp = 0; comp < TDim; comp++)
1588 slip_normal[comp] += node_factor * face_normal[comp];
1593 std::vector<unsigned int> tempmSlipBoundaryList;
1594 for (
unsigned int i_node = 0; i_node <
n_nodes; i_node++)
1596 if (mis_slip[i_node] ==
true)
1597 tempmSlipBoundaryList.push_back(i_node);
1598 mis_slip[i_node] =
false;
1600 mSlipBoundaryList.resize(tempmSlipBoundaryList.size(),
false);
1603 mSlipBoundaryList[
i] = tempmSlipBoundaryList[
i];
1607 for (
int i = 0; i < static_cast<int>(mSlipBoundaryList.size());
i++)
1609 unsigned int i_node = mSlipBoundaryList[
i];
1610 double tmp =
norm_2(mSlipNormal[i_node]);
1612 KRATOS_ERROR_IF(
tmp < 1.0e-15) <<
"found a slip node with zero normal on node with id " << i_node + 1 << std::endl;
1616 for (ModelPart::ConditionsContainerType::iterator cond_it = rConditions.begin(); cond_it != rConditions.end(); cond_it++)
1622 bool is_inlet_or_outlet =
false;
1623 if (cond_it->IsNot(SLIP))
1624 is_inlet_or_outlet =
true;
1627 for (
unsigned int if_node = 0; if_node < TDim; if_node++)
1628 if (face_geometry[if_node].Is(INLET) || face_geometry[if_node].Is(OUTLET) || face_geometry[if_node].IsFixed(PRESSURE))
1629 is_inlet_or_outlet =
true;
1632 if (is_inlet_or_outlet)
1633 for (
unsigned int if_node = 0; if_node < TDim; if_node++)
1635 unsigned int i_node =
static_cast<unsigned int>(face_geometry[if_node].FastGetSolutionStepValue(AUX_INDEX));
1637 mis_slip[i_node] =
true;
1638 for (
unsigned int comp = 0; comp < TDim; comp++)
1640 inout_normal[comp] += node_factor * face_normal[comp];
1645 std::vector<unsigned int> tempmInOutBoundaryList;
1646 for (
unsigned int i_node = 0; i_node <
n_nodes; i_node++)
1648 if (mis_slip[i_node] ==
true)
1649 tempmInOutBoundaryList.push_back(i_node);
1651 mInOutBoundaryList.resize(tempmInOutBoundaryList.size(),
false);
1654 mInOutBoundaryList[
i] = tempmInOutBoundaryList[
i];
1659 mis_slip[
i] =
false;
1663 mis_slip[mSlipBoundaryList[
i]] =
true;
1682 mSlipNormal.clear();
1684 mFixedVelocities.clear();
1685 mFixedVelocitiesValues.clear();
1686 mPressureOutletList.clear();
1687 mSlipBoundaryList.clear();
1689 mTauPressure.clear();
1690 mTauConvection.clear();
1693 mPiConvection.clear();
1700 mWallReductionFactor.clear();
1701 mdiag_stiffness.clear();
1703 mis_visited.clear();
1717 WorkConvection.resize(
n_nodes);
1725 for (
unsigned int i = 0;
i < mDistanceValuesList.size();
i++)
1727 mDistanceValuesList[
i] = mphi_n1[mDistanceBoundaryList[
i]];
1731 for (
int i_node = 0; i_node <
n_nodes; i_node++)
1733 active_nodes[i_node] = mis_visited[i_node];
1738 double delta_t = CurrentProcessInfo[DELTA_TIME];
1739 double n_substeps = mnumsubsteps;
1741 double delta_t_substep =
delta_t / n_substeps;
1742 for (
unsigned int substep = 0; substep < n_substeps; substep++)
1747 ComputeConvectiveProjection(mPiConvection, mphi_n1, mEps, mvel_n1);
1748 ComputeLimitor(mPiConvection, mphi_n1, mBeta, mvel_n1, mEdgeDimensions);
1749 CalculateRHS_convection(mphi_n1, mvel_n1,
rhs, active_nodes);
1755 ComputeConvectiveProjection(mPiConvection, mphi_n1, mEps, mvel_n1);
1756 ComputeLimitor(mPiConvection, mphi_n1, mBeta, mvel_n1, mEdgeDimensions);
1757 CalculateRHS_convection(mphi_n1, mvel_n1,
rhs, active_nodes);
1763 ComputeConvectiveProjection(mPiConvection, mphi_n1, mEps, mvel_n1);
1764 ComputeLimitor(mPiConvection, mphi_n1, mBeta, mvel_n1, mEdgeDimensions);
1765 CalculateRHS_convection(mphi_n1, mvel_n1,
rhs, active_nodes);
1771 ComputeConvectiveProjection(mPiConvection, mphi_n1, mEps, mvel_n1);
1772 ComputeLimitor(mPiConvection, mphi_n1, mBeta, mvel_n1, mEdgeDimensions);
1773 CalculateRHS_convection(mphi_n1, mvel_n1,
rhs, active_nodes);
1782 int corner_size = mcorner_nodes.size();
1783 for (
int i = 0;
i < corner_size;
i++)
1785 int i_node = mcorner_nodes[
i];
1786 bool to_be_wettened =
true;
1787 double min_dist = 0.0;
1788 for (
unsigned int csr_index = mr_matrix_container.
GetRowStartIndex()[i_node]; csr_index != mr_matrix_container.
GetRowStartIndex()[i_node + 1]; csr_index++)
1790 unsigned int j_neighbour = mr_matrix_container.
GetColumnIndex()[csr_index];
1791 double neighb_dist = mphi_n1[j_neighbour];
1792 if (min_dist > neighb_dist)
1793 min_dist = neighb_dist;
1794 if (neighb_dist >= 0.0)
1796 to_be_wettened =
false;
1799 if (to_be_wettened ==
true)
1800 mphi_n1[i_node] = min_dist;
1816 int n_large_distance_gradient = 0;
1821 for (
int i_node = 0; i_node <
n_nodes; i_node++)
1823 double dist = mdistances[i_node];
1826 for (
unsigned int comp = 0; comp < TDim; comp++)
1828 double dist_i = mdistances[i_node];
1829 for (
unsigned int csr_index = mr_matrix_container.
GetRowStartIndex()[i_node]; csr_index != mr_matrix_container.
GetRowStartIndex()[i_node + 1]; csr_index++)
1832 unsigned int j_neighbour = mr_matrix_container.
GetColumnIndex()[csr_index];
1833 const double &dist_j = mdistances[j_neighbour];
1839 for (
unsigned int l_comp = 0; l_comp < TDim; l_comp++)
1840 grad_d[l_comp] *= m_inv;
1841 double norm_grad =
norm_2(grad_d);
1842 if (norm_grad > 1.5)
1843 n_large_distance_gradient += 1;
1846 if (n_large_distance_gradient != 0)
1848 bool success =
false;
1853 bool success =
true;
1859 mWallLawIsActive =
true;
1861 double max_angle_overall = 0.0;
1864 int slip_size = mSlipBoundaryList.size();
1866 #pragma omp parallel for firstprivate(slip_size)
1867 for (
int i_slip = 0; i_slip < slip_size; i_slip++)
1869 unsigned int i_node = mSlipBoundaryList[i_slip];
1870 mWallReductionFactor[i_node] = 1.0;
1873 std::cout <<
"max angle between normals found in the model = " << max_angle_overall << std::endl;
1875 int edge_size = medge_nodes.size();
1877 #pragma omp parallel for firstprivate(edge_size)
1878 for (
int i = 0;
i < edge_size;
i++)
1880 int i_node = medge_nodes[
i];
1881 mWallReductionFactor[i_node] = medge_coefficient;
1885 int corner_size = mcorner_nodes.size();
1886 for (
int i = 0;
i < corner_size;
i++)
1888 int i_node = mcorner_nodes[
i];
1889 mWallReductionFactor[i_node] = mcorner_coefficient;
1894 mWallLawIsActive =
true;
1896 for (
unsigned int i = 0;
i < mWallReductionFactor.size();
i++)
1897 mWallReductionFactor[
i] = 1.0;
1902 double dt = CurrentProcessInfo[DELTA_TIME];
1904 int inout_size = mInOutBoundaryList.size();
1905 double vol_var = 0.0;
1907 for (
int i = 0;
i < inout_size;
i++)
1909 unsigned int i_node = mInOutBoundaryList[
i];
1910 double dist = mdistances[i_node];
1915 double projection_length = 0.0;
1916 for (
unsigned int comp = 0; comp < TDim; comp++)
1918 projection_length += U_i[comp] * an_i[comp];
1920 vol_var += projection_length;
1923 return -vol_var *
dt;
1930 double wet_volume = 0.0;
1932 for (
int i = 0; i < static_cast<int>(mdistances.size());
i++)
1934 double dist = mdistances[
i];
1952 for (
int i = 0; i < static_cast<int>(mdistances.size());
i++)
1963 double volume_error = expected_volume - measured_volume;
1964 if (measured_volume < expected_volume)
1966 double layer_volume = 0.0;
1967 std::vector<unsigned int> first_outside;
1968 int n_nodes = mdistances.size();
1970 for (
int i_node = 0; i_node <
n_nodes; i_node++)
1972 double dist = mdistances[i_node];
1975 for (
unsigned int csr_index = mr_matrix_container.
GetRowStartIndex()[i_node]; csr_index != mr_matrix_container.
GetRowStartIndex()[i_node + 1]; csr_index++)
1977 unsigned int j_neighbour = mr_matrix_container.
GetColumnIndex()[csr_index];
1978 if (mdistances[j_neighbour] <= 0.0)
1980 const double nodal_mass = 1.0 / mr_matrix_container.
GetInvertedMass()[i_node];
1981 if (nodal_mass < volume_error - layer_volume)
1983 first_outside.push_back(i_node);
1984 layer_volume += nodal_mass;
1993 for (
unsigned int i = 0;
i < first_outside.size();
i++)
1995 unsigned int i_node = first_outside[
i];
1996 mdistances[i_node] = -mHavg[i_node];
2004 mcorner_coefficient = corner_coefficient;
2005 medge_coefficient = edge_coefficient;
2009 double volume_error = expected_volume - measured_volume;
2010 if (volume_error == 0.0)
2012 if (measured_volume < expected_volume)
2014 double layer_volume = 0.0;
2015 std::vector<unsigned int> first_outside;
2016 int n_nodes = mdistances.size();
2018 for (
int i_node = 0; i_node <
n_nodes; i_node++)
2020 double dist = mdistances[i_node];
2021 bool is_bubble =
true;
2022 bool is_first_outside =
false;
2025 for (
unsigned int csr_index = mr_matrix_container.
GetRowStartIndex()[i_node]; csr_index != mr_matrix_container.
GetRowStartIndex()[i_node + 1]; csr_index++)
2027 unsigned int j_neighbour = mr_matrix_container.
GetColumnIndex()[csr_index];
2028 if (mdistances[j_neighbour] <= 0.0)
2030 is_first_outside =
true;
2036 if (is_first_outside && !is_bubble)
2038 const double nodal_mass = 1.0 / mr_matrix_container.
GetInvertedMass()[i_node];
2039 first_outside.push_back(i_node);
2040 layer_volume += nodal_mass;
2043 if (layer_volume == 0.00)
2045 double ratio = volume_error / layer_volume;
2050 double average_layer_h = 0.0;
2051 for (
unsigned int i = 0;
i < first_outside.size();
i++)
2053 unsigned int i_node = first_outside[
i];
2054 average_layer_h += mHavg[i_node];
2056 average_layer_h /=
static_cast<double>(first_outside.size());
2057 for (
int i_node = 0; i_node <
n_nodes; i_node++)
2058 mdistances[i_node] -= average_layer_h * ratio;
2070 for (ModelPart::NodesContainerType::iterator inode = mr_model_part.
NodesBegin();
2074 const double eps = inode->FastGetSolutionStepValue(POROSITY);
2075 const double d = inode->FastGetSolutionStepValue(DIAMETER);
2076 double &
a = inode->FastGetSolutionStepValue(LIN_DARCY_COEF);
2077 double &
b = inode->FastGetSolutionStepValue(NONLIN_DARCY_COEF);
2080 double k_inv = 150.0 * (1.0 - eps) * (1.0 - eps) / (eps * eps * eps *
d *
d);
2081 a = mViscosity * k_inv;
2082 b = (1.75 / eps) * sqrt(k_inv / (150.0 * eps));
2094 for (ModelPart::NodesContainerType::iterator inode = mr_model_part.
NodesBegin();
2098 const double eps = inode->FastGetSolutionStepValue(POROSITY);
2099 double &
a = inode->FastGetSolutionStepValue(LIN_DARCY_COEF);
2100 double &
b = inode->FastGetSolutionStepValue(NONLIN_DARCY_COEF);
2113 double mcorner_coefficient;
2114 double medge_coefficient;
2119 bool muse_mass_correction;
2121 bool mWallLawIsActive;
2124 double mstabdt_pressure_factor;
2125 double mstabdt_convection_factor;
2126 double mtau2_factor;
2127 bool massume_constant_dp;
2152 IndicesVectorType mSlipBoundaryList, mPressureOutletList, mFixedVelocities, mInOutBoundaryList, mDistanceBoundaryList;
2161 boost::numeric::ublas::vector<bool> mis_slip;
2162 boost::numeric::ublas::vector<int> mis_visited;
2182 double mdelta_t_avg;
2184 double mshock_coeff;
2187 void CalculateNormal2D(ModelPart::ConditionsContainerType::iterator cond_it,
array_1d<double, 3> &area_normal)
2190 area_normal[0] = face_geometry[1].Y() - face_geometry[0].Y();
2191 area_normal[1] = -(face_geometry[1].X() - face_geometry[0].X());
2192 area_normal[2] = 0.00;
2195 void CalculateNormal3D(ModelPart::ConditionsContainerType::iterator cond_it, array_1d<double, 3> &area_normal, array_1d<double, 3> &v1, array_1d<double, 3> &v2)
2197 Geometry<Node> &face_geometry = (cond_it)->GetGeometry();
2199 v1[0] = face_geometry[1].X() - face_geometry[0].X();
2200 v1[1] = face_geometry[1].Y() - face_geometry[0].Y();
2201 v1[2] = face_geometry[1].Z() - face_geometry[0].Z();
2203 v2[0] = face_geometry[2].X() - face_geometry[0].X();
2204 v2[1] = face_geometry[2].Y() - face_geometry[0].Y();
2205 v2[2] = face_geometry[2].Z() - face_geometry[0].Z();
2208 area_normal *= -0.5;
2218 unsigned int n_nodes = rNodes.size();
2220 std::vector<array_1d<double, TDim>> position;
2223 for (
typename ModelPart::NodesContainerType::iterator node_it = rNodes.begin(); node_it != rNodes.end(); node_it++)
2226 unsigned int i_node =
static_cast<unsigned int>(node_it->FastGetSolutionStepValue(AUX_INDEX));
2228 noalias(position[i_node]) = node_it->Coordinates();
2231 for (
unsigned int i_node = 0; i_node <
n_nodes; i_node++)
2233 mHmin[i_node] = aaa[i_node];
2235 KRATOS_ERROR_IF(aaa[i_node] == 0.0) <<
"found a 0 hmin on node " << i_node << std::endl;
2238 if constexpr (TDim == 2)
2240 for (
unsigned int i_node = 0; i_node <
n_nodes; i_node++)
2242 double &h_i = mHavg[i_node];
2244 h_i = sqrt(2.0 * m_i);
2247 else if constexpr (TDim == 3)
2249 for (
unsigned int i_node = 0; i_node <
n_nodes; i_node++)
2251 double &h_i = mHavg[i_node];
2253 h_i = pow(6.0 * m_i, 1.0 / 3.0);
2257 for (
unsigned int i_node = 0; i_node <
n_nodes; i_node++)
2259 array_1d<double, TDim> &pos_i = position[i_node];
2260 for (
unsigned int csr_index = mr_matrix_container.
GetRowStartIndex()[i_node]; csr_index != mr_matrix_container.
GetRowStartIndex()[i_node + 1]; csr_index++)
2262 unsigned int j_neighbour = mr_matrix_container.
GetColumnIndex()[csr_index];
2263 array_1d<double, TDim> &pos_j = position[j_neighbour];
2264 array_1d<double, TDim> &l_k = mEdgeDimensions[csr_index];
2265 for (
unsigned int comp = 0; comp < TDim; comp++)
2266 l_k[comp] = pos_i[comp] - pos_j[comp];
2273 void CalculateRHS_convection(
2285 array_1d<double, TDim> a_i;
2286 array_1d<double, TDim> a_j;
2288 #pragma omp parallel for private(stab_low, stab_high, a_i, a_j)
2289 for (
int i_node = 0; i_node <
n_nodes; i_node++)
2291 double &rhs_i =
rhs[i_node];
2292 const double &h_i = mHavg[i_node];
2293 const double &phi_i = mphi[i_node];
2294 noalias(a_i) = convective_velocity[i_node];
2295 a_i /= mEps[i_node];
2296 const array_1d<double, TDim> &proj_i = mPiConvection[i_node];
2297 double pi_i = proj_i[0] * a_i[0];
2298 for (
unsigned int l_comp = 1; l_comp < TDim; l_comp++)
2299 pi_i += proj_i[l_comp] * a_i[l_comp];
2301 if (active_nodes[i_node] != 0.0)
2303 const double &beta = mBeta[i_node];
2304 double norm_a = a_i[0] * a_i[0];
2305 for (
unsigned int l_comp = 1; l_comp < TDim; l_comp++)
2306 norm_a += a_i[l_comp] * a_i[l_comp];
2307 norm_a = sqrt(norm_a);
2309 for (
unsigned int csr_index = mr_matrix_container.
GetRowStartIndex()[i_node]; csr_index != mr_matrix_container.
GetRowStartIndex()[i_node + 1]; csr_index++)
2311 unsigned int j_neighbour = mr_matrix_container.
GetColumnIndex()[csr_index];
2312 if (active_nodes[j_neighbour] != 0.0)
2315 const double &phi_j = mphi[j_neighbour];
2316 noalias(a_j) = convective_velocity[j_neighbour];
2317 a_j /= mEps[j_neighbour];
2318 const array_1d<double, TDim> &proj_j = mPiConvection[j_neighbour];
2319 double pi_j = proj_j[0] * a_i[0];
2320 for (
unsigned int l_comp = 1; l_comp < TDim; l_comp++)
2321 pi_j += proj_j[l_comp] * a_i[l_comp];
2324 edge_ij.Sub_ConvectiveContribution(rhs_i, a_i, phi_i, a_j, phi_j);
2326 edge_ij.CalculateConvectionStabilization_LOW(stab_low, a_i, phi_i, a_j, phi_j);
2327 double edge_tau = mTauConvection[i_node];
2328 edge_ij.CalculateConvectionStabilization_HIGH(stab_high, a_i, pi_i, a_j, pi_j);
2329 edge_ij.Sub_StabContribution(rhs_i, edge_tau, 1.0, stab_low, stab_high);
2330 double coeff = 0.5 * mshock_coeff;
2331 double laplacian_ij = 0.0;
2332 edge_ij.CalculateScalarLaplacian(laplacian_ij);
2333 double capturing = laplacian_ij * (phi_j - phi_i);
2335 for (
unsigned int k_comp = 0; k_comp < TDim; k_comp++)
2336 for (
unsigned int m_comp = 0; m_comp < TDim; m_comp++)
2337 aaa += a_i[k_comp] * a_i[m_comp] * edge_ij.LaplacianIJ(k_comp, m_comp);
2340 aaa /= (norm_a * norm_a);
2341 double capturing2 = aaa * (phi_j - phi_i);
2342 if (fabs(capturing) > fabs(capturing2))
2343 rhs_i -=
coeff * (capturing - capturing2) * beta * norm_a * h_i;
2354 void CornerDectectionHelper(Geometry<Node> &face_geometry,
2355 const array_1d<double, 3> &face_normal,
2357 const GlobalPointersVector<Condition> &neighb,
2358 const unsigned int i1,
2359 const unsigned int i2,
2360 const unsigned int neighb_index,
2361 std::vector<unsigned int> &edge_nodes,
2364 double acceptable_angle = 45.0 / 180.0 * 3.1;
2365 double acceptable_cos = cos(acceptable_angle);
2366 if (face_geometry[i1].Id() < face_geometry[i2].Id())
2368 const array_1d<double, 3> &neighb_normal = neighb[neighb_index].GetValue(NORMAL);
2369 double neighb_An =
norm_2(neighb_normal);
2370 double cos_normal = 1.0 / (An * neighb_An) *
inner_prod(face_normal, neighb_normal);
2372 if (cos_normal < acceptable_cos)
2374 array_1d<double, 3> edge = face_geometry[i2].Coordinates() - face_geometry[i1].Coordinates();
2377 int index1 = face_geometry[i1].FastGetSolutionStepValue(AUX_INDEX);
2378 int index2 = face_geometry[i2].FastGetSolutionStepValue(AUX_INDEX);
2379 edge_nodes[index1] += 1;
2380 edge_nodes[index2] += 1;
2383 for (
unsigned int i = 0;
i < edge.size();
i++)
2385 sign1 += cornern_list[index1][
i] * edge[
i];
2390 for (
unsigned int i = 0;
i < edge.size();
i++)
2391 cornern_list[index1][
i] += edge[
i];
2395 for (
unsigned int i = 0;
i < edge.size();
i++)
2396 cornern_list[index1][
i] -= edge[
i];
2399 double sign2 =
inner_prod(cornern_list[index2], edge);
2402 for (
unsigned int i = 0;
i < edge.size();
i++)
2403 cornern_list[index2][
i] += edge[
i];
2407 for (
unsigned int i = 0;
i < edge.size();
i++)
2408 cornern_list[index2][
i] -= edge[
i];
2418 array_1d<double, 3> area_normal;
2420 unsigned int n_nodes = mNodalFlag.size();
2421 std::vector<unsigned int> temp_edge_nodes(
n_nodes);
2423 for (
unsigned int i_node = 0; i_node <
n_nodes; i_node++)
2425 temp_edge_nodes[i_node] = 0.0;
2429 for (ModelPart::ConditionsContainerType::iterator cond_it = rConditions.begin(); cond_it != rConditions.end(); cond_it++)
2432 Geometry<Node> &face_geometry = cond_it->GetGeometry();
2434 const array_1d<double, 3> &face_normal = cond_it->GetValue(NORMAL);
2435 double An =
norm_2(face_normal);
2438 if (cond_it->Is(SLIP))
2440 const GlobalPointersVector<Condition> &neighb = cond_it->GetValue(NEIGHBOUR_CONDITIONS);
2443 CornerDectectionHelper(face_geometry, face_normal, An, neighb, 1, 2, 0, temp_edge_nodes, temp_cornern_list);
2446 CornerDectectionHelper(face_geometry, face_normal, An, neighb, 2, 0, 1, temp_edge_nodes, temp_cornern_list);
2449 CornerDectectionHelper(face_geometry, face_normal, An, neighb, 0, 1, 2, temp_edge_nodes, temp_cornern_list);
2454 std::vector<unsigned int> tempmedge_nodes;
2455 std::vector<array_1d<double, TDim>> tempmedge_nodes_direction;
2456 std::vector<unsigned int> tempmcorner_nodes;
2457 for (
unsigned int i_node = 0; i_node <
n_nodes; i_node++)
2459 if (temp_edge_nodes[i_node] == 2)
2461 tempmedge_nodes.push_back(i_node);
2462 array_1d<double, TDim> &node_edge = temp_cornern_list[i_node];
2463 node_edge /=
norm_2(node_edge);
2464 tempmedge_nodes_direction.push_back(node_edge);
2466 else if (temp_edge_nodes[i_node] > 2)
2467 tempmcorner_nodes.push_back(i_node);
2469 medge_nodes.resize(tempmedge_nodes.size(),
false);
2470 medge_nodes_direction.resize(tempmedge_nodes_direction.size(),
false);
2471 mcorner_nodes.resize(tempmcorner_nodes.size(),
false);
2473 IndexPartition<unsigned int>(tempmedge_nodes.size()).for_each([&](
unsigned int i){
2474 medge_nodes[
i] = tempmedge_nodes[
i];
2475 medge_nodes_direction[
i] = tempmedge_nodes_direction[
i];
2478 IndexPartition<unsigned int>(tempmcorner_nodes.size()).for_each([&](
unsigned int i){
2479 mcorner_nodes[
i] = tempmcorner_nodes[
i];
2482 for (
unsigned int i = 0;
i < mcorner_nodes.size();
i++)
2489 double ComputePorosityCoefficient(
const double &vel_norm,
const double &eps,
const double &
a,
const double &
b)
2494 non_linear = eps *
b * vel_norm;
2495 return linear + non_linear;
2502 IndexPartition<unsigned int>(
n_nodes).for_each([&](
unsigned int i_node){
2503 double dist = mdistances[i_node];
2504 double correction = 0.0;
2505 const double &origin_i = to_be_smoothed[i_node];
2508 for (
unsigned int csr_index = mr_matrix_container.
GetRowStartIndex()[i_node]; csr_index != mr_matrix_container.
GetRowStartIndex()[i_node + 1]; csr_index++)
2510 unsigned int j_neighbour = mr_matrix_container.GetColumnIndex()[csr_index];
2511 const double &origin_j = to_be_smoothed[j_neighbour];
2512 CSR_Tuple &edge_ij = mr_matrix_container.GetEdgeValues()[csr_index];
2514 edge_ij.CalculateScalarLaplacian(l_ikjk);
2515 correction += l_ikjk * (origin_j - origin_i);
2518 aux[i_node] = origin_i - correction;
2521 IndexPartition<unsigned int>(
n_nodes).for_each([&](
unsigned int i_node){
2522 to_be_smoothed[i_node] = aux[i_node];
2526 void ComputeWallResistance(
2532 double ym = mY_wall;
2536 int slip_size = mSlipBoundaryList.size();
2538 #pragma omp parallel for firstprivate(slip_size, ym)
2539 for (
int i_slip = 0; i_slip < slip_size; i_slip++)
2541 unsigned int i_node = mSlipBoundaryList[i_slip];
2542 double dist = mdistances[i_node];
2545 KRATOS_ERROR_IF(mViscosity[i_node] == 0) <<
"it is not possible to use the wall law with 0 viscosity" << std::endl;
2547 double nu = mViscosity[i_node];
2549 const array_1d<double, TDim> &U_i =
vel[i_node];
2550 const array_1d<double, TDim> &an_i = mSlipNormal[i_node];
2553 double mod_vel = 0.0;
2555 for (
unsigned int comp = 0; comp < TDim; comp++)
2557 mod_vel += U_i[comp] * U_i[comp];
2558 area += an_i[comp] * an_i[comp];
2560 mod_vel = sqrt(mod_vel);
2564 diag_stiffness[i_node] = area *
nu * mod_vel / (ym)*mWallReductionFactor[i_node];
2568 diag_stiffness[i_node] = 0.0;
2573 void ApplySmagorinsky3D(
double MolecularViscosity,
double Cs)
2578 array_1d<double, TDim> grad_vx;
2579 array_1d<double, TDim> grad_vy;
2580 array_1d<double, TDim> grad_vz;
2583 array_1d<double, TDim> stab_high;
2585 #pragma omp parallel for private(grad_vx, grad_vy, grad_vz)
2586 for (
int i_node = 0; i_node <
n_nodes; i_node++)
2589 for (
unsigned int comp = 0; comp < TDim; comp++)
2591 grad_vx[comp] = 0.0;
2592 grad_vy[comp] = 0.0;
2593 grad_vz[comp] = 0.0;
2596 const array_1d<double, TDim> &U_i = mvel_n1[i_node];
2597 const double h = mHmin[i_node];
2599 for (
unsigned int csr_index = mr_matrix_container.
GetRowStartIndex()[i_node]; csr_index != mr_matrix_container.
GetRowStartIndex()[i_node + 1]; csr_index++)
2601 unsigned int j_neighbour = mr_matrix_container.
GetColumnIndex()[csr_index];
2602 const array_1d<double, TDim> &U_j = mvel_n1[j_neighbour];
2604 edge_ij.Add_grad_p(grad_vx, U_i[0], U_j[0]);
2605 edge_ij.Add_grad_p(grad_vy, U_i[1], U_j[1]);
2606 edge_ij.Add_grad_p(grad_vz, U_i[2], U_j[2]);
2610 for (
unsigned int comp = 0; comp < TDim; comp++)
2612 grad_vx[comp] *= m_inv;
2613 grad_vy[comp] *= m_inv;
2614 grad_vz[comp] *= m_inv;
2619 if constexpr (TDim > 2)
2621 grad_vx[1] += grad_vy[0];
2622 if constexpr (TDim > 2)
2623 grad_vx[2] += grad_vz[0];
2624 if constexpr (TDim > 2)
2625 grad_vy[2] += grad_vz[1];
2626 grad_vy[0] += grad_vx[1];
2627 grad_vz[0] += grad_vx[2];
2628 grad_vz[1] += grad_vy[2];
2632 for (
unsigned int comp = 0; comp < TDim; comp++)
2634 aux += grad_vx[comp] * grad_vx[comp];
2635 aux += grad_vy[comp] * grad_vy[comp];
2636 aux += grad_vz[comp] * grad_vz[comp];
2641 double turbulent_viscosity = Cs *
h *
h * sqrt(aux);
2642 mViscosity[i_node] = turbulent_viscosity + MolecularViscosity;
2648 void Add_Effective_Inverse_Multiply(
2657 int loop_size = destination.size();
2660 IndexPartition<unsigned int>(loop_size).for_each([&](
unsigned int i_node){
2661 array_1d<double, TDim> &dest = destination[i_node];
2662 const double m = mass[i_node];
2663 const double d = diag_stiffness[i_node];
2664 const array_1d<double, TDim> &origin_vec1 = origin1[i_node];
2665 const array_1d<double, TDim> &origin_value = origin[i_node];
2667 for (
unsigned int comp = 0; comp < TDim; comp++)
2668 dest[comp] = value / (
m + value *
d) * (
m / value * origin_vec1[comp] + origin_value[comp]);
2674 void ComputeConvectiveProjection(
2680 int n_nodes = mPiConvection.size();
2682 array_1d<double, TDim> a_i;
2683 array_1d<double, TDim> a_j;
2685 #pragma omp parallel for private(a_i, a_j)
2686 for (
int i_node = 0; i_node <
n_nodes; i_node++)
2688 array_1d<double, TDim> &pi_i = mPiConvection[i_node];
2690 for (
unsigned int l_comp = 0; l_comp < TDim; l_comp++)
2693 const double &phi_i = mphi_n1[i_node];
2694 noalias(a_i) = mvel_n1[i_node];
2695 a_i /= mEps[i_node];
2697 for (
unsigned int csr_index = mr_matrix_container.
GetRowStartIndex()[i_node]; csr_index != mr_matrix_container.
GetRowStartIndex()[i_node + 1]; csr_index++)
2699 unsigned int j_neighbour = mr_matrix_container.
GetColumnIndex()[csr_index];
2700 noalias(a_j) = mvel_n1[j_neighbour];
2701 a_j /= mEps[j_neighbour];
2702 const double &phi_j = mphi_n1[j_neighbour];
2704 edge_ij.Add_grad_p(pi_i, phi_i, phi_j);
2708 for (
unsigned int l_comp = 0; l_comp < TDim; l_comp++)
2709 pi_i[l_comp] *= m_inv;
2713 void ComputeLimitor(
2720 int n_nodes = mPiConvection.size();
2722 IndexPartition<unsigned int>(
n_nodes).for_each([&](
unsigned int i_node){
2723 const array_1d<double, TDim> &pi_i = mPiConvection[i_node];
2724 const double &p_i = mphi_n1[i_node];
2725 double &beta_i = mBeta[i_node];
2728 for (
unsigned int csr_index = mr_matrix_container.
GetRowStartIndex()[i_node]; csr_index != mr_matrix_container.
GetRowStartIndex()[i_node + 1]; csr_index++)
2730 unsigned int j_neighbour = mr_matrix_container.GetColumnIndex()[csr_index];
2731 const double &p_j = mphi_n1[j_neighbour];
2732 const array_1d<double, TDim> &l_k = mEdgeDimensions[csr_index];
2733 const array_1d<double, TDim> &pi_j = mPiConvection[j_neighbour];
2735 for (unsigned int comp = 0; comp < TDim; comp++)
2736 proj += 0.5 * l_k[comp] * (pi_i[comp] + pi_j[comp]);
2738 double numerator = fabs(fabs(p_j - p_i) - fabs(proj));
2739 double denom = fabs(fabs(p_j - p_i) + 1e-6);
2740 beta_i += numerator / denom;
Definition: edgebased_levelset_substep.h:53
int SolveStep2(typename TLinearSolver::Pointer pLinearSolver)
Definition: edgebased_levelset_substep.h:742
EdgeBasedLevelSetSubstep(MatrixContainer &mr_matrix_container, ModelPart &mr_model_part, const double viscosity, const double density, bool use_mass_correction, double stabdt_pressure_factor, double stabdt_convection_factor, double tau2_factor, bool assume_constant_dp)
Definition: edgebased_levelset_substep.h:69
void ActivateClassicalWallResistance(double Ywall)
Definition: edgebased_levelset_substep.h:1892
double ComputeTimeStep(const double CFLNumber, const double MaxDt)
Definition: edgebased_levelset_substep.h:336
double ComputeWetVolume()
Definition: edgebased_levelset_substep.h:1925
void ChangeSignToDistance()
Definition: edgebased_levelset_substep.h:1443
void GatherValues()
Definition: edgebased_levelset_substep.h:316
double ComputeTotalVolume()
Definition: edgebased_levelset_substep.h:1945
vector< CSR_Tuple > EdgesVectorType
Definition: edgebased_levelset_substep.h:57
void SetWallReductionCoefficients(double corner_coefficient, double edge_coefficient)
Definition: edgebased_levelset_substep.h:2002
std::size_t SizeType
Definition: edgebased_levelset_substep.h:67
void ApplyDistanceBC()
Definition: edgebased_levelset_substep.h:1160
bool CheckDistanceConvection()
Definition: edgebased_levelset_substep.h:1814
void SolveStep1()
Definition: edgebased_levelset_substep.h:464
void Clear()
Definition: edgebased_levelset_substep.h:1670
void CalculateNormals(ModelPart::ConditionsContainerType &rConditions)
Definition: edgebased_levelset_substep.h:1541
void CalculateRHS(const CalcVectorType &vel, const ValuesVectorType &pressure, const CalcVectorType &convective_velocity, CalcVectorType &rhs, ValuesVectorType &diag_stiffness)
Definition: edgebased_levelset_substep.h:648
vector< array_1d< double, TDim > > CalcVectorType
Definition: edgebased_levelset_substep.h:61
void ConvectDistance()
Definition: edgebased_levelset_substep.h:1708
TSparseSpace::MatrixType TSystemMatrixType
Definition: edgebased_levelset_substep.h:65
~EdgeBasedLevelSetSubstep()
Definition: edgebased_levelset_substep.h:100
void DiscreteVolumeCorrection(double expected_volume, double measured_volume)
Definition: edgebased_levelset_substep.h:1961
void UpdateFixedVelocityValues()
Definition: edgebased_levelset_substep.h:444
vector< double > ValuesVectorType
Definition: edgebased_levelset_substep.h:63
void ApplyVelocityBC(CalcVectorType &VelArray)
Definition: edgebased_levelset_substep.h:1177
TSparseSpace::VectorType TSystemVectorType
Definition: edgebased_levelset_substep.h:66
void ExtrapolateValues(unsigned int extrapolation_layers)
Definition: edgebased_levelset_substep.h:1260
vector< unsigned int > IndicesVectorType
Definition: edgebased_levelset_substep.h:59
void MarkExternalAndMixedNodes()
Definition: edgebased_levelset_substep.h:1480
void MarkInternalAndMixedNodes()
Definition: edgebased_levelset_substep.h:1503
void SetShockCapturingCoefficient(double coeff)
Definition: edgebased_levelset_substep.h:311
void MarkNodesByDistance(double min, double max)
Definition: edgebased_levelset_substep.h:1455
void Initialize()
Definition: edgebased_levelset_substep.h:104
void ActivateWallResistance(double Ywall)
Definition: edgebased_levelset_substep.h:1857
EdgesStructureTypeC2C< TDim > CSR_Tuple
Definition: edgebased_levelset_substep.h:56
void SolveStep3()
Definition: edgebased_levelset_substep.h:1069
void CalculatePorousResistanceLaw(unsigned int res_law)
Definition: edgebased_levelset_substep.h:2065
void MarkInternalNodes()
Definition: edgebased_levelset_substep.h:1526
void ContinuousVolumeCorrection(double expected_volume, double measured_volume)
Definition: edgebased_levelset_substep.h:2007
double ComputeVolumeVariation()
Definition: edgebased_levelset_substep.h:1899
void SaveScalarVariableToOldStep(Variable< double > &rVar)
Definition: edgebased_levelset_substep.h:1469
void ReduceTimeStep(ModelPart &rModelPart, double NewTime)
Definition: edgebased_levelset_substep.h:1805
void ApplySmagorinsky(double MolecularViscosity, double Cs)
Definition: edgebased_levelset_substep.h:433
Definition: edge_data_c2c.h:80
void CalculateConvectionStabilization_LOW(array_1d< double, TDim > &stab_low, const array_1d< double, TDim > &a_i, const array_1d< double, TDim > &U_i, const array_1d< double, TDim > &a_j, const array_1d< double, TDim > &U_j)
Definition: edge_data_c2c.h:260
void Sub_StabContribution(array_1d< double, TDim > &destination, const double tau, const double beta, const array_1d< double, TDim > &stab_low, const array_1d< double, TDim > &stab_high)
Definition: edge_data_c2c.h:351
void Sub_ConvectiveContribution(array_1d< double, TDim > &destination, const array_1d< double, TDim > &a_i, const array_1d< double, TDim > &U_i, const array_1d< double, TDim > &a_j, const array_1d< double, TDim > &U_j)
Definition: edge_data_c2c.h:196
void Sub_grad_p(array_1d< double, TDim > &destination, const double &p_i, const double &p_j)
Definition: edge_data_c2c.h:143
void Sub_ViscousContribution(array_1d< double, TDim > &destination, const array_1d< double, TDim > &U_i, const double &nu_i, const array_1d< double, TDim > &U_j, const double &nu_j)
Definition: edge_data_c2c.h:383
void Add_grad_p(array_1d< double, TDim > &destination, const double &p_i, const double &p_j)
Definition: edge_data_c2c.h:137
void CalculateConvectionStabilization_HIGH(array_1d< double, TDim > &stab_high, const array_1d< double, TDim > &a_i, const array_1d< double, TDim > &pi_i, const array_1d< double, TDim > &a_j, const array_1d< double, TDim > &pi_j)
Definition: edge_data_c2c.h:286
void Add_D_v(double &destination, const array_1d< double, TDim > &v_i, const array_1d< double, TDim > &v_j)
Definition: edge_data_c2c.h:116
Geometry base class.
Definition: geometry.h:71
This class is useful for index iteration over containers.
Definition: parallel_utilities.h:451
void for_each(TUnaryFunction &&f)
Definition: parallel_utilities.h:514
static T CrossProduct(const T &a, const T &b)
Performs the vector product of the two input vectors a,b.
Definition: math_utils.h:762
Definition: edge_data.h:381
void WriteVectorToDatabase(Variable< array_1d< double, 3 >> &rVariable, CalcVectorType &rOrigin, ModelPart::NodesContainerType &rNodes)
Definition: edge_data.h:905
void AssignVectorToVector(const CalcVectorType &origin, CalcVectorType &destination)
Definition: edge_data.h:1082
ValuesVectorType & GetLumpedMass()
Definition: edge_data.h:420
void FillOldScalarFromDatabase(Variable< double > &rVariable, ValuesVectorType &rDestination, ModelPart::NodesContainerType &rNodes)
Definition: edge_data.h:879
void SetToZero(EdgesVectorType &data_vector)
Definition: edge_data.h:1038
IndicesVectorType & GetColumnIndex()
Definition: edge_data.h:410
ValuesVectorType & GetInvertedMass()
Definition: edge_data.h:425
IndicesVectorType & GetRowStartIndex()
Definition: edge_data.h:415
void FillVectorFromDatabase(Variable< array_1d< double, 3 >> &rVariable, CalcVectorType &rDestination, ModelPart::NodesContainerType &rNodes)
Definition: edge_data.h:790
void FillScalarFromDatabase(Variable< double > &rVariable, ValuesVectorType &rDestination, ModelPart::NodesContainerType &rNodes)
Definition: edge_data.h:851
void WriteScalarToDatabase(Variable< double > &rVariable, ValuesVectorType &rOrigin, ModelPart::NodesContainerType &rNodes)
Definition: edge_data.h:933
void Add_Minv_value(CalcVectorType &destination, const CalcVectorType &origin1, const double value, const ValuesVectorType &Minv_vec, const CalcVectorType &origin)
Definition: edge_data.h:963
void FillOldVectorFromDatabase(Variable< array_1d< double, 3 >> &rVariable, CalcVectorType &rDestination, ModelPart::NodesContainerType &rNodes)
Definition: edge_data.h:821
void FillCoordinatesFromDatabase(CalcVectorType &rDestination, ModelPart::NodesContainerType &rNodes)
Definition: edge_data.h:759
ValuesVectorType & GetHmin()
Definition: edge_data.h:435
unsigned int GetNumberEdges()
Definition: edge_data.h:400
EdgesVectorType & GetEdgeValues()
Definition: edge_data.h:405
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
ElementIterator ElementsBegin(IndexType ThisIndex=0)
Definition: model_part.h:1169
MeshType::ConditionsContainerType ConditionsContainerType
Condintions container. A vector set of Conditions with their Id's as key.
Definition: model_part.h:183
void OverwriteSolutionStepData(IndexType SourceSolutionStepIndex, IndexType DestinationSourceSolutionStepIndex)
Definition: model_part.cpp:180
NodeIterator NodesBegin(IndexType ThisIndex=0)
Definition: model_part.h:487
ConditionsContainerType & Conditions(IndexType ThisIndex=0)
Definition: model_part.h:1381
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
MeshType::NodesContainerType NodesContainerType
Nodes container. Which is a vector set of nodes with their Id's as key.
Definition: model_part.h:128
ElementIterator ElementsEnd(IndexType ThisIndex=0)
Definition: model_part.h:1179
NodeIterator NodesEnd(IndexType ThisIndex=0)
Definition: model_part.h:497
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
static void DivideInPartitions(const int NumTerms, const int NumThreads, PartitionVector &Partitions)
Divide an array of length NumTerms between NumThreads threads.
Definition: openmp_utils.h:158
static int ThisThread()
Wrapper for omp_get_thread_num().
Definition: openmp_utils.h:108
static int GetNumThreads()
Returns the current number of threads.
Definition: parallel_utilities.cpp:34
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
void SetCurrentTime(double NewTime)
Definition: process_info.cpp:63
#define KRATOS_THROW_ERROR(ExceptionType, ErrorMessage, MoreInfo)
Definition: define.h:77
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_WATCH(variable)
Definition: define.h:806
#define KRATOS_TRY
Definition: define.h:109
#define KRATOS_ERROR_IF(conditional)
Definition: exception.h:162
dt
Definition: DEM_benchmarks.py:173
static double max(double a, double b)
Definition: GeometryFunctions.h:79
static double min(double a, double b)
Definition: GeometryFunctions.h:71
Parameters GetValue(Parameters &rParameters, const std::string &rEntry)
Definition: add_kratos_parameters_to_python.cpp:53
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
TExpressionType::data_type norm_2(AMatrix::MatrixExpression< TExpressionType, TCategory > const &TheExpression)
Definition: amatrix_interface.h:625
TExpression1Type::data_type inner_prod(AMatrix::MatrixExpression< TExpression1Type, TCategory1 > const &First, AMatrix::MatrixExpression< TExpression2Type, TCategory2 > const &Second)
Definition: amatrix_interface.h:592
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
list coeff
Definition: bombardelli_test.py:41
float dist
Definition: edgebased_PureConvection.py:89
bool use_mass_correction
Definition: edgebased_var.py:13
float viscosity
Definition: edgebased_var.py:8
int extrapolation_layers
Definition: edgebased_var.py:15
float density
Definition: face_heat.py:56
v
Definition: generate_convection_diffusion_explicit_element.py:114
tau
Definition: generate_convection_diffusion_explicit_element.py:115
h
Definition: generate_droplet_dynamics.py:91
rhs
Definition: generate_frictional_mortar_condition.py:297
a
Definition: generate_stokes_twofluid_element.py:77
tuple tmp
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:98
b
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:31
int n_nodes
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:15
nu
Definition: isotropic_damage_automatic_differentiation.py:135
int t
Definition: ode_solve.py:392
int d
Definition: ode_solve.py:397
int n
manufactured solution and derivatives (u=0 at z=0 dudz=0 at z=domain_height)
Definition: ode_solve.py:402
vel
Definition: pure_conduction.py:76
int k
Definition: quadrature.py:595
int j
Definition: quadrature.py:648
float temp
Definition: rotating_cone.py:85
float delta_t
Definition: rotatingcone_PureConvectionBenchmarking.py:129
int m
Definition: run_marine_rain_substepping.py:8
int counter
Definition: script_THERMAL_CORRECT.py:218
int current_id
Output settings end ####.
Definition: script.py:194
porosity
Definition: sp_statistics.py:18
volume
Definition: sp_statistics.py:15
integer i
Definition: TensorModule.f:17
integer function sign1(a)
Definition: TensorModule.f:872
float pressure
Definition: test_pureconvectionsolver_benchmarking.py:101
e
Definition: run_cpp_mpi_tests.py:31
float factor
for node in (self.combined_model_part).Nodes: pold = node.GetSolutionStepValue(PRESSURE,...
Definition: ulf_PGLASS.py:254