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

scalar.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_H__
00030 #define __CSFL_FIELD_VALUE_SCALAR_H__
00031 
00032 
00033 // Include
00034 #include <csfl/sys/math/matrix.h>
00035 #include <csfl/field/core/field.h>
00036 
00037 
00038 // Namespace
00039 namespace csfl {
00040 
00041 //==============================================================================
00042 //              Class IFieldScalar
00043 //              Description: Represents a scalar field
00044 //==============================================================================
00045 
00046 class IFieldScalar : 
00047         public IField
00048 
00052 
00053 {
00054 
00055 public:
00061         IFieldScalar( const IString &_name = IString::empty, 
00062                 IGrid *_grid = NULL, double _value = 0.0 );
00063 
00069         IFieldScalar( const IString &_name, IGrid *_grid, Matrix *_data );
00070 
00076         IFieldScalar( const IString &_name, const ISize &_size, double _value = 0.0 );
00077 
00083         IFieldScalar( const IString &_name, int _row, int _col, double _value = 0.0 );
00084 
00086         IFieldScalar( IFieldScalar *_field );
00087 
00088         ~IFieldScalar();
00089 
00094         inline virtual double Value( const IPoint &_p );
00095 
00100         inline virtual double Value( int _i, int _j );
00101 
00103         double MaxValue();
00104 
00106         double MinValue();
00107         
00109         inline const IFieldScalar & operator = ( const IFieldScalar &_field );
00110 
00115         inline void SetValue( const IPoint &_p , double _value );
00116 
00121         inline void SetValue( int _x, int _y, double _value );
00122         
00124         void Read( ifstream &_is );
00125 
00129     void Write( ofstream &_os );
00130 
00131 protected:
00132         Matrix *data;
00133 
00134 };
00135 
00136 // =============================================================================
00137 // Inline functions
00138 // =============================================================================
00139 
00140 inline double IFieldScalar::Value( int _i, int _j )
00141 {
00146 
00147     if ( _i>=0.0 && _i<fsize.width && _j>=0.0 && _j<fsize.height)  
00148         return data->Value( _i, _j );
00149     else
00150         return 0.0;
00151 }
00152 
00153 inline double IFieldScalar::Value( const IPoint & _p )
00154 {
00155         return Value( _p.x, _p.y );     
00156 }
00157 
00158 inline const IFieldScalar & IFieldScalar::operator = ( const IFieldScalar & _field ) 
00159 {
00160         ( IFieldScalar & )*this = _field;
00161         data = _field.data;
00162         return *this;
00163 }
00164 
00165 inline void IFieldScalar::SetValue( const IPoint &_p, double _value )
00166 {
00171 
00172         data->SetValue( _p, _value );
00173 }
00174 
00175 inline void IFieldScalar::SetValue( int _x, int _y, double _value )
00176 {
00177         data->SetValue( _x, _y, _value );
00178 }
00179      
00180 //==============================================================================
00181 } // csfl namespace
00182 
00183 #endif// __CSFL_FIELD_VALUE_SCALAR_H__

 

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

 

© SINMEC/EMC/UFSC, 2001.

All rights reserved.

Last Update: Jan. 18, 2002

 Webmaster