extendedFaceToCellStencilTemplates.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 -------------------------------------------------------------------------------
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 
29 
30 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
31 
32 template<class Type>
34 (
35  const mapDistribute& map,
36  const labelListList& stencil,
38  List<List<Type>>& stencilFld
39 )
40 {
41  // 1. Construct face data in compact addressing
42  List<Type> flatFld(map.constructSize(), Zero);
43 
44  // Insert my internal values
45  forAll(fld, celli)
46  {
47  flatFld[celli] = fld[celli];
48  }
49  // Insert my boundary values
50  forAll(fld.boundaryField(), patchi)
51  {
52  const fvsPatchField<Type>& pfld = fld.boundaryField()[patchi];
53 
54  label nCompact = pfld.patch().start();
55 
56  forAll(pfld, i)
57  {
58  flatFld[nCompact++] = pfld[i];
59  }
60  }
61 
62  // Do all swapping
63  map.distribute(flatFld);
64 
65  // 2. Pull to stencil
66  stencilFld.setSize(stencil.size());
67 
68  forAll(stencil, facei)
69  {
70  const labelList& compactCells = stencil[facei];
71 
72  stencilFld[facei].setSize(compactCells.size());
73 
74  forAll(compactCells, i)
75  {
76  stencilFld[facei][i] = flatFld[compactCells[i]];
77  }
78  }
79 }
80 
81 
82 template<class Type>
85 (
86  const mapDistribute& map,
87  const labelListList& stencil,
89  const List<List<scalar>>& stencilWeights
90 )
91 {
92  const fvMesh& mesh = fld.mesh();
93 
94  // Collect internal and boundary values
95  List<List<Type>> stencilFld;
96  collectData(map, stencil, fld, stencilFld);
97 
99  (
101  (
102  IOobject
103  (
104  fld.name(),
105  mesh.time().timeName(),
106  mesh
107  ),
108  mesh,
109  dimensioned<Type>(fld.dimensions(), Zero)
110  )
111  );
113 
114  // cells
115  forAll(sf, celli)
116  {
117  const List<Type>& stField = stencilFld[celli];
118  const List<scalar>& stWeight = stencilWeights[celli];
119 
120  forAll(stField, i)
121  {
122  sf[celli] += stField[i]*stWeight[i];
123  }
124  }
125 
126  // Boundaries values?
127 
128  return tsfCorr;
129 }
130 
131 
132 // ************************************************************************* //
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::fvsPatchField
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:68
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::List::setSize
void setSize(const label n)
Alias for resize()
Definition: List.H:222
Foam::mapDistribute
Class containing processor-to-processor mapping information.
Definition: mapDistribute.H:163
fld
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))
Definition: gmvOutputLagrangian.H:23
Foam::mapDistribute::distribute
void distribute(List< T > &fld, const bool dummyTransform=true, const int tag=UPstream::msgType()) const
Distribute data using default commsType.
Definition: mapDistributeTemplates.C:152
Foam::extendedFaceToCellStencil::weightedSum
static tmp< GeometricField< Type, fvPatchField, volMesh > > weightedSum(const mapDistribute &map, const labelListList &stencil, const GeometricField< Type, fvsPatchField, surfaceMesh > &fld, const List< List< scalar >> &stencilWeights)
Sum surface field contributions to create cell values.
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::dimensioned
Generic dimensioned Type class.
Definition: dimensionedScalarFwd.H:42
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam::extendedFaceToCellStencil::collectData
static void collectData(const mapDistribute &map, const labelListList &stencil, const GeometricField< T, fvsPatchField, surfaceMesh > &fld, List< List< T >> &stencilFld)
Use map to get the data into stencil order.
Foam::mapDistributeBase::constructSize
label constructSize() const
Constructed data size.
Definition: mapDistributeBase.H:277
extendedFaceToCellStencil.H
Foam::fvsPatchField::patch
const fvPatch & patch() const
Return patch.
Definition: fvsPatchField.H:281
Foam::GeometricField::ref
Internal & ref(const bool updateAccessTime=true)
Return a reference to the dimensioned internal field.
Definition: GeometricField.C:749
Foam::List< labelList >
Foam::GeometricField
Generic GeometricField class.
Definition: areaFieldsFwd.H:53