preCICE v3.2.0
Loading...
Searching...
No Matches
AbsoluteConvergenceMeasure.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <Eigen/Core>
4#include <iomanip>
5#include <ostream>
6#include <string>
8#include "logging/Logger.hpp"
9#include "utils/IntraComm.hpp"
10#include "utils/assertion.hpp"
11
13class AbsoluteConvergenceMeasureTest;
14}
15
17
29public:
30 explicit AbsoluteConvergenceMeasure(double convergenceLimit);
31
32 ~AbsoluteConvergenceMeasure() override = default;
33
34 void newMeasurementSeries() override
35 {
36 _isConvergence = false;
37 }
38
39 void measure(
40 const Eigen::VectorXd &oldValues,
41 const Eigen::VectorXd &newValues) override
42 {
43 PRECICE_ASSERT(oldValues.size() == newValues.size());
44 _normDiff = utils::IntraComm::l2norm(newValues - oldValues);
46 }
47
48 bool isConvergence() const override
49 {
50 return _isConvergence;
51 }
52
54 std::string printState(const std::string &dataName) override
55 {
57 os << "absolute convergence measure: ";
58 os << "two-norm diff of data \"" << dataName << "\" = ";
60 os << ", limit = " << _convergenceLimit;
61 os << ", conv = ";
63 os << "true";
64 else
65 os << "false";
66 return os.str();
67 }
68
69 double getNormResidual() override
70 {
71 return _normDiff;
72 }
73
75 {
76 return "Abs";
77 }
78
79private:
80 logging::Logger _log{"cplscheme::AbsoluteConvergenceMeasure"};
81
83
84 double _normDiff = 0;
85
86 bool _isConvergence = false;
87};
88} // namespace precice::cplscheme::impl
#define PRECICE_ASSERT(...)
Definition assertion.hpp:85
bool isConvergence() const override
Returns true, if the last measurement indicates convergence.
void measure(const Eigen::VectorXd &oldValues, const Eigen::VectorXd &newValues) override
Performs convergence measurement.
std::string getAbbreviation() const override
Returns an abbreviation of the name of the measure for the log file headers.
void newMeasurementSeries() override
To be called when a new meas. series (iteration process) starts.
double getNormResidual() override
Returns the l2-norm of the coupling residuum.
std::string printState(const std::string &dataName) override
Adds current convergence information to output stream.
Interface for measures checking the convergence of a series of datasets.
This class provides a lightweight logger.
Definition Logger.hpp:17
static double l2norm(const Eigen::VectorXd &vec)
The l2 norm of a vector is calculated on distributed data.
Definition IntraComm.cpp:67
T scientific(T... args)
T setprecision(T... args)
T str(T... args)