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);
38  defineRunTimeSelectionTable(decompositionConstraint, dictionary);
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 // ************************************************************************* //
Foam::labelMax
constexpr label labelMax
Definition: label.H:61
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::polyBoundaryMesh
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
Definition: polyBoundaryMesh.H:63
decompositionConstraint.H
Foam::defineRunTimeSelectionTable
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
Foam::FatalIOError
IOerror FatalIOError
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
syncTools.H
Foam::min
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::decompositionConstraint::getMinBoundaryValue
void getMinBoundaryValue(const polyMesh &mesh, const labelList &decomposition, labelList &destProc) const
Get minimum label across coupled boundary faces.
Definition: decompositionConstraint.C:45
Foam::decompositionConstraint::New
static autoPtr< decompositionConstraint > New(const dictionary &constraintDict)
Return a reference to the selected decompositionConstraint.
Definition: decompositionConstraint.C:155
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::minEqOp
Definition: ops.H:81
FatalIOErrorInLookup
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition: error.H:478
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:68
Foam::List::setSize
void setSize(const label n)
Alias for resize()
Definition: List.H:222
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
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
cyclicAMIPolyPatch.H
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::decompositionConstraint::decompositionConstraint
decompositionConstraint(const decompositionConstraint &)=delete
No copy construct.
Foam::List< label >
Foam::UList< label >
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::faceCells
Smooth ATC in cells next to a set of patches supplied by type.
Definition: faceCells.H:56