00001 /* 00002 * Copyright (c) 2001 The AUTHORS 00003 * Romeu Andre' Pieritz, Ph.D. - romeu_pieritz@hotmail.com 00004 * Rafael Mendes, Eng. – mendes_rafael@yahoo.com 00005 * Rodrigo Ferraz de Andrade, Eng. – rferraz@iname.com 00006 * All rights reserved. 00007 * 00008 * Permission to use, copy and distribute this software and its 00009 * documentation for educational and personal use, without fee is hereby granted, 00010 * provided that the above copyright notice and the following 00011 * two paragraphs appear in all copies of this software. 00012 * 00013 * IN NO EVENT SHALL THE AUTHORS BE LIABLE TO ANY PARTY FOR 00014 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT 00015 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE AUTHORS 00016 * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00017 * 00018 * THE AUTHORS SPECIFICALLY DISCLAIMS ANY WARRANTIES, 00019 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 00020 * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HERE UNDER IS 00021 * ON AN "AS IS" BASIS, AND THE AUTHORS HAVE NO OBLIGATION TO 00022 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 00023 * 00024 * SINMEC Lab. - CFD Sinflow Project - http://www.sinmec.ufsc.br/cfd 00025 */ 00026 00027 00028 // File Define 00029 #ifndef __CSFL_SYS_MATH_FUNCTION_H__ 00030 #define __CSFL_SYS_MATH_FUNCTION_H__ 00031 00032 00033 // Include 00034 #include <csfl/sys/core/sflobject.h> 00035 #include <csfl/sys/core/string.h> 00036 00037 00038 // Namespace 00039 namespace csfl { 00040 00041 00042 class IFunction : 00043 virtual public ISFLObject 00044 00048 { 00049 00050 public: 00051 00055 IFunction( IString _name ) 00056 : ISFLObject(), name( _name ) {} 00057 IFunction( IFunction * _f ) 00058 : ISFLObject(), name( _f->Name() ) {} 00059 ~IFunction() {} 00060 00062 virtual int Dimension() { return 1; } 00063 00065 virtual double Eval( double _pos ) { return 1.0; } 00066 00068 const IString & Name() { return name; } 00069 00071 void Setname( const IString & _n ) { name = _n; } 00072 00073 protected: 00074 IString name; 00075 }; 00076 00077 00078 class IFConstant : 00079 public IFunction 00080 00082 { 00083 00084 public: 00086 IFConstant( double _k ) : 00087 IFunction( "Constant" ), k( _k ) {} 00088 IFConstant( IFConstant * _f ) : 00089 IFunction( _f->Name() ), k( _f->k ) {} 00090 00092 double Eval( double _pos ) { return k; } 00093 00095 void SetCoefficient( double _v ) { k = _v; } 00096 00097 private: 00098 double k; 00099 }; 00100 00101 00102 00103 class IFLinear : 00104 public IFunction 00105 00107 { 00108 00109 public: 00111 IFLinear( double _a, double _b ) 00112 : IFunction( "Linear" ), a( _a ), b( _b ) {} 00113 IFLinear( IFLinear *_f ) 00114 : IFunction( _f->Name() ), a( _f->a ), b( _f->b ) {} 00115 00117 double GetAngular() const { return a; } 00118 00120 double GetLinear() const { return b; } 00121 00123 double Eval( double _pos ) { return a*_pos + b; } 00124 00125 private: 00126 double a, b; 00127 }; 00128 00129 00130 00131 class IFQuadratic : 00132 public IFunction 00133 00134 /*Classe que representa uma função quadrática a*x*x + b*x + c.*/ 00135 { 00136 00137 public: 00139 IFQuadratic( double _a, double _b, double _c ) 00140 : IFunction( "Quadratic" ), a( _a ), b( _b ), c( _c ) {} 00141 IFQuadratic( IFQuadratic *_f ) 00142 : IFunction( _f->Name() ), a( _f->a ), b( _f->b ), c( _f->c ) {} 00143 00145 double GetAngular() const { return a; } 00146 00148 double GetLinear() const { return b; } 00149 00151 double GetConst() const { return c; } 00152 00154 double Eval( double _pos ) 00155 { return a*_pos*_pos + b*_pos + c; } 00156 00157 private: 00158 double a, b, c; 00159 }; 00160 00161 00162 00163 class IFSin : 00164 public IFunction 00165 00167 00168 { 00169 00170 public: 00172 IFSin( double _a, double _b, double _c, double _d = 0.0 ) 00173 : IFunction( "Sine" ), a( _a ), b( _b ), c( _c ), d( _d ) {} 00174 IFSin( IFSin *_f ) 00175 : IFunction( _f->Name() ), a( _f->a ), b( _f->b ), c( _f->c ), 00176 d( _f->d ) {} 00177 00179 double GetAmplitude() const { return a; } 00180 00182 double GetLinear() const { return b; } 00183 00185 double GetScalar() const { return c; } 00186 00188 double GetPhase() const { return d; } 00189 00191 double Eval( double _pos ) 00192 { return a + b*sin(c*_pos + d); } 00193 00194 private: 00195 double a, b, c, d; 00196 }; 00197 00198 00199 00200 class IFCos : 00201 public IFunction 00202 00204 { 00205 00206 public: 00208 IFCos( double _a, double _b, double _c, double _d ) 00209 : IFunction( "Cosine" ), a( _a ), b( _b ), c( _c ), d( _d ) {} 00210 IFCos( IFCos *_f ) 00211 : IFunction( _f->Name() ), a( _f->a ), b( _f->b ), c( _f->c ), 00212 d( _f->d ){} 00213 00215 double GetAmplitude() const { return a; } 00216 00218 double GetLinear() const { return b; } 00219 00221 double GetScalar() const { return c; } 00222 00224 double GetPhase() const { return d; } 00225 00227 double Eval( double _pos ) 00228 { return a + b*cos(c*_pos + d); } 00229 00230 private: 00231 double a, b, c, d; 00232 }; 00233 00234 00235 00236 class IFExponential : 00237 public IFunction 00238 00240 00241 { 00242 00243 public: 00245 IFExponential( double _a, double _b, double _c = 0.0 ) 00246 : IFunction( "Exponential" ), a( _a ), b( _b ), c( _c ) {} 00247 IFExponential( IFExponential *_f ) 00248 : IFunction( _f->Name() ), a( _f->a ), b( _f->b ), c( _f->c ) {} 00249 00251 double GetA() const { return a; } 00253 double GetB() const { return b; } 00255 double GetC() const { return c; } 00256 00258 double Eval( double _pos ) { return ( a*exp( b*_pos ) + c); } 00259 00260 private: 00261 double a, b, c; 00262 }; 00263 00264 } // csfl namespace 00265 00266 #endif // __CSFL_SYS_MATH_FUNCTION_H__ 00267
CFD Project
|
Documents |
Downloads |
Contact us |
Use Terms |
|
|||
© SINMEC/EMC/UFSC,
2001. |
All rights
reserved. |
Last Update: Jan. 18, 2002 |
|