KerMor  0.9
Model order reduction for nonlinear dynamical systems and nonlinear approximation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BaseCompLemmaEstimator.m
Go to the documentation of this file.
1 namespace error{
2 
3 
4 /* (Autoinserted by mtoc++)
5  * This source code has been filtered by the mtoc++ executable,
6  * which generates code that can be processed by the doxygen documentation tool.
7  *
8  * On the other hand, it can neither be interpreted by MATLAB, nor can it be compiled with a C++ compiler.
9  * Except for the comments, the function bodies of your M-file functions are untouched.
10  * Consequently, the FILTER_SOURCE_FILES doxygen switch (default in our Doxyfile.template) will produce
11  * attached source files that are highly readable by humans.
12  *
13  * Additionally, links in the doxygen generated documentation to the source code of functions and class members refer to
14  * the correct locations in the source code browser.
15  * However, the line numbers most likely do not correspond to the line numbers in the original MATLAB source files.
16  */
17 
19  :public error.BaseEstimator {
45  protected: /* ( Transient ) */
46 
59  public:
60 
73  public:
74 
76 
77 
78  private: /* ( Transient ) */
79 
80  lstPreSolve;
91  public: /* ( Transient ) */
92 
94  this = this@error.BaseEstimator;
95  this.ExtraODEDims= 1;
96  }
97 
98 
100 
101  /* Call superclass */
102  offlineComputations@error.BaseEstimator(this, model);
103  }
113  function prepared = prepareForReducedModel(models.ReducedModel rm) {
114  prepared = prepareForReducedModel@error.BaseEstimator(this, rm);
115 
116  if isa(rm.FullModel.System.B," dscomponents.AffLinInputConv ")
117  prepared.aComp= error.alpha.AffineParametric(rm);
118  else
119  prepared.aComp= error.alpha.Constant(rm);
120  end
121 
122  prepared.lstPreSolve= addlistener(rm.ODESolver," PreSolve ",@prepared.cbPreSolve);
123  }
140  function e = evalODEPart(colvec x,double t,double ut) {
141  phi = this.ReducedModel.System.f.Expansion.getKernelVector(x(1:end-1), t, this.mu);
142 
143  a = this.aComp.getAlpha(phi, ut, t, this.mu);
144  b = this.getBeta(x, t);
145  e = b*x(end) + a;
146 
147  this.EstimationData(:,this.StepNr) = [t; a; b];
148  this.StepNr= this.StepNr + 1;
149  }
169  function ct = prepareConstants(colvec<double> mu,integer inputidx) {
170  st = tic;
171  if isempty(this.lstPreSolve)
172  this.lstPreSolve= addlistener(this.ReducedModel.ODESolver," PreSolve ",@this.cbPreSolve);
173  end
174  this.lstPreSolve.Enabled= true;
175  this.StepNr= 1;
176  ct = toc(st) + prepareConstants@error.BaseEstimator(this, mu, inputidx);
177  }
178 
179 
180  function copy = clone(copy) {
181  copy = clone@error.BaseEstimator(this, copy);
182  copy.EstimationData= this.EstimationData;
183  copy.aComp= this.aComp;
184  copy.StepNr= this.StepNr;
185  if ~isempty(copy.ReducedModel)
186  copy.lstPreSolve= addlistener(copy.ReducedModel.ODESolver," PreSolve ",@copy.cbPreSolve);
187  copy.lstPreSolve.Enabled= this.lstPreSolve.Enabled;
188  end
189  }
190 
191 
192  function clear() {
193  clear@error.BaseEstimator(this);
194  this.EstimationData= [];
195  }
196 
197 
198  function a = getAlpha(colvec<double> x,double t,colvec<double> ut) {
199  phi = this.ReducedModel.System.f.getKernelVector(x, t, this.mu);
200  a = this.aComp.getAlpha(phi, ut, t, this.mu);
201  }
213  function ct = postProcess(colvec<double> x,double t,integer inputidx) {
214  if ~isempty(this.lstPreSolve)
215  this.lstPreSolve.Enabled= false;
216  end
217  ct = postProcess@error.BaseEstimator(this, x, t, inputidx);
218  }
231  public: /* ( Abstract ) */ /* ( Transient ) */
232 
233  virtual function b = getBeta(colvec x,double t) = 0;
245  private: /* ( Transient ) */
246 
247  function cbPreSolve(sender,data) {
248  if isempty(this.EstimationData) || size(this.EstimationData,2) ~= length(data.Times)
249  this.EstimationData= zeros(3,length(data.Times));
250  end
251  }
262  public: /* ( Static ) */ /* ( Transient ) */
263 
264  static function errmsg = validModelForEstimator(models.BaseFullModel model) {
265  errmsg = [];
266  if ~isempty(model.Approx)
267  if ~isa(model.Approx," approx.KernelApprox ")
268  errmsg = " The full model "" s approx function must be a subclass of approx.KernelApprox for this error estimator. ";
269  return;
270  end
271  elseif ~isa(model.System.f," dscomponents.ParamTimeKernelCoreFun ")
272  errmsg = " If no approximation is used, the full model "" s core function must be a subclass of kernels.ParamTimeKernelCoreFun for this error estimator. ";
273  return;
274  end
275  if ~isa(model.System.C," dscomponents.LinearOutputConv ")
276  errmsg = " Local Lipschitz estimators work only for constant linear output conversion. ";
277  return;
278  elseif model.System.C.TimeDependent
279  errmsg = " Output error estimation for time dependent output not implemented yet. ";
280  return;
281  end
282  if ~isa(model.ODESolver," solvers.BaseCustomSolver ");
283  errmsg = " The reduced models ODE solver must be a subclass of BaseCustomSolver. ";
284  end
285  }
297 };
298 }
299 
300 
301 
function a = getAlpha(colvec< double > x,double t,colvec< double > ut)
Convenience access method for semi-implicit euler method.
function copy = clone(copy)
The interface method with returns a copy of the current class instance.
BaseCompLemmaEstimator: Base class for error estimators using the comparison lemma formulation...
The base class for any KerMor detailed model.
Definition: BaseFullModel.m:18
models.BaseFullModel FullModel
The full model this reduced model was created from.
Definition: ReducedModel.m:53
models.BaseFirstOrderSystem System
The actual dynamical system used in the model.
Definition: BaseModel.m:102
dscomponents.AInputConv B
The input conversion.
An integer value.
The KerMor reduced model class.
Definition: ReducedModel.m:18
function prepared = prepareForReducedModel(models.ReducedModel rm)
Prepares this estimator for use with a given reduced model. Basically uses the projection matrices an...
function offlineComputations(models.BaseFullModel model)
Overrides the method from BaseEstimator and performs additional computations.
Base class for all error estimators.
Definition: BaseEstimator.m:18
virtual function b = getBeta(colvec x,double t)
Computes the term from the error estimation ODE for given time and place.
solvers.BaseSolver ODESolver
The solver to use for the ODE. Must be an instance of any solvers.BaseSolver subclass.
Definition: BaseModel.m:315
A matlab column vector.
static function errmsg = validModelForEstimator(models.BaseFullModel model)
Validations.
function ct = prepareConstants(colvec< double > mu,integer inputidx)
EstimationData
matrix containing the values at each time step.
dscomponents.ACoreFun f
The core f function from the dynamical system.
function ct = postProcess(colvec< double > x,double t,integer inputidx)
Return values: ct: The time needed for postprocessing.
models.ReducedModel ReducedModel
The reduced model associated with the error estimator.
addlistener
Creates a listener for the specified event and assigns a callback function to execute when the event ...
ExtraODEDims
The dimensions added to the ODE function by the estimator.
Definition: BaseEstimator.m:97
function e = evalODEPart(colvec x,double t,double ut)
Evaluates the auxiliary ode part for the comparison-lemma based error estimators. ...