oomph::OomphLibPreconditionerEpetraOperator Class Reference

#include <trilinos_solver.h>

+ Inheritance diagram for oomph::OomphLibPreconditionerEpetraOperator:

Public Member Functions

 OomphLibPreconditionerEpetraOperator (Preconditioner *preconditioner_pt, bool use_epetra_values=false)
 
 ~OomphLibPreconditionerEpetraOperator ()
 
 OomphLibPreconditionerEpetraOperator (const OomphLibPreconditionerEpetraOperator &)=delete
 Broken copy constructor. More...
 
void operator= (const OomphLibPreconditionerEpetraOperator &)=delete
 Broken assignment operator. More...
 
int SetUseTranspose (bool UseTranspose)
 Broken Epetra_Operator member - SetUseTranspose. More...
 
int Apply (const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
 Broken Epetra_Operator member - Apply. More...
 
int ApplyInverse (const Epetra_MultiVector &epetra_r, Epetra_MultiVector &epetra_z) const
 
double NormInf () const
 Broken Epetra_Operator member - NormInf. More...
 
const charLabel () const
 Epetra_Operator::Label - returns a string describing the operator. More...
 
bool UseTranspose () const
 Broken Epetra_Operator member - UseTranspose. More...
 
bool HasNormInf () const
 Broken Epetra_Operator member - HasNormInf. More...
 
const Epetra_Comm & Comm () const
 Returns the Epetra MPI_Comm object. More...
 
const Epetra_Map & OperatorDomainMap () const
 Epetra_Operator member - OperatorDomainMap. More...
 
const Epetra_Map & OperatorRangeMap () const
 Epetra_Operator member - OperatorRangeMap. More...
 

Private Attributes

PreconditionerOomph_lib_preconditioner_pt
 A pointer to the oomph-lib preconditioner. More...
 
Epetra_SerialComm Operator_comm
 An Epetra Serial Comm object. More...
 
bool Use_epetra_values
 
Epetra_Map * Operator_map_pt
 
std::string Preconditioner_label
 a label for the preconditioner ( for Epetra_Operator::Label() ) More...
 

Detailed Description

An Epetra_Operator class for oomph-lib preconditioners. A helper class for TrilinosOomphLibPreconditioner to allow an oomph-lib preconditioner (i.e. one derived from Preconditioner) to be used with a trilinos solver (TrilinosAztecOOSolver)

Constructor & Destructor Documentation

◆ OomphLibPreconditionerEpetraOperator() [1/2]

oomph::OomphLibPreconditionerEpetraOperator::OomphLibPreconditionerEpetraOperator ( Preconditioner preconditioner_pt,
bool  use_epetra_values = false 
)
inline

Constructor - takes the pointer to the oomph-lib preconditioner and the distribution of the preconditioner Note: the oomph-lib preconditioner must be setup. If use_eptra_values is true then the epetra vector values is used within the vectors passed to the oomph-lib preconditioner. If this is true none of the vector rebuild methods can be called.

55  : Operator_comm(
56  preconditioner_pt->distribution_pt()->communicator_pt()->mpi_comm()),
57  Use_epetra_values(use_epetra_values)
58 #else
59  : Operator_comm(), Use_epetra_values(use_epetra_values)
60 #endif
61  {
62  // set the ooomph-lib preconditioner
63  Oomph_lib_preconditioner_pt = preconditioner_pt;
64 
65  // set the preconditioner label
66  Preconditioner_label = "oomph-lib Preconditioner";
67 
68  // setup the Epetra_map
71  }
LinearAlgebraDistribution * distribution_pt() const
access to the LinearAlgebraDistribution
Definition: linear_algebra_distribution.h:457
Epetra_SerialComm Operator_comm
An Epetra Serial Comm object.
Definition: trilinos_solver.h:238
Preconditioner * Oomph_lib_preconditioner_pt
A pointer to the oomph-lib preconditioner.
Definition: trilinos_solver.h:231
bool Use_epetra_values
Definition: trilinos_solver.h:244
std::string Preconditioner_label
a label for the preconditioner ( for Epetra_Operator::Label() )
Definition: trilinos_solver.h:253
Epetra_Map * Operator_map_pt
Definition: trilinos_solver.h:250
Epetra_Map * create_epetra_map(const LinearAlgebraDistribution *const dist)
create an Epetra_Map corresponding to the LinearAlgebraDistribution
Definition: trilinos_helpers.cc:977

References oomph::TrilinosEpetraHelpers::create_epetra_map(), oomph::DistributableLinearAlgebraObject::distribution_pt(), Oomph_lib_preconditioner_pt, Operator_map_pt, and Preconditioner_label.

◆ ~OomphLibPreconditionerEpetraOperator()

oomph::OomphLibPreconditionerEpetraOperator::~OomphLibPreconditionerEpetraOperator ( )
inline

Destructor - deletes the Epetra_map and My_global_rows vector (if MPI)

76  {
77  delete Operator_map_pt;
78  Operator_map_pt = 0;
79  }

References Operator_map_pt.

◆ OomphLibPreconditionerEpetraOperator() [2/2]

oomph::OomphLibPreconditionerEpetraOperator::OomphLibPreconditionerEpetraOperator ( const OomphLibPreconditionerEpetraOperator )
delete

Broken copy constructor.

Member Function Documentation

◆ Apply()

int oomph::OomphLibPreconditionerEpetraOperator::Apply ( const Epetra_MultiVector &  X,
Epetra_MultiVector &  Y 
) const
inline

Broken Epetra_Operator member - Apply.

101  {
102  std::ostringstream error_message;
103  error_message << "Apply() is a pure virtual Epetra_Operator member"
104  << "that is not required for a Preconditioner" << std::endl;
105  throw OomphLibError(
106  error_message.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
107  }
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86

References OOMPH_CURRENT_FUNCTION, and OOMPH_EXCEPTION_LOCATION.

◆ ApplyInverse()

int oomph::OomphLibPreconditionerEpetraOperator::ApplyInverse ( const Epetra_MultiVector &  epetra_r,
Epetra_MultiVector &  epetra_z 
) const
inline

applies the oomph-lib preconditioner. Converts the Epetra vector applys the preconditioner by calling the oomph-lib preconditioner's preconditioner_solve functionality. NOTE : the oomph-lib preconditioner is setup prior to being passed to this class

117  {
118  // the oomph-lib vector for r
119  DoubleVector oomph_r;
120 
121  // copy the Epetra_MultiVector r into an oomph-lib vector
122  double** r_pt;
123  epetra_r.ExtractView(&r_pt);
124  if (Use_epetra_values)
125  {
126  oomph_r.set_external_values(
128  }
129  else
130  {
131  oomph_r.build(Oomph_lib_preconditioner_pt->distribution_pt(), 0.0);
132  unsigned nrow_local =
134  for (unsigned i = 0; i < nrow_local; i++)
135  {
136  oomph_r[i] = r_pt[0][i];
137  }
138  }
139 
140  // oomph-lib vector for Y
141  DoubleVector oomph_z;
142  if (Use_epetra_values)
143  {
144  double** z_pt;
145  epetra_z.ExtractView(&z_pt);
146  DoubleVector oomph_z;
147  oomph_z.set_external_values(
149  }
150  else
151  {
152  oomph_z.build(Oomph_lib_preconditioner_pt->distribution_pt(), 0.0);
153  }
154 
155  // apply the preconditioner
157 
158  // if not using external data copy the oomph-lib vector oomph_Y back to Y
159  if (!Use_epetra_values)
160  {
161  unsigned nrow_local =
163  for (unsigned i = 0; i < nrow_local; i++)
164  {
165  epetra_z.ReplaceMyValue(i, 0, oomph_z[i]);
166  }
167  }
168 
169  // return 0 to indicate success
170  return 0;
171  }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
std::vector< double > DoubleVector
loads clump configuration
Definition: ClumpInput.h:26
unsigned nrow_local() const
Definition: linear_algebra_distribution.h:193
virtual void preconditioner_solve(const DoubleVector &r, DoubleVector &z)=0

References oomph::DoubleVector::build(), oomph::DistributableLinearAlgebraObject::distribution_pt(), i, oomph::LinearAlgebraDistribution::nrow_local(), Oomph_lib_preconditioner_pt, oomph::Preconditioner::preconditioner_solve(), oomph::DoubleVector::set_external_values(), and Use_epetra_values.

◆ Comm()

const Epetra_Comm& oomph::OomphLibPreconditionerEpetraOperator::Comm ( ) const
inline

Returns the Epetra MPI_Comm object.

212  {
213  return Operator_comm;
214  }

References Operator_comm.

◆ HasNormInf()

bool oomph::OomphLibPreconditionerEpetraOperator::HasNormInf ( ) const
inline

Broken Epetra_Operator member - HasNormInf.

202  {
203  std::ostringstream error_message;
204  error_message << "HasNormInf() is a pure virtual Epetra_Operator member "
205  << "that is not required for a Preconditioner" << std::endl;
206  throw OomphLibError(
207  error_message.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
208  }

References OOMPH_CURRENT_FUNCTION, and OOMPH_EXCEPTION_LOCATION.

◆ Label()

const char* oomph::OomphLibPreconditionerEpetraOperator::Label ( ) const
inline

Epetra_Operator::Label - returns a string describing the operator.

185  {
186  return Preconditioner_label.c_str();
187  }

References Preconditioner_label.

◆ NormInf()

double oomph::OomphLibPreconditionerEpetraOperator::NormInf ( ) const
inline

Broken Epetra_Operator member - NormInf.

175  {
176  std::ostringstream error_message;
177  error_message << "NormInf() is a pure virtual Epetra_Operator member"
178  << "that is not required for a Preconditioner" << std::endl;
179  throw OomphLibError(
180  error_message.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
181  }

References OOMPH_CURRENT_FUNCTION, and OOMPH_EXCEPTION_LOCATION.

◆ operator=()

void oomph::OomphLibPreconditionerEpetraOperator::operator= ( const OomphLibPreconditionerEpetraOperator )
delete

Broken assignment operator.

◆ OperatorDomainMap()

const Epetra_Map& oomph::OomphLibPreconditionerEpetraOperator::OperatorDomainMap ( ) const
inline

Epetra_Operator member - OperatorDomainMap.

218  {
219  return *Operator_map_pt;
220  }

References Operator_map_pt.

◆ OperatorRangeMap()

const Epetra_Map& oomph::OomphLibPreconditionerEpetraOperator::OperatorRangeMap ( ) const
inline

Epetra_Operator member - OperatorRangeMap.

224  {
225  return *Operator_map_pt;
226  }

References Operator_map_pt.

◆ SetUseTranspose()

int oomph::OomphLibPreconditionerEpetraOperator::SetUseTranspose ( bool  UseTranspose)
inline

Broken Epetra_Operator member - SetUseTranspose.

90  {
91  std::ostringstream error_message;
92  error_message << "SetUseTranspose() is a pure virtual Epetra_Operator "
93  << "member that is not required for a Preconditioner"
94  << std::endl;
95  throw OomphLibError(
96  error_message.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
97  }

References OOMPH_CURRENT_FUNCTION, and OOMPH_EXCEPTION_LOCATION.

◆ UseTranspose()

bool oomph::OomphLibPreconditionerEpetraOperator::UseTranspose ( ) const
inline

Broken Epetra_Operator member - UseTranspose.

191  {
192  std::ostringstream error_message;
193  error_message
194  << "UseTranspose() is a pure virtual Epetra_Operator member "
195  << "that is not required for a Preconditioner" << std::endl;
196  throw OomphLibError(
197  error_message.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
198  }

References OOMPH_CURRENT_FUNCTION, and OOMPH_EXCEPTION_LOCATION.

Member Data Documentation

◆ Oomph_lib_preconditioner_pt

Preconditioner* oomph::OomphLibPreconditionerEpetraOperator::Oomph_lib_preconditioner_pt
private

A pointer to the oomph-lib preconditioner.

Referenced by ApplyInverse(), and OomphLibPreconditionerEpetraOperator().

◆ Operator_comm

Epetra_SerialComm oomph::OomphLibPreconditionerEpetraOperator::Operator_comm
private

An Epetra Serial Comm object.

Referenced by Comm().

◆ Operator_map_pt

Epetra_Map* oomph::OomphLibPreconditionerEpetraOperator::Operator_map_pt
private

A pointer to an Epetra_Map object - describes distribution of the preconditioner, in this instance it is primarily used to prescribe the distribution of the residual and solution vector

Referenced by OomphLibPreconditionerEpetraOperator(), OperatorDomainMap(), OperatorRangeMap(), and ~OomphLibPreconditionerEpetraOperator().

◆ Preconditioner_label

std::string oomph::OomphLibPreconditionerEpetraOperator::Preconditioner_label
private

a label for the preconditioner ( for Epetra_Operator::Label() )

Referenced by Label(), and OomphLibPreconditionerEpetraOperator().

◆ Use_epetra_values

bool oomph::OomphLibPreconditionerEpetraOperator::Use_epetra_values
private

Use the epetra data within the vectors passed to the oomph-lib preconditioner. If this is true none of the vector rebuild methods can be called.

Referenced by ApplyInverse().


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