Skip to content

Commit 31650ee

Browse files
authored
Added DCDD from previous gradient (#1293)
Description Previously, the tracer physics used the current time tracer gradient to compute the DCDD stabilization. Using the previous time gradient instead allows to reduce the number of non-linear iterations while still converging to proper solutions. Testing All tests still pass. Documentation Not applicable. Former-commit-id: c2c8cfd
1 parent 5cab0b2 commit 31650ee

File tree

8 files changed

+81
-54
lines changed

8 files changed

+81
-54
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
1111

1212
### Changed
1313

14+
- MINOR The tracer gradient used for DCDD stabilization calculations is now from the previous solution, which reduces the number of non-linear iterations. [#1293](https://github.com/chaos-polymtl/lethe/pull/1293)
15+
16+
## [Master] - 2024-09-25
17+
18+
### Changed
19+
1420
- MINOR Remove the GIFs from the repository to reduce its size. [#1289](https://github.com/chaos-polymtl/lethe/pull/1289)
1521

1622
## [Master] - 2024-09-24

applications_tests/lethe-fluid-sharp/tracer_around_sphere.output

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ Tracer statistics :
3131
Min : -0.0071
3232
Max : 1.007
3333
Average : 0.441
34-
Std-Dev : 0.3645
34+
Std-Dev : 0.3645

applications_tests/lethe-fluid/gls_tracer_advection_tanh.output

+32-32
Original file line numberDiff line numberDiff line change
@@ -8,80 +8,80 @@ Running on 1 MPI rank(s)...
88
Transient iteration: 1 Time: 0.02 Time step: 0.02 CFL: 0.567185
99
*******************************************************************************
1010
L2 error velocity : 5.55112e-17
11-
L2 error tracer : 0.0101988
11+
L2 error tracer : 0.0118489
1212

1313
*******************************************************************************
1414
Transient iteration: 2 Time: 0.04 Time step: 0.02 CFL: 0.567185
1515
*******************************************************************************
1616
L2 error velocity : 5.55112e-17
17-
L2 error tracer : 0.0186561
17+
L2 error tracer : 0.0203913
1818

1919
*******************************************************************************
2020
Transient iteration: 3 Time: 0.06 Time step: 0.02 CFL: 0.567185
2121
*******************************************************************************
2222
L2 error velocity : 5.55112e-17
23-
L2 error tracer : 0.0253479
23+
L2 error tracer : 0.0265709
2424

2525
*******************************************************************************
2626
Transient iteration: 4 Time: 0.08 Time step: 0.02 CFL: 0.567185
2727
*******************************************************************************
2828
L2 error velocity : 5.55112e-17
29-
L2 error tracer : 0.0320367
29+
L2 error tracer : 0.0329647
3030

3131
*******************************************************************************
3232
Transient iteration: 5 Time: 0.1 Time step: 0.02 CFL: 0.567185
3333
*******************************************************************************
3434
L2 error velocity : 5.55112e-17
35-
L2 error tracer : 0.0369237
35+
L2 error tracer : 0.0376841
3636

3737
*******************************************************************************
3838
Transient iteration: 6 Time: 0.12 Time step: 0.02 CFL: 0.567185
3939
*******************************************************************************
4040
L2 error velocity : 5.55112e-17
41-
L2 error tracer : 0.0416248
41+
L2 error tracer : 0.0422934
4242

4343
*******************************************************************************
4444
Transient iteration: 7 Time: 0.14 Time step: 0.02 CFL: 0.567185
4545
*******************************************************************************
4646
L2 error velocity : 5.55112e-17
47-
L2 error tracer : 0.046606
47+
L2 error tracer : 0.0471852
4848

4949
*******************************************************************************
5050
Transient iteration: 8 Time: 0.16 Time step: 0.02 CFL: 0.567185
5151
*******************************************************************************
5252
L2 error velocity : 5.55112e-17
53-
L2 error tracer : 0.0500243
53+
L2 error tracer : 0.050532
5454

5555
*******************************************************************************
5656
Transient iteration: 9 Time: 0.18 Time step: 0.02 CFL: 0.567185
5757
*******************************************************************************
5858
L2 error velocity : 5.55112e-17
59-
L2 error tracer : 0.0540616
59+
L2 error tracer : 0.0545255
6060

6161
*******************************************************************************
6262
Transient iteration: 10 Time: 0.2 Time step: 0.02 CFL: 0.567185
6363
*******************************************************************************
6464
L2 error velocity : 5.55112e-17
65-
L2 error tracer : 0.0579947
66-
time error_velocity
67-
0.0200 5.551115e-17
68-
0.0400 5.551115e-17
69-
0.0600 5.551115e-17
70-
0.0800 5.551115e-17
71-
0.1000 5.551115e-17
72-
0.1200 5.551115e-17
73-
0.1400 5.551115e-17
74-
0.1600 5.551115e-17
75-
0.1800 5.551115e-17
76-
0.2000 5.551115e-17
77-
cells error_tracer
78-
1024 1.019878e-02
79-
1024 1.865606e-02
80-
1024 2.534790e-02
81-
1024 3.203667e-02
82-
1024 3.692370e-02
83-
1024 4.162480e-02
84-
1024 4.660604e-02
85-
1024 5.002435e-02
86-
1024 5.406162e-02
87-
1024 5.799467e-02
65+
L2 error tracer : 0.0584056
66+
time error_velocity
67+
0.0200 5.551115e-17
68+
0.0400 5.551115e-17
69+
0.0600 5.551115e-17
70+
0.0800 5.551115e-17
71+
0.1000 5.551115e-17
72+
0.1200 5.551115e-17
73+
0.1400 5.551115e-17
74+
0.1600 5.551115e-17
75+
0.1800 5.551115e-17
76+
0.2000 5.551115e-17
77+
cells error_tracer
78+
1024 1.184893e-02
79+
1024 2.039130e-02
80+
1024 2.657085e-02
81+
1024 3.296468e-02
82+
1024 3.768408e-02
83+
1024 4.229345e-02
84+
1024 4.718519e-02
85+
1024 5.053197e-02
86+
1024 5.452552e-02
87+
1024 5.840562e-02

applications_tests/lethe-fluid/time_dependent_boundaries_tracer.output

+10-10
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ Tracer statistics :
1313
Transient iteration: 1 Time: 0.5 Time step: 0.5 CFL: 2.79578
1414
*******************************************************************************
1515
Tracer statistics :
16-
Min : 0.436485
17-
Max : 0.499339
18-
Average : 0.470525
19-
Std-Dev : 0.0191026
16+
Min : 0.436653
17+
Max : 0.499349
18+
Average : 0.470664
19+
Std-Dev : 0.019052
2020

2121
*******************************************************************************
22-
Transient iteration: 2 Time: 1 Time step: 0.5 CFL: 3.0594
22+
Transient iteration: 2 Time: 1 Time step: 0.5 CFL: 3.0594
2323
*******************************************************************************
24-
Tracer statistics :
25-
Min : 0.0441899
26-
Max : 0.956945
27-
Average : 0.516389
28-
Std-Dev : 0.25533
24+
Tracer statistics :
25+
Min : 0.0444703
26+
Max : 0.956999
27+
Average : 0.516871
28+
Std-Dev : 0.255247

include/solvers/tracer_scratch_data.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ class TracerScratchData
185185
this->tracer_gradients);
186186
this->fe_values_tracer.get_function_laplacians(current_solution,
187187
this->tracer_laplacians);
188+
this->fe_values_tracer.get_function_gradients(
189+
previous_solutions[0], this->previous_tracer_gradients);
188190

189191
// Gather previous tracer values
190192
for (unsigned int p = 0; p < previous_solutions.size(); ++p)
@@ -286,8 +288,6 @@ class TracerScratchData
286288
std::vector<double> tracer_diffusivity_0;
287289
std::vector<double> tracer_diffusivity_1;
288290

289-
290-
291291
// FEValues for the Tracer problem
292292
FEValues<dim> fe_values_tracer;
293293
unsigned int n_dofs;
@@ -303,6 +303,7 @@ class TracerScratchData
303303
std::vector<Tensor<1, dim>> tracer_gradients;
304304
std::vector<double> tracer_laplacians;
305305
std::vector<std::vector<double>> previous_tracer_values;
306+
std::vector<Tensor<1, dim>> previous_tracer_gradients;
306307

307308
// Solid signed distance function
308309
std::vector<double> sdf_values;

include/solvers/vof_scratch_data.h

-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ class VOFScratchData
173173
this->phase_gradients);
174174
fe_values_vof.get_function_laplacians(current_solution,
175175
this->phase_laplacians);
176-
177176
fe_values_vof.get_function_gradients(previous_solutions[0],
178177
this->previous_phase_gradients);
179178

source/solvers/tracer_assemblers.cc

+25-6
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ TracerAssemblerCore<dim>::assemble_matrix(TracerScratchData<dim> &scratch_data,
4343
// Store JxW in local variable for faster access;
4444
const double JxW = JxW_vec[q];
4545

46+
// We use the previous concentration for the shock capture if the
47+
// simulation is transient
48+
const Tensor<1, dim> tracer_gradient_for_dcdd =
49+
is_steady(method) ? tracer_gradient :
50+
scratch_data.previous_tracer_gradients[q];
51+
const double tracer_gradient_for_dcdd_norm =
52+
tracer_gradient_for_dcdd.norm();
53+
4654
// Shock capturing viscosity term
4755
const double order = scratch_data.fe_values_tracer.get_fe().degree;
4856

@@ -51,7 +59,8 @@ TracerAssemblerCore<dim>::assemble_matrix(TracerScratchData<dim> &scratch_data,
5159

5260
const double tolerance = 1e-12;
5361
Tensor<1, dim> s = velocity / (velocity.norm() + tolerance);
54-
Tensor<1, dim> r = tracer_gradient / (tracer_gradient.norm() + tolerance);
62+
Tensor<1, dim> r =
63+
tracer_gradient_for_dcdd / (tracer_gradient_for_dcdd_norm + tolerance);
5564

5665
const Tensor<2, dim> k_corr = (r * s) * outer_product(s, s);
5766
const Tensor<2, dim> rr = outer_product(r, r);
@@ -60,7 +69,7 @@ TracerAssemblerCore<dim>::assemble_matrix(TracerScratchData<dim> &scratch_data,
6069

6170
const double d_vdcdd = order * (0.5 * h * h) *
6271
(velocity.norm() * velocity.norm()) *
63-
pow(tracer_gradient.norm() * h, order - 1);
72+
pow(tracer_gradient_for_dcdd_norm * h, order - 1);
6473

6574

6675

@@ -149,24 +158,34 @@ TracerAssemblerCore<dim>::assemble_rhs(TracerScratchData<dim> &scratch_data,
149158
for (unsigned int q = 0; q < n_q_points; ++q)
150159
{
151160
// Gather into local variables the relevant fields
152-
const double diffusivity = diffusivity_vector[q];
153-
const Tensor<1, dim> tracer_gradient = scratch_data.tracer_gradients[q];
161+
const double diffusivity = diffusivity_vector[q];
162+
const Tensor<1, dim> tracer_gradient = scratch_data.tracer_gradients[q];
163+
const Tensor<1, dim> previous_tracer_gradient =
164+
scratch_data.previous_tracer_gradients[q];
154165
const double tracer_laplacian = scratch_data.tracer_laplacians[q];
155166
const Tensor<1, dim> velocity = scratch_data.velocity_values[q];
156167

157168
// Store JxW in local variable for faster access;
158169
const double JxW = JxW_vec[q];
159170

171+
// We use the previous concentration for the shock capture if the
172+
// simulation is transient
173+
const Tensor<1, dim> tracer_gradient_for_dcdd =
174+
is_steady(method) ? tracer_gradient : previous_tracer_gradient;
175+
const double tracer_gradient_for_dcdd_norm =
176+
tracer_gradient_for_dcdd.norm();
177+
160178
// Shock capturing viscosity term
161179
const double order = scratch_data.fe_values_tracer.get_fe().degree;
162180

163181

164182
const double vdcdd = (0.5 * h) * (velocity.norm() * velocity.norm()) *
165-
pow(tracer_gradient.norm() * h, order);
183+
pow(tracer_gradient_for_dcdd_norm * h, order);
166184

167185
const double tolerance = 1e-12;
168186
Tensor<1, dim> s = velocity / (velocity.norm() + tolerance);
169-
Tensor<1, dim> r = tracer_gradient / (tracer_gradient.norm() + tolerance);
187+
Tensor<1, dim> r =
188+
tracer_gradient_for_dcdd / (tracer_gradient_for_dcdd_norm + tolerance);
170189

171190
const Tensor<2, dim> k_corr = (r * s) * outer_product(s, s);
172191
const Tensor<2, dim> rr = outer_product(r, r);

source/solvers/tracer_scratch_data.cc

+4-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ TracerScratchData<dim>::allocate()
2121
// Velocity
2222
this->velocity_values = std::vector<Tensor<1, dim>>(n_q_points);
2323
// Tracer
24-
this->tracer_values = std::vector<double>(n_q_points);
25-
this->tracer_gradients = std::vector<Tensor<1, dim>>(n_q_points);
24+
this->tracer_values = std::vector<double>(n_q_points);
25+
this->tracer_gradients = std::vector<Tensor<1, dim>>(n_q_points);
26+
this->previous_tracer_gradients =
27+
std::vector<Tensor<1, dim>>(this->n_q_points);
2628
this->tracer_laplacians = std::vector<double>(n_q_points);
2729
this->tracer_diffusivity = std::vector<double>(n_q_points);
2830
this->tracer_diffusivity_0 = std::vector<double>(n_q_points);

0 commit comments

Comments
 (0)