@@ -51,7 +51,7 @@ CahnHilliard<dim>::setup_assemblers()
51
51
// Time-stepping schemes
52
52
if (is_bdf (this ->simulation_control ->get_assembly_method ()))
53
53
{
54
- this ->assemblers .push_back (
54
+ this ->assemblers .emplace_back (
55
55
std::make_shared<CahnHilliardAssemblerBDF<dim>>(
56
56
this ->simulation_control ));
57
57
}
@@ -63,7 +63,7 @@ CahnHilliard<dim>::setup_assemblers()
63
63
// to the constructor separately.
64
64
65
65
// Angle of contact boundary condition
66
- this ->assemblers .push_back (
66
+ this ->assemblers .emplace_back (
67
67
std::make_shared<CahnHilliardAssemblerAngleOfContact<dim>>(
68
68
this ->simulation_control ,
69
69
this ->simulation_parameters .multiphysics .cahn_hilliard_parameters ,
@@ -75,7 +75,7 @@ CahnHilliard<dim>::setup_assemblers()
75
75
this ->simulation_parameters .boundary_conditions_cahn_hilliard ));
76
76
77
77
// Free angle of contact boundary condition
78
- this ->assemblers .push_back (
78
+ this ->assemblers .emplace_back (
79
79
std::make_shared<CahnHilliardAssemblerFreeAngle<dim>>(
80
80
this ->simulation_control ,
81
81
this ->simulation_parameters .multiphysics .cahn_hilliard_parameters ,
@@ -87,14 +87,15 @@ CahnHilliard<dim>::setup_assemblers()
87
87
this ->simulation_parameters .boundary_conditions_cahn_hilliard ));
88
88
89
89
// Core assembler
90
- this ->assemblers .push_back (std::make_shared<CahnHilliardAssemblerCore<dim>>(
91
- this ->simulation_control ,
92
- this ->simulation_parameters .multiphysics .cahn_hilliard_parameters ,
93
- (this ->simulation_parameters .multiphysics .cahn_hilliard_parameters
94
- .epsilon_set_method == Parameters::EpsilonSetMethod::manual) ?
95
- this ->simulation_parameters .multiphysics .cahn_hilliard_parameters
96
- .epsilon :
97
- GridTools::minimal_cell_diameter (*triangulation)));
90
+ this ->assemblers .emplace_back (
91
+ std::make_shared<CahnHilliardAssemblerCore<dim>>(
92
+ this ->simulation_control ,
93
+ this ->simulation_parameters .multiphysics .cahn_hilliard_parameters ,
94
+ (this ->simulation_parameters .multiphysics .cahn_hilliard_parameters
95
+ .epsilon_set_method == Parameters::EpsilonSetMethod::manual) ?
96
+ this ->simulation_parameters .multiphysics .cahn_hilliard_parameters
97
+ .epsilon :
98
+ GridTools::minimal_cell_diameter (*triangulation)));
98
99
}
99
100
100
101
template <int dim>
@@ -299,12 +300,12 @@ CahnHilliard<dim>::attach_solution_to_output(DataOut<dim> &data_out)
299
300
// phase order (Phi) and the following one is the chemical potential (eta)
300
301
301
302
std::vector<std::string> solution_names;
302
- solution_names.push_back (" phase_order" );
303
- solution_names.push_back (" chemical_potential" );
303
+ solution_names.emplace_back (" phase_order" );
304
+ solution_names.emplace_back (" chemical_potential" );
304
305
305
306
std::vector<std::string> solution_names_filtered;
306
- solution_names_filtered.push_back (" phase_order_filtered" );
307
- solution_names_filtered.push_back (" chemical_potential_filtered" );
307
+ solution_names_filtered.emplace_back (" phase_order_filtered" );
308
+ solution_names_filtered.emplace_back (" chemical_potential_filtered" );
308
309
309
310
std::vector<DataComponentInterpretation::DataComponentInterpretation>
310
311
data_component_interpretation (
@@ -783,14 +784,14 @@ CahnHilliard<dim>::postprocess(bool first_iteration)
783
784
std::string independent_column_names = " time" ;
784
785
785
786
std::vector<std::string> dependent_column_names;
786
- dependent_column_names.push_back (" x_cahn_hilliard" );
787
- dependent_column_names.push_back (" y_cahn_hilliard" );
787
+ dependent_column_names.emplace_back (" x_cahn_hilliard" );
788
+ dependent_column_names.emplace_back (" y_cahn_hilliard" );
788
789
if constexpr (dim == 3 )
789
- dependent_column_names.push_back (" z_cahn_hilliard" );
790
- dependent_column_names.push_back (" vx_cahn_hilliard" );
791
- dependent_column_names.push_back (" vy_cahn_hilliard" );
790
+ dependent_column_names.emplace_back (" z_cahn_hilliard" );
791
+ dependent_column_names.emplace_back (" vx_cahn_hilliard" );
792
+ dependent_column_names.emplace_back (" vy_cahn_hilliard" );
792
793
if constexpr (dim == 3 )
793
- dependent_column_names.push_back (" vz_cahn_hilliard" );
794
+ dependent_column_names.emplace_back (" vz_cahn_hilliard" );
794
795
795
796
std::vector<Tensor<1 , dim>> position_vector{
796
797
position_and_velocity.first };
@@ -941,10 +942,10 @@ CahnHilliard<dim>::write_checkpoint()
941
942
parallel::distributed::SolutionTransfer<dim, GlobalVectorType>>(
942
943
dof_handler);
943
944
944
- sol_set_transfer.push_back (&present_solution);
945
- for (unsigned int i = 0 ; i < previous_solutions. size (); ++i )
945
+ sol_set_transfer.emplace_back (&present_solution);
946
+ for (const auto &previous_solution : previous_solutions)
946
947
{
947
- sol_set_transfer.push_back (&previous_solutions[i] );
948
+ sol_set_transfer.emplace_back (&previous_solution );
948
949
}
949
950
solution_transfer->prepare_for_serialization (sol_set_transfer);
950
951
@@ -1491,14 +1492,10 @@ CahnHilliard<dim>::output_newton_update_norms(
1491
1492
double local_max = std::numeric_limits<double >::lowest ();
1492
1493
1493
1494
1494
- for (auto j = index_set_phase_order[0 ].begin ();
1495
- j != index_set_phase_order[0 ].end ();
1496
- j++)
1495
+ for (const auto &j : index_set_phase_order[0 ])
1497
1496
{
1498
- double dof_newton_update = newton_update[*j];
1499
-
1497
+ double dof_newton_update = newton_update[j];
1500
1498
local_sum += dof_newton_update * dof_newton_update;
1501
-
1502
1499
local_max = std::max (local_max, std::abs (dof_newton_update));
1503
1500
}
1504
1501
@@ -1511,14 +1508,10 @@ CahnHilliard<dim>::output_newton_update_norms(
1511
1508
local_sum = 0.0 ;
1512
1509
local_max = std::numeric_limits<double >::lowest ();
1513
1510
1514
- for (auto j = index_set_chemical_potential[1 ].begin ();
1515
- j != index_set_chemical_potential[1 ].end ();
1516
- j++)
1511
+ for (const auto &j : index_set_chemical_potential[0 ])
1517
1512
{
1518
- double dof_newton_update = newton_update[*j];
1519
-
1513
+ double dof_newton_update = newton_update[j];
1520
1514
local_sum += dof_newton_update * dof_newton_update;
1521
-
1522
1515
local_max = std::max (local_max, std::abs (dof_newton_update));
1523
1516
}
1524
1517
0 commit comments