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

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