decompositionConstraint.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) 2015-2017 OpenFOAM Foundation
9  Copyright (C) 2015-2021 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 
30 #include "syncTools.H"
31 #include "cyclicAMIPolyPatch.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37  defineTypeNameAndDebug(decompositionConstraint, 1);
39 }
40 
41 
42 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
43 
45 (
46  const polyMesh& mesh,
47  const labelList& decomposition,
48  labelList& destProc
49 ) const
50 {
51  destProc.setSize(mesh.nBoundaryFaces());
52  destProc = labelMax;
53 
54  const polyBoundaryMesh& pbm = mesh.boundaryMesh();
55 
56  for (const polyPatch& pp : pbm)
57  {
58  const labelUList& faceCells = pp.faceCells();
59 
60  forAll(faceCells, i)
61  {
62  label bFacei = pp.offset()+i;
63  destProc[bFacei] = decomposition[faceCells[i]];
64  }
65  }
66 
67  // Take minimum of coupled faces (over all patches!)
68  syncTools::syncBoundaryFaceList(mesh, destProc, minEqOp<label>());
69 
70  // Do cyclicAMI ourselves
71  for (const auto& pp : pbm)
72  {
73  const auto* ppp = isA<cyclicAMIPolyPatch>(pp);
74  if (ppp)
75  {
76  const auto& cycPp = *ppp;
77  const auto& nbrPp = cycPp.neighbPatch();
78  const labelList nbrDecomp(decomposition, nbrPp.faceCells());
79  labelList thisDecomp(decomposition, cycPp.faceCells());
80 
81  if (cycPp.owner())
82  {
83  cycPp.AMI().interpolateToSource
84  (
85  nbrDecomp,
86  []
87  (
88  label& res,
89  const label facei,
90  const label& fld,
91  const scalar& w
92  )
93  {
94  res = min(res, fld);
95  },
96  thisDecomp,
97  thisDecomp // used in case of low-weight-corr
98  );
99  }
100  else
101  {
102  nbrPp.AMI().interpolateToTarget
103  (
104  nbrDecomp,
105  []
106  (
107  label& res,
108  const label facei,
109  const label& fld,
110  const scalar& w
111  )
112  {
113  res = min(res, fld);
114  },
115  thisDecomp,
116  thisDecomp // used in case of low-weight-corr
117  );
118  }
119 
120  forAll(thisDecomp, i)
121  {
122  label& proc = destProc[cycPp.offset()+i];
123  proc = min(proc, thisDecomp[i]);
124  }
125  }
126  }
127 }
128 
129 
130 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
131 
133 (
134  const dictionary& constraintDict
135 )
136 :
137  coeffDict_(constraintDict)
138 {}
139 
140 
142 (
143  const dictionary& constraintDict,
144  const word&
145 )
146 :
147  coeffDict_(constraintDict)
148 {}
149 
150 
151 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
152 
155 (
156  const dictionary& dict
157 )
158 {
160  (
161  dict,
162  dict.get<word>("type")
163  );
164 }
165 
166 
169 (
170  const dictionary& dict,
171  const word& modelType
172 )
173 {
174  Info<< "Selecting decompositionConstraint " << modelType << endl;
175 
176  auto* ctorPtr = dictionaryConstructorTable(modelType);
177 
178  if (!ctorPtr)
179  {
181  (
182  dict,
183  "decompositionConstraint",
184  modelType,
185  *dictionaryConstructorTablePtr_
186  ) << exit(FatalIOError);
187  }
188 
189  return autoPtr<decompositionConstraint>(ctorPtr(dict));
190 }
191 
192 
193 // ************************************************************************* //
const polyBoundaryMesh & pbm
Abstract class for handling decomposition constraints.
dictionary dict
static void syncBoundaryFaceList(const polyMesh &mesh, UList< T > &faceValues, const CombineOp &cop, const TransformOp &top, const bool parRun=UPstream::parRun())
Synchronize values on boundary faces only.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T. FatalIOError if not found, or if the number of tokens is incorrect.
Smooth ATC in cells next to a set of patches supplied by type.
Definition: faceCells.H:52
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
static autoPtr< decompositionConstraint > New(const dictionary &constraintDict)
Return a reference to the selected decompositionConstraint.
void setSize(const label n)
Alias for resize()
Definition: List.H:316
dynamicFvMesh & mesh
void getMinBoundaryValue(const polyMesh &mesh, const labelList &decomposition, labelList &destProc) const
Get minimum label across coupled boundary faces.
A class for handling words, derived from Foam::string.
Definition: word.H:63
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:26
decompositionConstraint(const decompositionConstraint &)=delete
No copy construct.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO...
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
defineTypeNameAndDebug(combustionModel, 0)
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))
messageStream Info
Information stream (stdout output on master, null elsewhere)
constexpr label labelMax
Definition: label.H:55
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
List< label > labelList
A List of labels.
Definition: List.H:62
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:69
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition: error.H:635
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
Namespace for OpenFOAM.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL IO ERROR&#39; header text and ...