Loading...
Searching...
No Matches
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"
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!)
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 }
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 (
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;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edges")));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
const polyBoundaryMesh & pbm
void setSize(label n)
Alias for resize().
Definition List.H:536
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
Abstract class for handling decomposition constraints.
dictionary coeffDict_
Constraint coefficients dictionary.
void getMinBoundaryValue(const polyMesh &mesh, const labelList &decomposition, labelList &destProc) const
Get minimum label across coupled boundary faces.
decompositionConstraint(const decompositionConstraint &)=delete
No copy construct.
static autoPtr< decompositionConstraint > New(const dictionary &constraintDict)
Return a reference to the selected decompositionConstraint.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Smooth ATC in cells next to a set of patches supplied by type.
Definition faceCells.H:55
A polyBoundaryMesh is a polyPatch list with registered IO, a reference to the associated polyMesh,...
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
A patch is a list of labels that address the faces in the global face list.
Definition polyPatch.H:73
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.
A class for handling words, derived from Foam::string.
Definition word.H:66
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
dynamicFvMesh & mesh
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition error.H:637
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition List.H:62
messageStream Info
Information stream (stdout output on master, null elsewhere).
constexpr label labelMax
Definition label.H:55
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
Definition typeInfo.H:87
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition hashSets.C:26
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition errorManip.H:125
UList< label > labelUList
A UList of labels.
Definition UList.H:75
#define defineRunTimeSelectionTable(baseType, argNames)
Define run-time selection table.
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299