queso-0.57.0
Public Member Functions | Protected Attributes | List of all members
QUESO::LibMeshOperatorBase Class Referenceabstract

Abstract base class for operator objects using libmesh in the backend. More...

#include <LibMeshOperatorBase.h>

Inheritance diagram for QUESO::LibMeshOperatorBase:
Inheritance graph
[legend]
Collaboration diagram for QUESO::LibMeshOperatorBase:
Collaboration graph
[legend]

Public Member Functions

virtual void assemble ()=0
 Must implement this for the solve to work. More...
 
virtual void print_info () const =0
 Print libmesh related information. More...
 
virtual void save_converged_evals (const std::string &filename) const
 Save the eigenvalues to file filename. More...
 
virtual void save_converged_evec (const std::string &filename, unsigned int i) const
 Save converged eigenfunction i to filename. More...
 
virtual unsigned int get_num_converged () const
 Return the number of converged eigenpairs. More...
 
virtual double get_eigenvalue (unsigned int i) const
 Return eigenvalue i. More...
 
virtual double get_inverted_eigenvalue (unsigned int i) const
 Return the reciprocal of eigenvalue i. More...
 
virtual libMesh::EquationSystems & get_equation_systems () const
 Return the internal libmesh equation systems object. More...
 
virtual SharedPtr
< FunctionBase >::Type 
inverse_kl_transform (std::vector< double > &xi, double alpha) const
 Given coefficients xi, computes the Karhunen-Loeve transform. More...
 
Constructor/Destructor methods
 LibMeshOperatorBase (const FunctionOperatorBuilder &builder, libMesh::MeshBase &m)
 Constuct an operator on the mesh m using a builder builder. More...
 
 ~LibMeshOperatorBase ()
 Destructor. More...
 
- Public Member Functions inherited from QUESO::OperatorBase
 OperatorBase ()
 Constructor. More...
 
virtual ~OperatorBase ()
 Destructor. More...
 

Protected Attributes

SharedPtr
< libMesh::EquationSystems >
::Type 
equation_systems
 
const FunctionOperatorBuilderbuilder
 
unsigned int num_req_pairs
 The number of requested eigenpairs. More...
 
unsigned int nconv
 The number of converged eigenpairs. More...
 

Detailed Description

Abstract base class for operator objects using libmesh in the backend.

Definition at line 57 of file LibMeshOperatorBase.h.

Constructor & Destructor Documentation

QUESO::LibMeshOperatorBase::LibMeshOperatorBase ( const FunctionOperatorBuilder builder,
libMesh::MeshBase &  m 
)

Constuct an operator on the mesh m using a builder builder.

A FunctionOperatorBuilder object is just one that a FEM library backend can use to set up various options. Polynomial type, polynomial order, and the number of eigenpairs to request are good examples.

Definition at line 50 of file LibMeshOperatorBase.C.

References equation_systems.

52  : OperatorBase(),
53  equation_systems(new libMesh::EquationSystems(m)),
55 {
56 #ifndef LIBMESH_HAVE_SLEPC
57  if (m.processor_id() == 0)
58  std::cerr << "ERROR: This example requires libMesh to be\n"
59  << "compiled with SLEPc eigen solvers support!"
60  << std::endl;
61 #else
62 
63 #ifdef LIBMESH_DEFAULT_SINGLE_PRECISION
64  // SLEPc currently gives us a nasty crash with Real==float
65  libmesh_example_assert(false, "--disable-singleprecision");
66 #endif
67 
68 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
69  // SLEPc currently gives us an "inner product not well defined" with
70  // Number==complex
71  libmesh_example_assert(false, "--disable-complex");
72 #endif
73 
74  // Create a CondensedEigenSystem named "Eigensystem" and (for convenience)
75  // use a reference to the system we create.
76  this->equation_systems->add_system<libMesh::CondensedEigenSystem>("Eigensystem");
77 
78 #endif // LIBMESH_HAVE_SLEPC
79 }
SharedPtr< libMesh::EquationSystems >::Type equation_systems
const FunctionOperatorBuilder & builder
OperatorBase()
Constructor.
Definition: OperatorBase.C:30
QUESO::LibMeshOperatorBase::~LibMeshOperatorBase ( )

Destructor.

Definition at line 81 of file LibMeshOperatorBase.C.

82 {
83 }

Member Function Documentation

virtual void QUESO::LibMeshOperatorBase::assemble ( )
pure virtual

Must implement this for the solve to work.

This gets called by libMesh to do the assembly for the eigenvalue problem

Implemented in QUESO::LibMeshNegativeLaplacianOperator.

double QUESO::LibMeshOperatorBase::get_eigenvalue ( unsigned int  i) const
virtual

Return eigenvalue i.

You can store them however you want, but having some kind of order to them is useful for InfiniteDimensionalMeasure

Implements QUESO::OperatorBase.

Definition at line 122 of file LibMeshOperatorBase.C.

References equation_systems, and nconv.

Referenced by get_inverted_eigenvalue().

123 {
124  if (i < this->nconv) {
125  std::pair<libMesh::Real, libMesh::Real> eval;
127  eval = es->get_system<libMesh::EigenSystem>("Eigensystem").get_eigenpair(i);
128  return eval.first;
129  }
130  else {
131  return -1;
132  }
133 }
SharedPtr< libMesh::EquationSystems >::Type equation_systems
Definition of a shared pointer.
unsigned int nconv
The number of converged eigenpairs.
libMesh::EquationSystems & QUESO::LibMeshOperatorBase::get_equation_systems ( ) const
virtual

Return the internal libmesh equation systems object.

Definition at line 140 of file LibMeshOperatorBase.C.

References equation_systems.

141 {
142  return *this->equation_systems;
143 }
SharedPtr< libMesh::EquationSystems >::Type equation_systems
double QUESO::LibMeshOperatorBase::get_inverted_eigenvalue ( unsigned int  i) const
virtual

Return the reciprocal of eigenvalue i.

Implements QUESO::OperatorBase.

Definition at line 135 of file LibMeshOperatorBase.C.

References get_eigenvalue().

136 {
137  return 1.0 / this->get_eigenvalue(i);
138 }
virtual double get_eigenvalue(unsigned int i) const
Return eigenvalue i.
unsigned int QUESO::LibMeshOperatorBase::get_num_converged ( ) const
virtual

Return the number of converged eigenpairs.

Implements QUESO::OperatorBase.

Definition at line 118 of file LibMeshOperatorBase.C.

References nconv.

Referenced by inverse_kl_transform().

118  {
119  return this->nconv;
120 }
unsigned int nconv
The number of converged eigenpairs.
SharedPtr< FunctionBase >::Type QUESO::LibMeshOperatorBase::inverse_kl_transform ( std::vector< double > &  xi,
double  alpha 
) const
virtual

Given coefficients xi, computes the Karhunen-Loeve transform.

This transform goes from coefficient space to physical space using this as the precision operator: / pow(, alpha / 2.0) (x) where the lambda are eigenvalues of the precision operator, this, and the (x) are eigenfunctions of the precision operator, this

Implements QUESO::OperatorBase.

Definition at line 146 of file LibMeshOperatorBase.C.

References builder, equation_systems, QUESO::LibMeshFunction::get_equation_systems(), and get_num_converged().

148 {
149  unsigned int i;
151  LibMeshFunction *kl = new LibMeshFunction(this->builder, es->get_mesh());
152 
153  // Make sure all procs in libmesh mpi communicator all have the same xi. No,
154  // I can't set the seed in QUESO. That would mess with the QUESO
155  // communicator.
156  this->equation_systems->comm().broadcast(xi);
157 
158  SharedPtr<libMesh::EquationSystems>::Type kl_eq_sys(kl->get_equation_systems());
159 
160  std::pair<libMesh::Real, libMesh::Real> eval;
161  for (i = 0; i < this->get_num_converged(); i++) {
162  eval = es->get_system<libMesh::EigenSystem>("Eigensystem").get_eigenpair(i);
163  kl_eq_sys->get_system<libMesh::ExplicitSystem>("Function").solution->add(
164  xi[i] / pow(eval.first, alpha / 2.0),
165  *es->get_system<libMesh::EigenSystem>("Eigensystem").solution);
166  }
167 
169  return ap;
170 }
virtual unsigned int get_num_converged() const
Return the number of converged eigenpairs.
SharedPtr< libMesh::EquationSystems >::Type equation_systems
const FunctionOperatorBuilder & builder
Definition of a shared pointer.
virtual void QUESO::LibMeshOperatorBase::print_info ( ) const
pure virtual

Print libmesh related information.

Implemented in QUESO::LibMeshNegativeLaplacianOperator.

void QUESO::LibMeshOperatorBase::save_converged_evals ( const std::string &  filename) const
virtual

Save the eigenvalues to file filename.

Definition at line 85 of file LibMeshOperatorBase.C.

References equation_systems, and nconv.

86 {
87  unsigned int i;
88  std::ofstream evals_file(filename.c_str());
89 
90  std::pair<libMesh::Real, libMesh::Real> eval;
91  for (i = 0; i < this->nconv; i++) {
92  eval = this->equation_systems
93  ->get_system<libMesh::EigenSystem>("Eigensystem").get_eigenpair(i);
94  if (equation_systems->processor_id() == 0) {
95  evals_file << eval.first << " " << eval.second << std::endl;
96  }
97  }
98  if (this->equation_systems->processor_id() == 0) {
99  evals_file.close();
100  }
101 }
SharedPtr< libMesh::EquationSystems >::Type equation_systems
unsigned int nconv
The number of converged eigenpairs.
void QUESO::LibMeshOperatorBase::save_converged_evec ( const std::string &  filename,
unsigned int  i 
) const
virtual

Save converged eigenfunction i to filename.

Definition at line 103 of file LibMeshOperatorBase.C.

References equation_systems, and nconv.

105 {
106  if (i < this->nconv) {
108  es->get_system<libMesh::EigenSystem>("Eigensystem").get_eigenpair(i);
109  libMesh::ExodusII_IO(es->get_mesh()).write_equation_systems(filename, *es);
110  }
111  else {
112  std::cerr << "Warning: eigenpair " << i
113  << " did not converge. Not saving."
114  << std::endl;
115  }
116 }
SharedPtr< libMesh::EquationSystems >::Type equation_systems
Definition of a shared pointer.
unsigned int nconv
The number of converged eigenpairs.

Member Data Documentation

const FunctionOperatorBuilder& QUESO::LibMeshOperatorBase::builder
protected

Definition at line 121 of file LibMeshOperatorBase.h.

Referenced by inverse_kl_transform().

SharedPtr<libMesh::EquationSystems>::Type QUESO::LibMeshOperatorBase::equation_systems
protected
unsigned int QUESO::LibMeshOperatorBase::nconv
protected
unsigned int QUESO::LibMeshOperatorBase::num_req_pairs
protected

The number of requested eigenpairs.

Definition at line 124 of file LibMeshOperatorBase.h.


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

Generated on Sat Apr 22 2017 14:04:39 for queso-0.57.0 by  doxygen 1.8.5