libMesh
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Attributes | List of all members
libMesh::RBConstructionBase< Base > Class Template Reference

This class is part of the rbOOmit framework. More...

#include <rb_construction_base.h>

Inheritance diagram for libMesh::RBConstructionBase< Base >:
[legend]

Public Types

typedef RBConstructionBase< Base > sys_type
 The type of system. More...
 

Public Member Functions

 RBConstructionBase (EquationSystems &es, const std::string &name, const unsigned int number)
 Constructor. More...
 
virtual ~RBConstructionBase ()
 Destructor. More...
 
sys_typesystem ()
 
virtual void clear ()
 Clear all the data structures associated with the system. More...
 
numeric_index_type get_n_training_samples () const
 Get the total number of training samples. More...
 
numeric_index_type get_local_n_training_samples () const
 Get the total number of training samples local to this processor. More...
 
numeric_index_type get_first_local_training_index () const
 Get the first local index of the training parameters. More...
 
numeric_index_type get_last_local_training_index () const
 Get the last local index of the training parameters. More...
 
virtual void initialize_training_parameters (const RBParameters &mu_min, const RBParameters &mu_max, unsigned int n_training_parameters, std::map< std::string, bool > log_param_scale, bool deterministic=true)
 Initialize the parameter ranges and indicate whether deterministic or random training parameters should be used and whether or not we want the parameters to be scaled logarithmically. More...
 
virtual void load_training_set (std::map< std::string, std::vector< Number >> &new_training_set)
 Overwrite the training parameters with new_training_set. More...
 
void broadcast_parameters (unsigned int proc_id)
 Broadcasts parameters on processor proc_id to all processors. More...
 
void set_training_random_seed (unsigned int seed)
 Set the seed that is used to randomly generate training parameters. More...
 
void set_deterministic_training_parameter_name (const std::string &name)
 In some cases we only want to allow discrete parameter values, instead of parameters that may take any value in a specified interval. More...
 
const std::string & get_deterministic_training_parameter_name () const
 Get the name of the parameter that we will generate deterministic training parameters for. More...
 
void set_deterministic_training_parameter_repeats (unsigned int repeats)
 Set the number of times each sample of the deterministic training parameter is repeated. More...
 
unsigned int get_deterministic_training_parameter_repeats () const
 Get the number of times each sample of the deterministic training parameter is repeated. More...
 
void initialize_parameters (const RBParameters &mu_min_in, const RBParameters &mu_max_in, const std::map< std::string, std::vector< Real >> &discrete_parameter_values)
 Initialize the parameter ranges and set current_parameters. More...
 
void initialize_parameters (const RBParametrized &rb_parametrized)
 Initialize the parameter ranges and set current_parameters. More...
 
unsigned int get_n_params () const
 Get the number of parameters. More...
 
unsigned int get_n_continuous_params () const
 Get the number of continuous parameters. More...
 
unsigned int get_n_discrete_params () const
 Get the number of discrete parameters. More...
 
std::set< std::string > get_parameter_names () const
 Get a set that stores the parameter names. More...
 
const RBParametersget_parameters () const
 Get the current parameters. More...
 
void set_parameters (const RBParameters &params)
 Set the current parameters to params. More...
 
const RBParametersget_parameters_min () const
 Get an RBParameters object that specifies the minimum allowable value for each parameter. More...
 
const RBParametersget_parameters_max () const
 Get an RBParameters object that specifies the maximum allowable value for each parameter. More...
 
Real get_parameter_min (const std::string &param_name) const
 Get minimum allowable value of parameter param_name. More...
 
Real get_parameter_max (const std::string &param_name) const
 Get maximum allowable value of parameter param_name. More...
 
void print_parameters () const
 Print the current parameters. More...
 
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. More...
 
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. More...
 
bool is_discrete_parameter (const std::string &mu_name) const
 Is parameter mu_name discrete? More...
 
const std::map< std::string, std::vector< Real > > & get_discrete_parameter_values () const
 Get a const reference to the discrete parameter values. More...
 
void print_discrete_parameter_values () const
 Print out all the discrete parameter values. More...
 

Static Public Member Functions

static Real get_closest_value (Real value, const std::vector< Real > &list_of_values)
 
static std::string get_info ()
 Gets a string containing the reference information. More...
 
static void print_info (std::ostream &out=libMesh::out)
 Prints the reference information, by default to libMesh::out. More...
 
static unsigned int n_objects ()
 Prints the number of outstanding (created, but not yet destroyed) objects. More...
 
static void enable_print_counter_info ()
 Methods to enable/disable the reference counter output from print_info() More...
 
static void disable_print_counter_info ()
 

Public Attributes

bool verbose_mode
 Public boolean to toggle verbose mode. More...
 

Protected Types

typedef std::map< std::string, std::pair< unsigned int, unsigned int > > Counts
 Data structure to log the information. More...
 

Protected Member Functions

virtual void init_data ()
 Initializes the member data fields associated with the system, so that, e.g., assemble() may be used. More...
 
RBParameters get_params_from_training_set (unsigned int index)
 Return the RBParameters in index index of training set. More...
 
void set_params_from_training_set (unsigned int index)
 Set parameters to the RBParameters stored in index index of the training set. More...
 
virtual void set_params_from_training_set_and_broadcast (unsigned int index)
 Load the specified training parameter and then broadcast to all processors. More...
 
void increment_constructor_count (const std::string &name)
 Increments the construction counter. More...
 
void increment_destructor_count (const std::string &name)
 Increments the destruction counter. More...
 

Static Protected Member Functions

static void get_global_max_error_pair (const Parallel::Communicator &communicator, std::pair< numeric_index_type, Real > &error_pair)
 Static function to return the error pair (index,error) that is corresponds to the largest error on all processors. More...
 
static void generate_training_parameters_random (const Parallel::Communicator &communicator, std::map< std::string, bool > log_param_scale, std::map< std::string, NumericVector< Number > * > &training_parameters_in, unsigned int n_training_samples_in, const RBParameters &min_parameters, const RBParameters &max_parameters, int training_parameters_random_seed=-1, bool serial_training_set=false)
 Static helper function for generating a randomized set of parameters. More...
 
static void generate_training_parameters_deterministic (const Parallel::Communicator &communicator, std::map< std::string, bool > log_param_scale, std::map< std::string, NumericVector< Number > * > &training_parameters_in, unsigned int n_training_samples_in, const RBParameters &min_parameters, const RBParameters &max_parameters, bool serial_training_set=false)
 Static helper function for generating a deterministic set of parameters. More...
 

Protected Attributes

bool serial_training_set
 This boolean flag indicates whether or not the training set should be the same on all processors. More...
 
UniquePtr< NumericVector< Number > > inner_product_storage_vector
 We keep an extra temporary vector that is useful for performing inner products (avoids unnecessary memory allocation/deallocation). More...
 

Static Protected Attributes

static Counts _counts
 Actually holds the data. More...
 
static Threads::atomic< unsigned int_n_objects
 The number of objects. More...
 
static Threads::spin_mutex _mutex
 Mutual exclusion object to enable thread-safe reference counting. More...
 
static bool _enable_print_counter = true
 Flag to control whether reference count information is printed when print_info is called. More...
 

Private Attributes

bool training_parameters_initialized
 Boolean flag to indicate whether or not the parameter ranges have been initialized. More...
 
std::map< std::string, NumericVector< Number > * > training_parameters
 The training samples. More...
 
int training_parameters_random_seed
 If < 0, use std::time() * processor_id() to seed the random number generator for the training parameters (default). More...
 

Detailed Description

template<class Base>
class libMesh::RBConstructionBase< Base >

This class is part of the rbOOmit framework.

This is the base class for the Construction stage of the certified reduced basis (RB) method. We template the Base class so that we can derive from the appropriate libMesh System type (e.g. LinearImplicitSystem for standard reduced basis, EigenSystem for SCM) at compile time.

Author
David J. Knezevic
Date
2009

Definition at line 54 of file rb_construction_base.h.

Member Typedef Documentation

typedef std::map<std::string, std::pair<unsigned int, unsigned int> > libMesh::ReferenceCounter::Counts
protectedinherited

Data structure to log the information.

The log is identified by the class name.

Definition at line 119 of file reference_counter.h.

template<class Base>
typedef RBConstructionBase<Base> libMesh::RBConstructionBase< Base >::sys_type

The type of system.

Definition at line 74 of file rb_construction_base.h.

Constructor & Destructor Documentation

template<class Base >
libMesh::RBConstructionBase< Base >::RBConstructionBase ( EquationSystems es,
const std::string &  name,
const unsigned int  number 
)

Constructor.

Initializes required data structures.

Definition at line 46 of file rb_construction_base.C.

References libMesh::RBConstructionBase< Base >::training_parameters.

49  : Base(es, name_in, number_in),
50  serial_training_set(false),
52  training_parameters_random_seed(-1) // by default, use std::time to seed RNG
53 {
54  training_parameters.clear();
55 }
bool training_parameters_initialized
Boolean flag to indicate whether or not the parameter ranges have been initialized.
std::map< std::string, NumericVector< Number > * > training_parameters
The training samples.
bool serial_training_set
This boolean flag indicates whether or not the training set should be the same on all processors...
int training_parameters_random_seed
If < 0, use std::time() * processor_id() to seed the random number generator for the training paramet...
template<class Base >
libMesh::RBConstructionBase< Base >::~RBConstructionBase ( )
virtual

Destructor.

Definition at line 58 of file rb_construction_base.C.

References libMesh::RBConstructionBase< Base >::clear().

59 {
60  this->clear();
61 }
virtual void clear()
Clear all the data structures associated with the system.

Member Function Documentation

template<class Base >
void libMesh::RBConstructionBase< Base >::broadcast_parameters ( unsigned int  proc_id)

Broadcasts parameters on processor proc_id to all processors.

Definition at line 654 of file rb_construction_base.C.

References libMesh::RBParameters::begin(), libMesh::RBParameters::end(), libMesh::RBParametrized::get_parameters(), libMesh::n_processors(), libMesh::RBParametrized::set_parameters(), and libMesh::RBParameters::set_value().

Referenced by libMesh::RBConstructionBase< Base >::set_params_from_training_set_and_broadcast(), and libMesh::RBConstructionBase< CondensedEigenSystem >::system().

655 {
656  libmesh_assert_less (proc_id, this->n_processors());
657 
658  // create a copy of the current parameters
659  RBParameters current_parameters = get_parameters();
660 
661  // copy current_parameters to current_parameters_vector in order to broadcast
662  std::vector<Real> current_parameters_vector;
663 
664  RBParameters::const_iterator it = current_parameters.begin();
665  RBParameters::const_iterator it_end = current_parameters.end();
666 
667  for ( ; it != it_end; ++it)
668  {
669  current_parameters_vector.push_back(it->second);
670  }
671 
672  // do the broadcast
673  this->comm().broadcast(current_parameters_vector, proc_id);
674 
675  // update the copy of the RBParameters object
676  it = current_parameters.begin();
677  unsigned int count = 0;
678  for ( ; it != it_end; ++it)
679  {
680  std::string param_name = it->first;
681  current_parameters.set_value(param_name, current_parameters_vector[count]);
682  count++;
683  }
684 
685  // set the parameters globally
686  set_parameters(current_parameters);
687 }
void set_parameters(const RBParameters &params)
Set the current parameters to params.
const RBParameters & get_parameters() const
Get the current parameters.
std::map< std::string, Real >::const_iterator const_iterator
Definition: rb_parameters.h:57
processor_id_type n_processors()
Definition: libmesh_base.h:88
template<class Base >
void libMesh::RBConstructionBase< Base >::clear ( )
virtual

Clear all the data structures associated with the system.

Reimplemented from libMesh::RBParametrized.

Reimplemented in libMesh::RBConstruction, libMesh::RBSCMConstruction, libMesh::TransientSystem< RBConstruction >, libMesh::RBEIMConstruction, and libMesh::TransientRBConstruction.

Definition at line 64 of file rb_construction_base.C.

References libMesh::RBParametrized::clear(), libmesh_nullptr, and libMesh::RBConstructionBase< Base >::training_parameters.

Referenced by libMesh::RBConstructionBase< CondensedEigenSystem >::system(), and libMesh::RBConstructionBase< Base >::~RBConstructionBase().

65 {
66  // clear the parent data
67  Base::clear();
69 
70  std::map<std::string, NumericVector<Number> *>::iterator it = training_parameters.begin();
71  std::map<std::string, NumericVector<Number> *>::const_iterator it_end = training_parameters.end();
72 
73  for ( ; it != it_end; ++it)
74  {
75  NumericVector<Number> * training_vector = it->second;
76  delete training_vector;
77  training_vector = libmesh_nullptr;
78  }
79  training_parameters.clear();
80 }
virtual void clear()
Clear all the data structures associated with the system.
const class libmesh_nullptr_t libmesh_nullptr
std::map< std::string, NumericVector< Number > * > training_parameters
The training samples.
void libMesh::ReferenceCounter::disable_print_counter_info ( )
staticinherited

Definition at line 107 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter.

Referenced by libMesh::LibMeshInit::LibMeshInit(), and libMesh::ReferenceCounter::n_objects().

108 {
109  _enable_print_counter = false;
110  return;
111 }
static bool _enable_print_counter
Flag to control whether reference count information is printed when print_info is called...
void libMesh::ReferenceCounter::enable_print_counter_info ( )
staticinherited

Methods to enable/disable the reference counter output from print_info()

Definition at line 101 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter.

Referenced by libMesh::ReferenceCounter::n_objects().

102 {
103  _enable_print_counter = true;
104  return;
105 }
static bool _enable_print_counter
Flag to control whether reference count information is printed when print_info is called...
template<class Base >
void libMesh::RBConstructionBase< Base >::generate_training_parameters_deterministic ( const Parallel::Communicator communicator,
std::map< std::string, bool >  log_param_scale,
std::map< std::string, NumericVector< Number > * > &  training_parameters_in,
unsigned int  n_training_samples_in,
const RBParameters min_parameters,
const RBParameters max_parameters,
bool  serial_training_set = false 
)
staticprotected

Static helper function for generating a deterministic set of parameters.

Only works with 1 or 2 parameters (as defined by the lengths of min/max parameters vectors), otherwise throws an error.

Definition at line 451 of file rb_construction_base.C.

References libMesh::RBParameters::begin(), libMesh::NumericVector< T >::build(), libMesh::RBParameters::end(), libMesh::NumericVector< T >::first_local_index(), libMesh::RBParameters::get_value(), libmesh_nullptr, libMesh::NumericVector< T >::local_size(), std::max(), libMesh::RBParameters::n_parameters(), libMesh::out, libMesh::PARALLEL, std::pow(), libMesh::Parallel::Communicator::rank(), libMesh::Real, libMesh::SERIAL, libMesh::NumericVector< T >::set(), and libMesh::Parallel::Communicator::size().

Referenced by libMesh::RBConstructionBase< Base >::initialize_training_parameters(), and libMesh::RBConstructionBase< CondensedEigenSystem >::system().

458 {
459  libmesh_assert_equal_to ( min_parameters.n_parameters(), max_parameters.n_parameters() );
460  const unsigned int num_params = min_parameters.n_parameters();
461 
462  if (num_params == 0)
463  return;
464 
465  if (num_params > 2)
466  {
467  libMesh::out << "ERROR: Deterministic training sample generation "
468  << " not implemented for more than two parameters." << std::endl;
469  libmesh_not_implemented();
470  }
471 
472  // Clear training_parameters_in
473  {
474  std::map<std::string, NumericVector<Number> *>::iterator it = training_parameters_in.begin();
475  std::map<std::string, NumericVector<Number> *>::const_iterator it_end = training_parameters_in.end();
476 
477  for ( ; it != it_end; ++it)
478  {
479  NumericVector<Number> * training_vector = it->second;
480  delete training_vector;
481  training_vector = libmesh_nullptr;
482  }
483  }
484 
485  // Initialize training_parameters_in
486  {
487  RBParameters::const_iterator it = min_parameters.begin();
488  RBParameters::const_iterator it_end = min_parameters.end();
489  for ( ; it != it_end; ++it)
490  {
491  std::string param_name = it->first;
492  training_parameters_in[param_name] = NumericVector<Number>::build(communicator).release();
493 
494  if (!serial_training_set)
495  {
496  // Calculate the number of training parameters local to this processor
497  unsigned int n_local_training_samples;
498  unsigned int quotient = n_training_samples_in/communicator.size();
499  unsigned int remainder = n_training_samples_in%communicator.size();
500  if (communicator.rank() < remainder)
501  n_local_training_samples = (quotient + 1);
502  else
503  n_local_training_samples = quotient;
504 
505  training_parameters_in[param_name]->init(n_training_samples_in, n_local_training_samples, false, PARALLEL);
506  }
507  else
508  {
509  training_parameters_in[param_name]->init(n_training_samples_in, false, SERIAL);
510  }
511  }
512  }
513 
514  if (num_params == 1)
515  {
516  NumericVector<Number> * training_vector = training_parameters_in.begin()->second;
517  bool use_log_scaling = log_param_scale.begin()->second;
518  Real min_param = min_parameters.begin()->second;
519  Real max_param = max_parameters.begin()->second;
520 
521  numeric_index_type first_index = training_vector->first_local_index();
522  for (numeric_index_type i=0; i<training_vector->local_size(); i++)
523  {
524  numeric_index_type index = first_index+i;
525  if (use_log_scaling)
526  {
527  Real epsilon = 1.e-6; // Prevent rounding errors triggering asserts
528  Real log_min = log10(min_param + epsilon);
529  Real log_range = log10( (max_param-epsilon) / (min_param+epsilon) );
530  Real step_size = log_range /
531  std::max((unsigned int)1,(n_training_samples_in-1));
532 
533  if (index<(n_training_samples_in-1))
534  {
535  training_vector->set(index, pow(10., log_min + index*step_size ));
536  }
537  else
538  {
539  // due to rounding error, the last parameter can be slightly
540  // bigger than max_parameters, hence snap back to the max
541  training_vector->set(index, max_param);
542  }
543  }
544  else
545  {
546  // Generate linearly scaled training parameters
547  Real step_size = (max_param - min_param) /
548  std::max((unsigned int)1,(n_training_samples_in-1));
549  training_vector->set(index, index*step_size + min_param);
550  }
551  }
552  }
553 
554 
555  // This is for two parameters
556  if (num_params == 2)
557  {
558  // First make sure n_training_samples_in is a square number
559  unsigned int n_training_parameters_per_var = static_cast<unsigned int>( std::sqrt(static_cast<Real>(n_training_samples_in)) );
560  if ((n_training_parameters_per_var*n_training_parameters_per_var) != n_training_samples_in)
561  libmesh_error_msg("Error: Number of training parameters = " \
562  << n_training_samples_in \
563  << ".\n" \
564  << "Deterministic training set generation with two parameters requires\n " \
565  << "the number of training parameters to be a perfect square.");
566 
567  // make a matrix to store all the parameters, put them in vector form afterwards
568  std::vector<std::vector<Real>> training_parameters_matrix(num_params);
569 
570  RBParameters::const_iterator it = min_parameters.begin();
571  RBParameters::const_iterator it_end = min_parameters.end();
572  unsigned int i = 0;
573  for ( ; it != it_end; ++it)
574  {
575  std::string param_name = it->first;
576  Real min_param = it->second;
577  bool use_log_scaling = log_param_scale[param_name];
578  Real max_param = max_parameters.get_value(param_name);
579 
580  training_parameters_matrix[i].resize(n_training_parameters_per_var);
581 
582  for (unsigned int j=0; j<n_training_parameters_per_var; j++)
583  {
584  // Generate log10 scaled training parameters
585  if (use_log_scaling)
586  {
587  Real epsilon = 1.e-6; // Prevent rounding errors triggering asserts
588  Real log_min = log10(min_param + epsilon);
589  Real log_range = log10( (max_param-epsilon) / (min_param+epsilon) );
590  Real step_size = log_range /
591  std::max((unsigned int)1,(n_training_parameters_per_var-1));
592 
593  if (j<(n_training_parameters_per_var-1))
594  {
595  training_parameters_matrix[i][j] = pow(10., log_min + j*step_size );
596  }
597  else
598  {
599  // due to rounding error, the last parameter can be slightly
600  // bigger than max_parameters, hence snap back to the max
601  training_parameters_matrix[i][j] = max_param;
602  }
603  }
604  else
605  {
606  // Generate linearly scaled training parameters
607  Real step_size = (max_param - min_param) /
608  std::max((unsigned int)1,(n_training_parameters_per_var-1));
609  training_parameters_matrix[i][j] = j*step_size + min_param;
610  }
611 
612  }
613  i++;
614  }
615 
616  // now load into training_samples_in:
617  std::map<std::string, NumericVector<Number> *>::iterator new_it = training_parameters_in.begin();
618 
619  NumericVector<Number> * training_vector_0 = new_it->second;
620  ++new_it;
621  NumericVector<Number> * training_vector_1 = new_it->second;
622 
623  for (unsigned int index1=0; index1<n_training_parameters_per_var; index1++)
624  {
625  for (unsigned int index2=0; index2<n_training_parameters_per_var; index2++)
626  {
627  unsigned int index = index1*n_training_parameters_per_var + index2;
628 
629  if ((training_vector_0->first_local_index() <= index) &&
630  (index < training_vector_0->last_local_index()))
631  {
632  training_vector_0->set(index, training_parameters_matrix[0][index1]);
633  training_vector_1->set(index, training_parameters_matrix[1][index2]);
634  }
635  }
636  }
637 
638  // libMesh::out << "n_training_samples = " << n_training_samples_in << std::endl;
639  // for (unsigned int index=0; index<n_training_samples_in; index++)
640  // {
641  // libMesh::out << "training parameters for index="<<index<<":"<<std::endl;
642  // for (unsigned int param=0; param<num_params; param++)
643  // {
644  // libMesh::out << " " << (*training_parameters_in[param])(index);
645  // }
646  // libMesh::out << std::endl << std::endl;
647  // }
648 
649  }
650 }
MPI_Comm communicator
Communicator object for talking with subsets of processors.
Definition: parallel.h:181
const class libmesh_nullptr_t libmesh_nullptr
long double max(long double a, double b)
static UniquePtr< 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...
dof_id_type numeric_index_type
Definition: id_types.h:92
double pow(double a, int b)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
OStreamProxy out
bool serial_training_set
This boolean flag indicates whether or not the training set should be the same on all processors...
std::map< std::string, Real >::const_iterator const_iterator
Definition: rb_parameters.h:57
template<class Base >
void libMesh::RBConstructionBase< Base >::generate_training_parameters_random ( const Parallel::Communicator communicator,
std::map< std::string, bool >  log_param_scale,
std::map< std::string, NumericVector< Number > * > &  training_parameters_in,
unsigned int  n_training_samples_in,
const RBParameters min_parameters,
const RBParameters max_parameters,
int  training_parameters_random_seed = -1,
bool  serial_training_set = false 
)
staticprotected

