Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
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
28template<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
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// ************************************************************************* //
Info<< nl;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edges")));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
autoPtr< singleCellFvMesh > agglomMeshPtr_
Agglomerated mesh representation.
void interpolate(GeometricField< Type, fvPatchField, volMesh > &fld, const List< List< Type > > &values) const
Interpolate field.
labelList patchIDs_
List of participating patch IDs.
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
List< label > labelList
A List of labels.
Definition List.H:62
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1, const label comm)
labelListList invertOneToMany(const label len, const labelUList &map)
Invert one-to-many map. Unmapped elements will be size 0.
Definition ListOps.C:125
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299