preCICE v3.1.2
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
11namespace precice {
12namespace cplscheme {
13namespace tests {
14class AbsoluteConvergenceMeasureTest;
15}
16} // namespace cplscheme
17} // namespace precice
18
19namespace precice {
20namespace cplscheme {
21namespace impl {
22
34public:
35 explicit AbsoluteConvergenceMeasure(double convergenceLimit);
36
38
39 virtual void newMeasurementSeries()
40 {
41 _isConvergence = false;
42 }
43
44 virtual void measure(
45 const Eigen::VectorXd &oldValues,
46 const Eigen::VectorXd &newValues)
47 {
48 _normDiff = utils::IntraComm::l2norm(newValues - oldValues);
50 }
51
52 virtual bool isConvergence() const
53 {
54 return _isConvergence;
55 }
56
58 virtual std::string printState(const std::string &dataName)
59 {
61 os << "absolute convergence measure: ";
62 os << "two-norm diff of data \"" << dataName << "\" = ";
64 os << ", limit = " << _convergenceLimit;
65 os << ", conv = ";
67 os << "true";
68 else
69 os << "false";
70 return os.str();
71 }
72
73 virtual double getNormResidual()
74 {
75 return _normDiff;
76 }
77
79 {
80 return "Abs";
81 }
82
83private:
84 logging::Logger _log{"cplscheme::AbsoluteConvergenceMeasure"};
85
87
88 double _normDiff = 0;
89
90 bool _isConvergence = false;
91};
92} // namespace impl
93} // namespace cplscheme
94} // namespace precice
Measures the convergence from an old data set to a new one.
virtual std::string getAbbreviation() const
Returns an abbreviation of the name of the measure for the log file headers.
virtual void measure(const Eigen::VectorXd &oldValues, const Eigen::VectorXd &newValues)
Performs convergence measurement.
virtual bool isConvergence() const
Returns true, if the last measurement indicates convergence.
virtual double getNormResidual()
Returns the l2-norm of the coupling residuum.
virtual std::string printState(const std::string &dataName)
Adds current convergence information to output stream.
virtual void newMeasurementSeries()
To be called when a new meas. series (iteration process) starts.
Interface for measures checking the convergence of a series of datasets.
This class provides a lightweight logger.
Definition Logger.hpp:16
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)
Main namespace of the precice library.
static std::unique_ptr< precice::Participant > impl
Definition preciceC.cpp:21
T setprecision(T... args)