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

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