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

pointFieldDecomposerDecomposeFields.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 "pointFieldDecomposer.H"
00028 #include "processorPointPatchFields.H"
00029 #include "globalPointPatchFields.H"
00030 
00031 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00032 
00033 namespace Foam
00034 {
00035 
00036 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00037 
00038 template<class Type>
00039 tmp<GeometricField<Type, pointPatchField, pointMesh> >
00040 pointFieldDecomposer::decomposeField
00041 (
00042     const GeometricField<Type, pointPatchField, pointMesh>& field
00043 ) const
00044 {
00045     // Create and map the internal field values
00046     Field<Type> internalField(field.internalField(), pointAddressing_);
00047 
00048     // Create a list of pointers for the patchFields including one extra
00049     // for the global patch
00050     PtrList<pointPatchField<Type> > patchFields
00051     (
00052         boundaryAddressing_.size() + 1
00053     );
00054 
00055     // Create and map the patch field values
00056     forAll (boundaryAddressing_, patchi)
00057     {
00058         if (patchFieldDecomposerPtrs_[patchi])
00059         {
00060             patchFields.set
00061             (
00062                 patchi,
00063                 pointPatchField<Type>::New
00064                 (
00065                     field.boundaryField()[boundaryAddressing_[patchi]],
00066                     procMesh_.boundary()[patchi],
00067                     DimensionedField<Type, pointMesh>::null(),
00068                     *patchFieldDecomposerPtrs_[patchi]
00069                 )
00070             );
00071         }
00072         else
00073         {
00074             patchFields.set
00075             (
00076                 patchi,
00077                 new processorPointPatchField<Type>
00078                 (
00079                     procMesh_.boundary()[patchi],
00080                     DimensionedField<Type, pointMesh>::null()
00081                 )
00082             );
00083         }
00084     }
00085 
00086     // Add the global patch
00087     patchFields.set
00088     (
00089         boundaryAddressing_.size(),
00090         new globalPointPatchField<Type>
00091         (
00092             procMesh_.boundary().globalPatch(),
00093             DimensionedField<Type, pointMesh>::null()
00094         )
00095     );
00096 
00097     // Create the field for the processor
00098     return tmp<GeometricField<Type, pointPatchField, pointMesh> >
00099     (
00100         new GeometricField<Type, pointPatchField, pointMesh>
00101         (
00102             IOobject
00103             (
00104                 field.name(),
00105                 procMesh_().time().timeName(),
00106                 procMesh_(),
00107                 IOobject::NO_READ,
00108                 IOobject::NO_WRITE
00109             ),
00110             procMesh_,
00111             field.dimensions(),
00112             internalField,
00113             patchFields
00114         )
00115     );
00116 }
00117 
00118 
00119 template<class GeoField>
00120 void pointFieldDecomposer::decomposeFields
00121 (
00122     const PtrList<GeoField>& fields
00123 ) const
00124 {
00125     forAll (fields, fieldI)
00126     {
00127         decomposeField(fields[fieldI])().write();
00128     }
00129 }
00130 
00131 
00132 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00133 
00134 } // End namespace Foam
00135 
00136 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd