pointConstraintsTemplates.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) 2013-2018 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 "pointConstraints.H"
27 #include "pointFields.H"
28 #include "valuePointPatchFields.H"
29 
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 
32 template<class Type, class CombineOp>
34 (
35  const polyMesh& mesh,
36  List<Type>& pointData,
37  const CombineOp& cop
38 )
39 {
40  // Transfer onto coupled patch
41  const globalMeshData& gmd = mesh.globalData();
42  const indirectPrimitivePatch& cpp = gmd.coupledPatch();
43  const labelList& meshPoints = cpp.meshPoints();
44 
45  const mapDistribute& slavesMap = gmd.globalCoPointSlavesMap();
46  const labelListList& slaves = gmd.globalCoPointSlaves();
47 
48  List<Type> elems(slavesMap.constructSize());
49  forAll(meshPoints, i)
50  {
51  elems[i] = pointData[meshPoints[i]];
52  }
53 
54  // Pull slave data onto master. No need to update transformed slots.
55  slavesMap.distribute(elems, false);
56 
57  // Combine master data with slave data
58  forAll(slaves, i)
59  {
60  Type& elem = elems[i];
61 
62  const labelList& slavePoints = slaves[i];
63 
64  // Combine master with untransformed slave data
65  forAll(slavePoints, j)
66  {
67  cop(elem, elems[slavePoints[j]]);
68  }
69 
70  // Copy result back to slave slots
71  forAll(slavePoints, j)
72  {
73  elems[slavePoints[j]] = elem;
74  }
75  }
76 
77  // Push slave-slot data back to slaves
78  slavesMap.reverseDistribute(elems.size(), elems, false);
79 
80  // Extract back onto mesh
81  forAll(meshPoints, i)
82  {
83  pointData[meshPoints[i]] = elems[i];
84  }
85 }
86 
87 
88 template<class Type>
90 (
92 )
93 {
95  Boundary& pfbf = pf.boundaryFieldRef();
96 
97  forAll(pfbf, patchi)
98  {
99  pointPatchField<Type>& ppf = pfbf[patchi];
100 
102  {
103  refCast<valuePointPatchField<Type>>(ppf) =
104  ppf.patchInternalField();
105  }
106  }
107 }
108 
109 
110 template<class Type>
112 (
114 ) const
115 {
116  forAll(patchPatchPointConstraintPoints_, pointi)
117  {
118  pf[patchPatchPointConstraintPoints_[pointi]] = transform
119  (
120  patchPatchPointConstraintTensors_[pointi],
121  pf[patchPatchPointConstraintPoints_[pointi]]
122  );
123  }
124 }
125 
126 
127 template<class Type>
129 (
131  const bool overrideFixedValue
132 ) const
133 {
134  // Override constrained pointPatchField types with the constraint value.
135  // This relies on only constrained pointPatchField implementing the evaluate
136  // function
138 
139  // Sync any dangling points
140  syncUntransformedData
141  (
142  mesh()(),
143  pf.primitiveFieldRef(),
145  );
146 
147  // Apply multiple constraints on edge/corner points
148  constrainCorners(pf);
149 
150  if (overrideFixedValue)
151  {
152  setPatchFields(pf);
153  }
154 }
155 
156 
157 // ************************************************************************* //
bool isA(const Type &t)
Check if a dynamic_cast to typeid is possible.
Definition: typeInfo.H:134
const mapDistribute & globalCoPointSlavesMap() const
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
Foam::valuePointPatchField.
void distribute(List< T > &fld, const bool dummyTransform=true, const int tag=UPstream::msgType()) const
Distribute data using default commsType.
Various mesh related information for a parallel run. Upon construction, constructs all info using par...
const labelList & meshPoints() const
Return labelList of mesh points in patch. They are constructed.
Abstract base class for point-mesh patch fields.
A list of faces which address into the list of points.
dynamicFvMesh & mesh
static void syncUntransformedData(const polyMesh &mesh, List< Type > &pointData, const CombineOp &cop)
Helper: sync data on collocated points only.
void constrainCorners(GeometricField< Type, pointPatchField, pointMesh > &pf) const
Apply patch-patch constraints only.
static void setPatchFields(GeometricField< Type, pointPatchField, pointMesh > &)
Helper: set patchField values from internal values (on.
const globalMeshData & globalData() const
Return parallel info.
Definition: polyMesh.C:1394
tmp< Field< Type > > patchInternalField() const
Return field created from appropriate internal field values.
Internal::FieldType & primitiveFieldRef()
Return a reference to the internal field.
void reverseDistribute(const label constructSize, List< T > &, const bool dummyTransform=true, const int tag=UPstream::msgType()) const
Reverse distribute data using default commsType.
const indirectPrimitivePatch & coupledPatch() const
Return patch of all coupled faces.
label constructSize() const
Constructed data size.
label patchi
Class containing processor-to-processor mapping information.
Boundary & boundaryFieldRef()
Return a reference to the boundary field.
void correctBoundaryConditions()
Correct boundary field.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
void constrain(GeometricField< Type, pointPatchField, pointMesh > &pf, const bool overrideValue=false) const
Apply boundary conditions (single-patch constraints) and.
dimensionSet transform(const dimensionSet &)
Definition: dimensionSet.C:477
const labelListList & globalCoPointSlaves() const