raySearchEngineTemplates.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) 2023-2024 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
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 template<class Type>
30 (
31  GeometricField<Type, fvPatchField, volMesh>& fld,
32  const List<List<Type>>& values
33 ) const
34 {
35  label compacti = 0;
36 
37  auto& vfbf = fld.boundaryFieldRef();
38 
39  if (agglomMeshPtr_)
40  {
41  const auto& coarseMesh = agglomMeshPtr_();
42  const auto& finalAgglom = coarseMesh.patchFaceAgglomeration();
43 
44  for (const label patchi : patchIDs_)
45  {
46  const labelList& agglom = finalAgglom[patchi];
47 
48  if (agglom.empty()) continue;
49 
50  label nAgglom = max(agglom) + 1;
51  const labelListList coarseToFine(invertOneToMany(nAgglom, agglom));
52  const labelList& coarsePatchFace =
53  coarseMesh.patchFaceMap()[patchi];
54 
55  forAll(coarseToFine, i)
56  {
57  const label coarseFacei = coarsePatchFace[i];
58  const labelList& fineFaces = coarseToFine[coarseFacei];
59  const Type sumValues = sum(values[compacti]);
60 
61  for (const label fineFacei : fineFaces)
62  {
63  vfbf[patchi][fineFacei] = sumValues;
64  }
65 
66  ++compacti;
67  }
68  }
69  }
70  else
71  {
72  label compacti = 0;
73  for (const label patchi : patchIDs_)
74  {
75  auto& vfp = vfbf[patchi];
76 
77  for (Type& vfi : vfp)
78  {
79  vfi = sum(values[compacti++]);
80  }
81  }
82  }
83 }
84 
85 
86 // ************************************************************************* //
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1)
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:40
List< labelList > labelListList
List of labelList.
Definition: labelList.H:38
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
Definition: HashOps.H:164
void interpolate(GeometricField< Type, fvPatchField, volMesh > &fld, const List< List< Type >> &values) const
Interpolate field.
labelListList invertOneToMany(const label len, const labelUList &map)
Invert one-to-many map. Unmapped elements will be size 0.
Definition: ListOps.C:126
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
autoPtr< singleCellFvMesh > agglomMeshPtr_
Agglomerated mesh representation.
List< label > labelList
A List of labels.
Definition: List.H:62
labelList patchIDs_
List of participating patch IDs.