OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

writeFunsTemplates.C

Go 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) 1991-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 Description
00026 
00027 \*---------------------------------------------------------------------------*/
00028 
00029 #include "writeFuns.H"
00030 #include "interpolatePointToCell.H"
00031 
00032 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00033 
00034 // Store List in dest
00035 template<class Type>
00036 void Foam::writeFuns::insert
00037 (
00038     const List<Type>& source,
00039     DynamicList<floatScalar>& dest
00040 )
00041 {
00042     forAll(source, i)
00043     {
00044         insert(source[i], dest);
00045     }
00046 }
00047 
00048 
00050 //template<class Type>
00051 //void Foam::writeFuns::insert
00052 //(
00053 //    const labelList& map,
00054 //    const List<Type>& source,
00055 //    DynamicList<floatScalar>& dest
00056 //)
00057 //{
00058 //    forAll(map, i)
00059 //    {
00060 //        insert(source[map[i]], dest);
00061 //    }
00062 //}
00063 
00064 
00065 template<class Type>
00066 void Foam::writeFuns::write
00067 (
00068     std::ostream& os,
00069     const bool binary,
00070     const GeometricField<Type, fvPatchField, volMesh>& vvf,
00071     const vtkMesh& vMesh
00072 )
00073 {
00074     const fvMesh& mesh = vMesh.mesh();
00075 
00076     const labelList& superCells = vMesh.topo().superCells();
00077 
00078     label nValues = mesh.nCells() + superCells.size();
00079 
00080     os  << vvf.name() << ' ' << pTraits<Type>::nComponents << ' '
00081         << nValues << " float" << std::endl;
00082 
00083     DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nValues);
00084 
00085     insert(vvf.internalField(), fField);
00086 
00087     forAll(superCells, superCellI)
00088     {
00089         label origCellI = superCells[superCellI];
00090 
00091         insert(vvf[origCellI], fField);
00092     }
00093     write(os, binary, fField);
00094 }
00095 
00096 
00097 template<class Type>
00098 void Foam::writeFuns::write
00099 (
00100     std::ostream& os,
00101     const bool binary,
00102     const GeometricField<Type, pointPatchField, pointMesh>& pvf,
00103     const vtkMesh& vMesh
00104 )
00105 {
00106     const fvMesh& mesh = vMesh.mesh();
00107     const vtkTopo& topo = vMesh.topo();
00108 
00109     const labelList& addPointCellLabels = topo.addPointCellLabels();
00110     const label nTotPoints = mesh.nPoints() + addPointCellLabels.size();
00111 
00112     os  << pvf.name() << ' ' << pTraits<Type>::nComponents << ' '
00113         << nTotPoints << " float" << std::endl;
00114 
00115     DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nTotPoints);
00116 
00117     insert(pvf, fField);
00118 
00119     forAll(addPointCellLabels, api)
00120     {
00121         label origCellI = addPointCellLabels[api];
00122 
00123         insert(interpolatePointToCell(pvf, origCellI), fField);
00124     }
00125     write(os, binary, fField);
00126 }
00127 
00128 
00129 template<class Type>
00130 void Foam::writeFuns::write
00131 (
00132     std::ostream& os,
00133     const bool binary,
00134     const GeometricField<Type, fvPatchField, volMesh>& vvf,
00135     const GeometricField<Type, pointPatchField, pointMesh>& pvf,
00136     const vtkMesh& vMesh
00137 )
00138 {
00139     const fvMesh& mesh = vMesh.mesh();
00140     const vtkTopo& topo = vMesh.topo();
00141 
00142     const labelList& addPointCellLabels = topo.addPointCellLabels();
00143     const label nTotPoints = mesh.nPoints() + addPointCellLabels.size();
00144 
00145     os  << vvf.name() << ' ' << pTraits<Type>::nComponents << ' '
00146         << nTotPoints << " float" << std::endl;
00147 
00148     DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nTotPoints);
00149 
00150     insert(pvf, fField);
00151 
00152     forAll(addPointCellLabels, api)
00153     {
00154         label origCellI = addPointCellLabels[api];
00155 
00156         insert(vvf[origCellI], fField);
00157     }
00158     write(os, binary, fField);
00159 }
00160 
00161 
00162 template<class Type, template<class> class PatchField, class GeoMesh>
00163 void Foam::writeFuns::write
00164 (
00165     std::ostream& os,
00166     const bool binary,
00167     const PtrList<GeometricField<Type, PatchField, GeoMesh> >& flds,
00168     const vtkMesh& vMesh
00169 )
00170 {
00171     forAll(flds, i)
00172     {
00173         write(os, binary, flds[i], vMesh);
00174     }
00175 }
00176 
00177 
00178 template<class Type>
00179 void Foam::writeFuns::write
00180 (
00181     std::ostream& os,
00182     const bool binary,
00183     const volPointInterpolation& pInterp,
00184     const PtrList<GeometricField<Type, fvPatchField, volMesh> >& flds,
00185     const vtkMesh& vMesh
00186 )
00187 {
00188     forAll(flds, i)
00189     {
00190         write(os, binary, flds[i], pInterp.interpolate(flds[i])(), vMesh);
00191     }
00192 }
00193 
00194 
00195 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd