libMesh
transient_rb_evaluation.C
Go to the documentation of this file.
1 // rbOOmit: An implementation of the Certified Reduced Basis method.
2 // Copyright (C) 2009, 2010 David J. Knezevic
3 
4 // This file is part of rbOOmit.
5 
6 // rbOOmit is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 
11 // rbOOmit is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
15 
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 
20 // rbOOmit includes
21 #include "libmesh/transient_rb_evaluation.h"
22 #include "libmesh/transient_rb_theta_expansion.h"
23 
24 // libMesh includes
25 #include "libmesh/getpot.h"
26 #include "libmesh/int_range.h"
27 #include "libmesh/libmesh_logging.h"
28 #include "libmesh/numeric_vector.h"
29 #include "libmesh/xdr_cxx.h"
30 
31 // C++ includes
32 #include <fstream>
33 #include <sstream>
34 #include <iomanip>
35 
36 namespace libMesh
37 {
38 
39 TransientRBEvaluation::TransientRBEvaluation(const Parallel::Communicator & comm_in) :
40  RBEvaluation(comm_in),
41  _rb_solve_data_cached(false)
42 {
43  // Indicate that we need to compute the RB
44  // inner product matrix in this case
46 }
47 
49 {
50  clear();
51 }
52 
54 {
55  Parent::clear();
56 
58 }
59 
61 {
63 
64  // Delete the M_q representors
65  M_q_representor.clear();
66 }
67 
68 void TransientRBEvaluation::resize_data_structures(const unsigned int Nmax,
69  bool resize_error_bound_data)
70 {
71  LOG_SCOPE("resize_data_structures()", "TransientRBEvaluation");
72 
73  Parent::resize_data_structures(Nmax, resize_error_bound_data);
74 
75  RB_L2_matrix.resize(Nmax,Nmax);
76  RB_LHS_matrix.resize(Nmax,Nmax);
77  RB_RHS_matrix.resize(Nmax,Nmax);
78  RB_RHS_save.resize(Nmax);
79 
80  TransientRBThetaExpansion & trans_theta_expansion =
81  cast_ref<TransientRBThetaExpansion &>(get_rb_theta_expansion());
82  const unsigned int Q_m = trans_theta_expansion.get_n_M_terms();
83  const unsigned int Q_a = trans_theta_expansion.get_n_A_terms();
84  const unsigned int Q_f = trans_theta_expansion.get_n_F_terms();
85 
86  // Allocate dense matrices for RB solves
87  RB_M_q_vector.resize(Q_m);
88  for (unsigned int q=0; q<Q_m; q++)
89  {
90  // Initialize the memory for the RB matrices
91  RB_M_q_vector[q].resize(Nmax,Nmax);
92  }
93 
94  // Initialize the initial condition storage
95  RB_initial_condition_all_N.resize(Nmax);
96  for (auto i : IntRange<unsigned int>(0, RB_initial_condition_all_N.size()))
97  {
98  // The i^th row holds a vector of lenght i+1
99  RB_initial_condition_all_N[i].resize(i+1);
100  }
101 
102  initial_L2_error_all_N.resize(Nmax, 0.);
103 
104 
105  if (resize_error_bound_data)
106  {
107  // Initialize vectors for the norms of the representors
108  Fq_Mq_representor_innerprods.resize(Q_f);
109  for (unsigned int i=0; i<Q_f; i++)
110  {
111  Fq_Mq_representor_innerprods[i].resize(Q_m);
112  for (unsigned int j=0; j<Q_m; j++)
113  {
114  Fq_Mq_representor_innerprods[i][j].resize(Nmax, 0.);
115  }
116  }
117 
118  unsigned int Q_m_hat = Q_m*(Q_m+1)/2;
119  Mq_Mq_representor_innerprods.resize(Q_m_hat);
120  for (unsigned int i=0; i<Q_m_hat; i++)
121  {
122  Mq_Mq_representor_innerprods[i].resize(Nmax);
123  for (unsigned int j=0; j<Nmax; j++)
124  {
125  Mq_Mq_representor_innerprods[i][j].resize(Nmax, 0.);
126  }
127  }
128 
129  Aq_Mq_representor_innerprods.resize(Q_a);
130  for (unsigned int i=0; i<Q_a; i++)
131  {
132  Aq_Mq_representor_innerprods[i].resize(Q_m);
133  for (unsigned int j=0; j<Q_m; j++)
134  {
135  Aq_Mq_representor_innerprods[i][j].resize(Nmax);
136  for (unsigned int k=0; k<Nmax; k++)
137  {
138  Aq_Mq_representor_innerprods[i][j][k].resize(Nmax, 0.);
139  }
140  }
141  }
142 
143  // Resize M_q_representor
144  // This is cleared in the call to clear_riesz_representors
145  // in Parent::resize_RB_data, so just resize here
146  M_q_representor.resize(Q_m);
147  for (unsigned int q_m=0; q_m<Q_m; q_m++)
148  {
149  M_q_representor[q_m].resize(Nmax);
150  }
151  }
152 }
153 
155 {
156  LOG_SCOPE("rb_solve()", "TransientRBEvaluation");
157 
158  if (N > get_n_basis_functions())
159  libmesh_error_msg("ERROR: N cannot be larger than the number of basis functions in rb_solve");
160 
161  const RBParameters & mu = get_parameters();
162 
163  TransientRBThetaExpansion & trans_theta_expansion =
164  cast_ref<TransientRBThetaExpansion &>(get_rb_theta_expansion());
165  const unsigned int Q_m = trans_theta_expansion.get_n_M_terms();
166  const unsigned int Q_a = trans_theta_expansion.get_n_A_terms();
167  const unsigned int Q_f = trans_theta_expansion.get_n_F_terms();
168 
169  const unsigned int n_time_steps = get_n_time_steps();
170  const Real dt = get_delta_t();
171  const Real euler_theta = get_euler_theta();
172 
173  // Resize the RB and error bound vectors
174  error_bound_all_k.resize(n_time_steps+1);
175  RB_outputs_all_k.resize(trans_theta_expansion.get_n_outputs());
176  RB_output_error_bounds_all_k.resize(trans_theta_expansion.get_n_outputs());
177  for (unsigned int n=0; n<trans_theta_expansion.get_n_outputs(); n++)
178  {
179  RB_outputs_all_k[n].resize(n_time_steps+1, 0.);
180  RB_output_error_bounds_all_k[n].resize(n_time_steps+1, 0.);
181  }
182 
183  // First assemble the mass matrix
184  DenseMatrix<Number> RB_mass_matrix_N(N,N);
185  RB_mass_matrix_N.zero();
186  DenseMatrix<Number> RB_M_q_m;
187  for (unsigned int q_m=0; q_m<Q_m; q_m++)
188  {
189  RB_M_q_vector[q_m].get_principal_submatrix(N, RB_M_q_m);
190  RB_mass_matrix_N.add(trans_theta_expansion.eval_M_theta(q_m, mu), RB_M_q_m);
191  }
192 
193  RB_LHS_matrix.resize(N,N);
195 
196  RB_RHS_matrix.resize(N,N);
198 
199  RB_LHS_matrix.add(1./dt, RB_mass_matrix_N);
200  RB_RHS_matrix.add(1./dt, RB_mass_matrix_N);
201 
202  DenseMatrix<Number> RB_Aq_a;
203  for (unsigned int q_a=0; q_a<Q_a; q_a++)
204  {
205  RB_Aq_vector[q_a].get_principal_submatrix(N, RB_Aq_a);
206 
207  RB_LHS_matrix.add( euler_theta*trans_theta_expansion.eval_A_theta(q_a,mu), RB_Aq_a);
208  RB_RHS_matrix.add( -(1.-euler_theta)*trans_theta_expansion.eval_A_theta(q_a,mu), RB_Aq_a);
209  }
210 
211  // Add forcing terms
212  DenseVector<Number> RB_Fq_f;
213  RB_RHS_save.resize(N);
214  RB_RHS_save.zero();
215  for (unsigned int q_f=0; q_f<Q_f; q_f++)
216  {
217  RB_Fq_vector[q_f].get_principal_subvector(N, RB_Fq_f);
218  RB_RHS_save.add(trans_theta_expansion.eval_F_theta(q_f,mu), RB_Fq_f);
219  }
220 
221  // Set system time level to 0
222  set_time_step(0);
223 
224  // Resize/clear the solution vector
225  RB_solution.resize(N);
226 
227  // Load the initial condition into RB_solution
228  if (N > 0)
229  {
231  }
232 
233  // Resize/clear the old solution vector
235 
236  // Initialize the RB rhs
237  DenseVector<Number> RB_rhs(N);
238  RB_rhs.zero();
239 
240  // Initialize the vectors storing solution data
241  RB_temporal_solution_data.resize(n_time_steps+1);
242  for (unsigned int time_level=0; time_level<=n_time_steps; time_level++)
243  {
244  RB_temporal_solution_data[time_level].resize(N);
245  }
246  // and load the initial data
248 
249  // Set outputs at initial time
250  {
251  DenseVector<Number> RB_output_vector_N;
252  for (unsigned int n=0; n<trans_theta_expansion.get_n_outputs(); n++)
253  {
254  RB_outputs_all_k[n][0] = 0.;
255  for (unsigned int q_l=0; q_l<trans_theta_expansion.get_n_output_terms(n); q_l++)
256  {
257  RB_output_vectors[n][q_l].get_principal_subvector(N, RB_output_vector_N);
258  RB_outputs_all_k[n][0] += trans_theta_expansion.eval_output_theta(n,q_l,mu)*RB_output_vector_N.dot(RB_solution);
259  }
260  }
261  }
262 
263  // Initialize error bounds, if necessary
264  Real error_bound_sum = 0.;
265  Real alpha_LB = 0.;
267  {
268  if (N > 0)
269  {
270  error_bound_sum += pow( initial_L2_error_all_N[N-1], 2.);
271  }
272 
273  // Set error bound at the initial time
274  error_bound_all_k[get_time_step()] = std::sqrt(error_bound_sum);
275 
276  // Compute the outputs and associated error bounds at the initial time
277  DenseVector<Number> RB_output_vector_N;
278  for (unsigned int n=0; n<trans_theta_expansion.get_n_outputs(); n++)
279  {
280  RB_outputs_all_k[n][0] = 0.;
281  for (unsigned int q_l=0; q_l<trans_theta_expansion.get_n_output_terms(n); q_l++)
282  {
283  RB_output_vectors[n][q_l].get_principal_subvector(N, RB_output_vector_N);
284  RB_outputs_all_k[n][0] += trans_theta_expansion.eval_output_theta(n,q_l,mu)*RB_output_vector_N.dot(RB_solution);
285  }
286 
288  }
289 
290  alpha_LB = get_stability_lower_bound();
291 
292  // Precompute time-invariant parts of the dual norm of the residual.
294  }
295 
296  for (unsigned int time_level=1; time_level<=n_time_steps; time_level++)
297  {
298  set_time_step(time_level);
300 
301  // Compute RB_rhs, as RB_LHS_matrix x old_RB_solution
303 
304  // Add forcing terms
305  RB_rhs.add(get_control(time_level), RB_RHS_save);
306 
307  if (N > 0)
308  {
310  }
311 
312  // Save RB_solution for current time level
314 
315  // Evaluate outputs
316  DenseVector<Number> RB_output_vector_N;
317  for (unsigned int n=0; n<trans_theta_expansion.get_n_outputs(); n++)
318  {
319  RB_outputs_all_k[n][time_level] = 0.;
320  for (unsigned int q_l=0; q_l<trans_theta_expansion.get_n_output_terms(n); q_l++)
321  {
322  RB_output_vectors[n][q_l].get_principal_subvector(N, RB_output_vector_N);
323  RB_outputs_all_k[n][time_level] += trans_theta_expansion.eval_output_theta(n,q_l,mu)*
324  RB_output_vector_N.dot(RB_solution);
325  }
326  }
327 
328  // Calculate RB error bounds
330  {
331  // Evaluate the dual norm of the residual for RB_solution_vector
332  // Real epsilon_N = uncached_compute_residual_dual_norm(N);
333  Real epsilon_N = compute_residual_dual_norm(N);
334 
335  error_bound_sum += residual_scaling_numer(alpha_LB) * pow(epsilon_N, 2.);
336 
337  // store error bound at time-level _k
338  error_bound_all_k[time_level] = std::sqrt(error_bound_sum/residual_scaling_denom(alpha_LB));
339 
340  // Now evaluated output error bounds
341  for (unsigned int n=0; n<trans_theta_expansion.get_n_outputs(); n++)
342  {
343  RB_output_error_bounds_all_k[n][time_level] = error_bound_all_k[time_level] *
344  eval_output_dual_norm(n,mu);
345  }
346  }
347  }
348 
349  _rb_solve_data_cached = true ;
350 
351  if (evaluate_RB_error_bound) // Calculate the error bounds
352  {
353  return error_bound_all_k[n_time_steps];
354  }
355  else // Don't calculate the error bounds
356  {
357  // Just return -1. if we did not compute the error bound
358  return -1.;
359  }
360 }
361 
363 {
365 
366  const unsigned int n_time_steps = get_n_time_steps();
367  // Set system time level to 0
368  set_time_step(0);
369 
370  // Resize/clear the solution vector
371  const unsigned int N = RB_RHS_save.size();
372  RB_solution.resize(N);
373 
374  // Load the initial condition into RB_solution
375  if (N > 0)
377 
378  // Resize/clear the old solution vector
380 
381  // Initialize the RB rhs
382  DenseVector<Number> RB_rhs(N);
383  RB_rhs.zero();
384 
385  for (unsigned int time_level=1; time_level<=n_time_steps; time_level++)
386  {
387  set_time_step(time_level);
389 
390  // Compute RB_rhs, as *RB_lhs_matrix x old_RB_solution
392 
393  // Add forcing terms
394  RB_rhs.add(get_control(time_level), RB_RHS_save);
395 
396  if (N > 0)
398  }
399 
400  {
401  // Just return -1. We did not compute the error bound
402  return -1.;
403  }
404 }
405 
407 {
408  // Just set the normalization factor to 1 in this case.
409  // Users can override this method if specific behavior
410  // is required.
411 
412  return 1.;
413 }
414 
416 {
417  return get_delta_t();
418 }
419 
421 {
422  LOG_SCOPE("cache_online_residual_terms()", "TransientRBEvaluation");
423 
424  const RBParameters mu = get_parameters();
425 
426  TransientRBThetaExpansion & trans_theta_expansion =
427  cast_ref<TransientRBThetaExpansion &>(get_rb_theta_expansion());
428  const unsigned int Q_m = trans_theta_expansion.get_n_M_terms();
429  const unsigned int Q_a = trans_theta_expansion.get_n_A_terms();
430  const unsigned int Q_f = trans_theta_expansion.get_n_F_terms();
431 
432  cached_Fq_term = 0.;
433  unsigned int q=0;
434  for (unsigned int q_f1=0; q_f1<Q_f; q_f1++)
435  {
436  Number cached_theta_q_f1 = trans_theta_expansion.eval_F_theta(q_f1,mu);
437  for (unsigned int q_f2=q_f1; q_f2<Q_f; q_f2++)
438  {
439  Real delta = (q_f1==q_f2) ? 1. : 2.;
440  cached_Fq_term += delta*cached_theta_q_f1*trans_theta_expansion.eval_F_theta(q_f2,mu) *
442 
443  q++;
444  }
445  }
446 
448  for (unsigned int q_f=0; q_f<Q_f; q_f++)
449  {
450  Number cached_theta_q_f = trans_theta_expansion.eval_F_theta(q_f,mu);
451  for (unsigned int q_a=0; q_a<Q_a; q_a++)
452  {
453  Number cached_theta_q_a = trans_theta_expansion.eval_A_theta(q_a,mu);
454  for (unsigned int i=0; i<N; i++)
455  {
456  cached_Fq_Aq_vector(i) += 2.*cached_theta_q_f*cached_theta_q_a*
457  Fq_Aq_representor_innerprods[q_f][q_a][i];
458  }
459  }
460  }
461 
463  q=0;
464  for (unsigned int q_a1=0; q_a1<Q_a; q_a1++)
465  {
466  Number cached_theta_q_a1 = trans_theta_expansion.eval_A_theta(q_a1,mu);
467  for (unsigned int q_a2=q_a1; q_a2<Q_a; q_a2++)
468  {
469  Number cached_theta_q_a2 = trans_theta_expansion.eval_A_theta(q_a2,mu);
470  Real delta = (q_a1==q_a2) ? 1. : 2.;
471 
472  for (unsigned int i=0; i<N; i++)
473  {
474  for (unsigned int j=0; j<N; j++)
475  {
476  cached_Aq_Aq_matrix(i,j) += delta*
477  cached_theta_q_a1*cached_theta_q_a2*
479  }
480  }
481  q++;
482  }
483  }
484 
486  for (unsigned int q_f=0; q_f<Q_f; q_f++)
487  {
488  Number cached_theta_q_f = trans_theta_expansion.eval_F_theta(q_f,mu);
489  for (unsigned int q_m=0; q_m<Q_m; q_m++)
490  {
491  Number cached_theta_q_m = trans_theta_expansion.eval_M_theta(q_m,mu);
492  for (unsigned int i=0; i<N; i++)
493  {
494  cached_Fq_Mq_vector(i) += 2.*cached_theta_q_f * cached_theta_q_m * Fq_Mq_representor_innerprods[q_f][q_m][i];
495  }
496  }
497  }
498 
500  for (unsigned int q_a=0; q_a<Q_a; q_a++)
501  {
502  Number cached_theta_q_a = trans_theta_expansion.eval_A_theta(q_a,mu);
503 
504  for (unsigned int q_m=0; q_m<Q_m; q_m++)
505  {
506  Number cached_theta_q_m = trans_theta_expansion.eval_M_theta(q_m,mu);
507 
508  for (unsigned int i=0; i<N; i++)
509  {
510  for (unsigned int j=0; j<N; j++)
511  {
512  cached_Aq_Mq_matrix(i,j) += 2.*cached_theta_q_a*cached_theta_q_m*Aq_Mq_representor_innerprods[q_a][q_m][i][j];
513  }
514  }
515  }
516  }
517 
519  q=0;
520  for (unsigned int q_m1=0; q_m1<Q_m; q_m1++)
521  {
522  Number cached_theta_q_m1 = trans_theta_expansion.eval_M_theta(q_m1,mu);
523  for (unsigned int q_m2=q_m1; q_m2<Q_m; q_m2++)
524  {
525  Number cached_theta_q_m2 = trans_theta_expansion.eval_M_theta(q_m2,mu);
526  Real delta = (q_m1==q_m2) ? 1. : 2.;
527 
528  for (unsigned int i=0; i<N; i++)
529  {
530  for (unsigned int j=0; j<N; j++)
531  {
532  cached_Mq_Mq_matrix(i,j) += delta*
533  cached_theta_q_m1*cached_theta_q_m2*
535  }
536  }
537  q++;
538  }
539  }
540 }
541 
543 {
544  LOG_SCOPE("compute_residual_dual_norm()", "TransientRBEvaluation");
545 
546  // This assembly assumes we have already called cache_online_residual_terms
547  // and that the rb_solve parameter is constant in time
548 
549  const Real dt = get_delta_t();
550  const Real euler_theta = get_euler_theta();
551  const Real current_control = get_control(get_time_step());
552 
553  DenseVector<Number> RB_u_euler_theta(N);
554  DenseVector<Number> mass_coeffs(N);
555  for (unsigned int i=0; i<N; i++)
556  {
557  RB_u_euler_theta(i) = euler_theta*RB_solution(i) +
558  (1.-euler_theta)*old_RB_solution(i);
559  mass_coeffs(i) = -(RB_solution(i) - old_RB_solution(i))/dt;
560  }
561 
562  Number residual_norm_sq = current_control*current_control*cached_Fq_term;
563 
564  residual_norm_sq += current_control*RB_u_euler_theta.dot(cached_Fq_Aq_vector);
565  residual_norm_sq += current_control*mass_coeffs.dot(cached_Fq_Mq_vector);
566 
567  for (unsigned int i=0; i<N; i++)
568  for (unsigned int j=0; j<N; j++)
569  {
570  residual_norm_sq += RB_u_euler_theta(i)*RB_u_euler_theta(j)*cached_Aq_Aq_matrix(i,j);
571  residual_norm_sq += mass_coeffs(i)*mass_coeffs(j)*cached_Mq_Mq_matrix(i,j);
572  residual_norm_sq += RB_u_euler_theta(i)*mass_coeffs(j)*cached_Aq_Mq_matrix(i,j);
573  }
574 
575 
576  if (libmesh_real(residual_norm_sq) < 0)
577  {
578  libMesh::out << "Warning: Square of residual norm is negative "
579  << "in TransientRBEvaluation::compute_residual_dual_norm()" << std::endl;
580 
581  // Sometimes this is negative due to rounding error,
582  // but error is on the order of 1.e-10, so shouldn't
583  // affect result
584  residual_norm_sq = std::abs(residual_norm_sq);
585  }
586 
587  return libmesh_real(std::sqrt( residual_norm_sq ));
588 }
589 
591 {
592  LOG_SCOPE("uncached_compute_residual_dual_norm()", "TransientRBEvaluation");
593 
594  // Use the stored representor inner product values
595  // to evaluate the residual norm
596 
597  const RBParameters & mu = get_parameters();
598 
599  TransientRBThetaExpansion & trans_theta_expansion =
600  cast_ref<TransientRBThetaExpansion &>(get_rb_theta_expansion());
601  const unsigned int Q_m = trans_theta_expansion.get_n_M_terms();
602  const unsigned int Q_a = trans_theta_expansion.get_n_A_terms();
603  const unsigned int Q_f = trans_theta_expansion.get_n_F_terms();
604 
605  const Real dt = get_delta_t();
606  const Real euler_theta = get_euler_theta();
607 
608  std::vector<Number> RB_u_euler_theta(N);
609  std::vector<Number> mass_coeffs(N);
610  for (unsigned int i=0; i<N; i++)
611  {
612  RB_u_euler_theta[i] = euler_theta*RB_solution(i) +
613  (1.-euler_theta)*old_RB_solution(i);
614  mass_coeffs[i] = -(RB_solution(i) - old_RB_solution(i))/dt;
615  }
616 
617  Number residual_norm_sq = 0.;
618 
619  unsigned int q=0;
620  for (unsigned int q_f1=0; q_f1<Q_f; q_f1++)
621  {
622  Number cached_theta_q_f1 = trans_theta_expansion.eval_F_theta(q_f1,mu);
623  for (unsigned int q_f2=q_f1; q_f2<Q_f; q_f2++)
624  {
625  Real delta = (q_f1==q_f2) ? 1. : 2.;
626  residual_norm_sq += delta*cached_theta_q_f1*trans_theta_expansion.eval_F_theta(q_f2,mu) * Fq_representor_innerprods[q];
627 
628  q++;
629  }
630  }
631 
632  for (unsigned int q_f=0; q_f<Q_f; q_f++)
633  {
634  Number cached_theta_q_f = trans_theta_expansion.eval_F_theta(q_f,mu);
635  for (unsigned int q_a=0; q_a<Q_a; q_a++)
636  {
637  Number cached_theta_q_a = trans_theta_expansion.eval_A_theta(q_a,mu);
638  for (unsigned int i=0; i<N; i++)
639  {
640  residual_norm_sq += 2.*RB_u_euler_theta[i]*cached_theta_q_f*cached_theta_q_a*
641  Fq_Aq_representor_innerprods[q_f][q_a][i];
642  }
643  }
644  }
645 
646  q=0;
647  for (unsigned int q_a1=0; q_a1<Q_a; q_a1++)
648  {
649  Number cached_theta_q_a1 = trans_theta_expansion.eval_A_theta(q_a1,mu);
650  for (unsigned int q_a2=q_a1; q_a2<Q_a; q_a2++)
651  {
652  Number cached_theta_q_a2 = trans_theta_expansion.eval_A_theta(q_a2,mu);
653  Real delta = (q_a1==q_a2) ? 1. : 2.;
654 
655  for (unsigned int i=0; i<N; i++)
656  {
657  for (unsigned int j=0; j<N; j++)
658  {
659  residual_norm_sq += delta*RB_u_euler_theta[i]*RB_u_euler_theta[j]*
660  cached_theta_q_a1*cached_theta_q_a2*
662  }
663  }
664  q++;
665  }
666  }
667 
668  // Now add the terms due to the time-derivative
669  q=0;
670  for (unsigned int q_m1=0; q_m1<Q_m; q_m1++)
671  {
672  Number cached_theta_q_m1 = trans_theta_expansion.eval_M_theta(q_m1,mu);
673  for (unsigned int q_m2=q_m1; q_m2<Q_m; q_m2++)
674  {
675  Number cached_theta_q_m2 = trans_theta_expansion.eval_M_theta(q_m2,mu);
676  Real delta = (q_m1==q_m2) ? 1. : 2.;
677 
678  for (unsigned int i=0; i<N; i++)
679  {
680  for (unsigned int j=0; j<N; j++)
681  {
682  residual_norm_sq += delta*mass_coeffs[i]*mass_coeffs[j]*
683  cached_theta_q_m1*cached_theta_q_m2*
685  }
686  }
687  q++;
688  }
689  }
690 
691  for (unsigned int q_f=0; q_f<Q_f; q_f++)
692  {
693  Number cached_theta_q_f = trans_theta_expansion.eval_F_theta(q_f,mu);
694  for (unsigned int q_m=0; q_m<Q_m; q_m++)
695  {
696  Number cached_theta_q_m = trans_theta_expansion.eval_M_theta(q_m,mu);
697  for (unsigned int i=0; i<N; i++)
698  {
699  residual_norm_sq += 2.*mass_coeffs[i]*cached_theta_q_f * cached_theta_q_m * Fq_Mq_representor_innerprods[q_f][q_m][i];
700  }
701  }
702  }
703 
704  for (unsigned int q_a=0; q_a<Q_a; q_a++)
705  {
706  Number cached_theta_q_a = trans_theta_expansion.eval_A_theta(q_a,mu);
707 
708  for (unsigned int q_m=0; q_m<Q_m; q_m++)
709  {
710  Number cached_theta_q_m = trans_theta_expansion.eval_M_theta(q_m,mu);
711 
712  for (unsigned int i=0; i<N; i++)
713  {
714  for (unsigned int j=0; j<N; j++)
715  {
716  residual_norm_sq += 2.*RB_u_euler_theta[i]*mass_coeffs[j]*
717  cached_theta_q_a*cached_theta_q_m*
718  Aq_Mq_representor_innerprods[q_a][q_m][i][j];
719  }
720  }
721  }
722  }
723 
724  if (libmesh_real(residual_norm_sq) < 0)
725  {
726  libMesh::out << "Warning: Square of residual norm is negative "
727  << "in TransientRBEvaluation::compute_residual_dual_norm()" << std::endl;
728 
729  // Sometimes this is negative due to rounding error,
730  // but error is on the order of 1.e-10, so shouldn't
731  // affect result
732  residual_norm_sq = std::abs(residual_norm_sq);
733  }
734 
735  // libMesh::out << "slow residual_sq = " << slow_residual_norm_sq
736  // << ", fast residual_sq = " << residual_norm_sq << std::endl;
737 
738  return libmesh_real(std::sqrt( residual_norm_sq ));
739 }
740 
741 void TransientRBEvaluation::legacy_write_offline_data_to_files(const std::string & directory_name,
742  const bool write_binary_data)
743 {
744  LOG_SCOPE("legacy_write_offline_data_to_files()", "TransientRBEvaluation");
745 
747 
748  TransientRBThetaExpansion & trans_theta_expansion =
749  cast_ref<TransientRBThetaExpansion &>(get_rb_theta_expansion());
750  const unsigned int Q_m = trans_theta_expansion.get_n_M_terms();
751  const unsigned int Q_a = trans_theta_expansion.get_n_A_terms();
752  const unsigned int Q_f = trans_theta_expansion.get_n_F_terms();
753 
754  const unsigned int n_bfs = get_n_basis_functions();
755 
756  // The writing mode: ENCODE for binary, WRITE for ASCII
757  XdrMODE mode = write_binary_data ? ENCODE : WRITE;
758 
759  // The suffix to use for all the files that are written out
760  const std::string suffix = write_binary_data ? ".xdr" : ".dat";
761 
762  if (this->processor_id() == 0)
763  {
764  std::ostringstream file_name;
765 
766  // Write out the temporal discretization data
767  file_name.str("");
768  file_name << directory_name << "/temporal_discretization_data" << suffix;
769  Xdr temporal_discretization_data_out(file_name.str(), mode);
770 
771  Real real_value; unsigned int int_value;
772  real_value = get_delta_t(); temporal_discretization_data_out << real_value;
773  real_value = get_euler_theta(); temporal_discretization_data_out << real_value;
774  int_value = get_n_time_steps(); temporal_discretization_data_out << int_value;
775  int_value = get_time_step(); temporal_discretization_data_out << int_value;
776  temporal_discretization_data_out.close();
777 
778 
779  // Write out the L2 matrix
780  file_name.str("");
781  file_name << directory_name << "/RB_L2_matrix" << suffix;
782  Xdr RB_L2_matrix_out(file_name.str(), mode);
783 
784  for (unsigned int i=0; i<n_bfs; i++)
785  {
786  for (unsigned int j=0; j<n_bfs; j++)
787  {
788  RB_L2_matrix_out << RB_L2_matrix(i,j);
789  }
790  }
791  RB_L2_matrix_out.close();
792 
793  // Write out the M_q matrices
794  for (unsigned int q_m=0; q_m<Q_m; q_m++)
795  {
796  file_name.str("");
797  file_name << directory_name << "/RB_M_";
798  file_name << std::setw(3)
799  << std::setprecision(0)
800  << std::setfill('0')
801  << std::right
802  << q_m;
803  file_name << suffix;
804  Xdr RB_M_q_m_out(file_name.str(), mode);
805 
806  for (unsigned int i=0; i<n_bfs; i++)
807  {
808  for (unsigned int j=0; j<n_bfs; j++)
809  {
810  RB_M_q_m_out << RB_M_q_vector[q_m](i,j);
811  }
812  }
813  RB_M_q_m_out.close();
814  }
815 
816  // Write out the initial condition data
817  // and the initial L2 error for all N
818  file_name.str("");
819  file_name << directory_name << "/initial_conditions" << suffix;
820  Xdr initial_conditions_out(file_name.str(), mode);
821  file_name.str("");
822  file_name << directory_name << "/initial_L2_error" << suffix;
823  Xdr initial_L2_error_out(file_name.str(), mode);
824 
825  for (unsigned int i=0; i<n_bfs; i++)
826  {
827  initial_L2_error_out << initial_L2_error_all_N[i];
828  for (unsigned int j=0; j<=i; j++)
829  {
830  initial_conditions_out << RB_initial_condition_all_N[i](j);
831  }
832  }
833  initial_conditions_out.close();
834  initial_L2_error_out.close();
835 
836  // Next write out the Fq_Mq representor norm data
837  file_name.str("");
838  file_name << directory_name << "/Fq_Mq_terms" << suffix;
839  Xdr RB_Fq_Mq_terms_out(file_name.str(), mode);
840 
841  for (unsigned int q_f=0; q_f<Q_f; q_f++)
842  {
843  for (unsigned int q_m=0; q_m<Q_m; q_m++)
844  {
845  for (unsigned int i=0; i<n_bfs; i++)
846  {
847  RB_Fq_Mq_terms_out << Fq_Mq_representor_innerprods[q_f][q_m][i];
848  }
849  }
850  }
851  RB_Fq_Mq_terms_out.close();
852 
853  // Next write out the Mq_Mq representor norm data
854  file_name.str("");
855  file_name << directory_name << "/Mq_Mq_terms" << suffix;
856  Xdr RB_Mq_Mq_terms_out(file_name.str(), mode);
857 
858  unsigned int Q_m_hat = Q_m*(Q_m+1)/2;
859  for (unsigned int q=0; q<Q_m_hat; q++)
860  {
861  for (unsigned int i=0; i<n_bfs; i++)
862  {
863  for (unsigned int j=0; j<n_bfs; j++)
864  {
865  RB_Mq_Mq_terms_out << Mq_Mq_representor_innerprods[q][i][j];
866  }
867  }
868  }
869  RB_Mq_Mq_terms_out.close();
870 
871  // Next write out the Aq_Mq representor norm data
872  file_name.str("");
873  file_name << directory_name << "/Aq_Mq_terms" << suffix;
874  Xdr RB_Aq_Mq_terms_out(file_name.str(), mode);
875 
876  for (unsigned int q_a=0; q_a<Q_a; q_a++)
877  {
878  for (unsigned int q_m=0; q_m<Q_m; q_m++)
879  {
880  for (unsigned int i=0; i<n_bfs; i++)
881  {
882  for (unsigned int j=0; j<n_bfs; j++)
883  {
884  RB_Aq_Mq_terms_out << Aq_Mq_representor_innerprods[q_a][q_m][i][j];
885  }
886  }
887  }
888  }
889  RB_Aq_Mq_terms_out.close();
890  }
891 }
892 
893 void TransientRBEvaluation::legacy_read_offline_data_from_files(const std::string & directory_name,
894  bool read_error_bound_data,
895  const bool read_binary_data)
896 {
897  LOG_SCOPE("legacy_read_offline_data_from_files()", "TransientRBEvaluation");
898 
900 
901  TransientRBThetaExpansion & trans_theta_expansion =
902  cast_ref<TransientRBThetaExpansion &>(get_rb_theta_expansion());
903  const unsigned int Q_m = trans_theta_expansion.get_n_M_terms();
904  const unsigned int Q_a = trans_theta_expansion.get_n_A_terms();
905  const unsigned int Q_f = trans_theta_expansion.get_n_F_terms();
906 
907  // First, find out how many basis functions we had when Greedy terminated
908  // This was set in RBSystem::read_offline_data_from_files
909  unsigned int n_bfs = this->get_n_basis_functions();
910 
911  // The reading mode: DECODE for binary, READ for ASCII
912  XdrMODE mode = read_binary_data ? DECODE : READ;
913 
914  // The suffix to use for all the files that are written out
915  const std::string suffix = read_binary_data ? ".xdr" : ".dat";
916 
917  // The string stream we'll use to make the file names
918  std::ostringstream file_name;
919 
920  // Write out the temporal discretization data
921  file_name.str("");
922  file_name << directory_name << "/temporal_discretization_data" << suffix;
923  assert_file_exists(file_name.str());
924 
925  Xdr temporal_discretization_data_in(file_name.str(), mode);
926 
927  Real real_value; unsigned int int_value;
928  temporal_discretization_data_in >> real_value; set_delta_t(real_value);
929  temporal_discretization_data_in >> real_value; set_euler_theta(real_value);
930  temporal_discretization_data_in >> int_value; set_n_time_steps(int_value);
931  temporal_discretization_data_in >> int_value; set_time_step(int_value);
932  temporal_discretization_data_in.close();
933 
934  file_name.str("");
935  file_name << directory_name << "/RB_L2_matrix" << suffix;
936  assert_file_exists(file_name.str());
937 
938  Xdr RB_L2_matrix_in(file_name.str(), mode);
939 
940  for (unsigned int i=0; i<n_bfs; i++)
941  {
942  for (unsigned int j=0; j<n_bfs; j++)
943  {
944  Number value;
945  RB_L2_matrix_in >> value;
946  RB_L2_matrix(i,j) = value;
947  }
948  }
949  RB_L2_matrix_in.close();
950 
951  // Read in the M_q matrices
952  for (unsigned int q_m=0; q_m<Q_m; q_m++)
953  {
954  file_name.str("");
955  file_name << directory_name << "/RB_M_";
956  file_name << std::setw(3)
957  << std::setprecision(0)
958  << std::setfill('0')
959  << std::right
960  << q_m;
961 
962  file_name << suffix;
963  assert_file_exists(file_name.str());
964 
965  Xdr RB_M_q_m_in(file_name.str(), mode);
966 
967  for (unsigned int i=0; i<n_bfs; i++)
968  {
969  for (unsigned int j=0; j<n_bfs; j++)
970  {
971  Number value;
972  RB_M_q_m_in >> value;
973  RB_M_q_vector[q_m](i,j) = value;
974  }
975  }
976  RB_M_q_m_in.close();
977  }
978 
979 
980  // Read in the initial condition data
981  // and the initial L2 error for all N
982  file_name.str("");
983  file_name << directory_name << "/initial_conditions" << suffix;
984  assert_file_exists(file_name.str());
985 
986  Xdr initial_conditions_in(file_name.str(), mode);
987 
988  file_name.str("");
989  file_name << directory_name << "/initial_L2_error" << suffix;
990  assert_file_exists(file_name.str());
991 
992  Xdr initial_L2_error_in(file_name.str(), mode);
993 
994  for (unsigned int i=0; i<n_bfs; i++)
995  {
996  initial_L2_error_in >> initial_L2_error_all_N[i];
997  for (unsigned int j=0; j<=i; j++)
998  {
999  initial_conditions_in >> RB_initial_condition_all_N[i](j);
1000  }
1001  }
1002  initial_conditions_in.close();
1003  initial_L2_error_in.close();
1004 
1005 
1006  if (read_error_bound_data)
1007  {
1008  // Next read in the Fq_Mq representor norm data
1009  file_name.str("");
1010  file_name << directory_name << "/Fq_Mq_terms" << suffix;
1011  assert_file_exists(file_name.str());
1012 
1013  Xdr RB_Fq_Mq_terms_in(file_name.str(), mode);
1014 
1015  for (unsigned int q_f=0; q_f<Q_f; q_f++)
1016  {
1017  for (unsigned int q_m=0; q_m<Q_m; q_m++)
1018  {
1019  for (unsigned int i=0; i<n_bfs; i++)
1020  {
1021  RB_Fq_Mq_terms_in >> Fq_Mq_representor_innerprods[q_f][q_m][i];
1022  }
1023  }
1024  }
1025  RB_Fq_Mq_terms_in.close();
1026 
1027  // Next read in the Mq_Mq representor norm data
1028  file_name.str("");
1029  file_name << directory_name << "/Mq_Mq_terms" << suffix;
1030  assert_file_exists(file_name.str());
1031 
1032  Xdr RB_Mq_Mq_terms_in(file_name.str(), mode);
1033 
1034  unsigned int Q_m_hat = Q_m*(Q_m+1)/2;
1035  for (unsigned int q=0; q<Q_m_hat; q++)
1036  {
1037  for (unsigned int i=0; i<n_bfs; i++)
1038  {
1039  for (unsigned int j=0; j<n_bfs; j++)
1040  {
1041  RB_Mq_Mq_terms_in >> Mq_Mq_representor_innerprods[q][i][j];
1042  }
1043  }
1044  }
1045  RB_Mq_Mq_terms_in.close();
1046 
1047  // Next read in the Aq_Mq representor norm data
1048  file_name.str("");
1049  file_name << directory_name << "/Aq_Mq_terms" << suffix;
1050  assert_file_exists(file_name.str());
1051 
1052  Xdr RB_Aq_Mq_terms_in(file_name.str(), mode);
1053 
1054  for (unsigned int q_a=0; q_a<Q_a; q_a++)
1055  {
1056  for (unsigned int q_m=0; q_m<Q_m; q_m++)
1057  {
1058  for (unsigned int i=0; i<n_bfs; i++)
1059  {
1060  for (unsigned int j=0; j<n_bfs; j++)
1061  {
1062  RB_Aq_Mq_terms_in >> Aq_Mq_representor_innerprods[q_a][q_m][i][j];
1063  }
1064  }
1065  }
1066  }
1067  RB_Aq_Mq_terms_in.close();
1068  }
1069 }
1070 
1071 }
libMesh::RBEvaluation::get_n_basis_functions
virtual unsigned int get_n_basis_functions() const
Get the current number of basis functions.
Definition: rb_evaluation.h:145
libMesh::Number
Real Number
Definition: libmesh_common.h:195
libMesh::RBEvaluation::RB_Aq_vector
std::vector< DenseMatrix< Number > > RB_Aq_vector
Dense matrices for the RB computations.
Definition: rb_evaluation.h:260
libMesh::RBThetaExpansion::get_n_output_terms
unsigned int get_n_output_terms(unsigned int output_index) const
Get the number of affine terms associated with the specified output.
Definition: rb_theta_expansion.C:53
libMesh::TransientRBEvaluation::legacy_write_offline_data_to_files
virtual void legacy_write_offline_data_to_files(const std::string &directory_name="offline_data", const bool write_binary_data=true) override
Write out all the data to text files in order to segregate the Offline stage from the Online stage.
Definition: transient_rb_evaluation.C:741
libMesh::RBThetaExpansion::get_n_F_terms
unsigned int get_n_F_terms() const
Get Q_f, the number of terms in the affine expansion for the right-hand side.
Definition: rb_theta_expansion.C:41
libMesh::RBTemporalDiscretization::get_control
Real get_control(const unsigned int k) const
Get/set the RHS control.
Definition: rb_temporal_discretization.C:79
libMesh::TransientRBEvaluation::get_error_bound_normalization
virtual Real get_error_bound_normalization() override
Definition: transient_rb_evaluation.C:406
libMesh::RBTemporalDiscretization::set_n_time_steps
void set_n_time_steps(const unsigned int K)
Definition: rb_temporal_discretization.C:73
libMesh::TransientRBThetaExpansion
This class stores the set of RBTheta functor objects that define the "parameter-dependent expansion" ...
Definition: transient_rb_theta_expansion.h:41
libMesh::TransientRBThetaExpansion::eval_M_theta
virtual Number eval_M_theta(unsigned int q, const RBParameters &mu)
Evaluate theta at the current parameter.
Definition: transient_rb_theta_expansion.C:33
libMesh::TransientRBEvaluation::M_q_representor
std::vector< std::vector< std::unique_ptr< NumericVector< Number > > > > M_q_representor
Vector storing the mass matrix representors.
Definition: transient_rb_evaluation.h:244
libMesh::TransientRBEvaluation::old_RB_solution
DenseVector< Number > old_RB_solution
The RB solution at the previous time-level.
Definition: transient_rb_evaluation.h:195
libMesh::TransientRBEvaluation::_rb_solve_data_cached
bool _rb_solve_data_cached
Check that the data has been cached in case of using rb_solve_again.
Definition: transient_rb_evaluation.h:249
libMesh::RBTemporalDiscretization::get_euler_theta
Real get_euler_theta() const
Get/set euler_theta, parameter that determines the temporal discretization.
Definition: rb_temporal_discretization.C:46
libMesh::libmesh_real
T libmesh_real(T a)
Definition: libmesh_common.h:166
libMesh::RBTemporalDiscretization::set_delta_t
void set_delta_t(const Real delta_t_in)
Definition: rb_temporal_discretization.C:41
libMesh::TransientRBEvaluation::clear
virtual void clear() override
Clear this TransientRBEvaluation object.
Definition: transient_rb_evaluation.C:53
libMesh::TransientRBEvaluation::RB_initial_condition_all_N
std::vector< DenseVector< Number > > RB_initial_condition_all_N
The RB initial conditions (i.e.
Definition: transient_rb_evaluation.h:218
libMesh
The libMesh namespace provides an interface to certain functionality in the library.
Definition: factoryfunction.C:55
libMesh::DenseVector::zero
virtual void zero() override
Set every element in the vector to 0.
Definition: dense_vector.h:379
libMesh::Xdr
This class implements a C++ interface to the XDR (eXternal Data Representation) format.
Definition: xdr_cxx.h:65
libMesh::DenseMatrix::add
boostcopy::enable_if_c< ScalarTraits< T2 >::value, void >::type add(const T2 factor, const DenseMatrix< T3 > &mat)
Adds factor times mat to this matrix.
Definition: dense_matrix.h:945
std::sqrt
MetaPhysicL::DualNumber< T, D > sqrt(const MetaPhysicL::DualNumber< T, D > &in)
libMesh::TransientRBEvaluation::rb_solve_again
virtual Real rb_solve_again()
If a solve has already been performed, then we cached some data and we can perform a new solve much m...
Definition: transient_rb_evaluation.C:362
libMesh::DenseMatrix< Number >
libMesh::TransientRBEvaluation::RB_L2_matrix
DenseMatrix< Number > RB_L2_matrix
Dense RB L2 matrix.
Definition: transient_rb_evaluation.h:166
libMesh::RBParameters
This class is part of the rbOOmit framework.
Definition: rb_parameters.h:42
libMesh::WRITE
Definition: enum_xdr_mode.h:40
libMesh::RBEvaluation::clear
virtual void clear() override
Clear this RBEvaluation object.
Definition: rb_evaluation.C:62
libMesh::RBThetaExpansion::eval_output_theta
virtual Number eval_output_theta(unsigned int output_index, unsigned int q_l, const RBParameters &mu)
Evaluate theta_q_l at the current parameter.
Definition: rb_theta_expansion.C:141
libMesh::RBTemporalDiscretization::get_delta_t
Real get_delta_t() const
Get/set delta_t, the time-step size.
Definition: rb_temporal_discretization.C:36
libMesh::RBEvaluation::assert_file_exists
void assert_file_exists(const std::string &file_name)
Helper function that checks if file_name exists.
Definition: rb_evaluation.C:874
libMesh::TransientRBEvaluation::TransientRBEvaluation
TransientRBEvaluation(const Parallel::Communicator &comm_in)
Constructor.
Definition: transient_rb_evaluation.C:39
libMesh::TransientRBEvaluation::cached_Fq_term
Number cached_Fq_term
Cached residual terms.
Definition: transient_rb_evaluation.h:233
libMesh::RBParametrized::get_parameters
const RBParameters & get_parameters() const
Get the current parameters.
Definition: rb_parametrized.C:166
libMesh::DenseMatrix::resize
void resize(const unsigned int new_m, const unsigned int new_n)
Resize the matrix.
Definition: dense_matrix.h:822
libMesh::DenseVector::add
boostcopy::enable_if_c< ScalarTraits< T2 >::value, void >::type add(const T2 factor, const DenseVector< T3 > &vec)
Adds factor times vec to this vector.
Definition: dense_vector.h:436
libMesh::RBTemporalDiscretization::set_time_step
void set_time_step(const unsigned int k)
Definition: rb_temporal_discretization.C:62
libMesh::TransientRBEvaluation::Fq_Mq_representor_innerprods
std::vector< std::vector< std::vector< Number > > > Fq_Mq_representor_innerprods
Vectors storing the residual representor inner products to be used in computing the residuals online.
Definition: transient_rb_evaluation.h:224
libMesh::TransientRBEvaluation::cached_Fq_Aq_vector
DenseVector< Number > cached_Fq_Aq_vector
Definition: transient_rb_evaluation.h:234
libMesh::RBEvaluation::residual_scaling_denom
virtual Real residual_scaling_denom(Real alpha_LB)
Specifies the residual scaling on the denominator to be used in the a posteriori error bound.
Definition: rb_evaluation.C:385
libMesh::RBTemporalDiscretization::get_n_time_steps
unsigned int get_n_time_steps() const
Get/set the total number of time-steps.
Definition: rb_temporal_discretization.C:68
libMesh::TransientRBEvaluation::error_bound_all_k
std::vector< Real > error_bound_all_k
The error bound data for all time-levels from the most recent rb_solve.
Definition: transient_rb_evaluation.h:206
libMesh::libmesh_assert
libmesh_assert(ctx)
libMesh::IntRange
The IntRange templated class is intended to make it easy to loop over integers which are indices of a...
Definition: int_range.h:53
libMesh::TransientRBEvaluation::~TransientRBEvaluation
~TransientRBEvaluation()
Destructor.
Definition: transient_rb_evaluation.C:48
libMesh::DenseMatrix::vector_mult
void vector_mult(DenseVector< T > &dest, const DenseVector< T > &arg) const
Performs the matrix-vector multiplication, dest := (*this) * arg.
Definition: dense_matrix_impl.h:403
libMesh::RBEvaluation::evaluate_RB_error_bound
bool evaluate_RB_error_bound
Boolean to indicate whether we evaluate a posteriori error bounds when rb_solve is called.
Definition: rb_evaluation.h:322
std::abs
MetaPhysicL::DualNumber< T, D > abs(const MetaPhysicL::DualNumber< T, D > &in)
libMesh::TransientRBThetaExpansion::get_n_M_terms
virtual unsigned int get_n_M_terms()
Get Q_m, the number of terms in the affine expansion for the mass operator.
Definition: transient_rb_theta_expansion.h:67
libMesh::RBEvaluation::legacy_read_offline_data_from_files
virtual void legacy_read_offline_data_from_files(const std::string &directory_name="offline_data", bool read_error_bound_data=true, const bool read_binary_data=true)
Read in the saved Offline reduced basis data to initialize the system for Online solves.
Definition: rb_evaluation.C:641
libMesh::TransientRBEvaluation::RB_outputs_all_k
std::vector< std::vector< Number > > RB_outputs_all_k
The RB outputs for all time-levels from the most recent rb_solve.
Definition: transient_rb_evaluation.h:184
libMesh::XdrMODE
XdrMODE
Defines an enum for read/write mode in Xdr format.
Definition: enum_xdr_mode.h:35
libMesh::RBTemporalDiscretization::get_time_step
unsigned int get_time_step() const
Get/set the current time-step.
Definition: rb_temporal_discretization.C:57
libMesh::DECODE
Definition: enum_xdr_mode.h:39
libMesh::TransientRBEvaluation::cached_Mq_Mq_matrix
DenseMatrix< Number > cached_Mq_Mq_matrix
Definition: transient_rb_evaluation.h:238
libMesh::RBEvaluation::RB_solution
DenseVector< Number > RB_solution
The RB solution vector.
Definition: rb_evaluation.h:270
libMesh::RBEvaluation::Fq_representor_innerprods
std::vector< Number > Fq_representor_innerprods
Vectors storing the residual representor inner products to be used in computing the residuals online.
Definition: rb_evaluation.h:290
libMesh::ParallelObject::processor_id
processor_id_type processor_id() const
Definition: parallel_object.h:106
libMesh::TransientRBEvaluation::RB_output_error_bounds_all_k
std::vector< std::vector< Real > > RB_output_error_bounds_all_k
The error bounds for each RB output for all time-levels from the most recent rb_solve.
Definition: transient_rb_evaluation.h:190
libMesh::RBEvaluation::Fq_Aq_representor_innerprods
std::vector< std::vector< std::vector< Number > > > Fq_Aq_representor_innerprods
Vectors storing the residual representor inner products to be used in computing the residuals online.
Definition: rb_evaluation.h:299
libMesh::TransientRBEvaluation::RB_M_q_vector
std::vector< DenseMatrix< Number > > RB_M_q_vector
Dense matrices for the RB mass matrices.
Definition: transient_rb_evaluation.h:178
libMesh::RBEvaluation::clear_riesz_representors
virtual void clear_riesz_representors()
Clear all the Riesz representors that are used to compute the RB residual (and hence error bound).
Definition: rb_evaluation.C:411
libMesh::TransientRBEvaluation::Mq_Mq_representor_innerprods
std::vector< std::vector< std::vector< Number > > > Mq_Mq_representor_innerprods
Definition: transient_rb_evaluation.h:225
libMesh::DenseVector::dot
CompareTypes< T, T2 >::supertype dot(const DenseVector< T2 > &vec) const
Definition: dense_vector.h:451
libMesh::TransientRBEvaluation::uncached_compute_residual_dual_norm
virtual Real uncached_compute_residual_dual_norm(const unsigned int N)
Compute the dual norm of the residual for the solution saved in RB_solution.
Definition: transient_rb_evaluation.C:590
libMesh::RBThetaExpansion::eval_A_theta
virtual Number eval_A_theta(unsigned int q, const RBParameters &mu)
Evaluate theta_q_a at the current parameter.
Definition: rb_theta_expansion.C:119
std::pow
double pow(double a, int b)
Definition: libmesh_augment_std_namespace.h:58
libMesh::TransientRBEvaluation::rb_solve
virtual Real rb_solve(unsigned int N) override
Perform online solve for current_params with the N basis functions.
Definition: transient_rb_evaluation.C:154
libMesh::RBEvaluation::get_stability_lower_bound
virtual Real get_stability_lower_bound()
Get a lower bound for the stability constant (e.g.
Definition: rb_evaluation.C:377
libMesh::TransientRBEvaluation::RB_temporal_solution_data
std::vector< DenseVector< Number > > RB_temporal_solution_data
Array storing the solution data at each time level from the most recent solve.
Definition: transient_rb_evaluation.h:200
libMesh::DenseVector::size
virtual unsigned int size() const override
Definition: dense_vector.h:92
libMesh::READ
Definition: enum_xdr_mode.h:41
libMesh::DenseMatrix::zero
virtual void zero() override
Set every element in the matrix to 0.
Definition: dense_matrix.h:838
libMesh::TransientRBEvaluation::clear_riesz_representors
virtual void clear_riesz_representors() override
Clear all the Riesz representors that are used to compute the RB residual (and hence error bound).
Definition: transient_rb_evaluation.C:60
libMesh::RBEvaluation::Aq_Aq_representor_innerprods
std::vector< std::vector< std::vector< Number > > > Aq_Aq_representor_innerprods
Definition: rb_evaluation.h:300
libMesh::RBThetaExpansion::get_n_outputs
unsigned int get_n_outputs() const
Get n_outputs, the number output functionals.
Definition: rb_theta_expansion.C:47
libMesh::RBEvaluation::legacy_write_offline_data_to_files
virtual void legacy_write_offline_data_to_files(const std::string &directory_name="offline_data", const bool write_binary_data=true)
Write out all the data to text files in order to segregate the Offline stage from the Online stage.
Definition: rb_evaluation.C:416
libMesh::TransientRBEvaluation::legacy_read_offline_data_from_files
virtual void legacy_read_offline_data_from_files(const std::string &directory_name="offline_data", bool read_error_bound_data=true, const bool read_binary_data=true) override
Read in the saved Offline reduced basis data to initialize the system for Online solves.
Definition: transient_rb_evaluation.C:893
libMesh::RBEvaluation::RB_output_vectors
std::vector< std::vector< DenseVector< Number > > > RB_output_vectors
The vectors storing the RB output vectors.
Definition: rb_evaluation.h:275
libMesh::ENCODE
Definition: enum_xdr_mode.h:38
libMesh::DenseVector::resize
void resize(const unsigned int n)
Resize the vector.
Definition: dense_vector.h:355
libMesh::RBEvaluation::eval_output_dual_norm
Real eval_output_dual_norm(unsigned int n, const RBParameters &mu)
Evaluate the dual norm of output n for the current parameters.
Definition: rb_evaluation.C:392
libMesh::TransientRBEvaluation::compute_residual_dual_norm
virtual Real compute_residual_dual_norm(const unsigned int N) override
Compute the dual norm of the residual for the solution saved in RB_solution.
Definition: transient_rb_evaluation.C:542
libMesh::RBEvaluation::compute_RB_inner_product
bool compute_RB_inner_product
Boolean flag to indicate whether we compute the RB_inner_product_matrix.
Definition: rb_evaluation.h:327
libMesh::TransientRBEvaluation::RB_RHS_save
DenseVector< Number > RB_RHS_save
Definition: transient_rb_evaluation.h:173
libMesh::TransientRBEvaluation::cache_online_residual_terms
void cache_online_residual_terms(const unsigned int N)
Helper function for caching the terms in the online residual assembly that do not change in time.
Definition: transient_rb_evaluation.C:420
value
static const bool value
Definition: xdr_io.C:56
libMesh::TransientRBEvaluation::Aq_Mq_representor_innerprods
std::vector< std::vector< std::vector< std::vector< Number > > > > Aq_Mq_representor_innerprods
Definition: transient_rb_evaluation.h:226
libMesh::RBEvaluation
This class is part of the rbOOmit framework.
Definition: rb_evaluation.h:50
libMesh::TransientRBEvaluation::cached_Fq_Mq_vector
DenseVector< Number > cached_Fq_Mq_vector
Definition: transient_rb_evaluation.h:236
libMesh::TransientRBEvaluation::initial_L2_error_all_N
std::vector< Real > initial_L2_error_all_N
Vector storing initial L2 error for all 1 <= N <= RB_size.
Definition: transient_rb_evaluation.h:212
libMesh::TransientRBEvaluation::residual_scaling_numer
virtual Real residual_scaling_numer(Real alpha_LB)
Specifies the residual scaling on the numerator to be used in the a posteriori error bound.
Definition: transient_rb_evaluation.C:415
libMesh::TransientRBEvaluation::RB_LHS_matrix
DenseMatrix< Number > RB_LHS_matrix
Cached data for subsequent solves.
Definition: transient_rb_evaluation.h:171
libMesh::RBThetaExpansion::get_n_A_terms
unsigned int get_n_A_terms() const
Get Q_a, the number of terms in the affine expansion for the bilinear form.
Definition: rb_theta_expansion.C:35
libMesh::RBThetaExpansion::eval_F_theta
virtual Number eval_F_theta(unsigned int q, const RBParameters &mu)
Evaluate theta_q_f at the current parameter.
Definition: rb_theta_expansion.C:130
libMesh::TransientRBEvaluation::cached_Aq_Aq_matrix
DenseMatrix< Number > cached_Aq_Aq_matrix
Definition: transient_rb_evaluation.h:235
libMesh::RBEvaluation::resize_data_structures
virtual void resize_data_structures(const unsigned int Nmax, bool resize_error_bound_data=true)
Resize and clear the data vectors corresponding to the value of Nmax.
Definition: rb_evaluation.C:108
libMesh::DenseMatrix::lu_solve
void lu_solve(const DenseVector< T > &b, DenseVector< T > &x)
Solve the system Ax=b given the input vector b.
Definition: dense_matrix_impl.h:625
libMesh::RBEvaluation::get_rb_theta_expansion
RBThetaExpansion & get_rb_theta_expansion()
Get a reference to the rb_theta_expansion.
Definition: rb_evaluation.C:88
libMesh::Real
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Definition: libmesh_common.h:121
libMesh::TransientRBEvaluation::RB_RHS_matrix
DenseMatrix< Number > RB_RHS_matrix
Definition: transient_rb_evaluation.h:172
libMesh::RBEvaluation::RB_Fq_vector
std::vector< DenseVector< Number > > RB_Fq_vector
Dense vector for the RHS.
Definition: rb_evaluation.h:265
libMesh::out
OStreamProxy out
libMesh::RBTemporalDiscretization::set_euler_theta
void set_euler_theta(const Real euler_theta_in)
Definition: rb_temporal_discretization.C:51
libMesh::TransientRBEvaluation::resize_data_structures
virtual void resize_data_structures(const unsigned int Nmax, bool resize_error_bound_data=true) override
Resize and clear the data vectors corresponding to the value of Nmax.
Definition: transient_rb_evaluation.C:68
libMesh::TransientRBEvaluation::cached_Aq_Mq_matrix
DenseMatrix< Number > cached_Aq_Mq_matrix
Definition: transient_rb_evaluation.h:237
libMesh::DenseVector< Number >