-
Notifications
You must be signed in to change notification settings - Fork 288
[ConvectionDiffusionApplication] Adding crosswind stabilization to Eulerian Convection–Diffusion element #14272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 7 commits
3eaaff4
1bd6076
8d01273
e9c9a16
d837e32
e153855
23d1045
04e9db3
6418514
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -103,6 +103,9 @@ namespace Kratos | |||||
| this-> GetNodalValues(Variables,rCurrentProcessInfo); | ||||||
| double h = this->ComputeH(DN_DX); | ||||||
|
|
||||||
| array_1d<double,TDim> grad_phi_halfstep = prod(trans(DN_DX), 0.5*(Variables.phi+Variables.phi_old)); | ||||||
| const double norm_grad = norm_2(grad_phi_halfstep); | ||||||
|
|
||||||
| //Computing the divergence | ||||||
| for (unsigned int i = 0; i < TNumNodes; i++) | ||||||
| { | ||||||
|
|
@@ -116,6 +119,11 @@ namespace Kratos | |||||
| BoundedMatrix<double,TNumNodes, TNumNodes> aux1 = ZeroMatrix(TNumNodes, TNumNodes); //terms multiplying dphi/dt | ||||||
| BoundedMatrix<double,TNumNodes, TNumNodes> aux2 = ZeroMatrix(TNumNodes, TNumNodes); //terms multiplying phi | ||||||
| bounded_matrix<double,TNumNodes, TDim> tmp; | ||||||
| // CrossWind variables | ||||||
| // Projected velocity | ||||||
| array_1d<double,TDim> u_proj; | ||||||
| // Diffusion contribution | ||||||
| BoundedMatrix<double,TDim,TDim> Dcw; | ||||||
|
|
||||||
| // Gauss points and Number of nodes coincides in this case. | ||||||
| for(unsigned int igauss=0; igauss<TNumNodes; igauss++) | ||||||
|
|
@@ -141,6 +149,55 @@ namespace Kratos | |||||
| //terms which multiply the gradient of phi | ||||||
| noalias(aux2) += (1.0+tau*Variables.beta*Variables.div_v)*outer_prod(N, a_dot_grad); | ||||||
| noalias(aux2) += tau*outer_prod(a_dot_grad, a_dot_grad); | ||||||
|
|
||||||
| // Cross-wind term | ||||||
| const double norm_vel2 = norm_vel * norm_vel; | ||||||
| if(Variables.C > 0.0 && norm_grad > 1e-3 && norm_vel2 > 1e-9) | ||||||
| { | ||||||
| // Temporal derivative | ||||||
| const double phi_gauss = inner_prod(N, Variables.phi); | ||||||
| const double phi_old_gauss = inner_prod(N, Variables.phi_old); | ||||||
| const double dphi_dt = Variables.dt_inv * (phi_gauss - phi_old_gauss); | ||||||
|
|
||||||
| // Convective term | ||||||
| const double conv = inner_prod(vel_gauss, grad_phi_halfstep); | ||||||
|
|
||||||
| // Residual | ||||||
| const double res = dphi_dt + conv; | ||||||
|
|
||||||
| // Projected velocity | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| u_proj = (conv/norm_grad) * (grad_phi_halfstep/norm_grad); | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Easier to follow |
||||||
|
|
||||||
| // Projected Peclet | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| const double Pe_proj = norm_2(u_proj) * h / (2.0 * Variables.conductivity + 1e-12); | ||||||
|
|
||||||
| // Limiter | ||||||
| const double alpha_c = std::max( 0.0, Variables.C - 1.0/(Pe_proj + 1e-12)); | ||||||
|
|
||||||
| // Discontinuity capturing coefficient | ||||||
| bool force_diffusion = true; // to avoid k_c = 0.0 when alpha_c = 0.0 using Pe_proj, add to ProjectParameters? | ||||||
| double k_c; | ||||||
| if (alpha_c == 0.0 && force_diffusion) | ||||||
| { | ||||||
| k_c = Variables.C * h * std::abs(res / norm_grad); | ||||||
| } else | ||||||
| { | ||||||
| k_c = 0.5 * alpha_c * h * std::abs(res / norm_grad); | ||||||
| } | ||||||
|
|
||||||
| // Crosswind diffusion tensor | ||||||
| Dcw = k_c * IdentityMatrix(TDim); | ||||||
|
|
||||||
| // Removing diffusion in streamline direcction | ||||||
| const double k_streamline = tau * norm_vel2; | ||||||
| const double correction = std::max(k_c - k_streamline, 0.0) - k_c; | ||||||
|
|
||||||
| Dcw += (correction / norm_vel2) * outer_prod(vel_gauss, vel_gauss); | ||||||
|
|
||||||
| // Add diffusion contribution | ||||||
| noalias(tmp) = prod(DN_DX, Dcw); | ||||||
| noalias(aux2) += prod(tmp, trans(DN_DX)); | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| //adding the second and third term in the formulation | ||||||
|
|
@@ -174,6 +231,7 @@ namespace Kratos | |||||
| { | ||||||
| KRATOS_TRY | ||||||
|
|
||||||
| rVariables.C = rCurrentProcessInfo[CROSS_WIND_STABILIZATION_FACTOR]; | ||||||
| rVariables.theta = rCurrentProcessInfo[TIME_INTEGRATION_THETA]; //Variable defining the temporal scheme (0: Forward Euler, 1: Backward Euler, 0.5: Crank-Nicolson) | ||||||
| rVariables.dyn_st_beta = rCurrentProcessInfo[DYNAMIC_TAU]; | ||||||
| const double delta_t = rCurrentProcessInfo[DELTA_TIME]; | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -119,6 +119,7 @@ class KRATOS_API(CONVECTION_DIFFUSION_APPLICATION) EulerianConvectionDiffusionEl | |
| double density; | ||
| double beta; | ||
| double div_v; | ||
| double C; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd use a more self-descriptive variable name |
||
|
|
||
| array_1d<double,TNumNodes> phi; | ||
| array_1d<double,TNumNodes> phi_old; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this include the source term and diffusion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also the
betaterm in case we use a compressible flux.