Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

scalar_face.h

Go to the documentation of this file.
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_FIELD_VALUE_SCALAR_FACE_H__
00030 #define __CSFL_FIELD_VALUE_SCALAR_FACE_H__
00031 
00032 
00033 // Include
00034 #include <csfl/field/core/field.h>
00035 #include <csfl/sys/math/matrix.h>
00036 
00037 
00038 // Namespace
00039 namespace csfl {
00040 
00041 //==============================================================================
00042 //              Class IFaceScalar
00043 //              Description: Represents a scalar in the cell faces
00044 //==============================================================================
00045 
00046 class IFaceScalar 
00047 
00051 
00052 {
00053 public:
00054 
00055     IFaceScalar();
00056     ~IFaceScalar();
00057 
00059         inline IFaceScalar * operator = ( const IFaceScalar & );
00060 
00061     double *N, *S, *E, *W;
00062 };
00063 
00064 // =============================================================================
00065 // Inline functions
00066 // =============================================================================
00067 
00068 inline IFaceScalar * IFaceScalar::operator = ( const IFaceScalar &_fv )
00069 {
00070     N = _fv.N;
00071     S = _fv.S;
00072     E = _fv.E;
00073     W = _fv.W;
00074     
00075     return this;
00076 }
00077 
00078 //==============================================================================
00079 //              Class IFieldScalarFace
00080 //              Description: Represents a discretized physical face scalar field 
00081 //==============================================================================
00082 
00083 class IFieldScalarFace : 
00084         public IField
00085 
00090 
00091 {
00092 public:
00093         
00098         IFieldScalarFace( const IString &_name, int _ni, int _nj );
00099 
00104     IFieldScalarFace( const IString &_name, const ISize &_s );
00105 
00109     IFieldScalarFace( IFieldScalarFace *_f );
00110 
00111         ~IFieldScalarFace();
00112 
00122     inline double Value( const IPoint &_p, TDirection _dir );   
00123 
00130   inline double Value( int _i, int _j, TDirection _dir );
00131 
00136         inline void SetValue( int _i, int _j, TDirection _dir, double _v );
00137   
00138 protected:
00139         IArray2D<IFaceScalar> *data;
00140 };
00141 
00142 
00143 
00144 // =============================================================================
00145 // Inline functions
00146 // =============================================================================
00147         
00148 inline double IFieldScalarFace::Value( int _i, int _j, TDirection _dir )
00149 {
00159     return Value( IPoint( _i, _j ), _dir );
00160 }
00161 
00162 inline double IFieldScalarFace::Value( const IPoint & _p, TDirection _dir )
00163 {
00164 
00165     int i, j;
00166 
00167     i = _p.x;
00168     j = _p.y;
00169 
00170     if ( i>=0.0 && i<fsize.width && j>=0.0 && j<fsize.height) {
00171         
00172         switch (_dir) {
00173         case (diNorth) :
00174             return *(*data)(i,j).N;
00175         case (diSouth) :
00176             return *(*data)(i,j).S;
00177         case (diEast) :
00178             return *(*data)(i,j).E;
00179         case (diWest) :
00180             return *(*data)(i,j).W;
00181         case (diNULL):
00182             return 0.0;
00183         }
00184     }
00185     return 0.0;
00186 }
00187         
00188 inline void IFieldScalarFace::SetValue( int _i, int _j, TDirection _dir, double _v )
00189 {  
00199 
00200     if ( _i>=0.0 && _i<fsize.width && _j>=0.0 && _j<fsize.height) {        
00201         switch (_dir) {
00202         case (diNorth) :
00203             *(*data)(_i,_j).N = _v;
00204             break;
00205         case (diSouth) :
00206             *(*data)(_i,_j).S = _v;
00207             break;
00208         case (diEast) :
00209             *(*data)(_i,_j).E = _v;
00210             break;
00211         case (diWest) :
00212             *(*data)(_i,_j).W = _v;
00213             break;
00214         }
00215     }
00216 }    } // csfl namespace
00217 
00218 #endif// __CSFL_FIELD_VALUE_SCALAR_FACE_H__

 

CFD Project | Documents | Downloads | Contact us | Use Terms

 

© SINMEC/EMC/UFSC, 2001.

All rights reserved.

Last Update: Jan. 18, 2002

 Webmaster