Static helper function for generating a randomized set of parameters.

Definition at line 319 of file rb_construction_base.C.

References libMesh::RBParameters::begin(), libMesh::Parallel::Communicator::broadcast(), libMesh::NumericVector< T >::build(), libMesh::RBParameters::end(), libMesh::NumericVector< T >::first_local_index(), libMesh::RBParameters::get_value(), libmesh_nullptr, libMesh::NumericVector< T >::local_size(), libMesh::RBParameters::n_parameters(), libMesh::PARALLEL, std::pow(), libMesh::Parallel::Communicator::rank(), libMesh::Real, libMesh::SERIAL, libMesh::NumericVector< T >::set(), and libMesh::Parallel::Communicator::size().

Referenced by libMesh::RBConstructionBase< Base >::initialize_training_parameters(), and libMesh::RBConstructionBase< CondensedEigenSystem >::system().

327 {
328  libmesh_assert_equal_to ( min_parameters.n_parameters(), max_parameters.n_parameters() );
329  const unsigned int num_params = min_parameters.n_parameters();
330 
331  // Clear training_parameters_in
332  {
333  std::map<std::string, NumericVector<Number> *>::iterator it = training_parameters_in.begin();
334  std::map<std::string, NumericVector<Number> *>::const_iterator it_end = training_parameters_in.end();
335 
336  for ( ; it != it_end; ++it)
337  {
338  NumericVector<Number> * training_vector = it->second;
339  delete training_vector;
340  training_vector = libmesh_nullptr;
341  }
342  training_parameters_in.clear();
343  }
344 
345  if (num_params == 0)
346  return;
347 
349  {
350  if (!serial_training_set)
351  {
352  // seed the random number generator with the system time
353  // and the processor ID so that the seed is different
354  // on different processors
355  std::srand( static_cast<unsigned>( std::time(0)*(1+communicator.rank()) ));
356  }
357  else
358  {
359  // seed the random number generator with the system time
360  // only so that the seed is the same on all processors
361  //
362  // Note that we broadcast the time on processor 0 to make
363  // sure all processors agree.
364  unsigned int current_time = static_cast<unsigned>( std::time(0) );
365  communicator.broadcast(current_time, 0);
366  std::srand(current_time);
367  }
368  }
369  else
370  {
371  if (!serial_training_set)
372  {
373  // seed the random number generator with the provided value
374  // and the processor ID so that the seed is different
375  // on different processors
376  std::srand( static_cast<unsigned>( training_parameters_random_seed*(1+communicator.rank()) ));
377  }
378  else
379  {
380  // seed the random number generator with the provided value
381  // so that the seed is the same on all processors
382  std::srand( static_cast<unsigned>( training_parameters_random_seed ));
383  }
384  }
385 
386  // initialize training_parameters_in
387  {
388  RBParameters::const_iterator it = min_parameters.begin();
389  RBParameters::const_iterator it_end = min_parameters.end();
390  for ( ; it != it_end; ++it)
391  {
392  std::string param_name = it->first;
393  training_parameters_in[param_name] = NumericVector<Number>::build(communicator).release();
394 
395  if (!serial_training_set)
396  {
397  // Calculate the number of training parameters local to this processor
398  unsigned int n_local_training_samples;
399  unsigned int quotient = n_training_samples_in/communicator.size();
400  unsigned int remainder = n_training_samples_in%communicator.size();
401  if (communicator.rank() < remainder)
402  n_local_training_samples = (quotient + 1);
403  else
404  n_local_training_samples = quotient;
405 
406  training_parameters_in[param_name]->init(n_training_samples_in, n_local_training_samples, false, PARALLEL);
407  }
408  else
409  {
410  training_parameters_in[param_name]->init(n_training_samples_in, false, SERIAL);
411  }
412  }
413  }
414 
415  // finally, set the values
416  {
417  std::map<std::string, NumericVector<Number> *>::iterator it = training_parameters_in.begin();
418  std::map<std::string, NumericVector<Number> *>::const_iterator it_end = training_parameters_in.end();
419 
420  for ( ; it != it_end; ++it)
421  {
422  std::string param_name = it->first;
423  NumericVector<Number> * training_vector = it->second;
424 
425  numeric_index_type first_index = training_vector->first_local_index();
426  for (numeric_index_type i=0; i<training_vector->local_size(); i++)
427  {
428  numeric_index_type index = first_index + i;
429  Real random_number = ((double)std::rand())/RAND_MAX; // in range [0,1]
430 
431  // Generate log10 scaled training parameters
432  if (log_param_scale[param_name])
433  {
434  Real log_min = log10(min_parameters.get_value(param_name));
435  Real log_range = log10(max_parameters.get_value(param_name) / min_parameters.get_value(param_name));
436 
437  training_vector->set(index, pow(10., log_min + random_number*log_range ) );
438  }
439  // Generate linearly scaled training parameters
440  else
441  {
442  training_vector->set(index, random_number*(max_parameters.get_value(param_name) - min_parameters.get_value(param_name))
443  + min_parameters.get_value(param_name));
444  }
445  }
446  }
447  }
448 }
MPI_Comm communicator
Communicator object for talking with subsets of processors.
Definition: parallel.h:181
const class libmesh_nullptr_t libmesh_nullptr
static UniquePtr< 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...
dof_id_type numeric_index_type
Definition: id_types.h:92
double pow(double a, int b)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
bool serial_training_set
This boolean flag indicates whether or not the training set should be the same on all processors...
int training_parameters_random_seed
If < 0, use std::time() * processor_id() to seed the random number generator for the training paramet...
std::map< std::string, Real >::const_iterator const_iterator
Definition: rb_parameters.h:57
Real libMesh::RBParametrized::get_closest_value ( Real  value,
const std::vector< Real > &  list_of_values 
)
staticinherited
Returns
The closest entry to value from list_of_values.

Definition at line 464 of file rb_parametrized.C.

References std::abs(), distance(), std::max(), and libMesh::Real.

Referenced by libMesh::RBConstructionBase< Base >::initialize_training_parameters(), and libMesh::RBParametrized::is_value_in_list().

