FreeFOAM The Cross-Platform CFD Toolkit
globalPointPatchField.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 "globalPointPatchField.H"
28 
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33 
34 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
35 
36 template<class Type>
38 (
39  const pointPatch& p,
41 )
42 :
44  globalPointPatch_(refCast<const globalPointPatch>(p))
45 {}
46 
47 
48 template<class Type>
50 (
51  const pointPatch& p,
53  const dictionary& dict
54 )
55 :
57  globalPointPatch_(refCast<const globalPointPatch>(p))
58 {
59  if (!isType<globalPointPatch>(p))
60  {
62  (
63  "globalPointPatchField<Type>::globalPointPatchField\n"
64  "(\n"
65  " const pointPatch& p,\n"
66  " const Field<Type>& field,\n"
67  " const dictionary& dict\n"
68  ")\n",
69  dict
70  ) << "patch " << this->patch().index()
71  << " not processorPoint type. "
72  << "Patch type = " << p.type()
73  << exit(FatalIOError);
74  }
75 }
76 
77 
78 template<class Type>
80 (
81  const globalPointPatchField<Type>& ptf,
82  const pointPatch& p,
84  const pointPatchFieldMapper& mapper
85 )
86 :
87  coupledPointPatchField<Type>(ptf, p, iF, mapper),
88  globalPointPatch_(refCast<const globalPointPatch>(ptf.patch()))
89 {
90  if (!isType<globalPointPatch>(this->patch()))
91  {
93  (
94  "globalPointPatchField<Type>::globalPointPatchField\n"
95  "(\n"
96  " const globalPointPatchField<Type>& ptf,\n"
97  " const pointPatch& p,\n"
98  " const DimensionedField<Type, pointMesh>& iF,\n"
99  " const pointPatchFieldMapper& mapper\n"
100  ")\n"
101  ) << "Field type does not correspond to patch type for patch "
102  << this->patch().index() << "." << endl
103  << "Field type: " << typeName << endl
104  << "Patch type: " << this->patch().type()
105  << exit(FatalError);
106  }
107 }
108 
109 
110 template<class Type>
112 (
113  const globalPointPatchField<Type>& ptf,
115 )
116 :
118  globalPointPatch_(refCast<const globalPointPatch>(ptf.patch()))
119 {}
120 
121 
122 // * * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
123 
124 template<class Type>
126 {}
127 
128 
129 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
130 
131 template<class Type>
133 {
134  // Create the global list and insert local values
135  if (globalPointPatch_.globalPointSize() > 0)
136  {
137  Field<Type> lpf = patchInternalField(pField);
138  const labelList& addr = globalPointPatch_.sharedPointAddr();
139 
140  Field<Type> gpf
141  (
142  globalPointPatch_.globalPointSize(),
144  );
145 
146  forAll(addr, i)
147  {
148  gpf[addr[i]] += lpf[i];
149  }
150 
152 
153  // Extract local data
154  forAll (addr, i)
155  {
156  lpf[i] = gpf[addr[i]];
157  }
158 
159  setInInternalField(pField, lpf);
160  }
161 }
162 
163 
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 
166 } // End namespace Foam
167 
168 // ************************ vim: set sw=4 sts=4 et: ************************ //