libMesh
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/rb_evaluation.h"
22 #include "libmesh/rb_theta_expansion.h"
23 
24 // libMesh includes
25 #include "libmesh/libmesh_version.h"
26 #include "libmesh/system.h"
27 #include "libmesh/numeric_vector.h"
28 #include "libmesh/libmesh_logging.h"
29 #include "libmesh/xdr_cxx.h"
30 #include "libmesh/mesh_tools.h"
31 #include "libmesh/utility.h"
32 
33 // TIMPI includes
34 #include "timpi/communicator.h"
35 
36 // C/C++ includes
37 #include <sys/types.h>
38 #include <sys/stat.h>
39 #include <errno.h>
40 #include <fstream>
41 #include <sstream>
42 #include <iomanip>
43 
44 namespace libMesh
45 {
46 
47 RBEvaluation::RBEvaluation (const Parallel::Communicator & comm_in)
48  :
49  ParallelObject(comm_in),
50  evaluate_RB_error_bound(true),
51  compute_RB_inner_product(false),
52  rb_theta_expansion(nullptr)
53 {
54 
55 }
56 
58 {
59  this->clear();
60 }
61 
63 {
64  LOG_SCOPE("clear()", "RBEvaluation");
65 
66  // Clear the basis functions
67  basis_functions.clear();
69 
71 
72  // Clear the Greedy param list
73  for (auto & plist : greedy_param_list)
74  plist.clear();
75  greedy_param_list.clear();
76 }
77 
78 void RBEvaluation::set_n_basis_functions(unsigned int n_bfs)
79 {
80  basis_functions.resize(n_bfs);
81 }
82 
84 {
85  rb_theta_expansion = &rb_theta_expansion_in;
86 }
87 
89 {
91  libmesh_error_msg("Error: rb_theta_expansion hasn't been initialized yet");
92 
93  return *rb_theta_expansion;
94 }
95 
97 {
99  {
100  return true;
101  }
102  else
103  {
104  return false;
105  }
106 }
107 
108 void RBEvaluation::resize_data_structures(const unsigned int Nmax,
109  bool resize_error_bound_data)
110 {
111  LOG_SCOPE("resize_data_structures()", "RBEvaluation");
112 
113  if (Nmax < this->get_n_basis_functions())
114  libmesh_error_msg("Error: Cannot set Nmax to be less than the current number of basis functions.");
115 
116  // Resize/clear inner product matrix
118  RB_inner_product_matrix.resize(Nmax,Nmax);
119 
120  // Allocate dense matrices for RB solves
122 
123  for (unsigned int q=0; q<rb_theta_expansion->get_n_A_terms(); q++)
124  {
125  // Initialize the memory for the RB matrices
126  RB_Aq_vector[q].resize(Nmax,Nmax);
127  }
128 
130 
131  for (unsigned int q=0; q<rb_theta_expansion->get_n_F_terms(); q++)
132  {
133  // Initialize the memory for the RB vectors
134  RB_Fq_vector[q].resize(Nmax);
135  }
136 
137 
138  // Initialize the RB output vectors
140  for (unsigned int n=0; n<rb_theta_expansion->get_n_outputs(); n++)
141  {
143  for (unsigned int q_l=0; q_l<rb_theta_expansion->get_n_output_terms(n); q_l++)
144  {
145  RB_output_vectors[n][q_l].resize(Nmax);
146  }
147  }
148 
149  // Initialize vectors storing output data
151 
152 
153  if (resize_error_bound_data)
154  {
155  // Initialize vectors for the norms of the Fq representors
156  unsigned int Q_f_hat = rb_theta_expansion->get_n_F_terms()*(rb_theta_expansion->get_n_F_terms()+1)/2;
157  Fq_representor_innerprods.resize(Q_f_hat);
158 
159  // Initialize vectors for the norms of the representors
161  for (unsigned int i=0; i<rb_theta_expansion->get_n_F_terms(); i++)
162  {
164  for (unsigned int j=0; j<rb_theta_expansion->get_n_A_terms(); j++)
165  {
166  Fq_Aq_representor_innerprods[i][j].resize(Nmax, 0.);
167  }
168  }
169 
170  unsigned int Q_a_hat = rb_theta_expansion->get_n_A_terms()*(rb_theta_expansion->get_n_A_terms()+1)/2;
171  Aq_Aq_representor_innerprods.resize(Q_a_hat);
172  for (unsigned int i=0; i<Q_a_hat; i++)
173  {
174  Aq_Aq_representor_innerprods[i].resize(Nmax);
175  for (unsigned int j=0; j<Nmax; j++)
176  {
177  Aq_Aq_representor_innerprods[i][j].resize(Nmax, 0.);
178  }
179  }
180 
182 
183  // Resize the output dual norm vectors
185  for (unsigned int n=0; n<rb_theta_expansion->get_n_outputs(); n++)
186  {
187  unsigned int Q_l_hat = rb_theta_expansion->get_n_output_terms(n)*(rb_theta_expansion->get_n_output_terms(n)+1)/2;
188  output_dual_innerprods[n].resize(Q_l_hat);
189  }
190 
191  // Clear and resize the vector of Aq_representors
193 
195  for (unsigned int q_a=0; q_a<rb_theta_expansion->get_n_A_terms(); q_a++)
196  {
197  Aq_representor[q_a].resize(Nmax);
198  }
199  }
200 }
201 
203 {
204  libmesh_assert_less (i, basis_functions.size());
205 
206  return *(basis_functions[i]);
207 }
208 
210 {
211  LOG_SCOPE("rb_solve()", "RBEvaluation");
212 
213  if (N > get_n_basis_functions())
214  libmesh_error_msg("ERROR: N cannot be larger than the number of basis functions in rb_solve");
215 
216  const RBParameters & mu = get_parameters();
217 
218  // Resize (and clear) the solution vector
219  RB_solution.resize(N);
220 
221  // Assemble the RB system
222  DenseMatrix<Number> RB_system_matrix(N,N);
223  RB_system_matrix.zero();
224 
225  DenseMatrix<Number> RB_Aq_a;
226  for (unsigned int q_a=0; q_a<rb_theta_expansion->get_n_A_terms(); q_a++)
227  {
228  RB_Aq_vector[q_a].get_principal_submatrix(N, RB_Aq_a);
229 
230  RB_system_matrix.add(rb_theta_expansion->eval_A_theta(q_a, mu), RB_Aq_a);
231  }
232 
233  // Assemble the RB rhs
234  DenseVector<Number> RB_rhs(N);
235  RB_rhs.zero();
236 
237  DenseVector<Number> RB_Fq_f;
238  for (unsigned int q_f=0; q_f<rb_theta_expansion->get_n_F_terms(); q_f++)
239  {
240  RB_Fq_vector[q_f].get_principal_subvector(N, RB_Fq_f);
241 
242  RB_rhs.add(rb_theta_expansion->eval_F_theta(q_f, mu), RB_Fq_f);
243  }
244 
245  // Solve the linear system
246  if (N > 0)
247  {
248  RB_system_matrix.lu_solve(RB_rhs, RB_solution);
249  }
250 
251  // Evaluate RB outputs
252  DenseVector<Number> RB_output_vector_N;
253  for (unsigned int n=0; n<rb_theta_expansion->get_n_outputs(); n++)
254  {
255  RB_outputs[n] = 0.;
256  for (unsigned int q_l=0; q_l<rb_theta_expansion->get_n_output_terms(n); q_l++)
257  {
258  RB_output_vectors[n][q_l].get_principal_subvector(N, RB_output_vector_N);
259  RB_outputs[n] += rb_theta_expansion->eval_output_theta(n,q_l,mu)*RB_output_vector_N.dot(RB_solution);
260  }
261  }
262 
263  if (evaluate_RB_error_bound) // Calculate the error bounds
264  {
265  // Evaluate the dual norm of the residual for RB_solution_vector
266  Real epsilon_N = compute_residual_dual_norm(N);
267 
268  // Get lower bound for coercivity constant
269  const Real alpha_LB = get_stability_lower_bound();
270  // alpha_LB needs to be positive to get a valid error bound
271  libmesh_assert_greater ( alpha_LB, 0. );
272 
273  // Evaluate the (absolute) error bound
274  Real abs_error_bound = epsilon_N / residual_scaling_denom(alpha_LB);
275 
276  // Now compute the output error bounds
277  for (unsigned int n=0; n<rb_theta_expansion->get_n_outputs(); n++)
278  {
279  RB_output_error_bounds[n] = abs_error_bound * eval_output_dual_norm(n, mu);
280  }
281 
282  return abs_error_bound;
283  }
284  else // Don't calculate the error bounds
285  {
286  // Just return -1. if we did not compute the error bound
287  return -1.;
288  }
289 }
290 
292 {
293  // Normalize the error based on the error bound in the
294  // case of an empty reduced basis. The error bound is based
295  // on the residual F - AU, so with an empty basis this gives
296  // a value based on the norm of F at the current parameters.
297 
298  Real normalization = rb_solve(0);
299  return normalization;
300 }
301 
303 {
304  LOG_SCOPE("compute_residual_dual_norm()", "RBEvaluation");
305 
306  const RBParameters & mu = get_parameters();
307 
308  // Use the stored representor inner product values
309  // to evaluate the residual norm
310  Number residual_norm_sq = 0.;
311 
312  unsigned int q=0;
313  for (unsigned int q_f1=0; q_f1<rb_theta_expansion->get_n_F_terms(); q_f1++)
314  {
315  for (unsigned int q_f2=q_f1; q_f2<rb_theta_expansion->get_n_F_terms(); q_f2++)
316  {
317  Real delta = (q_f1==q_f2) ? 1. : 2.;
318  residual_norm_sq += delta * libmesh_real(
321 
322  q++;
323  }
324  }
325 
326  for (unsigned int q_f=0; q_f<rb_theta_expansion->get_n_F_terms(); q_f++)
327  {
328  for (unsigned int q_a=0; q_a<rb_theta_expansion->get_n_A_terms(); q_a++)
329  {
330  for (unsigned int i=0; i<N; i++)
331  {
332  Real delta = 2.;
333  residual_norm_sq +=
334  delta * libmesh_real( rb_theta_expansion->eval_F_theta(q_f, mu) *
337  }
338  }
339  }
340 
341  q=0;
342  for (unsigned int q_a1=0; q_a1<rb_theta_expansion->get_n_A_terms(); q_a1++)
343  {
344  for (unsigned int q_a2=q_a1; q_a2<rb_theta_expansion->get_n_A_terms(); q_a2++)
345  {
346  Real delta = (q_a1==q_a2) ? 1. : 2.;
347 
348  for (unsigned int i=0; i<N; i++)
349  {
350  for (unsigned int j=0; j<N; j++)
351  {
352  residual_norm_sq +=
354  rb_theta_expansion->eval_A_theta(q_a2, mu) *
356  }
357  }
358 
359  q++;
360  }
361  }
362 
363  if (libmesh_real(residual_norm_sq) < 0.)
364  {
365  // libMesh::out << "Warning: Square of residual norm is negative "
366  // << "in RBSystem::compute_residual_dual_norm()" << std::endl;
367 
368  // Sometimes this is negative due to rounding error,
369  // but when this occurs the error is on the order of 1.e-10,
370  // so shouldn't affect error bound much...
371  residual_norm_sq = std::abs(residual_norm_sq);
372  }
373 
374  return std::sqrt( libmesh_real(residual_norm_sq) );
375 }
376 
378 {
379  // Return a default value of 1, this function should
380  // be overloaded to specify a problem-dependent stability
381  // factor lower bound
382  return 1.;
383 }
384 
386 {
387  // Here we implement the residual scaling for a coercive
388  // problem.
389  return alpha_LB;
390 }
391 
393 {
394  Number output_bound_sq = 0.;
395  unsigned int q=0;
396  for (unsigned int q_l1=0; q_l1<rb_theta_expansion->get_n_output_terms(n); q_l1++)
397  {
398  for (unsigned int q_l2=q_l1; q_l2<rb_theta_expansion->get_n_output_terms(n); q_l2++)
399  {
400  Real delta = (q_l1==q_l2) ? 1. : 2.;
401  output_bound_sq += delta * libmesh_real(
404  q++;
405  }
406  }
407 
408  return libmesh_real(std::sqrt( output_bound_sq ));
409 }
410 
412 {
413  Aq_representor.clear();
414 }
415 
416 void RBEvaluation::legacy_write_offline_data_to_files(const std::string & directory_name,
417  const bool write_binary_data)
418 {
419  LOG_SCOPE("legacy_write_offline_data_to_files()", "RBEvaluation");
420 
421  // Get the number of basis functions
422  unsigned int n_bfs = get_n_basis_functions();
423 
424  // The writing mode: ENCODE for binary, WRITE for ASCII
425  XdrMODE mode = write_binary_data ? ENCODE : WRITE;
426 
427  // The suffix to use for all the files that are written out
428  const std::string suffix = write_binary_data ? ".xdr" : ".dat";
429 
430  if (this->processor_id() == 0)
431  {
432 
433  // Make a directory to store all the data files
434  Utility::mkdir(directory_name.c_str());
435  // if (mkdir(directory_name.c_str(), 0777) == -1)
436  // {
437  // libMesh::out << "In RBEvaluation::write_offline_data_to_files, directory "
438  // << directory_name << " already exists, overwriting contents." << std::endl;
439  // }
440 
441  // First, write out how many basis functions we have generated
442  std::ostringstream file_name;
443  {
444  file_name << directory_name << "/n_bfs" << suffix;
445  Xdr n_bfs_out(file_name.str(), mode);
446  n_bfs_out << n_bfs;
447  n_bfs_out.close();
448  }
449 
450  // Write out the parameter ranges
451  file_name.str("");
452  file_name << directory_name << "/parameter_ranges" << suffix;
453  std::string continuous_param_file_name = file_name.str();
454 
455  // Write out the discrete parameter values
456  file_name.str("");
457  file_name << directory_name << "/discrete_parameter_values" << suffix;
458  std::string discrete_param_file_name = file_name.str();
459 
460  write_parameter_data_to_files(continuous_param_file_name,
461  discrete_param_file_name,
462  write_binary_data);
463 
464  // Write out Fq representor norm data
465  file_name.str("");
466  file_name << directory_name << "/Fq_innerprods" << suffix;
467  Xdr RB_Fq_innerprods_out(file_name.str(), mode);
468  unsigned int Q_f_hat = rb_theta_expansion->get_n_F_terms()*(rb_theta_expansion->get_n_F_terms()+1)/2;
469  for (unsigned int i=0; i<Q_f_hat; i++)
470  {
471  RB_Fq_innerprods_out << Fq_representor_innerprods[i];
472  }
473  RB_Fq_innerprods_out.close();
474 
475  // Write out output data
476  for (unsigned int n=0; n<rb_theta_expansion->get_n_outputs(); n++)
477  {
478  file_name.str("");
479  file_name << directory_name << "/output_";
480  file_name << std::setw(3)
481  << std::setprecision(0)
482  << std::setfill('0')
483  << std::right
484  << n;
485 
486  file_name << "_dual_innerprods" << suffix;
487  Xdr output_dual_innerprods_out(file_name.str(), mode);
488 
489  unsigned int Q_l_hat = rb_theta_expansion->get_n_output_terms(n)*(rb_theta_expansion->get_n_output_terms(n)+1)/2;
490  for (unsigned int q=0; q<Q_l_hat; q++)
491  {
492  output_dual_innerprods_out << output_dual_innerprods[n][q];
493  }
494  output_dual_innerprods_out.close();
495  }
496 
497 
498  // Write out output data to multiple files
499  for (unsigned int n=0; n<rb_theta_expansion->get_n_outputs(); n++)
500  {
501  for (unsigned int q_l=0; q_l<rb_theta_expansion->get_n_output_terms(n); q_l++)
502  {
503  file_name.str("");
504  file_name << directory_name << "/output_";
505  file_name << std::setw(3)
506  << std::setprecision(0)
507  << std::setfill('0')
508  << std::right
509  << n;
510  file_name << "_";
511  file_name << std::setw(3)
512  << std::setprecision(0)
513  << std::setfill('0')
514  << std::right
515  << q_l;
516  file_name << suffix;
517  Xdr output_n_out(file_name.str(), mode);
518 
519  for (unsigned int j=0; j<n_bfs; j++)
520  {
521  output_n_out << RB_output_vectors[n][q_l](j);
522  }
523  output_n_out.close();
524  }
525  }
526 
528  {
529  // Next write out the inner product matrix
530  file_name.str("");
531  file_name << directory_name << "/RB_inner_product_matrix" << suffix;
532  Xdr RB_inner_product_matrix_out(file_name.str(), mode);
533  for (unsigned int i=0; i<n_bfs; i++)
534  {
535  for (unsigned int j=0; j<n_bfs; j++)
536  {
537  RB_inner_product_matrix_out << RB_inner_product_matrix(i,j);
538  }
539  }
540  RB_inner_product_matrix_out.close();
541  }
542 
543  // Next write out the Fq vectors
544  for (unsigned int q_f=0; q_f<rb_theta_expansion->get_n_F_terms(); q_f++)
545  {
546  file_name.str("");
547  file_name << directory_name << "/RB_F_";
548  file_name << std::setw(3)
549  << std::setprecision(0)
550  << std::setfill('0')
551  << std::right
552  << q_f;
553  file_name << suffix;
554  Xdr RB_Fq_f_out(file_name.str(), mode);
555 
556  for (unsigned int i=0; i<n_bfs; i++)
557  {
558  RB_Fq_f_out << RB_Fq_vector[q_f](i);
559  }
560  RB_Fq_f_out.close();
561  }
562 
563  // Next write out the Aq matrices
564  for (unsigned int q_a=0; q_a<rb_theta_expansion->get_n_A_terms(); q_a++)
565  {
566  file_name.str("");
567  file_name << directory_name << "/RB_A_";
568  file_name << std::setw(3)
569  << std::setprecision(0)
570  << std::setfill('0')
571  << std::right
572  << q_a;
573  file_name << suffix;
574  Xdr RB_Aq_a_out(file_name.str(), mode);
575 
576  for (unsigned int i=0; i<n_bfs; i++)
577  {
578  for (unsigned int j=0; j<n_bfs; j++)
579  {
580  RB_Aq_a_out << RB_Aq_vector[q_a](i,j);
581  }
582  }
583  RB_Aq_a_out.close();
584  }
585 
586  // Next write out Fq_Aq representor norm data
587  file_name.str("");
588  file_name << directory_name << "/Fq_Aq_innerprods" << suffix;
589  Xdr RB_Fq_Aq_innerprods_out(file_name.str(), mode);
590 
591  for (unsigned int q_f=0; q_f<rb_theta_expansion->get_n_F_terms(); q_f++)
592  {
593  for (unsigned int q_a=0; q_a<rb_theta_expansion->get_n_A_terms(); q_a++)
594  {
595  for (unsigned int i=0; i<n_bfs; i++)
596  {
597  RB_Fq_Aq_innerprods_out << Fq_Aq_representor_innerprods[q_f][q_a][i];
598  }
599  }
600  }
601  RB_Fq_Aq_innerprods_out.close();
602 
603  // Next write out Aq_Aq representor norm data
604  file_name.str("");
605  file_name << directory_name << "/Aq_Aq_innerprods" << suffix;
606  Xdr RB_Aq_Aq_innerprods_out(file_name.str(), mode);
607 
608  unsigned int Q_a_hat = rb_theta_expansion->get_n_A_terms()*(rb_theta_expansion->get_n_A_terms()+1)/2;
609  for (unsigned int i=0; i<Q_a_hat; i++)
610  {
611  for (unsigned int j=0; j<n_bfs; j++)
612  {
613  for (unsigned int l=0; l<n_bfs; l++)
614  {
615  RB_Aq_Aq_innerprods_out << Aq_Aq_representor_innerprods[i][j][l];
616  }
617  }
618  }
619  RB_Aq_Aq_innerprods_out.close();
620 
621  // Also, write out the greedily selected parameters
622  {
623  file_name.str("");
624  file_name << directory_name << "/greedy_params" << suffix;
625  Xdr greedy_params_out(file_name.str(), mode);
626 
627  for (const auto & param : greedy_param_list)
628  for (const auto & pr : param)
629  {
630  // Need to make a copy of the value so that it's not const
631  // Xdr is not templated on const's
632  Real param_value = pr.second;
633  greedy_params_out << param_value;
634  }
635  greedy_params_out.close();
636  }
637 
638  }
639 }
640 
641 void RBEvaluation::legacy_read_offline_data_from_files(const std::string & directory_name,
642  bool read_error_bound_data,
643  const bool read_binary_data)
644 {
645  LOG_SCOPE("legacy_read_offline_data_from_files()", "RBEvaluation");
646 
647  // The reading mode: DECODE for binary, READ for ASCII
648  XdrMODE mode = read_binary_data ? DECODE : READ;
649 
650  // The suffix to use for all the files that are written out
651  const std::string suffix = read_binary_data ? ".xdr" : ".dat";
652 
653  // The string stream we'll use to make the file names
654  std::ostringstream file_name;
655 
656  // First, find out how many basis functions we had when Greedy terminated
657  unsigned int n_bfs;
658  {
659  file_name << directory_name << "/n_bfs" << suffix;
660  assert_file_exists(file_name.str());
661 
662  Xdr n_bfs_in(file_name.str(), mode);
663  n_bfs_in >> n_bfs;
664  n_bfs_in.close();
665  }
666  resize_data_structures(n_bfs, read_error_bound_data);
667 
668  // Read in the parameter ranges
669  file_name.str("");
670  file_name << directory_name << "/parameter_ranges" << suffix;
671  std::string continuous_param_file_name = file_name.str();
672 
673  // Read in the discrete parameter values
674  file_name.str("");
675  file_name << directory_name << "/discrete_parameter_values" << suffix;
676  std::string discrete_param_file_name = file_name.str();
677  read_parameter_data_from_files(continuous_param_file_name,
678  discrete_param_file_name,
679  read_binary_data);
680 
681  // Read in output data in multiple files
682  for (unsigned int n=0; n<rb_theta_expansion->get_n_outputs(); n++)
683  {
684  for (unsigned int q_l=0; q_l<rb_theta_expansion->get_n_output_terms(n); q_l++)
685  {
686  file_name.str("");
687  file_name << directory_name << "/output_";
688  file_name << std::setw(3)
689  << std::setprecision(0)
690  << std::setfill('0')
691  << std::right
692  << n;
693  file_name << "_";
694  file_name << std::setw(3)
695  << std::setprecision(0)
696  << std::setfill('0')
697  << std::right
698  << q_l;
699  file_name << suffix;
700  assert_file_exists(file_name.str());
701 
702  Xdr output_n_in(file_name.str(), mode);
703 
704  for (unsigned int j=0; j<n_bfs; j++)
705  {
706  Number value;
707  output_n_in >> value;
708  RB_output_vectors[n][q_l](j) = value;
709  }
710  output_n_in.close();
711  }
712  }
713 
715  {
716  // Next read in the inner product matrix
717  file_name.str("");
718  file_name << directory_name << "/RB_inner_product_matrix" << suffix;
719  assert_file_exists(file_name.str());
720 
721  Xdr RB_inner_product_matrix_in(file_name.str(), mode);
722 
723  for (unsigned int i=0; i<n_bfs; i++)
724  {
725  for (unsigned int j=0; j<n_bfs; j++)
726  {
727  Number value;
728  RB_inner_product_matrix_in >> value;
730  }
731  }
732  RB_inner_product_matrix_in.close();
733  }
734 
735  // Next read in the Fq vectors
736  for (unsigned int q_f=0; q_f<rb_theta_expansion->get_n_F_terms(); q_f++)
737  {
738  file_name.str("");
739  file_name << directory_name << "/RB_F_";
740  file_name << std::setw(3)
741  << std::setprecision(0)
742  << std::setfill('0')
743  << std::right
744  << q_f;
745  file_name << suffix;
746  assert_file_exists(file_name.str());
747 
748  Xdr RB_Fq_f_in(file_name.str(), mode);
749 
750  for (unsigned int i=0; i<n_bfs; i++)
751  {
752  Number value;
753  RB_Fq_f_in >> value;
754  RB_Fq_vector[q_f](i) = value;
755  }
756  RB_Fq_f_in.close();
757  }
758 
759  // Next read in the Aq matrices
760  for (unsigned int q_a=0; q_a<rb_theta_expansion->get_n_A_terms(); q_a++)
761  {
762  file_name.str("");
763  file_name << directory_name << "/RB_A_";
764  file_name << std::setw(3)
765  << std::setprecision(0)
766  << std::setfill('0')
767  << std::right
768  << q_a;
769  file_name << suffix;
770  assert_file_exists(file_name.str());
771 
772  Xdr RB_Aq_a_in(file_name.str(), mode);
773 
774  for (unsigned int i=0; i<n_bfs; i++)
775  {
776  for (unsigned int j=0; j<n_bfs; j++)
777  {
778  Number value;
779  RB_Aq_a_in >> value;
780  RB_Aq_vector[q_a](i,j) = value;
781  }
782  }
783  RB_Aq_a_in.close();
784  }
785 
786 
787  if (read_error_bound_data)
788  {
789  // Next read in Fq representor norm data
790  file_name.str("");
791  file_name << directory_name << "/Fq_innerprods" << suffix;
792  assert_file_exists(file_name.str());
793 
794  Xdr RB_Fq_innerprods_in(file_name.str(), mode);
795 
796  unsigned int Q_f_hat = rb_theta_expansion->get_n_F_terms()*(rb_theta_expansion->get_n_F_terms()+1)/2;
797  for (unsigned int i=0; i<Q_f_hat; i++)
798  {
799  RB_Fq_innerprods_in >> Fq_representor_innerprods[i];
800  }
801  RB_Fq_innerprods_in.close();
802 
803  // Read in output data
804  for (unsigned int n=0; n<rb_theta_expansion->get_n_outputs(); n++)
805  {
806  file_name.str("");
807  file_name << directory_name << "/output_";
808  file_name << std::setw(3)
809  << std::setprecision(0)
810  << std::setfill('0')
811  << std::right
812  << n;
813  file_name << "_dual_innerprods" << suffix;
814  assert_file_exists(file_name.str());
815 
816  Xdr output_dual_innerprods_in(file_name.str(), mode);
817 
818  unsigned int Q_l_hat = rb_theta_expansion->get_n_output_terms(n)*(rb_theta_expansion->get_n_output_terms(n)+1)/2;
819  for (unsigned int q=0; q<Q_l_hat; q++)
820  {
821  output_dual_innerprods_in >> output_dual_innerprods[n][q];
822  }
823  output_dual_innerprods_in.close();
824  }
825 
826 
827  // Next read in Fq_Aq representor norm data
828  file_name.str("");
829  file_name << directory_name << "/Fq_Aq_innerprods" << suffix;
830  assert_file_exists(file_name.str());
831 
832  Xdr RB_Fq_Aq_innerprods_in(file_name.str(), mode);
833 
834  for (unsigned int q_f=0; q_f<rb_theta_expansion->get_n_F_terms(); q_f++)
835  {
836  for (unsigned int q_a=0; q_a<rb_theta_expansion->get_n_A_terms(); q_a++)
837  {
838  for (unsigned int i=0; i<n_bfs; i++)
839  {
840  RB_Fq_Aq_innerprods_in >> Fq_Aq_representor_innerprods[q_f][q_a][i];
841  }
842  }
843  }
844  RB_Fq_Aq_innerprods_in.close();
845 
846  // Next read in Aq_Aq representor norm data
847  file_name.str("");
848  file_name << directory_name << "/Aq_Aq_innerprods" << suffix;
849  assert_file_exists(file_name.str());
850 
851  Xdr RB_Aq_Aq_innerprods_in(file_name.str(), mode);
852 
853  unsigned int Q_a_hat = rb_theta_expansion->get_n_A_terms()*(rb_theta_expansion->get_n_A_terms()+1)/2;
854  for (unsigned int i=0; i<Q_a_hat; i++)
855  {
856  for (unsigned int j=0; j<n_bfs; j++)
857  {
858  for (unsigned int l=0; l<n_bfs; l++)
859  {
860  RB_Aq_Aq_innerprods_in >> Aq_Aq_representor_innerprods[i][j][l];
861  }
862  }
863  }
864  RB_Aq_Aq_innerprods_in.close();
865  }
866 
867  // Resize basis_functions even if we don't read them in so that
868  // get_n_bfs() returns the correct value. Initialize the pointers
869  // to nullptr.
870  basis_functions.clear();
871  set_n_basis_functions(n_bfs);
872 }
873 
874 void RBEvaluation::assert_file_exists(const std::string & file_name)
875 {
876  if (!std::ifstream(file_name.c_str()))
877  libmesh_error_msg("File missing: " + file_name);
878 }
879 
881  const std::string & directory_name,
882  const bool write_binary_basis_functions)
883 {
884  LOG_SCOPE("write_out_basis_functions()", "RBEvaluation");
885 
886  std::vector<NumericVector<Number>*> basis_functions_ptrs;
887  for(std::size_t i=0; i<basis_functions.size(); i++)
888  {
889  basis_functions_ptrs.push_back(basis_functions[i].get());
890  }
891 
892  write_out_vectors(sys,
893  basis_functions_ptrs,
894  directory_name,
895  "bf",
896  write_binary_basis_functions);
897 }
898 
900  std::vector<NumericVector<Number>*> & vectors,
901  const std::string & directory_name,
902  const std::string & data_name,
903  const bool write_binary_vectors)
904 {
905  LOG_SCOPE("write_out_vectors()", "RBEvaluation");
906 
907  if (this->processor_id() == 0)
908  {
909  // Make a directory to store all the data files
910  Utility::mkdir(directory_name.c_str());
911  }
912 
913  // Make sure processors are synced up before we begin
914  this->comm().barrier();
915 
916  std::ostringstream file_name;
917  const std::string basis_function_suffix = (write_binary_vectors ? ".xdr" : ".dat");
918 
919  file_name << directory_name << "/" << data_name << "_data" << basis_function_suffix;
920  Xdr bf_data(file_name.str(),
921  write_binary_vectors ? ENCODE : WRITE);
922 
923  std::string version("libMesh-" + libMesh::get_io_compatibility_version());
924 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
925  version += " with infinite elements";
926 #endif
927  bf_data.data(version ,"# File Format Identifier");
928 
929  sys.write_header(bf_data, /*(unused arg)*/ version, /*write_additional_data=*/false);
930 
931  // Following EquationSystemsIO::write, we use a temporary numbering (node major)
932  // before writing out the data
934 
935  // Write all vectors at once.
936  {
937  // Note the API wants pointers to constant vectors, hence this...
938  std::vector<const NumericVector<Number> *> bf_out;
939  for (const auto & vec : vectors)
940  bf_out.push_back(vec);
941 
942  // for (auto & val : vectors)
943  // bf_out.push_back(val);
944  sys.write_serialized_vectors (bf_data, bf_out);
945  }
946 
947 
948  // set the current version
949  bf_data.set_version(LIBMESH_VERSION_ID(LIBMESH_MAJOR_VERSION,
950  LIBMESH_MINOR_VERSION,
951  LIBMESH_MICRO_VERSION));
952 
953 
954  // Undo the temporary renumbering
956 }
957 
959  const std::string & directory_name,
960  const bool read_binary_basis_functions)
961 {
962  LOG_SCOPE("read_in_basis_functions()", "RBEvaluation");
963 
964  read_in_vectors(sys,
966  directory_name,
967  "bf",
968  read_binary_basis_functions);
969 }
970 
972  std::vector<std::unique_ptr<NumericVector<Number>>> & vectors,
973  const std::string & directory_name,
974  const std::string & data_name,
975  const bool read_binary_vectors)
976 {
977  std::vector<std::vector<std::unique_ptr<NumericVector<Number>>> *> vectors_vec;
978  vectors_vec.push_back(&vectors);
979 
980  std::vector<std::string> directory_name_vec;
981  directory_name_vec.push_back(directory_name);
982 
983  std::vector<std::string> data_name_vec;
984  data_name_vec.push_back(data_name);
985 
987  vectors_vec,
988  directory_name_vec,
989  data_name_vec,
990  read_binary_vectors);
991 }
992 
994  std::vector<std::vector<std::unique_ptr<NumericVector<Number>>> *> multiple_vectors,
995  const std::vector<std::string> & multiple_directory_names,
996  const std::vector<std::string> & multiple_data_names,
997  const bool read_binary_vectors)
998 {
999  LOG_SCOPE("read_in_vectors_from_multiple_files()", "RBEvaluation");
1000 
1001  std::size_t n_files = multiple_vectors.size();
1002  std::size_t n_directories = multiple_directory_names.size();
1003  libmesh_assert((n_files == n_directories) && (n_files == multiple_data_names.size()));
1004 
1005  if (n_files == 0)
1006  return;
1007 
1008  // Make sure processors are synced up before we begin
1009  this->comm().barrier();
1010 
1011  std::ostringstream file_name;
1012  const std::string basis_function_suffix = (read_binary_vectors ? ".xdr" : ".dat");
1013 
1014  // Following EquationSystemsIO::read, we use a temporary numbering (node major)
1015  // before writing out the data. For the sake of efficiency, we do this once for
1016  // all the vectors that we read in.
1018 
1019  for (std::size_t data_index=0; data_index<n_directories; data_index++)
1020  {
1021  std::vector<std::unique_ptr<NumericVector<Number>>> & vectors = *multiple_vectors[data_index];
1022 
1023  // Allocate storage for each vector
1024  for (auto & vec : vectors)
1025  {
1026  // vectors should all be nullptr, otherwise we get a memory leak when
1027  // we create the new vectors in RBEvaluation::read_in_vectors.
1028  if (vec)
1029  libmesh_error_msg("Non-nullptr vector passed to read_in_vectors_from_multiple_files");
1030 
1031  vec = NumericVector<Number>::build(sys.comm());
1032 
1033  vec->init (sys.n_dofs(),
1034  sys.n_local_dofs(),
1035  false,
1036  PARALLEL);
1037  }
1038 
1039  file_name.str("");
1040  file_name << multiple_directory_names[data_index]
1041  << "/" << multiple_data_names[data_index]
1042  << "_data" << basis_function_suffix;
1043 
1044  // On processor zero check to be sure the file exists
1045  if (this->processor_id() == 0)
1046  {
1047  struct stat stat_info;
1048  int stat_result = stat(file_name.str().c_str(), &stat_info);
1049 
1050  if (stat_result != 0)
1051  libmesh_error_msg("File does not exist: " << file_name.str());
1052  }
1053 
1054  assert_file_exists(file_name.str());
1055  Xdr vector_data(file_name.str(),
1056  read_binary_vectors ? DECODE : READ);
1057 
1058  // Read the header data. This block of code is based on EquationSystems::_read_impl.
1059  {
1060  std::string version;
1061  vector_data.data(version);
1062 
1063  const std::string libMesh_label = "libMesh-";
1064  std::string::size_type lm_pos = version.find(libMesh_label);
1065  if (lm_pos==std::string::npos)
1066  libmesh_error_msg("version info missing in Xdr header");
1067 
1068  std::istringstream iss(version.substr(lm_pos + libMesh_label.size()));
1069  int ver_major = 0, ver_minor = 0, ver_patch = 0;
1070  char dot;
1071  iss >> ver_major >> dot >> ver_minor >> dot >> ver_patch;
1072  vector_data.set_version(LIBMESH_VERSION_ID(ver_major, ver_minor, ver_patch));
1073 
1074  // Actually read the header data. When we do this, set read_header=false
1075  // so taht we do not reinit sys, since we assume that it has already been
1076  // set up properly (e.g. the appropriate variables have already been added).
1077  sys.read_header(vector_data, version, /*read_header=*/false, /*read_additional_data=*/false);
1078  }
1079 
1080  // Comply with the System::read_serialized_vectors() interface which uses dumb pointers.
1081  std::vector<NumericVector<Number> *> vec_in;
1082  for (auto & vec : vectors)
1083  vec_in.push_back(vec.get());
1084 
1085  sys.read_serialized_vectors (vector_data, vec_in);
1086  }
1087 
1088  // Undo the temporary renumbering
1090 }
1091 
1092 } // namespace libMesh
libMesh::System
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition: system.h:100
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::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::RBEvaluation::set_n_basis_functions
virtual void set_n_basis_functions(unsigned int n_bfs)
Set the number of basis functions.
Definition: rb_evaluation.C:78
libMesh::RBEvaluation::~RBEvaluation
virtual ~RBEvaluation()
Destructor.
Definition: rb_evaluation.C:57
libMesh::RBEvaluation::write_out_basis_functions
virtual void write_out_basis_functions(System &sys, const std::string &directory_name="offline_data", const bool write_binary_basis_functions=true)
Write out all the basis functions to file.
Definition: rb_evaluation.C:880
libMesh::PARALLEL
Definition: enum_parallel_type.h:36
libMesh::RBParametrized::write_parameter_data_to_files
void write_parameter_data_to_files(const std::string &continuous_param_file_name, const std::string &discrete_param_file_name, const bool write_binary_data)
Write out the parameter ranges to files.
Definition: rb_parametrized.C:214
libMesh::RBEvaluation::is_rb_theta_expansion_initialized
bool is_rb_theta_expansion_initialized() const
Definition: rb_evaluation.C:96
libMesh::libmesh_real
T libmesh_real(T a)
Definition: libmesh_common.h:166
libMesh::RBEvaluation::rb_solve
virtual Real rb_solve(unsigned int N)
Perform online solve with the N RB basis functions, for the set of parameters in current_params,...
Definition: rb_evaluation.C:209
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
libMesh::RBEvaluation::output_dual_innerprods
std::vector< std::vector< Number > > output_dual_innerprods
The vector storing the dual norm inner product terms for each output.
Definition: rb_evaluation.h:308
std::sqrt
MetaPhysicL::DualNumber< T, D > sqrt(const MetaPhysicL::DualNumber< T, D > &in)
libMesh::ParallelObject::comm
const Parallel::Communicator & comm() const
Definition: parallel_object.h:94
libMesh::System::write_header
void write_header(Xdr &io, const std::string &version, const bool write_additional_data) const
Writes the basic data header for this System.
Definition: system_io.C:1298
libMesh::DenseMatrix< Number >
libMesh::RBEvaluation::read_in_basis_functions
virtual void read_in_basis_functions(System &sys, const std::string &directory_name="offline_data", const bool read_binary_basis_functions=true)
Read in all the basis functions from file.
Definition: rb_evaluation.C:958
libMesh::RBParameters
This class is part of the rbOOmit framework.
Definition: rb_parameters.h:42
libMesh::libmesh_conj
T libmesh_conj(T a)
Definition: libmesh_common.h:167
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::RBEvaluation::set_rb_theta_expansion
void set_rb_theta_expansion(RBThetaExpansion &rb_theta_expansion_in)
Set the RBThetaExpansion object.
Definition: rb_evaluation.C:83
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::NumericVector::build
static std::unique_ptr< NumericVector< T > > build(const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package())
Builds a NumericVector on the processors in communicator comm using the linear solver package specifi...
Definition: numeric_vector.C:49
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::RBEvaluation::RBEvaluation
RBEvaluation(const Parallel::Communicator &comm)
Constructor.
Definition: rb_evaluation.C:47
libMesh::RBEvaluation::RB_outputs
std::vector< Number > RB_outputs
The vectors storing the RB output values and corresponding error bounds.
Definition: rb_evaluation.h:281
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::NumericVector< Number >
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::libmesh_assert
libmesh_assert(ctx)
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::System::read_header
void read_header(Xdr &io, const std::string &version, const bool read_header=true, const bool read_additional_data=true, const bool read_legacy_format=false)
Reads the basic data header for this System.
Definition: system_io.C:114
libMesh::Xdr::data
void data(T &a, const char *comment="")
Inputs or outputs a single value.
Definition: xdr_cxx.C:766
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::XdrMODE
XdrMODE
Defines an enum for read/write mode in Xdr format.
Definition: enum_xdr_mode.h:35
libMesh::System::n_local_dofs
dof_id_type n_local_dofs() const
Definition: system.C:187
libMesh::DECODE
Definition: enum_xdr_mode.h:39
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::RBEvaluation::read_in_vectors
void read_in_vectors(System &sys, std::vector< std::unique_ptr< NumericVector< Number >>> &vectors, const std::string &directory_name, const std::string &data_name, const bool read_binary_vectors)
Same as read_in_basis_functions, except in this case we pass in the vectors to be written.
Definition: rb_evaluation.C:971
libMesh::System::get_mesh
const MeshBase & get_mesh() const
Definition: system.h:2083
libMesh::ParallelObject::processor_id
processor_id_type processor_id() const
Definition: parallel_object.h:106
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::get_io_compatibility_version
std::string get_io_compatibility_version()
Specifier for I/O file compatibility features.
Definition: libmesh_version.C:80
libMesh::System::read_serialized_vectors
std::size_t read_serialized_vectors(Xdr &io, const std::vector< NumericVector< Number > * > &vectors) const
Read a number of identically distributed vectors.
Definition: system_io.C:2199
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::RBEvaluation::rb_theta_expansion
RBThetaExpansion * rb_theta_expansion
A pointer to to the object that stores the theta expansion.
Definition: rb_evaluation.h:344
libMesh::DenseVector::dot
CompareTypes< T, T2 >::supertype dot(const DenseVector< T2 > &vec) const
Definition: dense_vector.h:451
libMesh::RBEvaluation::read_in_vectors_from_multiple_files
void read_in_vectors_from_multiple_files(System &sys, std::vector< std::vector< std::unique_ptr< NumericVector< Number >>> * > multiple_vectors, const std::vector< std::string > &multiple_directory_names, const std::vector< std::string > &multiple_data_names, const bool read_binary_vectors)
Performs read_in_vectors for a list of directory names and data names.
Definition: rb_evaluation.C:993
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
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::RBEvaluation::compute_residual_dual_norm
virtual Real compute_residual_dual_norm(const unsigned int N)
Compute the dual norm of the residual for the solution saved in RB_solution_vector.
Definition: rb_evaluation.C:302
libMesh::READ
Definition: enum_xdr_mode.h:41
libMesh::RBEvaluation::write_out_vectors
virtual void write_out_vectors(System &sys, std::vector< NumericVector< Number > * > &vectors, const std::string &directory_name="offline_data", const std::string &data_name="bf", const bool write_binary_basis_functions=true)
Same as write_out_basis_functions, except in this case we pass in the vectors to be written.
Definition: rb_evaluation.C:899
libMesh::DenseMatrix::zero
virtual void zero() override
Set every element in the matrix to 0.
Definition: dense_matrix.h:838
libMesh::Utility::mkdir
int mkdir(const char *pathname)
Create a directory.
Definition: utility.C:140
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::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::MeshTools::Private::globally_renumber_nodes_and_elements
void globally_renumber_nodes_and_elements(MeshBase &)
There is no reason for a user to ever call this function.
Definition: mesh_tools.C:2411
libMesh::ReferenceElem::get
const Elem & get(const ElemType type_in)
Definition: reference_elem.C:237
libMesh::Xdr::close
void close()
Closes the file if it is open.
Definition: xdr_cxx.C:273
libMesh::MeshBase::fix_broken_node_and_element_numbering
virtual void fix_broken_node_and_element_numbering()=0
There is no reason for a user to ever call this function.
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::RBEvaluation::RB_inner_product_matrix
DenseMatrix< Number > RB_inner_product_matrix
The inner product matrix.
Definition: rb_evaluation.h:255
libMesh::RBParametrized::read_parameter_data_from_files
void read_parameter_data_from_files(const std::string &continuous_param_file_name, const std::string &discrete_param_file_name, const bool read_binary_data)
Read in the parameter ranges from files.
Definition: rb_parametrized.C:284
value
static const bool value
Definition: xdr_io.C:56
libMesh::RBEvaluation::get_error_bound_normalization
virtual Real get_error_bound_normalization()
Definition: rb_evaluation.C:291
libMesh::RBEvaluation::Aq_representor
std::vector< std::vector< std::unique_ptr< NumericVector< Number > > > > Aq_representor
Vector storing the residual representors associated with the left-hand side.
Definition: rb_evaluation.h:316
libMesh::System::write_serialized_vectors
std::size_t write_serialized_vectors(Xdr &io, const std::vector< const NumericVector< Number > * > &vectors) const
Serialize & write a number of identically distributed vectors.
Definition: system_io.C:2293
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::RBEvaluation::RB_output_error_bounds
std::vector< Real > RB_output_error_bounds
Definition: rb_evaluation.h:282
libMesh::System::n_dofs
dof_id_type n_dofs() const
Definition: system.C:150
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::RBEvaluation::basis_functions
std::vector< std::unique_ptr< NumericVector< Number > > > basis_functions
The libMesh vectors storing the finite element coefficients of the RB basis functions.
Definition: rb_evaluation.h:241
libMesh::Real
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Definition: libmesh_common.h:121
libMesh::ParallelObject
An object whose state is distributed along a set of processors.
Definition: parallel_object.h:55
communicator.h
libMesh::RBEvaluation::RB_Fq_vector
std::vector< DenseVector< Number > > RB_Fq_vector
Dense vector for the RHS.
Definition: rb_evaluation.h:265
libMesh::RBThetaExpansion
This class stores the set of RBTheta functor objects that define the "parameter-dependent expansion" ...
Definition: rb_theta_expansion.h:44
libMesh::RBEvaluation::get_basis_function
NumericVector< Number > & get_basis_function(unsigned int i)
Get a reference to the i^th basis function.
Definition: rb_evaluation.C:202
libMesh::DenseVector< Number >
libMesh::RBEvaluation::greedy_param_list
std::vector< RBParameters > greedy_param_list
The list of parameters selected by the Greedy algorithm in generating the Reduced Basis associated wi...
Definition: rb_evaluation.h:247