singleCellFvMeshInterpolate.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 | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2016 OpenFOAM Foundation
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26\*---------------------------------------------------------------------------*/
27
28#include "singleCellFvMesh.H"
31#include "Time.H"
32
33// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34
35namespace Foam
36{
37
38// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
39
40template<class Type>
42(
44) const
45{
46 // 1. Create the complete field with dummy patch fields
48
49 forAll(patchFields, patchi)
50 {
51 patchFields.set
52 (
53 patchi,
55 (
57 boundary()[patchi],
59 )
60 );
61 }
62
63 // Create the complete field from the pieces
65 (
67 (
69 (
70 vf.name(),
71 time().timeName(),
72 *this,
75 ),
76 *this,
77 vf.dimensions(),
78 Field<Type>(1, gAverage(vf)),
79 patchFields
80 )
81 );
83
84
85 // 2. Change the fvPatchFields to the correct type using a mapper
86 // constructor (with reference to the now correct internal field)
87
89 Boundary& bf = resF.boundaryFieldRef();
90
91 if (agglomerate())
92 {
93 forAll(vf.boundaryField(), patchi)
94 {
95 const labelList& agglom = patchFaceAgglomeration_[patchi];
96 label nAgglom = max(agglom)+1;
97
98 // Use inverse of agglomeration. This is from agglomeration to
99 // original (fine) mesh patch face.
100 labelListList coarseToFine(invertOneToMany(nAgglom, agglom));
101 inplaceReorder(patchFaceMap_[patchi], coarseToFine);
102 scalarListList coarseWeights(nAgglom);
103 forAll(coarseToFine, coarseI)
104 {
105 const labelList& fineFaces = coarseToFine[coarseI];
106 coarseWeights[coarseI] = scalarList
107 (
108 fineFaces.size(),
109 1.0/fineFaces.size()
110 );
111 }
112
113 bf.set
114 (
115 patchi,
117 (
118 vf.boundaryField()[patchi],
119 boundary()[patchi],
120 resF(),
121 agglomPatchFieldMapper(coarseToFine, coarseWeights)
122 )
123 );
124 }
125 }
126 else
127 {
128 forAll(vf.boundaryField(), patchi)
129 {
130 labelList map(identity(vf.boundaryField()[patchi].size()));
131
132 bf.set
133 (
134 patchi,
136 (
137 vf.boundaryField()[patchi],
138 boundary()[patchi],
139 resF(),
141 )
142 );
143 }
144 }
145
146 return tresF;
147}
148
149
150// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
151
152} // End namespace Foam
153
154// ************************************************************************* //
const dimensionSet & dimensions() const
Return dimensions.
Generic templated field type.
Definition: Field.H:82
Generic GeometricField class.
Boundary & boundaryFieldRef(const bool updateAccessTime=true)
Return a reference to the boundary field.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
const word & name() const noexcept
Return the object name.
Definition: IOobjectI.H:65
std::enable_if< std::is_same< bool, TypeT >::value, bool >::type set(const label i, bool val=true)
A bitSet::set() method for a list of bool.
Definition: List.H:330
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: PtrList.H:73
const T * set(const label i) const
Definition: PtrList.H:138
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
label size() const noexcept
The number of elements in the list.
Definition: UPtrListI.H:106
This boundary condition is not designed to be evaluated; it is assmued that the value is assigned via...
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
Definition: fvMesh.C:712
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:290
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:82
bool interpolate() const noexcept
Same as isPointData()
Patch field mapper class for agglomerated meshes.
A class for managing temporary objects.
Definition: tmp.H:65
T & ref() const
Definition: tmpI.H:227
word timeName
Definition: getTimeIndex.H:3
Namespace for OpenFOAM.
DirectFieldMapper< fvPatchFieldMapper > directFvPatchFieldMapper
A fvPatchFieldMapper with direct mapping.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i)
Definition: labelList.C:38
List< scalar > scalarList
A List of scalars.
Definition: scalarList.H:64
void inplaceReorder(const labelUList &oldToNew, ListType &input, const bool prune=false)
Inplace reorder the elements of a list.
Type gAverage(const FieldField< Field, Type > &f)
labelListList invertOneToMany(const label len, const labelUList &map)
Invert one-to-many map. Unmapped elements will be size 0.
Definition: ListOps.C:114
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333