rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
MergedSpaceOpEvals.m
1 classdef MergedSpaceOpEvals < SnapshotsGenerator.SpaceOpEvals
2  % this class combines two SnapshotsGenerator.SpaceOpEvals and produces the
3  % combination of both operator/function evaluations.
4  %
5  % The generated snapshots are a concatenation of both underlying generators.
6  %
7  % Example:
8  % If you have more than one operator in your numerical scheme, for which
9  % you want to create a collateral reduced basis space, you can merge their
10  % space operator evaluation instances together and then create a collateral
11  % reduced basis space valid for all the operators.
12 
13  properties (Access = private);
14 
15  generator1; % first underlying object of type SnapshotsGenerator.SpaceOpEvals
16 
17  generator2; % second underlying object of type SnapshotsGenerator.SpaceOpEvals
18 
19  end
20 
21  methods
22  function sumeidg = MergedSpaceOpEvals(generator1, generator2)
23  % function sumeidg = MergedSpaceOpEvals(generator1, generator2)
24  % constructor merging two SnapshotsGenerator.SpaceOpEvals objects together.
25  %
26  % Parameters:
27  % generator1: first space operator evaluation object of type SnapshotsGenerator.SpaceOpEvals.
28  % generator2: second space operator evaluation object of type SnapshotsGenerator.SpaceOpEvals.
29 
30  assert(generator1.rb_detailed_generator == generator2.rb_detailed_generator);
31  id1 = generator1.id;
32  id2 = generator2.id;
33  if ~iscell(id1)
34  id1 = {id1};
35  end
36  id = [ id1, id2 ];
37 
38  model1 = get_underlying_model(generator1);
39  model2 = get_underlying_model(generator2);
40 
41  sumeidg = sumeidg@SnapshotsGenerator.SpaceOpEvals(model1, id, ...
42  generator1.rb_detailed_generator, ...
43  generator1.ophandle, ...
44  generator1.force_delete & generator2.force_delete, ...
45  generator1.enable_caching & generator2.enable_caching);
46  assert_model_is_consistent(sumeidg, model1, model2);
47 
48  sumeidg.generator1 = generator1;
49  sumeidg.generator2 = generator2;
50  end
51 
52  function combination = plus(this, other)
53  % function combination = plus(this, other)
54  % convenience function allowing to merge several
55  % SnapshotsGenerator.SpaceOpEvals instances together by "adding" them
56  % together with a '+' operator.
57  %
58  % Parameters:
59  % other: an "addend" of type SnapshotsGenerator.SpaceOpEvals
60  %
61  % Return values:
62  % combination: the merged object of type SnapshotsGenerator.MergedSpaceOpEvals
63  combination = MergedSpaceOpEvals(this, other);
64  end
65 
66  end
67  methods(Access = protected);
68 
69  function LU = generate_ei_impl(this, dmodel, detailed_data, U)
70  LU = [generate_ei_impl(this.generator1, dmodel, detailed_data, U), ...
71  generate_ei_impl(this.generator2, dmodel, detailed_data, U)];
72  end
73  end
74 
75 end
this class combines two SnapshotsGenerator.SpaceOpEvals and produces the combination of both operator...
Implementation of a SnapshotsGenerator.Cached for empirical basis generation. The generate() method r...
Definition: SpaceOpEvals.m:18
Cacheable generators of detailed data snapshots.
Definition: Cached.m:1