rawTopoChangerFvMeshTemplates.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  Copyright (C) 2024 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
30 
31 template<class Type, template<class> class PatchField, class GeoMesh>
32 void Foam::rawTopoChangerFvMesh::setUnmappedValues
33 (
34  GeometricField<Type, PatchField, GeoMesh>& fld,
35  const bitSet& mappedFace,
36  const GeometricField<Type, PatchField, GeoMesh>& baseFld
37 )
38 {
39  //Pout<< "Checking field " << fld.name() << endl;
40 
41  forAll(fld.boundaryField(), patchi)
42  {
43  auto& fvp = const_cast<PatchField<Type>&>(fld.boundaryField()[patchi]);
44 
45  const label start = fvp.patch().start();
46  forAll(fvp, i)
47  {
48  if (!mappedFace[start+i])
49  {
50  //Pout<< "** Resetting unassigned value on patch "
51  // << fvp.patch().name()
52  // << " localface:" << i
53  // << " to:" << baseFld.boundaryField()[patchi][i] << endl;
54  fvp[i] = baseFld.boundaryField()[patchi][i];
55  }
56  }
57  }
58 }
59 
60 
61 template<class Type, template<class> class PatchField, class GeoMesh>
62 void Foam::rawTopoChangerFvMesh::zeroUnmappedValues
63 (
64  const bitSet& mappedFace
65 ) const
66 {
67  typedef GeometricField<Type, PatchField, GeoMesh> FieldType;
68 
69  std::unique_ptr<FieldType> zeroFieldPtr;
70 
71  for (const word& fldName : names<FieldType>())
72  {
73  FieldType& fld = lookupObjectRef<FieldType>(fldName);
74  //Pout<< "Checking field " << fld.name() << endl;
75 
76  if (!zeroFieldPtr)
77  {
78  zeroFieldPtr = std::make_unique<FieldType>
79  (
80  this->newIOobject("zero"),
81  *this,
82  Foam::zero{},
83  dimless
84  );
85  }
86 
87  zeroFieldPtr->dimensions().reset(fld.dimensions());
88 
89  setUnmappedValues(fld, mappedFace, *zeroFieldPtr);
90  }
91 }
92 
93 
94 // ************************************************************************* //
const dimensionSet dimless
Dimensionless.
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
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 class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:57