|
|
|
addSubtract.HGo to the documentation of this file.00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 2008-2009 OpenCFD Ltd. 00006 \\/ M anipulation | 00007 ------------------------------------------------------------------------------- 00008 License 00009 This file is part of OpenFOAM. 00010 00011 OpenFOAM is free software; you can redistribute it and/or modify it 00012 under the terms of the GNU General Public License as published by the 00013 Free Software Foundation; either version 2 of the License, or (at your 00014 option) any later version. 00015 00016 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00018 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00019 for more details. 00020 00021 You should have received a copy of the GNU General Public License 00022 along with OpenFOAM; if not, write to the Free Software Foundation, 00023 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00024 00025 Class 00026 Foam::calcTypes::addSubtract 00027 00028 Description 00029 adds/subtracts a field or value to/from a base field. 00030 00031 New field name specified by -resultName option, or automatically as: 00032 <baseFieldName>_add_<addSubtractFieldName> 00033 <baseFieldName>_add_value 00034 <baseFieldName>_subtract_<addSubtractFieldName> 00035 <baseFieldName>_subtract_value 00036 00037 Example usage: 00038 addSubtract p add -value 100000 -resultName pAbs 00039 addSubtract U subtract -field U0 00040 00041 SourceFiles 00042 addSubtract.C 00043 writeaddSubtractField.C 00044 writeaddSubtractValue.C 00045 00046 \*---------------------------------------------------------------------------*/ 00047 00048 #ifndef addSubtract_H 00049 #define addSubtract_H 00050 00051 #include "calcType.H" 00052 00053 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00054 00055 namespace Foam 00056 { 00057 00058 namespace calcTypes 00059 { 00060 00061 /*---------------------------------------------------------------------------*\ 00062 Class addSubtract Declaration 00063 \*---------------------------------------------------------------------------*/ 00064 00065 class addSubtract 00066 : 00067 public calcType 00068 { 00069 public: 00070 00071 enum calcTypes 00072 { 00073 FIELD, 00074 VALUE 00075 }; 00076 00077 enum calcModes 00078 { 00079 ADD, 00080 SUBTRACT 00081 }; 00082 00083 00084 private: 00085 00086 // Private data 00087 00088 //- Name of base field (to addSubtract to) 00089 word baseFieldName_; 00090 00091 //- Calc type as given by enumerations above 00092 calcTypes calcType_; 00093 00094 //- Name of field to add/subtract 00095 word addSubtractFieldName_; 00096 00097 //- String representation of value to add/subtract 00098 string addSubtractValueStr_; 00099 00100 //- Name of result field 00101 word resultName_; 00102 00103 //- Mode - addSubtract/subtract 00104 calcModes calcMode_; 00105 00106 00107 // Private Member Functions 00108 00109 // Output 00110 00111 //- Calc and output field addSubtractitions 00112 void writeAddSubtractFields 00113 ( 00114 const Time& runTime, 00115 const fvMesh& mesh, 00116 const IOobject& baseFieldHeader 00117 ); 00118 00119 //- Calc and output field and value addSubtractitions 00120 void writeAddSubtractValues 00121 ( 00122 const Time& runTime, 00123 const fvMesh& mesh, 00124 const IOobject& baseFieldHeader 00125 ); 00126 00127 00128 //- Disallow default bitwise copy construct 00129 addSubtract(const addSubtract&); 00130 00131 //- Disallow default bitwise assignment 00132 void operator=(const addSubtract&); 00133 00134 00135 protected: 00136 00137 // Member Functions 00138 00139 // Calculation routines 00140 00141 //- Initialise - typically setting static variables, 00142 // e.g. command line arguments 00143 virtual void init(); 00144 00145 //- Pre-time loop calculations 00146 virtual void preCalc 00147 ( 00148 const argList& args, 00149 const Time& runTime, 00150 const fvMesh& mesh 00151 ); 00152 00153 //- Time loop calculations 00154 virtual void calc 00155 ( 00156 const argList& args, 00157 const Time& runTime, 00158 const fvMesh& mesh 00159 ); 00160 00161 00162 // I-O 00163 00164 //- Write addSubtract field 00165 template<class Type> 00166 void writeAddSubtractField 00167 ( 00168 const IOobject& baseHeader, 00169 const IOobject& addSubtractHeader, 00170 const fvMesh& mesh, 00171 bool& processed 00172 ); 00173 00174 //- Write addSubtract value 00175 template<class Type> 00176 void writeAddSubtractValue 00177 ( 00178 const IOobject& baseHeader, 00179 const string& valueStr, 00180 const fvMesh& mesh, 00181 bool& processed 00182 ); 00183 00184 00185 public: 00186 00187 //- Runtime type information 00188 TypeName("addSubtract"); 00189 00190 00191 // Constructors 00192 00193 //- Construct null 00194 addSubtract(); 00195 00196 00197 // Destructor 00198 00199 virtual ~addSubtract(); 00200 }; 00201 00202 00203 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00204 00205 } // End namespace calcTypes 00206 } // End namespace Foam 00207 00208 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00209 00210 #ifdef NoRepository 00211 # include "writeAddSubtractField.C" 00212 # include "writeAddSubtractValue.C" 00213 #endif 00214 00215 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00216 00217 #endif 00218 00219 // ************************************************************************* // |