faMeshToolsTemplates.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) 2022 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
28#include "edgeFields.H"
29
30// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
31
32template<class Type>
34(
36 const bool primitiveOrdering
37)
38{
39 const faMesh& mesh = fld.mesh();
40
41 auto tresult = tmp<Field<Type>>::New(mesh.nEdges(), Zero);
42 auto& result = tresult.ref();
43
44 // Internal field
45 result.slice(0, fld.size()) = fld.primitiveField();
46
47 label start = fld.size();
48
49 // Boundary fields
50 forAll(fld.boundaryField(), patchi)
51 {
52 const labelList& edgeLabels = mesh.boundary()[patchi].edgeLabels();
53 const label len = edgeLabels.size();
54 const auto& pfld = fld.boundaryField()[patchi];
55
56 // Only assign when field size matches underlying patch size
57 // ie, skip 'empty' patches etc
58
59 if (len == pfld.size())
60 {
61 if (primitiveOrdering)
62 {
63 // In primitive patch order
64 UIndirectList<Type>(result, edgeLabels) = pfld;
65 }
66 else
67 {
68 // In sub-list (slice) order
69 result.slice(start, len) = pfld;
70 }
71 }
72
73 start += len;
74 }
75
76 return tresult;
77}
78
79
80// ************************************************************************* //
Info<< nl<< "Wrote faMesh in vtk format: "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.mesh().time().globalPath()/"finiteArea-edges"));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
Generic GeometricField class.
A List with indirect addressing. Like IndirectList but does not store addressing.
Definition: IndirectList.H:79
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
static tmp< Field< Type > > flattenEdgeField(const GeometricField< Type, faePatchField, edgeMesh > &fld, const bool primitiveOrdering=false)
Flatten an edge field into linear addressing.
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
Definition: faMesh.H:100
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
Definition: fvMesh.C:712
label nEdges() const
Number of mesh edges.
A class for managing temporary objects.
Definition: tmp.H:65
dynamicFvMesh & mesh
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333