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

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