00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 2008-2010 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 00013 the Free Software Foundation, either version 3 of the License, or 00014 (at your 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, see <http://www.gnu.org/licenses/>. 00023 00024 Class 00025 Foam::calcTypes::addSubtract 00026 00027 Description 00028 adds/subtracts a field or value to/from a base field. 00029 00030 New field name specified by -resultName option, or automatically as: 00031 <baseFieldName>_add_<addSubtractFieldName> 00032 <baseFieldName>_add_value 00033 <baseFieldName>_subtract_<addSubtractFieldName> 00034 <baseFieldName>_subtract_value 00035 00036 Example usage: 00037 addSubtract p add -value 100000 -resultName pAbs 00038 addSubtract U subtract -field U0 00039 00040 SourceFiles 00041 addSubtract.C 00042 writeaddSubtractField.C 00043 writeaddSubtractValue.C 00044 00045 \*---------------------------------------------------------------------------*/ 00046 00047 #ifndef addSubtract_H 00048 #define addSubtract_H 00049 00050 #include <foamCalcFunctions/calcType.H> 00051 00052 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00053 00054 namespace Foam 00055 { 00056 00057 namespace calcTypes 00058 { 00059 00060 /*---------------------------------------------------------------------------*\ 00061 Class addSubtract Declaration 00062 \*---------------------------------------------------------------------------*/ 00063 00064 class addSubtract 00065 : 00066 public calcType 00067 { 00068 public: 00069 00070 enum calcTypes 00071 { 00072 FIELD, 00073 VALUE 00074 }; 00075 00076 enum calcModes 00077 { 00078 ADD, 00079 SUBTRACT 00080 }; 00081 00082 00083 private: 00084 00085 // Private data 00086 00087 //- Name of base field (to addSubtract to) 00088 word baseFieldName_; 00089 00090 //- Calc type as given by enumerations above 00091 calcTypes calcType_; 00092 00093 //- Name of field to add/subtract 00094 word addSubtractFieldName_; 00095 00096 //- String representation of value to add/subtract 00097 string addSubtractValueStr_; 00098 00099 //- Name of result field 00100 word resultName_; 00101 00102 //- Mode - addSubtract/subtract 00103 calcModes calcMode_; 00104 00105 00106 // Private Member Functions 00107 00108 // Output 00109 00110 //- Calc and output field addSubtractitions 00111 void writeAddSubtractFields 00112 ( 00113 const Time& runTime, 00114 const fvMesh& mesh, 00115 const IOobject& baseFieldHeader 00116 ); 00117 00118 //- Calc and output field and value addSubtractitions 00119 void writeAddSubtractValues 00120 ( 00121 const Time& runTime, 00122 const fvMesh& mesh, 00123 const IOobject& baseFieldHeader 00124 ); 00125 00126 00127 //- Disallow default bitwise copy construct 00128 addSubtract(const addSubtract&); 00129 00130 //- Disallow default bitwise assignment 00131 void operator=(const addSubtract&); 00132 00133 00134 protected: 00135 00136 // Member Functions 00137 00138 // Calculation routines 00139 00140 //- Initialise - typically setting static variables, 00141 // e.g. command line arguments 00142 virtual void init(); 00143 00144 //- Pre-time loop calculations 00145 virtual void preCalc 00146 ( 00147 const argList& args, 00148 const Time& runTime, 00149 const fvMesh& mesh 00150 ); 00151 00152 //- Time loop calculations 00153 virtual void calc 00154 ( 00155 const argList& args, 00156 const Time& runTime, 00157 const fvMesh& mesh 00158 ); 00159 00160 00161 // I-O 00162 00163 //- Write addSubtract field 00164 template<class Type> 00165 void writeAddSubtractField 00166 ( 00167 const IOobject& baseHeader, 00168 const IOobject& addSubtractHeader, 00169 const fvMesh& mesh, 00170 bool& processed 00171 ); 00172 00173 //- Write addSubtract value 00174 template<class Type> 00175 void writeAddSubtractValue 00176 ( 00177 const IOobject& baseHeader, 00178 const string& valueStr, 00179 const fvMesh& mesh, 00180 bool& processed 00181 ); 00182 00183 00184 public: 00185 00186 //- Runtime type information 00187 TypeName("addSubtract"); 00188 00189 00190 // Constructors 00191 00192 //- Construct null 00193 addSubtract(); 00194 00195 00196 // Destructor 00197 00198 virtual ~addSubtract(); 00199 }; 00200 00201 00202 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00203 00204 } // End namespace calcTypes 00205 } // End namespace Foam 00206 00207 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00208 00209 #ifdef NoRepository 00210 # include "writeAddSubtractField.C" 00211 # include "writeAddSubtractValue.C" 00212 #endif 00213 00214 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00215 00216 #endif 00217 00218 // ************************ vim: set sw=4 sts=4 et: ************************ //