Skip to content

Commit 126f5be

Browse files
authored
Merge pull request #4065 from dknez/eim_greedy_normalization_fix
Update _max_abs_value_in_training_set after normalizing snapshots
2 parents f543821 + 36305d2 commit 126f5be

1 file changed

Lines changed: 22 additions & 3 deletions

File tree

src/reduced_basis/rb_eim_construction.C

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -640,9 +640,10 @@ void RBEIMConstruction::apply_normalization_to_solution_snapshots()
640640

641641
for (unsigned int i=0; i<n_snapshots; i++)
642642
{
643+
Real norm_val = 0.;
643644
if (rbe.get_parametrized_function().on_mesh_sides())
644645
{
645-
Real norm_val = std::sqrt(std::real(side_inner_product(
646+
norm_val = std::sqrt(std::real(side_inner_product(
646647
_local_side_parametrized_functions_for_training[i],
647648
_local_side_parametrized_functions_for_training[i],
648649
apply_comp_scaling)));
@@ -652,7 +653,7 @@ void RBEIMConstruction::apply_normalization_to_solution_snapshots()
652653
}
653654
else if (rbe.get_parametrized_function().on_mesh_nodes())
654655
{
655-
Real norm_val = std::sqrt(std::real(node_inner_product(
656+
norm_val = std::sqrt(std::real(node_inner_product(
656657
_local_node_parametrized_functions_for_training[i],
657658
_local_node_parametrized_functions_for_training[i],
658659
apply_comp_scaling)));
@@ -662,15 +663,33 @@ void RBEIMConstruction::apply_normalization_to_solution_snapshots()
662663
}
663664
else
664665
{
665-
Real norm_val = std::sqrt(std::real(inner_product(
666+
norm_val = std::sqrt(std::real(inner_product(
666667
_local_parametrized_functions_for_training[i],
667668
_local_parametrized_functions_for_training[i],
668669
apply_comp_scaling)));
669670

670671
if (norm_val > 0.)
671672
scale_parametrized_function(_local_parametrized_functions_for_training[i], 1./norm_val);
672673
}
674+
675+
// Since we're rescaling the training samples, we should also rescale
676+
// _max_abs_value_in_training_set in the same way. We obtained the
677+
// _max_abs_value_in_training_set value from the sample with index
678+
// _max_abs_value_in_training_set_index, so we rescale using the norm
679+
// of this sample here. Note that the value we obtain may not be exactly
680+
// equal to the max value we would obtain after looping over all the
681+
// normalized samples, because we normalized in the L2 norm rather than
682+
// in the max norm, but it should be close to this "true max" value. The
683+
// main use-case of _max_abs_value_in_training_set is to scale the relative
684+
// error tolerance in the Greedy training, and the L2-norm-scaled value of
685+
// _max_abs_value_in_training_set that we obtain here should be sufficient
686+
// for that purpose.
687+
if ((i == _max_abs_value_in_training_set_index) && (norm_val > 0.))
688+
_max_abs_value_in_training_set /= norm_val;
673689
}
690+
691+
libMesh::out << "Maximum absolute value in the training set after normalization: "
692+
<< _max_abs_value_in_training_set << std::endl << std::endl;
674693
}
675694

676695
Real RBEIMConstruction::train_eim_approximation_with_POD()

0 commit comments

Comments
 (0)