├── .gitignore ├── README.md ├── interpolateVolumeField ├── Make │ ├── files │ └── options └── interpolateVolumeField.C └── reconstructSurfaceField ├── Make ├── files └── options └── reconstructSurfaceField.C /.gitignore: -------------------------------------------------------------------------------- 1 | # git-ls-files --others --exclude-from=.git/info/exclude 2 | # Lines that start with '#' are comments. 3 | 4 | # editor and misc backup files - anywhere 5 | *~ 6 | .*~ 7 | *.bak 8 | *.bak[0-9][0-9] 9 | *.orig 10 | *.orig[0-9][0-9] 11 | \#*\# 12 | 13 | # file-browser settings - anywhere 14 | .directory 15 | 16 | # CVS recovered versions - anywhere 17 | .#* 18 | 19 | # objects and archives - anywhere 20 | *.[oa] 21 | *.la 22 | *.so 23 | *.jar 24 | 25 | # derived files 26 | lex.yy.c 27 | 28 | # Corefiles 29 | core 30 | 31 | # dependency files - anywhere 32 | *.dep 33 | 34 | # lnInclude (symlink) folders - anywhere 35 | lnInclude 36 | 37 | # build folders - anywhere 38 | linux*Clang*/ 39 | linux*Gcc*/ 40 | linux*Icc*/ 41 | linuxming*/ 42 | SiCortex*Gcc*/ 43 | solaris*Gcc*/ 44 | SunOS*Gcc*/ 45 | platforms/ 46 | 47 | # reinstate wmake/rules that might look like build folders 48 | !wmake/rules/*/ 49 | 50 | # doxygen generated documentation 51 | doc/Doxygen/html 52 | doc/Doxygen/latex 53 | doc/Doxygen/man 54 | doc/Doxygen/DTAGS 55 | 56 | # generated files in the main directory (e.g. ReleaseNotes-?.?.html) 57 | # and in the doc directory 58 | /*.html 59 | /doc/*.html 60 | 61 | # untracked configuration files 62 | /etc/prefs.csh 63 | /etc/prefs.sh 64 | /etc/config/prefs.csh 65 | /etc/config/prefs.sh 66 | 67 | # source packages - anywhere 68 | *.tar.bz2 69 | *.tar.gz 70 | *.tar 71 | *.tgz 72 | *.gtgz 73 | 74 | # ignore the persistent .build tag in the main directory 75 | /.build 76 | 77 | # ignore .timeStamp in the main directory 78 | /.timeStamp 79 | 80 | # ignore .tags in the main directory 81 | /.tags 82 | 83 | # ignore eclipse project files in the main directory 84 | /.cproject 85 | /.project 86 | 87 | # end-of-file 88 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | reconstruct-interpolate-fields 2 | ============================== 3 | 4 | Utilities designed for OpenFOAM, for reconstructing and interpolating fields at the post-processing stage. 5 | 6 | Requirements: 7 | * [OpenFOAM](http://www.openfoam.org) 8 | * Git (actually, this one is optional) 9 | 10 | How to get and build: 11 | ``` 12 | git clone git://github.com/wyldckat/reconstruct-interpolate-fields.git 13 | cd reconstruct-interpolate-fields 14 | wmake all 15 | ``` 16 | 17 | If you don't have Git installed, you can use the ZIP option shown in the project page: https://github.com/wyldckat/reconstruct-interpolate-fields 18 | 19 | For logistical reasons, more instructions are available here: https://github.com/wyldckat/reconstruct-interpolate-fields/wiki 20 | 21 | This [git repository](https://github.com/wyldckat/reconstruct-interpolate-fields) was brought to you by Bruno Santos (wyldckat@github working at [blueCAPE Lda](http://www.bluecape.com.pt)). 22 | 23 | License 24 | ======= 25 | 26 | This is bound to the same license as OpenFOAM, namely GPLv3. Which means that you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 27 | See http://www.gnu.org/licenses/ for more information about GPL. 28 | -------------------------------------------------------------------------------- /interpolateVolumeField/Make/files: -------------------------------------------------------------------------------- 1 | interpolateVolumeField.C 2 | 3 | EXE = $(FOAM_USER_APPBIN)/interpolateVolumeField 4 | -------------------------------------------------------------------------------- /interpolateVolumeField/Make/options: -------------------------------------------------------------------------------- 1 | EXE_INC = \ 2 | -I$(LIB_SRC)/finiteVolume/lnInclude 3 | 4 | EXE_LIBS = \ 5 | -lfiniteVolume 6 | -------------------------------------------------------------------------------- /interpolateVolumeField/interpolateVolumeField.C: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------* \ 2 | License 3 | This file is designed to work with OpenFOAM. 4 | 5 | OpenFOAM is free software: you can redistribute it and/or modify it 6 | under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 11 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with OpenFOAM. If not, see . 17 | 18 | Application 19 | interpolateVolumeField 20 | 21 | Description 22 | Interpolate vol*Field to surface*Field. 23 | 24 | Author 25 | wyldckat@github 26 | 27 | \*---------------------------------------------------------------------------*/ 28 | 29 | #include "fvCFD.H" 30 | #include "OSspecific.H" 31 | 32 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 33 | // Main program: 34 | 35 | int main(int argc, char *argv[]) 36 | { 37 | 38 | timeSelector::addOptions(); 39 | 40 | argList::addNote 41 | ( 42 | "Interpolate vol*Field to surface*Field." 43 | ); 44 | argList::addOption 45 | ( 46 | "scalar", 47 | "volumeScalarField", 48 | "the name of the volumeScalarField" 49 | ); 50 | argList::addOption 51 | ( 52 | "vector", 53 | "volumeVectorField", 54 | "the name of the volumeVectorField" 55 | ); 56 | argList::validArgs.append 57 | ( 58 | "outputSurface*Field" 59 | ); 60 | # include "addRegionOption.H" 61 | 62 | # include "setRootCase.H" 63 | # include "createTime.H" 64 | 65 | const fileName surfFieldName = args[1]; 66 | 67 | fileName scalarFieldName, vectorFieldName; 68 | bool scalarBool = args.optionReadIfPresent("scalar", scalarFieldName); 69 | bool vectorBool = args.optionReadIfPresent("vector", vectorFieldName); 70 | 71 | if(scalarBool && vectorBool) 72 | { 73 | FatalErrorIn(args.executable()) 74 | << "Pick only one type of volume field, either scalar or vector, not both." 75 | << exit(FatalError); 76 | } 77 | else if(!scalarBool && !vectorBool) 78 | { 79 | FatalErrorIn(args.executable()) 80 | << "Pick one type of volume field, -scalar or -vector." 81 | << exit(FatalError); 82 | } 83 | 84 | if(scalarBool) 85 | { 86 | if (scalarFieldName == surfFieldName) 87 | { 88 | FatalErrorIn(args.executable()) 89 | << "Volume field cannot have the same name as the surface field." 90 | << exit(FatalError); 91 | } 92 | } 93 | else if(vectorBool) 94 | { 95 | if (vectorFieldName == surfFieldName) 96 | { 97 | FatalErrorIn(args.executable()) 98 | << "Volume field cannot have the same name as the surface field." 99 | << exit(FatalError); 100 | } 101 | } 102 | 103 | instantList timeDirs = timeSelector::select0(runTime, args); 104 | 105 | # include "createNamedMesh.H" 106 | 107 | forAll(timeDirs, timeI) 108 | { 109 | runTime.setTime(timeDirs[timeI], timeI); 110 | 111 | Info<< nl << "Time: " << runTime.timeName() << endl; 112 | 113 | mesh.readUpdate(); 114 | 115 | if(scalarBool) 116 | { 117 | Info<< nl << "Reading volume scalar field " << scalarFieldName << endl; 118 | 119 | volScalarField volScaField 120 | ( 121 | IOobject 122 | ( 123 | scalarFieldName, 124 | runTime.timeName(), 125 | mesh, 126 | IOobject::MUST_READ, 127 | IOobject::NO_WRITE 128 | ), 129 | mesh 130 | ); 131 | 132 | surfaceScalarField surfScaField 133 | ( 134 | IOobject 135 | ( 136 | surfFieldName, 137 | runTime.timeName(), 138 | mesh, 139 | IOobject::NO_READ, 140 | IOobject::NO_WRITE 141 | ), 142 | fvc::interpolate(volScaField) 143 | ); 144 | 145 | Info<< nl << "Write surface scalar field " << surfFieldName << endl; 146 | 147 | surfScaField.write(); 148 | } 149 | else if(vectorBool) 150 | { 151 | Info<< nl << "Reading volume field " << vectorFieldName << endl; 152 | 153 | volVectorField volVecField 154 | ( 155 | IOobject 156 | ( 157 | vectorFieldName, 158 | runTime.timeName(), 159 | mesh, 160 | IOobject::MUST_READ, 161 | IOobject::NO_WRITE 162 | ), 163 | mesh 164 | ); 165 | 166 | surfaceVectorField surfVectorField 167 | ( 168 | IOobject 169 | ( 170 | surfFieldName, 171 | runTime.timeName(), 172 | mesh, 173 | IOobject::NO_READ, 174 | IOobject::NO_WRITE 175 | ), 176 | fvc::interpolate(volVecField) 177 | ); 178 | 179 | Info<< nl << "Write surface vector field " << surfFieldName << endl; 180 | 181 | surfVectorField.write(); 182 | } 183 | } 184 | 185 | Info<< "\nEnd\n" << endl; 186 | 187 | return 0; 188 | } 189 | 190 | 191 | // ************************************************************************* // 192 | -------------------------------------------------------------------------------- /reconstructSurfaceField/Make/files: -------------------------------------------------------------------------------- 1 | reconstructSurfaceField.C 2 | 3 | EXE = $(FOAM_USER_APPBIN)/reconstructSurfaceField 4 | -------------------------------------------------------------------------------- /reconstructSurfaceField/Make/options: -------------------------------------------------------------------------------- 1 | EXE_INC = \ 2 | -I$(LIB_SRC)/finiteVolume/lnInclude 3 | 4 | EXE_LIBS = \ 5 | -lfiniteVolume 6 | -------------------------------------------------------------------------------- /reconstructSurfaceField/reconstructSurfaceField.C: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------* \ 2 | License 3 | This file is designed to work with OpenFOAM. 4 | 5 | OpenFOAM is free software: you can redistribute it and/or modify it 6 | under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 11 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with OpenFOAM. If not, see . 17 | 18 | Application 19 | reconstructSurfaceField 20 | 21 | Description 22 | Reconstruct surfaceScalarField to volVectorField or surfaceVectorField 23 | to volTensorField. 24 | 25 | Author 26 | wyldckat@github 27 | 28 | \*---------------------------------------------------------------------------*/ 29 | 30 | #include "fvCFD.H" 31 | #include "OSspecific.H" 32 | 33 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 34 | // Main program: 35 | 36 | int main(int argc, char *argv[]) 37 | { 38 | 39 | timeSelector::addOptions(); 40 | 41 | argList::addNote 42 | ( 43 | "Reconstruct surfaceScalarField to volVectorField or surfaceVectorField to volTensorField." 44 | ); 45 | argList::addOption 46 | ( 47 | "scalar", 48 | "surfaceScalarField", 49 | "the name of the surfaceScalarField" 50 | ); 51 | argList::addOption 52 | ( 53 | "vector", 54 | "surfaceVectorField", 55 | "the name of the surfaceVectorField" 56 | ); 57 | argList::validArgs.append 58 | ( 59 | "outputVol*Field" 60 | ); 61 | # include "addRegionOption.H" 62 | 63 | # include "setRootCase.H" 64 | # include "createTime.H" 65 | 66 | const fileName volFieldName = args[1]; 67 | 68 | fileName scalarFieldName, vectorFieldName; 69 | bool scalarBool = args.optionReadIfPresent("scalar", scalarFieldName); 70 | bool vectorBool = args.optionReadIfPresent("vector", vectorFieldName); 71 | 72 | if(scalarBool && vectorBool) 73 | { 74 | FatalErrorIn(args.executable()) 75 | << "Pick only one type of surface field, either scalar or vector, not both." 76 | << exit(FatalError); 77 | } 78 | else if(!scalarBool && !vectorBool) 79 | { 80 | FatalErrorIn(args.executable()) 81 | << "Pick one type of surface field, -scalar or -vector." 82 | << exit(FatalError); 83 | } 84 | 85 | if(scalarBool) 86 | { 87 | if (scalarFieldName == volFieldName) 88 | { 89 | FatalErrorIn(args.executable()) 90 | << "Volume field cannot have the same name as the surface field." 91 | << exit(FatalError); 92 | } 93 | } 94 | else if(vectorBool) 95 | { 96 | if (vectorFieldName == volFieldName) 97 | { 98 | FatalErrorIn(args.executable()) 99 | << "Volume field cannot have the same name as the surface field." 100 | << exit(FatalError); 101 | } 102 | } 103 | 104 | instantList timeDirs = timeSelector::select0(runTime, args); 105 | 106 | # include "createNamedMesh.H" 107 | 108 | forAll(timeDirs, timeI) 109 | { 110 | runTime.setTime(timeDirs[timeI], timeI); 111 | 112 | Info<< nl << "Time: " << runTime.timeName() << endl; 113 | 114 | mesh.readUpdate(); 115 | 116 | if(scalarBool) 117 | { 118 | Info<< nl << "Reading surface scalar field " << scalarFieldName << endl; 119 | 120 | surfaceScalarField surfScaField 121 | ( 122 | IOobject 123 | ( 124 | scalarFieldName, 125 | runTime.timeName(), 126 | mesh, 127 | IOobject::MUST_READ, 128 | IOobject::NO_WRITE 129 | ), 130 | mesh 131 | ); 132 | 133 | volVectorField volVecField 134 | ( 135 | IOobject 136 | ( 137 | volFieldName, 138 | runTime.timeName(), 139 | mesh, 140 | IOobject::NO_READ, 141 | IOobject::NO_WRITE 142 | ), 143 | fvc::reconstruct(surfScaField) 144 | ); 145 | 146 | Info<< nl << "Write volume vector field " << volFieldName << endl; 147 | 148 | volVecField.write(); 149 | } 150 | else if(vectorBool) 151 | { 152 | Info<< nl << "Reading field " << vectorFieldName << endl; 153 | 154 | surfaceVectorField surfVecField 155 | ( 156 | IOobject 157 | ( 158 | vectorFieldName, 159 | runTime.timeName(), 160 | mesh, 161 | IOobject::MUST_READ, 162 | IOobject::NO_WRITE 163 | ), 164 | mesh 165 | ); 166 | 167 | volTensorField volTenField 168 | ( 169 | IOobject 170 | ( 171 | volFieldName, 172 | runTime.timeName(), 173 | mesh, 174 | IOobject::NO_READ, 175 | IOobject::NO_WRITE 176 | ), 177 | fvc::reconstruct(surfVecField) 178 | ); 179 | 180 | Info<< nl << "Write volume tensor field " << volFieldName << endl; 181 | 182 | volTenField.write(); 183 | } 184 | } 185 | 186 | Info<< "\nEnd\n" << endl; 187 | 188 | return 0; 189 | } 190 | 191 | 192 | // ************************************************************************* // 193 | --------------------------------------------------------------------------------