xc
ConvergenceTest.h
1 // -*-c++-*-
2 //----------------------------------------------------------------------------
3 // XC program; finite element analysis code
4 // for structural analysis and design.
5 //
6 // Copyright (C) Luis C. Pérez Tato
7 //
8 // This program derives from OpenSees <http://opensees.berkeley.edu>
9 // developed by the «Pacific earthquake engineering research center».
10 //
11 // Except for the restrictions that may arise from the copyright
12 // of the original program (see copyright_opensees.txt)
13 // XC is free software: you can redistribute it and/or modify
14 // it under the terms of the GNU General Public License as published by
15 // the Free Software Foundation, either version 3 of the License, or
16 // (at your option) any later version.
17 //
18 // This software is distributed in the hope that it will be useful, but
19 // WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 // GNU General Public License for more details.
22 //
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with this program.
26 // If not, see <http://www.gnu.org/licenses/>.
27 //----------------------------------------------------------------------------
28 /* ****************************************************************** **
29 ** OpenSees - Open System for Earthquake Engineering Simulation **
30 ** Pacific Earthquake Engineering Research Center **
31 ** **
32 ** **
33 ** (C) Copyright 1999, The Regents of the University of California **
34 ** All Rights Reserved. **
35 ** **
36 ** Commercial use of this program without express permission of the **
37 ** University of California, Berkeley, is strictly prohibited. See **
38 ** file 'COPYRIGHT' in main directory for information on usage and **
39 ** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
40 ** **
41 ** Developed by: **
42 ** Frank McKenna (fmckenna@ce.berkeley.edu) **
43 ** Gregory L. Fenves (fenves@ce.berkeley.edu) **
44 ** Filip C. Filippou (filippou@ce.berkeley.edu) **
45 ** **
46 ** ****************************************************************** */
47 
48 // $Revision: 1.4 $
49 // $Date: 2005/12/15 00:19:28 $
50 // $Source: /usr/local/cvs/OpenSees/SRC/analysis/convergenceTest/ConvergenceTest.h,v $
51 
52 
53 #ifndef ConvergenceTest_h
54 #define ConvergenceTest_h
55 
56 // Written: fmk
57 // Date: 09/98
58 // Revised:
59 //
60 // Purpose: This file contains the class definition for ConvergenceTest,
61 // which is an abstract class. Objects of concrete subclasses can be used
62 // to test the convergence of an algorithm.
63 
64 #include <utility/actor/actor/MovableObject.h>
65 #include "utility/kernel/CommandEntity.h"
66 #include "utility/matrix/Vector.h"
67 #include "solution/system_of_eqn/linearSOE/LinearSOE.h"
68 
69 namespace XC {
70 class EquiSolnAlgo;
71 class SolutionStrategy;
72 
74 //
82  {
83  SolutionStrategy *getSolutionStrategy(void);
84  const SolutionStrategy *getSolutionStrategy(void) const;
85  protected:
87  int maxNumIter;
88  int printFlag;
89  int nType;
91 
92  //Intermediate results:
93  mutable double lastRatio;
94  mutable double calculatedNormX;
95  mutable double calculatedNormB;
96  mutable double calculatedEnergyProduct;
97 
98  bool hasLinearSOE(void) const;
100  const LinearSOE *getLinearSOEPtr(void) const;
101  const Vector &getX(void) const;
102  double getNormX(void) const;
103  const Vector &getB(void) const;
104  double getNormB(void) const;
105  double getEnergyProduct(void) const;
106 
107  protected:
108  int sendData(Communicator &);
109  int recvData(const Communicator &);
110 
111  public:
112  ConvergenceTest(CommandEntity *owr,int classTag);
113  ConvergenceTest(CommandEntity *owr,int clasTag,int maxIter,int prtFlg, int normType,int sz_norms= 1);
114  inline virtual ~ConvergenceTest(void) {}
115 
116  virtual ConvergenceTest *getCopy(void) const= 0;
117  virtual ConvergenceTest *getCopy(int iterations) const;
118 
119  virtual std::string getStatusMsg(const int &flag= 1) const= 0;
120  virtual int start(void);
130  virtual int test(void)= 0;
131 
132  int getMaxNumIter(void) const;
133  void setMaxNumIter(const int &);
134  int getCurrentIter(void) const;
135  void setCurrentIter(const int &);
136  int getPrintFlag(void) const;
137  void setPrintFlag(const int &);
138  int getNormType(void) const;
139  void setNormType(const int &);
140 
141  virtual int getNumTests(void) const;
142  virtual int getMaxNumTests(void) const;
143  virtual double getRatioNumToMax(void) const;
144  virtual const Vector &getNorms(void) const;
145  int sendSelf(Communicator &);
146  int recvSelf(const Communicator &);
147 
148  std::string getTestIterationMessage(void) const;
149  std::string getFailedToConvergeMessage(void) const;
150  std::string getDeltaXRMessage(void) const;
151  std::string getDeltaXRNormsMessage(void) const;
152  };
153 } // end of XC namespace
154 
155 
156 #endif
157 
double lastRatio
Last calculated ratio (if any).
Definition: ConvergenceTest.h:93
std::string getDeltaXRMessage(void) const
Returns a string with the values of x and b vectors.
Definition: ConvergenceTest.cpp:288
double calculatedNormB
Last calculated |b|.
Definition: ConvergenceTest.h:95
Float vector abstraction.
Definition: Vector.h:94
const Vector & getX(void) const
Returns the vector of unknowns.
Definition: ConvergenceTest.cpp:189
bool hasLinearSOE(void) const
Returns true ifpuede acceder al system of equations.
Definition: ConvergenceTest.cpp:169
Communication parameters between processes.
Definition: Communicator.h:66
Linear system of equations.
Definition: LinearSOE.h:92
Object that can move between processes.
Definition: MovableObject.h:100
virtual int test(void)=0
Return a positive number if convergence is achieved.
int nType
type of norm to use (1-norm, 2-norm, p-norm, max-norm)
Definition: ConvergenceTest.h:89
double calculatedEnergyProduct
Last calculated |0.5*(x ^ b)|.
Definition: ConvergenceTest.h:96
int recvSelf(const Communicator &)
Receive the object.
Definition: ConvergenceTest.cpp:251
int recvData(const Communicator &)
Receives object members through the communicator argument.
Definition: ConvergenceTest.cpp:228
const Vector & getB(void) const
Return the vector at the right hand side of the equation.
Definition: ConvergenceTest.cpp:197
double getEnergyProduct(void) const
Returns the the energy increment, which is 0.5 times the absolute value of the product of the rhs and...
Definition: ConvergenceTest.cpp:208
double getNormX(void) const
Return the norma del vector of unknowns.
Definition: ConvergenceTest.cpp:193
int sendData(Communicator &)
Send object members through the communicator argument.
Definition: ConvergenceTest.cpp:219
ConvergenceTest(CommandEntity *owr, int classTag)
Default constructor.
Definition: ConvergenceTest.cpp:72
void setCurrentIter(const int &)
Set the current iteration number.
Definition: ConvergenceTest.cpp:125
double getNormB(void) const
Return the norm of the vector at the right hand side of the equation.
Definition: ConvergenceTest.cpp:202
double calculatedNormX
Last calculated |x|.
Definition: ConvergenceTest.h:94
Objet that can execute python scripts.
Definition: CommandEntity.h:40
std::string getTestIterationMessage(void) const
Returns a string with the name of the class and the iteration number.
Definition: ConvergenceTest.cpp:272
convergence test.
Definition: ConvergenceTest.h:81
int getCurrentIter(void) const
Return the current iteration number.
Definition: ConvergenceTest.cpp:122
Solution strategy for the finite element problem.
Definition: SolutionStrategy.h:94
LinearSOE * getLinearSOEPtr(void)
Returns a pointer to the system of equations.
Definition: ConvergenceTest.cpp:173
int currentIter
number of times test() has been invokes since last start()
Definition: ConvergenceTest.h:86
Open source finite element program for structural analysis.
Definition: ContinuaReprComponent.h:35
int printFlag
a flag indicating if to print on test
Definition: ConvergenceTest.h:88
std::string getDeltaXRNormsMessage(void) const
Returns a string with the values of x and b vector norms.
Definition: ConvergenceTest.cpp:296
Vector norms
vector to hold the norms
Definition: ConvergenceTest.h:90
int maxNumIter
max number of iterations
Definition: ConvergenceTest.h:87
std::string getFailedToConvergeMessage(void) const
Returns a string with the proper failed to converge message.
Definition: ConvergenceTest.cpp:278
int sendSelf(Communicator &)
Send the object.
Definition: ConvergenceTest.cpp:236
virtual int start(void)
This is invoked at the start of each iteration.
Definition: ConvergenceTest.cpp:142