FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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