mappedPatchBaseTemplates.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "mappedPatchBase.H"
27 
28 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
29 
30 template<class Type>
33 {
35  {
36  return nbrFld;
37  }
38 
39  if (usingTree_)
40  {
41  if (!mappingIsValid())
42  {
43  calcMapping();
44  }
45 
46  tmp<Field<Type>> tResult
47  (
49  );
50  treeMapPtr_->distribute(tResult.ref());
51  return transform_.transform().transform(tResult);
52  }
53  else
54  {
55  if
56  (
59  )
60  {
61  calcMapping();
62  }
63 
64  return
66  (
68  ? patchToPatchPtr_->tgtToSrc(nbrFld)
69  : nbrMappedPatch().patchToPatchPtr_->srcToTgt(nbrFld)
70  );
71  }
72 }
73 
74 
75 template<class Type>
78 {
79  tmp<Field<Type>> tResult = fromNeighbour(nbrFld());
80  nbrFld.clear();
81  return tResult;
82 }
83 
84 
85 template<class Type>
88 {
89  if (sameUntransformedPatch())
90  {
91  return fld;
92  }
93 
94  if (usingTree_)
95  {
96  if (!mappingIsValid())
97  {
98  calcMapping();
99  }
100 
101  Field<Type> nbrFld(fld);
102  treeMapPtr_->reverseDistribute(treeNbrPatchFaceIndices_.size(), nbrFld);
103  tmp<Field<Type>> tResult(new Field<Type>(nbrPolyPatch().size()));
104  tResult.ref().rmap(nbrFld, treeNbrPatchFaceIndices_);
105  return transform_.transform().invTransform(tResult);
106  }
107  else
108  {
109  if
110  (
111  !mappingIsValid()
112  && !(symmetric() && nbrMappedPatch().mappingIsValid())
113  )
114  {
115  calcMapping();
116  }
117 
118  return
119  transform_.transform().invTransform
120  (
121  mappingIsValid()
122  ? patchToPatchPtr_->srcToTgt(fld)
123  : nbrMappedPatch().patchToPatchPtr_->tgtToSrc(fld)
124  );
125  }
126 }
127 
128 
129 template<class Type>
132 {
133  tmp<Field<Type>> tResult = toNeighbour(fld());
134  fld.clear();
135  return tResult;
136 }
137 
138 
139 // ************************************************************************* //
Pre-declare SubField and related Field type.
Definition: Field.H:83
const transformer & transform() const
Return transformation between the coupled patches.
cyclicTransform transform_
The transformation between the patches.
bool sameUntransformedPatch() const
Is the neighbour patch the same as this patch with no transform?
tmp< Field< Type > > toNeighbour(const Field< Type > &fld) const
Map/interpolate patch field to the neighbour patch.
bool symmetric() const
Determine whether the neighbouring patch maps from this patch in.
autoPtr< patchToPatch > patchToPatchPtr_
Patch-to-patch intersection engine (if using patch-to-patch)
labelList treeNbrPatchFaceIndices_
Indices of the neighbouring patch faces who's values.
autoPtr< distributionMap > treeMapPtr_
Distributor (if using tree)
const mappedPatchBase & nbrMappedPatch() const
Get the mapped neighbouring patch.
bool mappingIsValid() const
Return whether or not the mapping is valid.
void calcMapping() const
Calculate mapping.
tmp< Field< Type > > fromNeighbour(const Field< Type > &nbrFld) const
Map/interpolate the neighbour patch field to this patch.
const bool usingTree_
Are we using the tree mapping method, or a patch-to-patch.
A class for managing temporary objects.
Definition: tmp.H:55
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:197
Type transform(const Type &) const
Transform the given type.
gmvFile<< "tracers "<< particles.size()<< nl;{ pointField positions(particles.size());label particlei=0;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter) { positions[particlei++]=iter().position(mesh);} for(i=0;i< pTraits< point >::nComponents;i++) { forAll(positions, particlei) { gmvFile<< component(positions[particlei], i)<< ' ';} gmvFile<< nl;}}forAll(lagrangianScalarNames, i){ const word &name=lagrangianScalarNames[i];IOField< scalar > fld(IOobject(name, runTime.name(), lagrangian::cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))