Loading [MathJax]/extensions/tex2jax.js
ug4
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
newtonUpdaterGeneric.h
Go to the documentation of this file.
1/*
2 * newtonUpdaterGeneric.h
3 *
4 * Created on: 28.07.2021
5 * Author: Markus Knodel
6 */
7
8#ifndef UGCORE_UGBASE_LIB_DISC_OPERATOR_NON_LINEAR_OPERATOR_NEWTON_SOLVER_NEWTONUPDATERGENERIC_H_
9#define UGCORE_UGBASE_LIB_DISC_OPERATOR_NON_LINEAR_OPERATOR_NEWTON_SOLVER_NEWTONUPDATERGENERIC_H_
10
11#include <ostream>
12#include <string>
13#include <vector>
14#include <cmath>
15#include <sstream>
16#include <type_traits>
17
18#include "common/common.h"
19
20namespace ug
21{
22
23template <typename TVector>
25{
26
27public:
28
30
31
32 using vector_type = TVector;
33
34 virtual bool updateSolution( vector_type & sol, vector_type const & corr, bool signNegative = true )
35 {
36 if( signNegative )
37 sol -= corr;
38 else
39 sol += corr;
40
41 return true;
42// return (*this)(sol, 1, sol, - 1, corr );
43 }
44
45
46 virtual bool updateSolution( vector_type & solNew, number scaleOldSol, vector_type const & solOld,
47 number scaleCorr, vector_type const & corr )
48 {
49 VecScaleAdd(solNew, scaleOldSol, solOld, scaleCorr, corr);
50
51 return true;
52
53 }
54
55 virtual bool resetSolution( vector_type & resettedSol, vector_type const & oldSol )
56 {
57 resettedSol = oldSol;
58
59 // reset not only u, but also internal variables if available!!!!!
60
61 return true;
62 }
63
64 virtual bool tellAndFixUpdateEvents( vector_type const & sol )
65 {
66 return true;
67 }
68
69};
70
71}
72
73
74#endif /* UGCORE_UGBASE_LIB_DISC_OPERATOR_NON_LINEAR_OPERATOR_NEWTON_SOLVER_NEWTONUPDATERGENERIC_H_ */
75
76
77// muss noch im Newton und line search irgendwie automatisch so initialisiert werden, aber auf User-Wunsch ueberschrieben
78// mit Hilfe von gettern und settern, damit entweder der line search oder der Newton selber sich das vom anderen holen koennen
79// und dann muss es soweit registriert werden, wie es noetig ist, damit man von aussen zu greifen kann
80// und die abgeleiteten Klassen brauchen ggf einen Konstruktor und so weiter
82//typedef typename TAlgebra::vector_type vector_type;
83
84// using vector_type = TVector; // typename TAlgebra::vector_type;
85// using vec_typ_val_typ = typename vector_type::value_type;
86
87//typedef TVector vector_type; // typename TAlgebra::vector_type;
88//typedef typename vector_type::value_type vec_typ_val_typ;
89//typedef typename vector_type::value_type value_type;
90
91// template <typename VecTyp> //, typename ScalTyp >
92// template <typename ScalTyp> //, typename ScalTyp >
93// bool updateNewton( vector_type & solNew, value_type scaleOldSol, vector_type const & solOld,
94// value_type scaleCorr, vector_type const & corr )
95// bool updateNewton( VecTyp & solNew, ScalTyp scaleOldSol, VecTyp const & solOld,
96// ScalTyp scaleCorr, VecTyp const & corr )
97// bool updateNewton( VecTyp & solNew, typename VecTyp::value_type scaleOldSol, VecTyp const & solOld,
98// typename VecTyp::value_type scaleCorr, VecTyp const & corr )
99// bool updateNewton( vector_type & solNew, ScalTyp scaleOldSol, vector_type const & solOld,
100// ScalTyp scaleCorr, vector_type const & corr )
101// static_assert( std::is_same<ScalTyp, double>::value, "is ScalType double" );
102//
103// static_assert( !std::is_same<ScalTyp, number>::value, "! is ScalType number" );
104//
105// static_assert( std::is_same<ScalTyp, value_type>::value, "is it value_type" );
106//
107// static_assert( std::is_same<double, value_type>::value, "is value_type double" );
108//
109// static_assert( std::is_same<number, value_type>::value, "is value_type number" );
110
111 // Standard: try on line u := u - lambda*p
112 // VecScaleAdd(u, 1.0, u, (-1)*lambda, p);
113
114// typedef typename vector_type::size_type size_type;
116//
117// for(size_type i = 0; i < solNew.size(); ++i)
118// {
119// solNew[i] = scaleOldSol * solOld[i] + scaleCorr * corr[i];
120// }
Definition newtonUpdaterGeneric.h:25
virtual bool updateSolution(vector_type &solNew, number scaleOldSol, vector_type const &solOld, number scaleCorr, vector_type const &corr)
Definition newtonUpdaterGeneric.h:46
TVector vector_type
Definition newtonUpdaterGeneric.h:32
virtual bool updateSolution(vector_type &sol, vector_type const &corr, bool signNegative=true)
Definition newtonUpdaterGeneric.h:34
virtual bool tellAndFixUpdateEvents(vector_type const &sol)
Definition newtonUpdaterGeneric.h:64
virtual bool resetSolution(vector_type &resettedSol, vector_type const &oldSol)
Definition newtonUpdaterGeneric.h:55
virtual ~NewtonUpdaterGeneric()
Definition newtonUpdaterGeneric.h:29
double number
Definition types.h:124
void VecScaleAdd(vector_t &vOut, typename vector_t::value_type s1, const vector_t &v1, typename vector_t::value_type s2, const vector_t &v2)
Scales two Vectors, adds them and returns the sum in a third vector.
Definition math_vector_functions_common_impl.hpp:265
the ug namespace