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

patchWriterTemplates.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 \*---------------------------------------------------------------------------*/
00025 
00026 #include "patchWriter.H"
00027 #include "writeFuns.H"
00028 
00029 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00030 
00031 template<class Type>
00032 void Foam::patchWriter::write
00033 (
00034     const PtrList<GeometricField<Type, fvPatchField, volMesh> >& flds
00035 )
00036 {
00037     forAll(flds, fieldI)
00038     {
00039         const GeometricField<Type, fvPatchField, volMesh>& fld = flds[fieldI];
00040 
00041         os_ << fld.name() << ' ' << pTraits<Type>::nComponents << ' '
00042             << nFaces_ << " float" << std::endl;
00043 
00044         DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nFaces_);
00045 
00046         forAll(patchIDs_, j)
00047         {
00048             label patchI = patchIDs_[j];
00049 
00050             const fvPatchField<Type>& pfld = fld.boundaryField()[patchI];
00051 
00052             if (nearCellValue_)
00053             {
00054                 writeFuns::insert(pfld.patchInternalField()(), fField);
00055             }
00056             else
00057             {
00058                 writeFuns::insert(pfld, fField);
00059             }
00060         }
00061         writeFuns::write(os_, binary_, fField);
00062     }
00063 }
00064 
00065 
00066 template<class Type>
00067 void Foam::patchWriter::write
00068 (
00069     const PtrList<GeometricField<Type, pointPatchField, pointMesh> >& flds
00070 )
00071 {
00072     forAll(flds, fieldI)
00073     {
00074         const GeometricField<Type, pointPatchField, pointMesh>& fld =
00075             flds[fieldI];
00076 
00077         os_ << fld.name() << ' ' << pTraits<Type>::nComponents << ' '
00078             << nPoints_ << " float" << std::endl;
00079 
00080         DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nPoints_);
00081 
00082         forAll(patchIDs_, j)
00083         {
00084             label patchI = patchIDs_[j];
00085 
00086             const pointPatchField<Type>& pfld = fld.boundaryField()[patchI];
00087 
00088             writeFuns::insert(pfld.patchInternalField()(), fField);
00089         }
00090         writeFuns::write(os_, binary_, fField);
00091     }
00092 }
00093 
00094 
00095 template<class Type>
00096 void Foam::patchWriter::write
00097 (
00098     const PrimitivePatchInterpolation<primitivePatch>& pInter,
00099     const PtrList<GeometricField<Type, fvPatchField, volMesh> >& flds
00100 )
00101 {
00102     forAll(flds, fieldI)
00103     {
00104         const GeometricField<Type, fvPatchField, volMesh>& fld = flds[fieldI];
00105 
00106         os_ << fld.name() << ' ' << pTraits<Type>::nComponents << ' '
00107             << nPoints_ << " float" << std::endl;
00108 
00109         DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nPoints_);
00110 
00111         forAll(patchIDs_, j)
00112         {
00113             label patchI = patchIDs_[j];
00114 
00115             const fvPatchField<Type>& pfld = fld.boundaryField()[patchI];
00116 
00117             if (nearCellValue_)
00118             {
00119                 writeFuns::insert
00120                 (
00121                     pInter.faceToPointInterpolate
00122                     (
00123                         pfld.patchInternalField()()
00124                     )(),
00125                     fField
00126                 );
00127             }
00128             else
00129             {
00130                 writeFuns::insert
00131                 (
00132                     pInter.faceToPointInterpolate(pfld)(),
00133                     fField
00134                 );
00135             }
00136         }
00137         writeFuns::write(os_, binary_, fField);
00138     }
00139 }
00140 
00141 
00142 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines