sampledPatchInternalFieldTemplates.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) 2011-2013 OpenFOAM Foundation
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 
27 #include "interpolationCellPoint.H"
29 
30 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
31 
32 template<class Type>
35 (
37 ) const
38 {
39  // One value per face
40  tmp<Field<Type> > tvalues(new Field<Type>(patchFaceLabels().size()));
41  Field<Type>& values = tvalues();
42 
43  forAll(patchStart(), i)
44  {
45  // Get patchface wise data by sampling internal field
46  Field<Type> interpVals = vField.internalField();
47  mappers_[i].map().distribute(interpVals);
48 
49  // Store at correct position in values
50  label end =
51  (
52  i < patchStart().size()-1
53  ? patchStart()[i+1]
54  : patchFaceLabels().size()
55  );
56 
57  for (label triI = patchStart()[i]; triI < end; triI++)
58  {
59  values[triI] = interpVals[patchFaceLabels()[triI]];
60  }
61  }
62 
63  return tvalues;
64 }
65 
66 
67 template<class Type>
70 (
71  const interpolation<Type>& interpolator
72 ) const
73 {
74  label sz = 0;
75  forAll(patchIDs(), i)
76  {
77  sz += mesh().boundaryMesh()[patchIDs()[i]].size();
78  }
79 
80  Field<Type> allPatchVals(sz);
81  sz = 0;
82 
83  forAll(patchIDs(), i)
84  {
85  // See mappedFixedValueFvPatchField
86  const mapDistribute& distMap = mappers_[i].map();
87 
88  // Send back sample points to processor that holds the cell.
89  // Mark cells with point::max so we know which ones we need
90  // to interpolate (since expensive).
91  vectorField samples(mappers_[i].samplePoints());
92  distMap.reverseDistribute(mesh().nCells(), point::max, samples);
93 
94  Field<Type> patchVals(mesh().nCells());
95 
96  forAll(samples, cellI)
97  {
98  if (samples[cellI] != point::max)
99  {
100  patchVals[cellI] = interpolator.interpolate
101  (
102  samples[cellI],
103  cellI
104  );
105  }
106  }
107 
108  distMap.distribute(patchVals);
109 
110  // Now patchVals holds the interpolated data in patch face order.
111  // Collect.
112  SubList<Type>(allPatchVals, patchVals.size(), sz).assign(patchVals);
113  sz += patchVals.size();
114  }
115 
116  // Interpolate to points. Reconstruct the patch of all faces to aid
117  // interpolation.
118 
119  labelList meshFaceLabels(allPatchVals.size());
120  sz = 0;
121  forAll(patchIDs(), i)
122  {
123  const polyPatch& pp = mesh().boundaryMesh()[patchIDs()[i]];
124  forAll(pp, i)
125  {
126  meshFaceLabels[sz++] = pp.start()+i;
127  }
128  }
129 
130  indirectPrimitivePatch allPatches
131  (
132  IndirectList<face>(mesh().faces(), meshFaceLabels),
133  mesh().points()
134  );
135 
137  (
138  allPatches
139  ).faceToPointInterpolate(allPatchVals);
140 }
141 
142 
143 // ************************************************************************* //
PrimitivePatchInterpolation.H
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::SubList
A List obtained as a section of another List.
Definition: SubList.H:53
Foam::interpolation::interpolate
virtual Type interpolate(const vector &position, const label cellI, const label faceI=-1) const =0
Interpolate field to the given point in the given cell.
interpolationCellPoint.H
Foam::Field::map
void map(const UList< Type > &mapF, const labelUList &mapAddressing)
1 to 1 map from the given field
Definition: Field.C:345
samples
scalarField samples(nIntervals, 0)
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::Field< Type >
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
Foam::mapDistribute
Class containing processor-to-processor mapping information.
Definition: mapDistribute.H:152
Foam::UList::assign
void assign(const UList< T > &)
Assign elements to those from UList.
Definition: UList.C:37
Foam::IndirectList
A List with indirect addressing.
Definition: IndirectList.H:102
Foam::GeometricField::internalField
InternalField & internalField()
Return internal field.
Definition: GeometricField.C:724
Foam::mapDistribute::distribute
void distribute(List< T > &fld, const bool dummyTransform=true, const int tag=UPstream::msgType()) const
Distribute data using default commsType.
Definition: mapDistributeTemplates.C:155
Foam::interpolation< Type >
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam::polyPatch::start
label start() const
Return start label of this patch in the polyMesh face list.
Definition: polyPatch.H:312
Foam::PrimitivePatchInterpolation::faceToPointInterpolate
tmp< Field< Type > > faceToPointInterpolate(const Field< Type > &ff) const
Interpolate from faces to points.
Definition: PrimitivePatchInterpolation.C:174
Foam::max
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
Foam::PrimitivePatchInterpolation
Interpolation class within a primitive patch. Allows interpolation from points to faces and vice vers...
Definition: PrimitivePatchInterpolation.H:51
sampledPatchInternalField.H
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::mapDistribute::reverseDistribute
void reverseDistribute(const label constructSize, List< T > &, const bool dummyTransform=true, const int tag=UPstream::msgType()) const
Reverse distribute data using default commsType.
Definition: mapDistributeTemplates.C:187
Foam::sampledPatchInternalField::sampleField
tmp< Field< Type > > sampleField(const GeometricField< Type, fvPatchField, volMesh > &vField) const
Sample field on faces.
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::sampledPatchInternalField::interpolateField
tmp< Field< Type > > interpolateField(const interpolation< Type > &) const
Foam::PrimitivePatch
A list of faces which address into the list of points.
Definition: PrimitivePatchTemplate.H:88