FreeFOAM The Cross-Platform CFD Toolkit
pointFieldDecomposerDecomposeFields.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "pointFieldDecomposer.H"
29 
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 
35 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
36 
37 template<class Type>
38 tmp<GeometricField<Type, pointPatchField, pointMesh> >
40 (
41  const GeometricField<Type, pointPatchField, pointMesh>& field
42 ) const
43 {
44  // Create and map the internal field values
45  Field<Type> internalField(field.internalField(), pointAddressing_);
46 
47  // Create a list of pointers for the patchFields including one extra
48  // for the global patch
49  PtrList<pointPatchField<Type> > patchFields
50  (
51  boundaryAddressing_.size() + 1
52  );
53 
54  // Create and map the patch field values
55  forAll (boundaryAddressing_, patchi)
56  {
57  if (patchFieldDecomposerPtrs_[patchi])
58  {
59  patchFields.set
60  (
61  patchi,
62  pointPatchField<Type>::New
63  (
64  field.boundaryField()[boundaryAddressing_[patchi]],
65  procMesh_.boundary()[patchi],
67  *patchFieldDecomposerPtrs_[patchi]
68  )
69  );
70  }
71  else
72  {
73  patchFields.set
74  (
75  patchi,
76  new processorPointPatchField<Type>
77  (
78  procMesh_.boundary()[patchi],
80  )
81  );
82  }
83  }
84 
85  // Add the global patch
86  patchFields.set
87  (
88  boundaryAddressing_.size(),
89  new globalPointPatchField<Type>
90  (
91  procMesh_.boundary().globalPatch(),
93  )
94  );
95 
96  // Create the field for the processor
97  return tmp<GeometricField<Type, pointPatchField, pointMesh> >
98  (
99  new GeometricField<Type, pointPatchField, pointMesh>
100  (
101  IOobject
102  (
103  field.name(),
104  procMesh_().time().timeName(),
105  procMesh_(),
108  ),
109  procMesh_,
110  field.dimensions(),
111  internalField,
112  patchFields
113  )
114  );
115 }
116 
117 
118 template<class GeoField>
120 (
121  const PtrList<GeoField>& fields
122 ) const
123 {
124  forAll (fields, fieldI)
125  {
126  decomposeField(fields[fieldI])().write();
127  }
128 }
129 
130 
131 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
132 
133 } // End namespace Foam
134 
135 // ************************ vim: set sw=4 sts=4 et: ************************ //