465 {
466  if (list_of_values.empty())
467  libmesh_error_msg("Error: list_of_values is empty.");
468 
469  std::vector<Real>::const_iterator it = list_of_values.begin();
470  std::vector<Real>::const_iterator it_end = list_of_values.end();
471 
472  Real min_distance = std::numeric_limits<Real>::max();
473  Real closest_val = 0.;
474  for ( ; it != it_end; ++it)
475  {
476  Real distance = std::abs(value - *it);
477  if (distance < min_distance)
478  {
479  min_distance = distance;
480  closest_val = *it;
481  }
482  }
483 
484  return closest_val;
485 }
double abs(double a)
long double max(long double a, double b)
Real distance(const Point &p)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const bool value
Definition: xdr_io.C:108
template<class Base>
const std::string& libMesh::RBConstructionBase< Base >::get_deterministic_training_parameter_name ( ) const

Get the name of the parameter that we will generate deterministic training parameters for.

Referenced by libMesh::RBConstructionBase< CondensedEigenSystem >::system().

template<class Base>
unsigned int libMesh::RBConstructionBase< Base >::get_deterministic_training_parameter_repeats ( ) const

Get the number of times each sample of the deterministic training parameter is repeated.

Referenced by libMesh::RBConstructionBase< CondensedEigenSystem >::system().

const std::map< std::string, std::vector< Real > > & libMesh::RBParametrized::get_discrete_parameter_values ( ) const
inherited

Get a const reference to the discrete parameter values.

Definition at line 403 of file rb_parametrized.C.

References libMesh::RBParametrized::_discrete_parameter_values, and libMesh::RBParametrized::parameters_initialized.

Referenced by libMesh::RBDataSerialization::add_parameter_ranges_to_builder(), libMesh::RBParametrized::get_n_discrete_params(), libMesh::RBParametrized::initialize_parameters(), libMesh::RBConstructionBase< Base >::initialize_training_parameters(), libMesh::RBParametrized::print_discrete_parameter_values(), libMesh::RBParametrized::valid_params(), and libMesh::RBParametrized::write_discrete_parameter_values_to_file().

404 {
406  libmesh_error_msg("Error: parameters not initialized in RBParametrized::get_discrete_parameter_values");
407 
409 }
bool parameters_initialized
Flag indicating whether the parameters have been initialized.
std::map< std::string, std::vector< Real > > _discrete_parameter_values
Map that defines the allowable values of any discrete parameters.
template<class Base >
numeric_index_type libMesh::RBConstructionBase< Base >::get_first_local_training_index ( ) const

Get the first local index of the training parameters.

Definition at line 125 of file rb_construction_base.C.

References libMesh::libmesh_assert(), libMesh::RBConstructionBase< Base >::training_parameters, and libMesh::RBConstructionBase< Base >::training_parameters_initialized.

Referenced by libMesh::RBConstructionBase< Base >::get_params_from_training_set(), libMesh::RBConstructionBase< Base >::set_params_from_training_set_and_broadcast(), and libMesh::RBConstructionBase< CondensedEigenSystem >::system().

126 {
128  return training_parameters.begin()->second->first_local_index();
129 }
bool training_parameters_initialized
Boolean flag to indicate whether or not the parameter ranges have been initialized.
libmesh_assert(j)
std::map< std::string, NumericVector< Number > * > training_parameters
The training samples.
template<class Base >
void libMesh::RBConstructionBase< Base >::get_global_max_error_pair ( const Parallel::Communicator communicator,
std::pair< numeric_index_type, Real > &  error_pair 
)
staticprotected

Static function to return the error pair (index,error) that is corresponds to the largest error on all processors.

Definition at line 94 of file rb_construction_base.C.

References libMesh::Parallel::Communicator::broadcast(), and libMesh::Parallel::Communicator::maxloc().

Referenced by libMesh::RBConstructionBase< CondensedEigenSystem >::system().

96 {
97  // Set error_pair.second to the maximum global value and also
98  // find which processor contains the maximum value
99  unsigned int proc_ID_index;
100  communicator.maxloc(error_pair.second, proc_ID_index);
101 
102  // Then broadcast error_pair.first from proc_ID_index
103  communicator.broadcast(error_pair.first, proc_ID_index);
104 }
MPI_Comm communicator
Communicator object for talking with subsets of processors.
Definition: parallel.h:181
std::string libMesh::ReferenceCounter::get_info ( )
staticinherited

Gets a string containing the reference information.

Definition at line 47 of file reference_counter.C.

References libMesh::ReferenceCounter::_counts, and libMesh::Quality::name().

Referenced by libMesh::ReferenceCounter::print_info().

48 {
49 #if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
50 
51  std::ostringstream oss;
52 
53  oss << '\n'
54  << " ---------------------------------------------------------------------------- \n"
55  << "| Reference count information |\n"
56  << " ---------------------------------------------------------------------------- \n";
57 
58  for (Counts::iterator it = _counts.begin();
59  it != _counts.end(); ++it)
60  {
61  const std::string name(it->first);
62  const unsigned int creations = it->second.first;
63  const unsigned int destructions = it->second.second;
64 
65  oss << "| " << name << " reference count information:\n"
66  << "| Creations: " << creations << '\n'
67  << "| Destructions: " << destructions << '\n';
68  }
69 
70  oss << " ---------------------------------------------------------------------------- \n";
71 
72  return oss.str();
73 
74 #else
75 
76  return "";
77 
78 #endif
79 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:39
static Counts _counts
Actually holds the data.
template<class Base >
numeric_index_type libMesh::RBConstructionBase< Base >::get_last_local_training_index ( ) const

Get the last local index of the training parameters.

Definition at line 132 of file rb_construction_base.C.

References libMesh::libmesh_assert(), libMesh::RBConstructionBase< Base >::training_parameters, and libMesh::RBConstructionBase< Base >::training_parameters_initialized.

Referenced by libMesh::RBConstructionBase< Base >::get_params_from_training_set(), libMesh::RBConstructionBase< Base >::set_params_from_training_set_and_broadcast(), and libMesh::RBConstructionBase< CondensedEigenSystem >::system().

133 {
135  return training_parameters.begin()->second->last_local_index();
136 }
bool training_parameters_initialized
Boolean flag to indicate whether or not the parameter ranges have been initialized.
libmesh_assert(j)
std::map< std::string, NumericVector< Number > * > training_parameters
The training samples.
template<class Base >
numeric_index_type libMesh::RBConstructionBase< Base >::get_local_n_training_samples ( ) const

Get the total number of training samples local to this processor.

Definition at line 118 of file rb_construction_base.C.

References libMesh::libmesh_assert(), libMesh::RBConstructionBase< Base >::training_parameters, and libMesh::RBConstructionBase< Base >::training_parameters_initialized.

Referenced by libMesh::RBConstructionBase< CondensedEigenSystem >::system().

119 {
121  return training_parameters.begin()->second->local_size();
122 }
bool training_parameters_initialized
Boolean flag to indicate whether or not the parameter ranges have been initialized.
libmesh_assert(j)
std::map< std::string, NumericVector< Number > * > training_parameters
The training samples.
unsigned int libMesh::RBParametrized::get_n_continuous_params ( ) const
inherited

Get the number of continuous parameters.

Definition at line 133 of file rb_parametrized.C.

References libMesh::RBParametrized::get_n_discrete_params(), libMesh::RBParametrized::get_n_params(), libMesh::libmesh_assert(), and libMesh::RBParametrized::parameters_initialized.

Referenced by libMesh::RBDataSerialization::add_parameter_ranges_to_builder(), and libMesh::RBParametrized::write_parameter_ranges_to_file().

134 {
136  libmesh_error_msg("Error: parameters not initialized in RBParametrized::get_n_continuous_params");
137 
139 
140  return static_cast<unsigned int>(get_n_params() - get_n_discrete_params());
141 }
bool parameters_initialized
Flag indicating whether the parameters have been initialized.
unsigned int get_n_params() const
Get the number of parameters.
libmesh_assert(j)
unsigned int get_n_discrete_params() const
Get the number of discrete parameters.
unsigned int libMesh::RBParametrized::get_n_discrete_params ( ) const
inherited

Get the number of discrete parameters.

Definition at line 143 of file rb_parametrized.C.

References libMesh::RBParametrized::get_discrete_parameter_values(), and libMesh::RBParametrized::parameters_initialized.

Referenced by libMesh::RBDataSerialization::add_parameter_ranges_to_builder(), libMesh::RBParametrized::get_n_continuous_params(), libMesh::RBConstructionBase< Base >::initialize_training_parameters(), and libMesh::RBParametrized::write_discrete_parameter_values_to_file().

144 {
146  libmesh_error_msg("Error: parameters not initialized in RBParametrized::get_n_discrete_params");
147 
148  return cast_int<unsigned int>
150 }
bool parameters_initialized
Flag indicating whether the parameters have been initialized.
const std::map< std::string, std::vector< Real > > & get_discrete_parameter_values() const
Get a const reference to the discrete parameter values.
unsigned int libMesh::RBParametrized::get_n_params ( ) const
inherited

Get the number of parameters.

Definition at line 123 of file rb_parametrized.C.

References libMesh::RBParameters::n_parameters(), libMesh::RBParametrized::parameters_initialized, libMesh::RBParametrized::parameters_max, and libMesh::RBParametrized::parameters_min.

Referenced by libMesh::RBConstruction::compute_max_error_bound(), libMesh::RBEIMTheta::evaluate(), libMesh::RBParametrized::get_n_continuous_params(), libMesh::RBConstructionBase< Base >::load_training_set(), libMesh::RBSCMConstruction::print_info(), libMesh::RBConstruction::print_info(), and libMesh::RBParametrized::valid_params().

124 {
126  libmesh_error_msg("Error: parameters not initialized in RBParametrized::get_n_params");
127 
128  libmesh_assert_equal_to ( parameters_min.n_parameters(), parameters_max.n_parameters() );
129 
130  return parameters_min.n_parameters();
131 }
bool parameters_initialized
Flag indicating whether the parameters have been initialized.
unsigned int n_parameters() const
Get the number of parameters that have been added.
Definition: rb_parameters.C:62
RBParameters parameters_min
Vectors that define the ranges (min and max) for the parameters.
template<class Base >
numeric_index_type libMesh::RBConstructionBase< Base >::get_n_training_samples ( ) const

Get the total number of training samples.

Definition at line 107 of file rb_construction_base.C.

References libMesh::libmesh_assert(), libMesh::RBConstructionBase< Base >::training_parameters, and libMesh::RBConstructionBase< Base >::training_parameters_initialized.

Referenced by libMesh::RBConstructionBase< CondensedEigenSystem >::system().

108 {
110 
111  if (training_parameters.empty())
112  return 0;
113 
114  return training_parameters.begin()->second->size();
115 }
bool training_parameters_initialized
Boolean flag to indicate whether or not the parameter ranges have been initialized.
libmesh_assert(j)
std::map< std::string, NumericVector< Number > * > training_parameters
The training samples.
Real libMesh::RBParametrized::get_parameter_max ( const std::string &  param_name) const
inherited

Get maximum allowable value of parameter param_name.

Definition at line 206 of file rb_parametrized.C.

References libMesh::RBParameters::get_value(), libMesh::RBParametrized::parameters_initialized, and libMesh::RBParametrized::parameters_max.

Referenced by libMesh::RBSCMConstruction::print_info(), libMesh::RBConstruction::print_info(), and libMesh::RBParametrized::valid_params().

207 {
209  libmesh_error_msg("Error: parameters not initialized in RBParametrized::get_parameter_max");
210 
211  return parameters_max.get_value(param_name);
212 }
bool parameters_initialized
Flag indicating whether the parameters have been initialized.
Real get_value(const std::string &param_name) const
Get the value of the specific parameter.
Definition: rb_parameters.C:45
Real libMesh::RBParametrized::get_parameter_min ( const std::string &  param_name) const
inherited

Get minimum allowable value of parameter param_name.

Definition at line 198 of file rb_parametrized.C.

References libMesh::RBParameters::get_value(), libMesh::RBParametrized::parameters_initialized, and libMesh::RBParametrized::parameters_min.

Referenced by libMesh::RBSCMConstruction::print_info(), libMesh::RBConstruction::print_info(), and libMesh::RBParametrized::valid_params().

199 {
201  libmesh_error_msg("Error: parameters not initialized in RBParametrized::get_parameter_min");
202 
203  return parameters_min.get_value(param_name);
204 }
bool parameters_initialized
Flag indicating whether the parameters have been initialized.
Real get_value(const std::string &param_name) const
Get the value of the specific parameter.
Definition: rb_parameters.C:45
RBParameters parameters_min
Vectors that define the ranges (min and max) for the parameters.
std::set< std::string > libMesh::RBParametrized::get_parameter_names ( ) const
inherited

Get a set that stores the parameter names.

Definition at line 152 of file rb_parametrized.C.

References libMesh::RBParameters::get_parameter_names(), libMesh::RBParametrized::parameters_initialized, and libMesh::RBParametrized::parameters_min.

Referenced by libMesh::RBDataSerialization::add_parameter_ranges_to_builder().

153 {
155  libmesh_error_msg("Error: parameters not initialized in RBParametrized::get_parameter_names");
156 
157  std::set<std::string> parameter_names;
158  parameters_min.get_parameter_names(parameter_names);
159 
160  return parameter_names;
161 }
bool parameters_initialized
Flag indicating whether the parameters have been initialized.
void get_parameter_names(std::set< std::string > &param_names) const
Fill param_names with the names of the parameters.
Definition: rb_parameters.C:68
RBParameters parameters_min
Vectors that define the ranges (min and max) for the parameters.
const RBParameters & libMesh::RBParametrized::get_parameters ( ) const
inherited

Get the current parameters.

Definition at line 174 of file rb_parametrized.C.

References libMesh::RBParametrized::parameters, and libMesh::RBParametrized::parameters_initialized.

Referenced by libMesh::TransientRBConstruction::add_scaled_mass_matrix(), libMesh::RBConstructionBase< Base >::broadcast_parameters(), libMesh::TransientRBEvaluation::cache_online_residual_terms(), libMesh::RBEIMConstruction::compute_best_fit_error(), libMesh::RBEvaluation::compute_residual_dual_norm(), libMesh::RBSCMConstruction::compute_SCM_bounds_on_training_set(), libMesh::RBSCMConstruction::enrich_C_J(), libMesh::RBEIMConstruction::enrich_RB_space(), libMesh::RBEIMTheta::evaluate(), libMesh::RBEIMEvaluation::evaluate_parametrized_function(), libMesh::RBSCMConstruction::evaluate_stability_constant(), libMesh::RBConstruction::get_RB_error_bound(), libMesh::RBSCMEvaluation::get_SCM_LB(), libMesh::RBSCMEvaluation::get_SCM_UB(), SimpleRBEvaluation::get_stability_lower_bound(), libMesh::RBConstruction::greedy_termination_test(), libMesh::RBSCMEvaluation::legacy_read_offline_data_from_files(), libMesh::TransientRBConstruction::mass_matrix_scaled_matvec(), libMesh::RBSCMConstruction::print_info(), libMesh::RBConstruction::print_info(), libMesh::RBParametrized::print_parameters(), libMesh::RBSCMConstruction::process_parameters_file(), libMesh::TransientRBEvaluation::rb_solve(), libMesh::RBEvaluation::rb_solve(), libMesh::RBEIMEvaluation::rb_solve(), libMesh::RBSCMEvaluation::save_current_parameters(), libMesh::TransientRBConstruction::truth_assembly(), libMesh::RBConstruction::truth_assembly(), libMesh::TransientRBConstruction::truth_solve(), libMesh::RBEIMConstruction::truth_solve(), libMesh::RBConstruction::truth_solve(), libMesh::TransientRBEvaluation::uncached_compute_residual_dual_norm(), and libMesh::RBConstruction::update_greedy_param_list().

175 {
177  libmesh_error_msg("Error: parameters not initialized in RBParametrized::get_current_parameters");
178 
179  return parameters;
180 }
bool parameters_initialized
Flag indicating whether the parameters have been initialized.
RBParameters parameters
Vector storing the current parameters.
const RBParameters & libMesh::RBParametrized::get_parameters_max ( ) const
inherited

Get an RBParameters object that specifies the maximum allowable value for each parameter.

Definition at line 190 of file rb_parametrized.C.

References libMesh::RBParametrized::parameters_initialized, and libMesh::RBParametrized::parameters_max.

Referenced by libMesh::RBDataSerialization::add_parameter_ranges_to_builder(), libMesh::RBParametrized::initialize_parameters(), libMesh::RBSCMConstruction::process_parameters_file(), libMesh::RBConstruction::set_rb_construction_parameters(), and libMesh::RBParametrized::write_parameter_ranges_to_file().

191 {
193  libmesh_error_msg("Error: parameters not initialized in RBParametrized::get_parameters_max");
194 
195  return parameters_max;
196 }
bool parameters_initialized
Flag indicating whether the parameters have been initialized.
const RBParameters & libMesh::RBParametrized::get_parameters_min ( ) const
inherited

Get an RBParameters object that specifies the minimum allowable value for each parameter.

Definition at line 182 of file rb_parametrized.C.

References libMesh::RBParametrized::parameters_initialized, and libMesh::RBParametrized::parameters_min.

Referenced by libMesh::RBDataSerialization::add_parameter_ranges_to_builder(), libMesh::RBParametrized::initialize_parameters(), libMesh::RBSCMConstruction::process_parameters_file(), libMesh::RBConstruction::set_rb_construction_parameters(), and libMesh::RBParametrized::write_parameter_ranges_to_file().

183 {
185  libmesh_error_msg("Error: parameters not initialized in RBParametrized::get_parameters_min");
186 
187  return parameters_min;
188 }
bool parameters_initialized
Flag indicating whether the parameters have been initialized.
RBParameters parameters_min
Vectors that define the ranges (min and max) for the parameters.
template<class Base >
RBParameters libMesh::RBConstructionBase< Base >::get_params_from_training_set ( unsigned int  index)
protected

Return the RBParameters in index index of training set.

Definition at line 145 of file rb_construction_base.C.

References libMesh::RBConstructionBase< Base >::get_first_local_training_index(), libMesh::RBConstructionBase< Base >::get_last_local_training_index(), libMesh::libmesh_assert(), libMesh::libmesh_real(), libMesh::Real, libMesh::RBParameters::set_value(), libMesh::RBConstructionBase< Base >::training_parameters, and libMesh::RBConstructionBase< Base >::training_parameters_initialized.

Referenced by libMesh::RBConstructionBase< Base >::set_params_from_training_set(), and libMesh::RBConstructionBase< CondensedEigenSystem >::system().

146 {
148 
149  libmesh_assert( (this->get_first_local_training_index() <= index) &&
150  (index < this->get_last_local_training_index()) );
151 
152  RBParameters params;
153  std::map<std::string, NumericVector<Number> *>::const_iterator it = training_parameters.begin();
154  std::map<std::string, NumericVector<Number> *>::const_iterator it_end = training_parameters.end();
155  for ( ; it != it_end; ++it)
156  {
157  std::string param_name = it->first;
158  Real param_value = libmesh_real( ( *(it->second) )(index) );
159 
160  params.set_value(param_name, param_value);
161  }
162 
163  return params;
164 }
T libmesh_real(T a)
bool training_parameters_initialized
Boolean flag to indicate whether or not the parameter ranges have been initialized.
libmesh_assert(j)
std::map< std::string, NumericVector< Number > * > training_parameters
The training samples.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
numeric_index_type get_first_local_training_index() const
Get the first local index of the training parameters.
numeric_index_type get_last_local_training_index() const
Get the last local index of the training parameters.
void libMesh::ReferenceCounter::increment_constructor_count ( const std::string &  name)
protectedinherited

Increments the construction counter.

Should be called in the constructor of any derived class that will be reference counted.

Definition at line 185 of file reference_counter.h.

References libMesh::ReferenceCounter::_counts, libMesh::Quality::name(), and libMesh::Threads::spin_mtx.

Referenced by libMesh::ReferenceCounter::n_objects(), and libMesh::ReferenceCountedObject< RBParametrized >::ReferenceCountedObject().

186 {
187  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
188  std::pair<unsigned int, unsigned int> & p = _counts[name];
189 
190  p.first++;
191 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:39
spin_mutex spin_mtx
A convenient spin mutex object which can be used for obtaining locks.
Definition: threads.C:29
static Counts _counts
Actually holds the data.
void libMesh::ReferenceCounter::increment_destructor_count ( const std::string &  name)
protectedinherited

Increments the destruction counter.

Should be called in the destructor of any derived class that will be reference counted.

Definition at line 198 of file reference_counter.h.

References libMesh::ReferenceCounter::_counts, libMesh::Quality::name(), and libMesh::Threads::spin_mtx.

Referenced by libMesh::ReferenceCounter::n_objects(), and libMesh::ReferenceCountedObject< RBParametrized >::~ReferenceCountedObject().

199 {
200  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
201  std::pair<unsigned int, unsigned int> & p = _counts[name];
202 
203  p.second++;
204 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:39
spin_mutex spin_mtx
A convenient spin mutex object which can be used for obtaining locks.
Definition: threads.C:29
static Counts _counts
Actually holds the data.
template<class Base >
void libMesh::RBConstructionBase< Base >::init_data ( )
protectedvirtual

Initializes the member data fields associated with the system, so that, e.g., assemble() may be used.

Reimplemented in libMesh::RBEIMConstruction, SimpleRBConstruction, SimpleRBConstruction, SimpleRBConstruction, SimpleRBConstruction, SimpleRBConstruction, SimpleRBConstruction, and ElasticityRBConstruction.

Definition at line 83 of file rb_construction_base.C.

References libMesh::NumericVector< T >::build(), libMesh::RBConstructionBase< Base >::inner_product_storage_vector, and libMesh::PARALLEL.

Referenced by libMesh::RBConstructionBase< CondensedEigenSystem >::system().

84 {
85  Base::init_data();
86 
87  // Initialize the inner product storage vector, which is useful for
88  // storing intermediate results when evaluating inner products
90  inner_product_storage_vector->init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
91 }
UniquePtr< NumericVector< Number > > inner_product_storage_vector
We keep an extra temporary vector that is useful for performing inner products (avoids unnecessary me...
static UniquePtr< 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...
void libMesh::RBParametrized::initialize_parameters ( const RBParameters mu_min_in,
const RBParameters mu_max_in,
const std::map< std::string, std::vector< Real >> &  discrete_parameter_values 
)
inherited

Initialize the parameter ranges and set current_parameters.

Definition at line 60 of file rb_parametrized.C.

References libMesh::RBParametrized::_discrete_parameter_values, libMesh::RBParameters::begin(), libMesh::RBParameters::end(), libMesh::RBParameters::get_value(), libMesh::RBParameters::n_parameters(), libMesh::RBParametrized::parameters_initialized, libMesh::RBParametrized::parameters_max, libMesh::RBParametrized::parameters_min, libMesh::Real, libMesh::RBParametrized::set_parameters(), and libMesh::RBParameters::set_value().

Referenced by libMesh::RBParametrized::initialize_parameters(), libMesh::RBEIMConstruction::initialize_parametrized_functions_in_training_set(), libMesh::RBDataDeserialization::load_parameter_ranges(), libMesh::RBSCMConstruction::perform_SCM_greedy(), libMesh::RBSCMConstruction::process_parameters_file(), libMesh::RBParametrized::read_parameter_data_from_files(), libMesh::RBConstruction::set_rb_construction_parameters(), and libMesh::RBConstruction::train_reduced_basis().

63 {
64  // Check that the min/max vectors are valid
65  {
66  const std::string err_string = "Error: Invalid mu_min/mu_max in RBParameters constructor.";
67  bool valid_min_max = (mu_min_in.n_parameters() == mu_max_in.n_parameters());
68  if (!valid_min_max)
69  libmesh_error_msg(err_string);
70 
71  else
72  {
73  RBParameters::const_iterator it = mu_min_in.begin();
74  RBParameters::const_iterator it_end = mu_min_in.end();
75  for ( ; it != it_end; ++it)
76  {
77  std::string param_name = it->first;
78  if (mu_min_in.get_value(param_name) > mu_max_in.get_value(param_name))
79  libmesh_error_msg(err_string);
80  }
81  }
82  }
83 
84  parameters_min = mu_min_in;
85  parameters_max = mu_max_in;
86 
87  // Add in min/max values due to the discrete parameters
88  {
89  std::map<std::string, std::vector<Real>>::const_iterator it =
90  discrete_parameter_values.begin();
91  const std::map<std::string, std::vector<Real>>::const_iterator it_end =
92  discrete_parameter_values.end();
93  for ( ; it != it_end; ++it)
94  {
95  if (it->second.empty())
96  libmesh_error_msg("Error: List of discrete parameters for " << it->first << " is empty.");
97 
98  Real min_val = *std::min_element(it->second.begin(), it->second.end());
99  Real max_val = *std::max_element(it->second.begin(), it->second.end());
100 
101  libmesh_assert_less_equal(min_val,max_val);
102 
103  parameters_min.set_value(it->first, min_val);
104  parameters_max.set_value(it->first, max_val);
105  }
106 
107  _discrete_parameter_values = discrete_parameter_values;
108  }
109 
110  parameters_initialized = true;
111 
112  // Initialize the current parameters to parameters_min
114 }
bool parameters_initialized
Flag indicating whether the parameters have been initialized.
RBParameters parameters_min
Vectors that define the ranges (min and max) for the parameters.
void set_parameters(const RBParameters &params)
Set the current parameters to params.
std::map< std::string, std::vector< Real > > _discrete_parameter_values
Map that defines the allowable values of any discrete parameters.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void set_value(const std::string &param_name, Real value)
Set the value of the specified parameter.
Definition: rb_parameters.C:57
const_iterator begin() const
Get a constant iterator to beginning of this RBParameters object.
Definition: rb_parameters.C:80
std::map< std::string, Real >::const_iterator const_iterator
Definition: rb_parameters.h:57
void libMesh::RBParametrized::initialize_parameters ( const RBParametrized rb_parametrized)
inherited

Initialize the parameter ranges and set current_parameters.

Definition at line 116 of file rb_parametrized.C.

References libMesh::RBParametrized::get_discrete_parameter_values(), libMesh::RBParametrized::get_parameters_max(), libMesh::RBParametrized::get_parameters_min(), and libMesh::RBParametrized::initialize_parameters().

117 {
118  initialize_parameters(rb_parametrized.get_parameters_min(),
119  rb_parametrized.get_parameters_max(),
120  rb_parametrized.get_discrete_parameter_values());
121 }
void initialize_parameters(const RBParameters &mu_min_in, const RBParameters &mu_max_in, const std::map< std::string, std::vector< Real >> &discrete_parameter_values)
Initialize the parameter ranges and set current_parameters.
template<class Base >
void libMesh::RBConstructionBase< Base >::initialize_training_parameters ( const RBParameters mu_min,
const RBParameters mu_max,
unsigned int  n_training_parameters,
std::map< std::string, bool >  log_param_scale,
bool  deterministic = true 
)
virtual

Initialize the parameter ranges and indicate whether deterministic or random training parameters should be used and whether or not we want the parameters to be scaled logarithmically.

Definition at line 188 of file rb_construction_base.C.

References libMesh::NumericVector< T >::first_local_index(), libMesh::RBConstructionBase< Base >::generate_training_parameters_deterministic(), libMesh::RBConstructionBase< Base >::generate_training_parameters_random(), libMesh::RBParametrized::get_closest_value(), libMesh::RBParametrized::get_discrete_parameter_values(), libMesh::RBParametrized::get_n_discrete_params(), libMesh::RBParametrized::is_discrete_parameter(), libMesh::NumericVector< T >::last_local_index(), libMesh::libmesh_real(), libMesh::out, libMesh::Real, libMesh::RBConstructionBase< Base >::serial_training_set, libMesh::NumericVector< T >::set(), libMesh::RBConstructionBase< Base >::training_parameters, libMesh::RBConstructionBase< Base >::training_parameters_initialized, libMesh::RBConstructionBase< Base >::training_parameters_random_seed, and value.

Referenced by libMesh::RBConstructionBase< CondensedEigenSystem >::system().

193 {
194  // Print out some info about the training set initialization
195  libMesh::out << "Initializing training parameters with "
196  << (deterministic ? "deterministic " : "random " )
197  << "training set..." << std::endl;
198 
199  {
200  std::map<std::string,bool>::iterator it = log_param_scale.begin();
201  std::map<std::string,bool>::const_iterator it_end = log_param_scale.end();
202  for (; it != it_end; ++it)
203  {
204  libMesh::out << "Parameter "
205  << it->first
206  << ": log scaling = "
207  << it->second
208  << std::endl;
209  }
210  }
211  libMesh::out << std::endl;
212 
213  if (deterministic)
214  {
216  log_param_scale,
218  n_training_samples,
219  mu_min,
220  mu_max,
222  }
223  else
224  {
225  // Generate random training samples for all parameters
227  log_param_scale,
229  n_training_samples,
230  mu_min,
231  mu_max,
234  }
235 
236  // For each parameter that only allows discrete values, we "snap" to the nearest
237  // allowable discrete value
238  if (get_n_discrete_params() > 0)
239  {
240  std::map<std::string, NumericVector<Number> *>::iterator it = training_parameters.begin();
241  std::map<std::string, NumericVector<Number> *>::const_iterator it_end = training_parameters.end();
242  for ( ; it != it_end; ++it)
243  {
244  std::string param_name = it->first;
245  if (is_discrete_parameter(param_name))
246  {
247  std::vector<Real> discrete_values =
248  get_discrete_parameter_values().find(param_name)->second;
249 
250  NumericVector<Number> * training_vector = it->second;
251 
252  for (numeric_index_type index=training_vector->first_local_index();
253  index<training_vector->last_local_index();
254  index++)
255  {
256  Real value = libmesh_real((*training_vector)(index));
257  Real nearest_discrete_value = get_closest_value(value, discrete_values);
258  training_vector->set(index, nearest_discrete_value);
259  }
260  }
261  }
262  }
263 
265 }
T libmesh_real(T a)
static void generate_training_parameters_random(const Parallel::Communicator &communicator, std::map< std::string, bool > log_param_scale, std::map< std::string, NumericVector< Number > * > &training_parameters_in, unsigned int n_training_samples_in, const RBParameters &min_parameters, const RBParameters &max_parameters, int training_parameters_random_seed=-1, bool serial_training_set=false)
Static helper function for generating a randomized set of parameters.
bool training_parameters_initialized
Boolean flag to indicate whether or not the parameter ranges have been initialized.
bool is_discrete_parameter(const std::string &mu_name) const
Is parameter mu_name discrete?
static Real get_closest_value(Real value, const std::vector< Real > &list_of_values)
dof_id_type numeric_index_type
Definition: id_types.h:92
std::map< std::string, NumericVector< Number > * > training_parameters
The training samples.
unsigned int get_n_discrete_params() const
Get the number of discrete parameters.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
OStreamProxy out
static const bool value
Definition: xdr_io.C:108
bool serial_training_set
This boolean flag indicates whether or not the training set should be the same on all processors...
const std::map< std::string, std::vector< Real > > & get_discrete_parameter_values() const
Get a const reference to the discrete parameter values.
int training_parameters_random_seed
If < 0, use std::time() * processor_id() to seed the random number generator for the training paramet...
static void generate_training_parameters_deterministic(const Parallel::Communicator &communicator, std::map< std::string, bool > log_param_scale, std::map< std::string, NumericVector< Number > * > &training_parameters_in, unsigned int n_training_samples_in, const RBParameters &min_parameters, const RBParameters &max_parameters, bool serial_training_set=false)
Static helper function for generating a deterministic set of parameters.
bool libMesh::RBParametrized::is_discrete_parameter ( const std::string &  mu_name) const
inherited

Is parameter mu_name discrete?

Definition at line 395 of file rb_parametrized.C.

References libMesh::RBParametrized::_discrete_parameter_values, and libMesh::RBParametrized::parameters_initialized.

Referenced by libMesh::RBDataSerialization::add_parameter_ranges_to_builder(), libMesh::RBConstructionBase< Base >::initialize_training_parameters(), libMesh::RBConstruction::print_info(), libMesh::RBParametrized::valid_params(), and libMesh::RBParametrized::write_parameter_ranges_to_file().

396 {
398  libmesh_error_msg("Error: parameters not initialized in RBParametrized::is_discrete_parameter");
399 
400  return (_discrete_parameter_values.find(mu_name) != _discrete_parameter_values.end());
401 }
bool parameters_initialized
Flag indicating whether the parameters have been initialized.
std::map< std::string, std::vector< Real > > _discrete_parameter_values
Map that defines the allowable values of any discrete parameters.
template<class Base >
void libMesh::RBConstructionBase< Base >::load_training_set ( std::map< std::string, std::vector< Number >> &  new_training_set)
virtual

Overwrite the training parameters with new_training_set.

Definition at line 268 of file rb_construction_base.C.

References libMesh::NumericVector< T >::build(), libMesh::NumericVector< T >::first_local_index(), libMesh::RBParametrized::get_n_params(), libmesh_nullptr, libMesh::PARALLEL, libMesh::NumericVector< T >::set(), libMesh::RBConstructionBase< Base >::training_parameters, and libMesh::RBConstructionBase< Base >::training_parameters_initialized.

Referenced by libMesh::RBConstructionBase< CondensedEigenSystem >::system().

269 {
270  // First, make sure that an initial training set has already been
271  // generated
273  libmesh_error_msg("Error: load_training_set cannot be used to initialize parameters");
274 
275  // Make sure that the training set has the correct number of parameters
276  if (new_training_set.size() != get_n_params())
277  libmesh_error_msg("Error: Incorrect number of parameters in load_training_set.");
278 
279  // Clear the training set
280  std::map<std::string, NumericVector<Number> *>::iterator it = training_parameters.begin();
281  std::map<std::string, NumericVector<Number> *>::const_iterator it_end = training_parameters.end();
282  for ( ; it != it_end; ++it)
283  {
284  NumericVector<Number> * training_vector = it->second;
285  delete training_vector;
286  training_vector = libmesh_nullptr;
287  }
288 
289  // Get the number of local and global training parameters
290  numeric_index_type n_local_training_samples =
291  cast_int<numeric_index_type>(new_training_set.begin()->second.size());
292  numeric_index_type n_global_training_samples = n_local_training_samples;
293  this->comm().sum(n_global_training_samples);
294 
295  it = training_parameters.begin();
296  for ( ; it != it_end; ++it)
297  {
298  it->second = NumericVector<Number>::build(this->comm()).release();
299  it->second->init(n_global_training_samples, n_local_training_samples, false, PARALLEL);
300  }
301 
302  it = training_parameters.begin();
303  for ( ; it != it_end; ++it)
304  {
305  std::string param_name = it->first;
306  NumericVector<Number> * training_vector = it->second;
307 
308  numeric_index_type first_index = training_vector->first_local_index();
309  for (numeric_index_type i=0; i<n_local_training_samples; i++)
310  {
311  numeric_index_type index = first_index + i;
312  training_vector->set(index, new_training_set[param_name][i]);
313  }
314  }
315 }
bool training_parameters_initialized
Boolean flag to indicate whether or not the parameter ranges have been initialized.
unsigned int get_n_params() const
Get the number of parameters.
const class libmesh_nullptr_t libmesh_nullptr
static UniquePtr< 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...
dof_id_type numeric_index_type
Definition: id_types.h:92
std::map< std::string, NumericVector< Number > * > training_parameters
The training samples.
static unsigned int libMesh::ReferenceCounter::n_objects ( )
staticinherited
void libMesh::RBParametrized::print_discrete_parameter_values ( ) const
inherited

Print out all the discrete parameter values.

Definition at line 411 of file rb_parametrized.C.

References libMesh::RBParametrized::get_discrete_parameter_values(), and libMesh::out.

Referenced by libMesh::RBSCMConstruction::print_info(), and libMesh::RBConstruction::print_info().

412 {
413  std::map<std::string, std::vector<Real>>::const_iterator it =
415  const std::map<std::string, std::vector<Real>>::const_iterator it_end =
417 
418  for ( ; it != it_end; ++it)
419  {
420  libMesh::out << "Discrete parameter " << it->first << ", values: ";
421 
422  std::vector<Real> values = it->second;
423  for (std::size_t i=0; i<values.size(); i++)
424  libMesh::out << values[i] << " ";
425  libMesh::out << std::endl;
426  }
427 }
OStreamProxy out
const std::map< std::string, std::vector< Real > > & get_discrete_parameter_values() const
Get a const reference to the discrete parameter values.
void libMesh::ReferenceCounter::print_info ( std::ostream &  out = libMesh::out)
staticinherited

Prints the reference information, by default to libMesh::out.

Definition at line 88 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter, and libMesh::ReferenceCounter::get_info().

Referenced by libMesh::LibMeshInit::LibMeshInit().

89 {
91  out_stream << ReferenceCounter::get_info();
92 }
static std::string get_info()
Gets a string containing the reference information.
static bool _enable_print_counter
Flag to control whether reference count information is printed when print_info is called...
void libMesh::RBParametrized::print_parameters ( ) const
inherited

Print the current parameters.

Definition at line 214 of file rb_parametrized.C.

References libMesh::RBParametrized::get_parameters(), libMesh::RBParametrized::parameters_initialized, and libMesh::RBParameters::print().

Referenced by libMesh::RBConstruction::train_reduced_basis().

215 {
217  libmesh_error_msg("Error: parameters not initialized in RBParametrized::print_current_parameters");
218 
219  get_parameters().print();
220 }
bool parameters_initialized
Flag indicating whether the parameters have been initialized.
void print() const
Print the parameters.
const RBParameters & get_parameters() const
Get the current parameters.
void libMesh::RBParametrized::read_parameter_data_from_files ( const std::string &  continuous_param_file_name,
const std::string &  discrete_param_file_name,
const bool  read_binary_data 
)
inherited

Read in the parameter ranges from files.

Definition at line 301 of file rb_parametrized.C.

References libMesh::RBParametrized::initialize_parameters(), libMesh::RBParametrized::read_discrete_parameter_values_from_file(), and libMesh::RBParametrized::read_parameter_ranges_from_file().

Referenced by libMesh::RBEvaluation::legacy_read_offline_data_from_files(), and libMesh::RBSCMEvaluation::legacy_read_offline_data_from_files().

304 {
305  RBParameters param_min;
306  RBParameters param_max;
307  read_parameter_ranges_from_file(continuous_param_file_name,
308  read_binary_data,
309  param_min,
310  param_max);
311 
312  std::map<std::string, std::vector<Real>> discrete_parameter_values_in;
313  read_discrete_parameter_values_from_file(discrete_param_file_name,
314  read_binary_data,
315  discrete_parameter_values_in);
316 
317  initialize_parameters(param_min, param_max, discrete_parameter_values_in);
318 }
void read_parameter_ranges_from_file(const std::string &file_name, const bool read_binary, RBParameters &param_min, RBParameters &param_max)
Read in the parameter ranges from file.
void read_discrete_parameter_values_from_file(const std::string &file_name, const bool read_binary_data, std::map< std::string, std::vector< Real >> &discrete_parameter_values_in)
Read in the discrete parameter values from file, if we have any.
void initialize_parameters(const RBParameters &mu_min_in, const RBParameters &mu_max_in, const std::map< std::string, std::vector< Real >> &discrete_parameter_values)
Initialize the parameter ranges and set current_parameters.
template<class Base>
void libMesh::RBConstructionBase< Base >::set_deterministic_training_parameter_name ( const std::string &  name)

In some cases we only want to allow discrete parameter values, instead of parameters that may take any value in a specified interval.

Here we provide a method to set the d Set the discrete values for parameter mu that are allowed in the training set. This must be called before the training set is generated. Set the name of the parameter that we will generate deterministic training parameters for. Defaults to "NONE".

Referenced by libMesh::RBConstructionBase< CondensedEigenSystem >::system().

template<class Base>
void libMesh::RBConstructionBase< Base >::set_deterministic_training_parameter_repeats ( unsigned int  repeats)

Set the number of times each sample of the deterministic training parameter is repeated.

Referenced by libMesh::RBConstructionBase< CondensedEigenSystem >::system().

void libMesh::RBParametrized::set_parameters ( const RBParameters params)
inherited

Set the current parameters to params.

Definition at line 163 of file rb_parametrized.C.

References libMesh::RBParametrized::parameters, libMesh::RBParametrized::parameters_initialized, and libMesh::RBParametrized::valid_params().

Referenced by libMesh::RBConstructionBase< Base >::broadcast_parameters(), libMesh::RBEIMConstruction::compute_best_fit_error(), libMesh::RBSCMConstruction::compute_SCM_bounds_on_training_set(), libMesh::RBEIMConstruction::enrich_RB_space(), libMesh::RBEIMTheta::evaluate(), libMesh::RBConstruction::get_RB_error_bound(), SimpleRBEvaluation::get_stability_lower_bound(), libMesh::RBParametrized::initialize_parameters(), libMesh::RBSCMEvaluation::reload_current_parameters(), libMesh::RBSCMEvaluation::set_current_parameters_from_C_J(), libMesh::RBConstructionBase< Base >::set_params_from_training_set(), and libMesh::RBEIMConstruction::truth_solve().

164 {
166  libmesh_error_msg("Error: parameters not initialized in RBParametrized::set_current_parameters");
167 
168  valid_params(params); // Terminates if params has the wrong number of parameters
169 
170  // Make a copy of params (default assignment operator just does memberwise copy, which is sufficient here)
171  this->parameters = params;
172 }
bool parameters_initialized
Flag indicating whether the parameters have been initialized.
bool valid_params(const RBParameters &params)
Helper function to check that params is valid.
RBParameters parameters
Vector storing the current parameters.
template<class Base >
void libMesh::RBConstructionBase< Base >::set_params_from_training_set ( unsigned int  index)
protected

Set parameters to the RBParameters stored in index index of the training set.

Definition at line 139 of file rb_construction_base.C.

References libMesh::RBConstructionBase< Base >::get_params_from_training_set(), and libMesh::RBParametrized::set_parameters().

Referenced by libMesh::RBConstructionBase< Base >::set_params_from_training_set_and_broadcast(), and libMesh::RBConstructionBase< CondensedEigenSystem >::system().

140 {
142 }
void set_parameters(const RBParameters &params)
Set the current parameters to params.
RBParameters get_params_from_training_set(unsigned int index)
Return the RBParameters in index index of training set.
template<class Base >
void libMesh::RBConstructionBase< Base >::set_params_from_training_set_and_broadcast ( unsigned int  index)
protectedvirtual

Load the specified training parameter and then broadcast to all processors.

Definition at line 167 of file rb_construction_base.C.

References libMesh::RBConstructionBase< Base >::broadcast_parameters(), libMesh::RBConstructionBase< Base >::get_first_local_training_index(), libMesh::RBConstructionBase< Base >::get_last_local_training_index(), libMesh::libmesh_assert(), libMesh::processor_id(), libMesh::RBConstructionBase< Base >::set_params_from_training_set(), and libMesh::RBConstructionBase< Base >::training_parameters_initialized.

Referenced by libMesh::RBConstructionBase< CondensedEigenSystem >::system().

168 {
170 
171  processor_id_type root_id = 0;
172  if ((this->get_first_local_training_index() <= index) &&
173  (index < this->get_last_local_training_index()))
174  {
175  // Set parameters on only one processor
177 
178  // set root_id, only non-zero on one processor
179  root_id = this->processor_id();
180  }
181 
182  // broadcast
183  this->comm().max(root_id);
184  broadcast_parameters(root_id);
185 }
bool training_parameters_initialized
Boolean flag to indicate whether or not the parameter ranges have been initialized.
void broadcast_parameters(unsigned int proc_id)
Broadcasts parameters on processor proc_id to all processors.
uint8_t processor_id_type
Definition: id_types.h:99
libmesh_assert(j)
void set_params_from_training_set(unsigned int index)
Set parameters to the RBParameters stored in index index of the training set.
numeric_index_type get_first_local_training_index() const
Get the first local index of the training parameters.
numeric_index_type get_last_local_training_index() const
Get the last local index of the training parameters.
processor_id_type processor_id()
Definition: libmesh_base.h:96
template<class Base >
void libMesh::RBConstructionBase< Base >::set_training_random_seed ( unsigned int  seed)

Set the seed that is used to randomly generate training parameters.

Definition at line 690 of file rb_construction_base.C.

References libMesh::RBConstructionBase< Base >::training_parameters_random_seed.

Referenced by libMesh::RBConstructionBase< CondensedEigenSystem >::system().

691 {
692  this->training_parameters_random_seed = seed;
693 }
int training_parameters_random_seed
If < 0, use std::time() * processor_id() to seed the random number generator for the training paramet...
template<class Base>
sys_type& libMesh::RBConstructionBase< Base >::system ( )
Returns
A reference to *this.

Definition at line 79 of file rb_construction_base.h.

79 { return *this; }
void libMesh::RBParametrized::write_parameter_data_to_files ( const std::string &  continuous_param_file_name,
const std::string &  discrete_param_file_name,
const bool  write_binary_data 
)
inherited

Write out the parameter ranges to files.

Definition at line 222 of file rb_parametrized.C.

References libMesh::RBParametrized::write_discrete_parameter_values_to_file(), and libMesh::RBParametrized::write_parameter_ranges_to_file().

Referenced by libMesh::RBEvaluation::legacy_write_offline_data_to_files(), and libMesh::RBSCMEvaluation::legacy_write_offline_data_to_files().

225 {
226  write_parameter_ranges_to_file(continuous_param_file_name, write_binary_data);
227  write_discrete_parameter_values_to_file(discrete_param_file_name, write_binary_data);
228 }
void write_discrete_parameter_values_to_file(const std::string &file_name, const bool write_binary_data)
Write out the discrete parameter values to file.
void write_parameter_ranges_to_file(const std::string &file_name, const bool write_binary)
Write out the parameter ranges to file.

Member Data Documentation

ReferenceCounter::Counts libMesh::ReferenceCounter::_counts
staticprotectedinherited
bool libMesh::ReferenceCounter::_enable_print_counter = true
staticprotectedinherited

Flag to control whether reference count information is printed when print_info is called.

Definition at line 143 of file reference_counter.h.

Referenced by libMesh::ReferenceCounter::disable_print_counter_info(), libMesh::ReferenceCounter::enable_print_counter_info(), and libMesh::ReferenceCounter::print_info().

Threads::spin_mutex libMesh::ReferenceCounter::_mutex
staticprotectedinherited

Mutual exclusion object to enable thread-safe reference counting.

Definition at line 137 of file reference_counter.h.

Threads::atomic< unsigned int > libMesh::ReferenceCounter::_n_objects
staticprotectedinherited

The number of objects.

Print the reference count information when the number returns to 0.

Definition at line 132 of file reference_counter.h.

Referenced by libMesh::ReferenceCounter::n_objects(), libMesh::ReferenceCounter::ReferenceCounter(), and libMesh::ReferenceCounter::~ReferenceCounter().

template<class Base>
UniquePtr<NumericVector<Number> > libMesh::RBConstructionBase< Base >::inner_product_storage_vector
protected

We keep an extra temporary vector that is useful for performing inner products (avoids unnecessary memory allocation/deallocation).

Definition at line 234 of file rb_construction_base.h.

Referenced by libMesh::RBConstructionBase< Base >::init_data().

template<class Base>
bool libMesh::RBConstructionBase< Base >::serial_training_set
protected

This boolean flag indicates whether or not the training set should be the same on all processors.

By default it is false, but in the case of the Empirical Interpolation Method (RBEIMConstruction), for example, we need the training set to be identical on all processors.

Definition at line 227 of file rb_construction_base.h.

Referenced by libMesh::RBConstructionBase< Base >::initialize_training_parameters(), and libMesh::RBConstructionBase< CondensedEigenSystem >::system().

template<class Base>
std::map<std::string, NumericVector<Number> * > libMesh::RBConstructionBase< Base >::training_parameters
private
template<class Base>
bool libMesh::RBConstructionBase< Base >::training_parameters_initialized
private
template<class Base>
int libMesh::RBConstructionBase< Base >::training_parameters_random_seed
private

If < 0, use std::time() * processor_id() to seed the random number generator for the training parameters (default).

If >= 0, use the provided value * processor_id() as the random number generator seed.

Definition at line 256 of file rb_construction_base.h.

Referenced by libMesh::RBConstructionBase< Base >::initialize_training_parameters(), libMesh::RBConstructionBase< Base >::set_training_random_seed(), and libMesh::RBConstructionBase< CondensedEigenSystem >::system().

bool libMesh::RBParametrized::verbose_mode
inherited

Public boolean to toggle verbose mode.

Definition at line 170 of file rb_parametrized.h.

Referenced by libMesh::RBParametrized::valid_params().


The documentation for this class was generated from the following files: