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-------------------------------------------------------------------------------
11License
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
35namespace Foam
36{
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
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!)
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// ************************************************************************* //
Info<< nl<< "Wrote faMesh in vtk format: "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.mesh().time().globalPath()/"finiteArea-edges"));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
void setSize(const label n)
Alias for resize()
Definition: List.H:218
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
Abstract class for handling decomposition constraints.
void getMinBoundaryValue(const polyMesh &mesh, const labelList &decomposition, labelList &destProc) const
Get minimum label across coupled boundary faces.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Smooth ATC in cells next to a set of patches supplied by type.
Definition: faceCells.H:59
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:456
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:75
label nBoundaryFaces() const noexcept
Number of boundary faces (== nFaces - nInternalFaces)
static void syncBoundaryFaceList(const polyMesh &mesh, UList< T > &faceValues, const CombineOp &cop, const TransformOp &top, const bool parRun=Pstream::parRun())
Synchronize values on boundary faces only.
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
dynamicFvMesh & mesh
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition: error.H:478
Namespace for OpenFOAM.
messageStream Info
Information stream (stdout output on master, null elsewhere)
constexpr label labelMax
Definition: label.H:61
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
IOerror FatalIOError
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
#define defineRunTimeSelectionTable(baseType, argNames)
Define run-time selection table.
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333