XC Open source finite element analysis program
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/nucleo/EntWOwner.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 SoluMethod;
71 
73 //
75 class ConvergenceTest: public MovableObject, public EntWOwner
76  {
77  SoluMethod *getSoluMethod(void);
78  const SoluMethod *getSoluMethod(void) const;
79  protected:
81  int maxNumIter;
82  int printFlag;
83  int nType;
85 
86  //Intermediate results:
87  mutable double lastRatio;
88  mutable double calculatedNormX;
89  mutable double calculatedNormB;
90  mutable double calculatedEnergyProduct;
91 
92  bool hasLinearSOE(void) const;
94  const LinearSOE *getLinearSOEPtr(void) const;
95  const Vector &getX(void) const;
96  double getNormX(void) const;
97  const Vector &getB(void) const;
98  double getNormB(void) const;
99  double getEnergyProduct(void) const;
100 
101  protected:
102  int sendData(CommParameters &);
103  int recvData(const CommParameters &);
104 
105  public:
106  ConvergenceTest(EntCmd *owr,int classTag);
107  ConvergenceTest(EntCmd *owr,int clasTag,int maxIter,int prtFlg, int normType,int sz_norms= 1);
108  inline virtual ~ConvergenceTest(void) {}
109 
110  virtual ConvergenceTest *getCopy(void) const= 0;
111  virtual ConvergenceTest *getCopy(int iterations) const;
112 
113  virtual std::string getStatusMsg(const int &flag= 1) const= 0;
114  virtual int start(void);
115  virtual int test(void)= 0;
116 
117  int getMaxNumIter(void) const;
118  void setMaxNumIter(const int &);
119  int getCurrentIter(void) const;
120  void setCurrentIter(const int &);
121  int getPrintFlag(void) const;
122  void setPrintFlag(const int &);
123  int getNormType(void) const;
124  void setNormType(const int &);
125 
126  virtual int getNumTests(void) const;
127  virtual int getMaxNumTests(void) const;
128  virtual double getRatioNumToMax(void) const;
129  virtual const Vector &getNorms(void) const;
130  int sendSelf(CommParameters &);
131  int recvSelf(const CommParameters &);
132 
133  std::string getTestIterationMessage(void) const;
134  std::string getFailedToConvergeMessage(void) const;
135  std::string getDeltaXRMessage(void) const;
136  std::string getDeltaXRNormsMessage(void) const;
137  };
138 } // end of XC namespace
139 
140 
141 #endif
142 
Definition: Vector.h:82
std::string getDeltaXRNormsMessage(void) const
Returns a string with the values of x and b vector norms.
Definition: ConvergenceTest.cpp:269
int maxNumIter
max number of iterations
Definition: ConvergenceTest.h:81
Solution procedure for the finite element problem. The solution procedure is definde by specifiying: ...
Definition: SoluMethod.h:76
std::string getDeltaXRMessage(void) const
Returns a string with the values of x and b vectors.
Definition: ConvergenceTest.cpp:261
int recvData(const CommParameters &)
Receives object members through the channel being passed as parameter.
Definition: ConvergenceTest.cpp:204
double calculatedEnergyProduct
Last calculated |0.5*(x ^ b)|.
Definition: ConvergenceTest.h:90
convergence test.
Definition: ConvergenceTest.h:75
Object that can move between processes.
Definition: MovableObject.h:91
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:184
double lastRatio
Last calculated ratio (if any).
Definition: ConvergenceTest.h:87
double calculatedNormB
Last calculated |b|.
Definition: ConvergenceTest.h:89
const Vector & getB(void) const
Returns the vector de términos independientes.
Definition: ConvergenceTest.cpp:174
std::string getFailedToConvergeMessage(void) const
Returns a string with the proper failed to converge message.
Definition: ConvergenceTest.cpp:251
Linea system of equations. This is the class definition for LinearSOE. LinearSOE is an abstract base ...
Definition: LinearSOE.h:86
std::string getTestIterationMessage(void) const
Returns a string with the name of the class and the iteration number.
Definition: ConvergenceTest.cpp:245
bool hasLinearSOE(void) const
Returns true ifpuede acceder al system of equations.
Definition: ConvergenceTest.cpp:146
int sendData(CommParameters &)
Send object members through the channel being passed as parameter.
Definition: ConvergenceTest.cpp:195
int printFlag
a flag indicating if to print on test
Definition: ConvergenceTest.h:82
Vector norms
vector to hold the norms
Definition: ConvergenceTest.h:84
LinearSOE * getLinearSOEPtr(void)
Returns a pointer to the system of equations.
Definition: ConvergenceTest.cpp:150
int nType
type of norm to use (1-norm, 2-norm, p-norm, max-norm)
Definition: ConvergenceTest.h:83
Communication parameters between processes.
Definition: CommParameters.h:65
double getNormB(void) const
Return the norma del vector de términos independientes.
Definition: ConvergenceTest.cpp:178
int currentIter
number of times test() has been invokes since last start()
Definition: ConvergenceTest.h:80
================================================================================
Definition: ContinuaReprComponent.h:34
double getNormX(void) const
Return the norma del vector de incógnitas.
Definition: ConvergenceTest.cpp:170
double calculatedNormX
Last calculated |x|.
Definition: ConvergenceTest.h:88
const Vector & getX(void) const
Returns the vector de incógnitas.
Definition: ConvergenceTest.cpp:166