@@ -1327,78 +1327,71 @@ void
1327
1327
CahnHilliard<dim>::output_newton_update_norms(
1328
1328
const unsigned int display_precision)
1329
1329
{
1330
- auto mpi_communicator = triangulation->get_communicator ();
1331
-
1332
- FEValuesExtractors::Scalar phase_order (0 );
1333
- FEValuesExtractors::Scalar chemical_potential (1 );
1334
-
1335
- ComponentMask phase_order_mask = fe->component_mask (phase_order);
1336
- ComponentMask chemical_potential_mask = fe->component_mask (chemical_potential);
1337
-
1338
- const std::vector<IndexSet> index_set_phase_order =
1339
- DoFTools::locally_owned_dofs_per_component (dof_handler, phase_order_mask);
1340
- const std::vector<IndexSet> index_set_chemical_potential =
1341
- DoFTools::locally_owned_dofs_per_component (dof_handler, chemical_potential_mask);
1342
-
1343
- double local_sum = 0.0 ;
1344
- double local_max = std::numeric_limits<double >::lowest ();
1345
-
1346
-
1347
- for (auto j = index_set_phase_order[0 ].begin ();
1348
- j != index_set_phase_order[0 ].end ();
1349
- j++)
1350
- {
1351
- double dof_newton_update = newton_update[*j];
1330
+ auto mpi_communicator = triangulation->get_communicator ();
1352
1331
1353
- local_sum += dof_newton_update * dof_newton_update;
1332
+ FEValuesExtractors::Scalar phase_order (0 );
1333
+ FEValuesExtractors::Scalar chemical_potential (1 );
1354
1334
1355
- local_max = std::max (local_max, dof_newton_update );
1356
- }
1357
-
1335
+ ComponentMask phase_order_mask = fe-> component_mask (phase_order );
1336
+ ComponentMask chemical_potential_mask =
1337
+ fe-> component_mask (chemical_potential);
1358
1338
1359
- double global_phase_order_l2_norm =
1360
- std::sqrt (Utilities::MPI::sum (local_sum, mpi_communicator));
1361
- double global_phase_order_linfty_norm =
1362
- Utilities::MPI::max (local_max, mpi_communicator);
1339
+ const std::vector<IndexSet> index_set_phase_order =
1340
+ DoFTools::locally_owned_dofs_per_component (dof_handler, phase_order_mask);
1341
+ const std::vector<IndexSet> index_set_chemical_potential =
1342
+ DoFTools::locally_owned_dofs_per_component (dof_handler,
1343
+ chemical_potential_mask);
1363
1344
1364
- local_sum = 0.0 ;
1365
- local_max = std::numeric_limits<double >::lowest ();
1345
+ double local_sum = 0.0 ;
1346
+ double local_max = std::numeric_limits<double >::lowest ();
1366
1347
1367
- for (auto j = index_set_chemical_potential[1 ].begin ();
1368
- j != index_set_chemical_potential[1 ].end ();
1369
- j++)
1370
- {
1371
- double dof_newton_update = newton_update[*j];
1372
1348
1373
- local_sum += dof_newton_update * dof_newton_update;
1349
+ for (auto j = index_set_phase_order[0 ].begin ();
1350
+ j != index_set_phase_order[0 ].end ();
1351
+ j++)
1352
+ {
1353
+ double dof_newton_update = newton_update[*j];
1354
+
1355
+ local_sum += dof_newton_update * dof_newton_update;
1374
1356
1375
- local_max = std::max (local_max, dof_newton_update);
1376
- }
1357
+ local_max = std::max (local_max, std::abs (dof_newton_update));
1358
+ }
1359
+
1360
+
1361
+ double global_phase_order_l2_norm =
1362
+ std::sqrt (Utilities::MPI::sum (local_sum, mpi_communicator));
1363
+ double global_phase_order_linfty_norm =
1364
+ Utilities::MPI::max (local_max, mpi_communicator);
1365
+
1366
+ local_sum = 0.0 ;
1367
+ local_max = std::numeric_limits<double >::lowest ();
1368
+
1369
+ for (auto j = index_set_chemical_potential[1 ].begin ();
1370
+ j != index_set_chemical_potential[1 ].end ();
1371
+ j++)
1372
+ {
1373
+ double dof_newton_update = newton_update[*j];
1374
+
1375
+ local_sum += dof_newton_update * dof_newton_update;
1376
+
1377
+ local_max = std::max (local_max, std::abs (dof_newton_update));
1378
+ }
1377
1379
1378
- double global_chemical_potential_l2_norm =
1379
- std::sqrt (Utilities::MPI::sum (local_sum, mpi_communicator));
1380
- double global_chemical_potential_linfty_norm =
1381
- Utilities::MPI::max (local_max, mpi_communicator);
1382
-
1383
- this ->pcout << std::setprecision (display_precision)
1384
- << " \n\t ||du||_L2 = " << std::setw (6 )
1385
- << newton_update.l2_norm () << std::setw (6 )
1386
- << " \t ||du||_Linfty = "
1387
- << std::setprecision (display_precision)
1388
- << newton_update.linfty_norm () << std::endl;
1389
-
1390
- this ->pcout << std::setprecision (display_precision)
1391
- << " \n\t ||dphi||_L2 = " << std::setw (6 )
1392
- << global_phase_order_l2_norm << std::setw (6 )
1393
- << " \t ||dphi||_Linfty = "
1394
- << std::setprecision (display_precision)
1395
- << global_phase_order_linfty_norm << std::endl;
1396
- this ->pcout << std::setprecision (display_precision)
1397
- << " \t ||deta||_L2 = " << std::setw (6 ) << global_chemical_potential_l2_norm
1398
- << std::setw (6 ) << " \t ||deta||_Linfty = "
1399
- << std::setprecision (display_precision)
1400
- << global_chemical_potential_linfty_norm << std::endl;
1401
-
1380
+ double global_chemical_potential_l2_norm =
1381
+ std::sqrt (Utilities::MPI::sum (local_sum, mpi_communicator));
1382
+ double global_chemical_potential_linfty_norm =
1383
+ Utilities::MPI::max (local_max, mpi_communicator);
1384
+
1385
+ this ->pcout << std::setprecision (display_precision)
1386
+ << " \n\t ||dphi||_L2 = " << std::setw (6 )
1387
+ << global_phase_order_l2_norm << std::setw (6 )
1388
+ << " \t ||dphi||_Linfty = " << std::setprecision (display_precision)
1389
+ << global_phase_order_linfty_norm << std::endl;
1390
+ this ->pcout << std::setprecision (display_precision)
1391
+ << " \t ||deta||_L2 = " << std::setw (6 )
1392
+ << global_chemical_potential_l2_norm << std::setw (6 )
1393
+ << " \t ||deta||_Linfty = " << std::setprecision (display_precision)
1394
+ << global_chemical_potential_linfty_norm << std::endl;
1402
1395
}
1403
1396
1404
1397
template std::pair<Tensor<1 , 2 >, Tensor<1 , 2 >>
0 commit comments