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