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 -------------------------------------------------------------------------------
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 #include "edgeFields.H"
29 
30 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
31 
32 template<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 // ************************************************************************* //
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
Definition: faMesh.H:87
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:116
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
Generic GeometricField class.
Definition: areaFieldsFwd.H:50
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
dynamicFvMesh & mesh
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))
A List with indirect addressing. Like IndirectList but does not store addressing. ...
Definition: faMatrix.H:56
A class for managing temporary objects.
Definition: HashPtrTable.H:50
static tmp< Field< Type > > flattenEdgeField(const GeometricField< Type, faePatchField, edgeMesh > &fld, const bool primitiveOrdering=false)
Flatten an edge field into linear addressing.
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127