Skip to content

Commit b86a451

Browse files
committed
fix the implicit bug
1 parent 2551739 commit b86a451

2 files changed

Lines changed: 57 additions & 42 deletions

File tree

src/core/solution_handler.cc

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -415,10 +415,14 @@ SolutionHandler<dim, number>::update(FieldSolveType field_solve_type,
415415
Types::Index variable_index)
416416
{
417417
// Helper function to swap vectors for all dependency types
418-
auto swap_all_dependency_vectors = [this](Types::Index index, auto &new_vector)
418+
auto swap_all_dependency_vectors =
419+
[this](Types::Index index, auto &new_vector, bool is_implicit = false)
419420
{
420-
// Always swap the Normal dependency
421-
new_vector->swap(*(solution_set.at(std::make_pair(index, DependencyType::Normal))));
421+
if (!is_implicit)
422+
{
423+
new_vector->swap(
424+
*(solution_set.at(std::make_pair(index, DependencyType::Normal))));
425+
}
422426

423427
// Swap old dependency types if they exist
424428
const std::array<DependencyType, 4> old_types = {
@@ -435,6 +439,17 @@ SolutionHandler<dim, number>::update(FieldSolveType field_solve_type,
435439
new_vector->swap(*(solution_set.at(std::make_pair(index, dep_type))));
436440
}
437441
}
442+
443+
if (is_implicit)
444+
{
445+
if (solution_set.contains(std::make_pair(index, DependencyType::OldOne)))
446+
{
447+
*new_vector =
448+
*(solution_set.at(std::make_pair(index, DependencyType::OldOne)));
449+
new_vector->swap(
450+
*(solution_set.at(std::make_pair(index, DependencyType::Normal))));
451+
}
452+
}
438453
};
439454

440455
// Loop through the solutions and swap them
@@ -472,7 +487,7 @@ SolutionHandler<dim, number>::update(FieldSolveType field_solve_type,
472487
// For Nonexplicit types we swap all dependency types if the index matches
473488
if (variable_index == index)
474489
{
475-
swap_all_dependency_vectors(index, new_vector);
490+
swap_all_dependency_vectors(index, new_vector, true);
476491
}
477492
break;
478493
default:

tests/regression_tests/allen_cahn_implicit/gold_output.txt

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -32,58 +32,58 @@ Iteration: 0
3232

3333

3434
Iteration: 300
35-
Solution index 0 l2-norm: 109.817 integrated value: 1911.34
36-
Solution index 1 l2-norm: 9.88843 integrated value: 94.0071
37-
Solution index 2 l2-norm: 4.16914 integrated value: 32.4592
38-
39-
Iteration: 600
4035
Solution index 0 l2-norm: 111.095 integrated value: 1942.03
4136
Solution index 1 l2-norm: 9.09367 integrated value: 81.6845
4237
Solution index 2 l2-norm: 3.82926 integrated value: 28.0514
4338

44-
Iteration: 900
45-
Solution index 0 l2-norm: 112.331 integrated value: 1969.05
46-
Solution index 1 l2-norm: 8.72713 integrated value: 72.3072
47-
Solution index 2 l2-norm: 3.62388 integrated value: 24.0953
48-
49-
Iteration: 1200
39+
Iteration: 600
5040
Solution index 0 l2-norm: 112.913 integrated value: 1982.79
5141
Solution index 1 l2-norm: 8.61869 integrated value: 69.1128
5242
Solution index 2 l2-norm: 3.57043 integrated value: 23.0561
5343

44+
Iteration: 900
45+
Solution index 0 l2-norm: 113.642 integrated value: 2003.2
46+
Solution index 1 l2-norm: 8.41 integrated value: 65.3784
47+
Solution index 2 l2-norm: 3.48117 integrated value: 21.7874
48+
49+
Iteration: 1200
50+
Solution index 0 l2-norm: 114.299 integrated value: 2022.76
51+
Solution index 1 l2-norm: 8.22981 integrated value: 62.4847
52+
Solution index 2 l2-norm: 3.40591 integrated value: 20.8132
53+
5454
Iteration: 1500
55-
Solution index 0 l2-norm: 113.295 integrated value: 1993.24
56-
Solution index 1 l2-norm: 8.5108 integrated value: 67.0845
57-
Solution index 2 l2-norm: 3.52369 integrated value: 22.366
55+
Solution index 0 l2-norm: 114.93 integrated value: 2042.11
56+
Solution index 1 l2-norm: 8.07034 integrated value: 60.019
57+
Solution index 2 l2-norm: 3.3396 integrated value: 19.987
5858

5959

6060

6161
+-----------------------------------------------+------------+------------+
62-
| Total wallclock time elapsed since start | 14.7s | |
62+
| Total wallclock time elapsed since start | 23.3s | |
6363
| | | |
6464
| Section | no. calls | wall time | % of total |
6565
+-----------------------------------+-----------+------------+------------+
66-
| Auxiliary solver | 1 | 6.85e-06s | 0% |
67-
| Create FESystem | 1 | 0.00479s | 0% |
68-
| Create constraints | 1 | 0.00476s | 0% |
69-
| Explicit solver | 1500 | 0.00236s | 0% |
70-
| Generate mesh | 1 | 0.0332s | 0.23% |
71-
| Initialization | 1 | 0.355s | 2.4% |
72-
| Nonexplicit auxiliary solver | 1500 | 0.00178s | 0% |
73-
| Nonexplicit co-nonlinear solver | 1501 | 0.00262s | 0% |
74-
| Nonexplicit linear solver | 1501 | 0.0017s | 0% |
75-
| Nonexplicit self-nonlinear solver | 1501 | 13.3s | 90% |
76-
| Output | 6 | 0.402s | 2.7% |
77-
| Postprocess solver | 6 | 0.0296s | 0.2% |
78-
| Solve Increment | 1500 | 13.3s | 90% |
79-
| Solver initialization | 1 | 0.0752s | 0.51% |
80-
| Update ghosts | 4212 | 0.00982s | 0% |
81-
| Update time-dependent constraints | 1500 | 0.00217s | 0% |
82-
| Zero ghosts | 6 | 3.04e-05s | 0% |
83-
| compute element volumes | 1 | 0.00606s | 0% |
84-
| reinitialize DoFHandlers | 1 | 0.00749s | 0% |
85-
| reinitialize element volumes | 1 | 0.000799s | 0% |
86-
| reinitialize invm | 1 | 0.0148s | 0.1% |
87-
| reinitialize matrix-free objects | 1 | 0.054s | 0.37% |
88-
| reinitialize solution set | 1 | 0.000382s | 0% |
66+
| Auxiliary solver | 1 | 3.81e-06s | 0% |
67+
| Create FESystem | 1 | 0.00868s | 0% |
68+
| Create constraints | 1 | 0.011s | 0% |
69+
| Explicit solver | 1500 | 0.00251s | 0% |
70+
| Generate mesh | 1 | 0.0573s | 0.25% |
71+
| Initialization | 1 | 0.394s | 1.7% |
72+
| Nonexplicit auxiliary solver | 1500 | 0.00192s | 0% |
73+
| Nonexplicit co-nonlinear solver | 1501 | 0.00337s | 0% |
74+
| Nonexplicit linear solver | 1501 | 0.00163s | 0% |
75+
| Nonexplicit self-nonlinear solver | 1501 | 21.8s | 94% |
76+
| Output | 6 | 0.364s | 1.6% |
77+
| Postprocess solver | 6 | 0.0257s | 0.11% |
78+
| Solve Increment | 1500 | 21.8s | 94% |
79+
| Solver initialization | 1 | 0.0671s | 0.29% |
80+
| Update ghosts | 4962 | 0.0129s | 0% |
81+
| Update time-dependent constraints | 1500 | 0.00208s | 0% |
82+
| Zero ghosts | 6 | 3.45e-05s | 0% |
83+
| compute element volumes | 1 | 0.00189s | 0% |
84+
| reinitialize DoFHandlers | 1 | 0.0172s | 0% |
85+
| reinitialize element volumes | 1 | 0.000857s | 0% |
86+
| reinitialize invm | 1 | 0.0159s | 0% |
87+
| reinitialize matrix-free objects | 1 | 0.0608s | 0.26% |
88+
| reinitialize solution set | 1 | 0.000637s | 0% |
8989
+-----------------------------------+-----------+------------+------------+

0 commit comments

Comments
 (0)