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

lagrangianFieldDecomposerDecomposeFields.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 "lagrangianFieldDecomposer.H"
00027 #include <OpenFOAM/IOobjectList.H>
00028 
00029 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00030 
00031 namespace Foam
00032 {
00033 
00034 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00035 
00036 template<class Type>
00037 void lagrangianFieldDecomposer::readFields
00038 (
00039     const label cloudI,
00040     const IOobjectList& lagrangianObjects,
00041     PtrList<PtrList<IOField<Type> > >& lagrangianFields
00042 )
00043 {
00044     // Search list of objects for lagrangian fields
00045     IOobjectList lagrangianTypeObjects
00046     (
00047         lagrangianObjects.lookupClass(IOField<Type>::typeName)
00048     );
00049 
00050     lagrangianFields.set
00051     (
00052         cloudI,
00053         new PtrList<IOField<Type> >
00054         (
00055             lagrangianTypeObjects.size()
00056         )
00057     );
00058 
00059     label lagrangianFieldi=0;
00060     forAllIter(IOobjectList, lagrangianTypeObjects, iter)
00061     {
00062         lagrangianFields[cloudI].set
00063         (
00064             lagrangianFieldi++,
00065             new IOField<Type>(*iter())
00066         );
00067     }
00068 }
00069 
00070 
00071 template<class Type>
00072 tmp<IOField<Type> > lagrangianFieldDecomposer::decomposeField
00073 (
00074     const word& cloudName,
00075     const IOField<Type>& field
00076 ) const
00077 {
00078     // Create and map the internal field values
00079     Field<Type> procField(field, particleIndices_);
00080 
00081     // Create the field for the processor
00082     return tmp<IOField<Type> >
00083     (
00084         new IOField<Type>
00085         (
00086             IOobject
00087             (
00088                 field.name(),
00089                 procMesh_.time().timeName(),
00090                 cloud::prefix/cloudName,
00091                 procMesh_,
00092                 IOobject::NO_READ,
00093                 IOobject::NO_WRITE
00094             ),
00095             procField
00096         )
00097     );
00098 }
00099 
00100 
00101 template<class GeoField>
00102 void lagrangianFieldDecomposer::decomposeFields
00103 (
00104     const word& cloudName,
00105     const PtrList<GeoField>& fields
00106 ) const
00107 {
00108     if (particleIndices_.size())
00109     {
00110         forAll (fields, fieldI)
00111         {
00112             decomposeField(cloudName, fields[fieldI])().write();
00113         }
00114     }
00115 }
00116 
00117 
00118 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00119 
00120 } // End namespace Foam
00121 
00122 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines