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