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 -------------------------------------------------------------------------------
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 "rawTopoChangerFvMesh.H"
29 #include "Time.H"
30 
31 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
32 
33 template<class Type, template<class> class PatchField, class GeoMesh>
34 void Foam::rawTopoChangerFvMesh::setUnmappedValues
35 (
36  GeometricField<Type, PatchField, GeoMesh>& fld,
37  const bitSet& mappedFace,
38  const GeometricField<Type, PatchField, GeoMesh>& baseFld
39 )
40 {
41  //Pout<< "Checking field " << fld.name() << endl;
42 
43  forAll(fld.boundaryField(), patchi)
44  {
45  PatchField<Type>& fvp = const_cast<PatchField<Type>&>
46  (
47  fld.boundaryField()[patchi]
48  );
49 
50  const label start = fvp.patch().start();
51  forAll(fvp, i)
52  {
53  if (!mappedFace[start+i])
54  {
55  //Pout<< "** Resetting unassigned value on patch "
56  // << fvp.patch().name()
57  // << " localface:" << i
58  // << " to:" << baseFld.boundaryField()[patchi][i] << endl;
59  fvp[i] = baseFld.boundaryField()[patchi][i];
60  }
61  }
62  }
63 }
64 
65 
66 template<class Type, template<class> class PatchField, class GeoMesh>
67 void Foam::rawTopoChangerFvMesh::zeroUnmappedValues
68 (
69  const bitSet& mappedFace
70 ) const
71 {
72  typedef GeometricField<Type, PatchField, GeoMesh> FieldType;
73 
74  const wordList fldNames(names(FieldType::typeName));
75 
76  forAll(fldNames, i)
77  {
78  //Pout<< "Checking field " << fldNames[i] << endl;
79 
80  FieldType& fld = lookupObjectRef<FieldType>(fldNames[i]);
81 
82  setUnmappedValues
83  (
84  fld,
85  mappedFace,
86  FieldType
87  (
88  IOobject
89  (
90  "zero",
91  time().timeName(),
92  *this,
95  false
96  ),
97  *this,
98  dimensioned<Type>(fld.dimensions(), Zero)
99  )
100  );
101  }
102 }
103 
104 
105 // ************************************************************************* //
Foam::IOobject::NO_WRITE
Definition: IOobject.H:195
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
rawTopoChangerFvMesh.H
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:62
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
timeName
word timeName
Definition: getTimeIndex.H:3
Time.H
Foam::IOobject::NO_READ
Definition: IOobject.H:188
Foam::PtrListOps::names
List< word > names(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)