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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2013-2016 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "pointConstraints.H"
29 #include "pointFields.H"
30 #include "valuePointPatchFields.H"
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 template<class Type, class CombineOp>
36 (
37  const polyMesh& mesh,
38  List<Type>& pointData,
39  const CombineOp& cop
40 )
41 {
42  // Transfer onto coupled patch
43  const globalMeshData& gmd = mesh.globalData();
44  const indirectPrimitivePatch& cpp = gmd.coupledPatch();
45  const labelList& meshPoints = cpp.meshPoints();
46 
47  const mapDistribute& slavesMap = gmd.globalCoPointSlavesMap();
48  const labelListList& slaves = gmd.globalCoPointSlaves();
49 
50  List<Type> elems(slavesMap.constructSize());
51  forAll(meshPoints, i)
52  {
53  elems[i] = pointData[meshPoints[i]];
54  }
55 
56  // Pull slave data onto master. No need to update transformed slots.
57  slavesMap.distribute(elems, false);
58 
59  // Combine master data with slave data
60  forAll(slaves, i)
61  {
62  Type& elem = elems[i];
63 
64  const labelList& slavePoints = slaves[i];
65 
66  // Combine master with untransformed slave data
67  forAll(slavePoints, j)
68  {
69  cop(elem, elems[slavePoints[j]]);
70  }
71 
72  // Copy result back to slave slots
73  forAll(slavePoints, j)
74  {
75  elems[slavePoints[j]] = elem;
76  }
77  }
78 
79  // Push slave-slot data back to slaves
80  slavesMap.reverseDistribute(elems.size(), elems, false);
81 
82  // Extract back onto mesh
83  forAll(meshPoints, i)
84  {
85  pointData[meshPoints[i]] = elems[i];
86  }
87 }
88 
89 
90 template<class Type>
92 (
94 )
95 {
97  Boundary& pfbf = pf.boundaryFieldRef();
98 
99  forAll(pfbf, patchi)
100  {
101  pointPatchField<Type>& ppf = pfbf[patchi];
102 
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
143  (
144  mesh()(),
145  pf.primitiveFieldRef(),
147  );
148 
149  // Apply multiple constraints on edge/corner points
150  constrainCorners(pf);
151 
152  if (overrideFixedValue)
153  {
154  setPatchFields(pf);
155  }
156 }
157 
158 
159 // ************************************************************************* //
Foam::pointConstraints::constrainCorners
void constrainCorners(GeometricField< Type, pointPatchField, pointMesh > &pf) const
Apply patch-patch constraints only.
Definition: pointConstraintsTemplates.C:114
Foam::globalMeshData::globalCoPointSlavesMap
const mapDistribute & globalCoPointSlavesMap() const
Definition: globalMeshData.C:2363
valuePointPatchFields.H
Foam::transform
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:521
Foam::pointPatchField
Abstract base class for point-mesh patch fields.
Definition: pointMVCWeight.H:60
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::pointConstraints::setPatchFields
static void setPatchFields(GeometricField< Type, pointPatchField, pointMesh > &)
Helper: set patchField values from internal values (on.
Definition: pointConstraintsTemplates.C:92
pointConstraints.H
Foam::mapDistribute
Class containing processor-to-processor mapping information.
Definition: mapDistribute.H:163
Foam::mapDistribute::distribute
void distribute(List< T > &fld, const bool dummyTransform=true, const int tag=UPstream::msgType()) const
Distribute data using default commsType.
Definition: mapDistributeTemplates.C:152
Foam::maxMagSqrEqOp
Definition: ops.H:83
Foam::globalMeshData
Various mesh related information for a parallel run. Upon construction, constructs all info using par...
Definition: globalMeshData.H:107
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::GeometricField::primitiveFieldRef
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field.
Definition: GeometricField.C:766
Foam::GeometricField::correctBoundaryConditions
void correctBoundaryConditions()
Correct boundary field.
Definition: GeometricField.C:940
Foam::mapDistributeBase::constructSize
label constructSize() const
Constructed data size.
Definition: mapDistributeBase.H:277
Foam::isA
const TargetType * isA(const Type &t)
Check if dynamic_cast to TargetType is possible.
Definition: typeInfo.H:197
Foam::valuePointPatchField
Foam::valuePointPatchField.
Definition: valuePointPatchField.H:52
Foam::pointConstraints::syncUntransformedData
static void syncUntransformedData(const polyMesh &mesh, List< Type > &pointData, const CombineOp &cop)
Helper: sync data on collocated points only.
Definition: pointConstraintsTemplates.C:36
Foam::GeometricField::boundaryFieldRef
Boundary & boundaryFieldRef(const bool updateAccessTime=true)
Return a reference to the boundary field.
Definition: GeometricField.C:783
Foam::List< Type >
Foam::globalMeshData::coupledPatch
const indirectPrimitivePatch & coupledPatch() const
Return patch of all coupled faces.
Definition: globalMeshData.C:2046
Foam::mapDistribute::reverseDistribute
void reverseDistribute(const label constructSize, List< T > &, const bool dummyTransform=true, const int tag=UPstream::msgType()) const
Reverse distribute data using default commsType.
Definition: mapDistributeTemplates.C:182
Foam::pointPatchField::patchInternalField
tmp< Field< Type > > patchInternalField() const
Return field created from appropriate internal field values.
Definition: pointPatchField.C:130
Foam::pointConstraints::constrain
void constrain(GeometricField< Type, pointPatchField, pointMesh > &pf, const bool overrideValue=false) const
Apply boundary conditions (single-patch constraints) and.
Definition: pointConstraintsTemplates.C:131
Foam::PrimitivePatch::meshPoints
const labelList & meshPoints() const
Return labelList of mesh points in patch.
Definition: PrimitivePatch.C:330
Foam::GeometricField
Generic GeometricField class.
Definition: areaFieldsFwd.H:53
pointFields.H
Foam::globalMeshData::globalCoPointSlaves
const labelListList & globalCoPointSlaves() const
Definition: globalMeshData.C:2353
Foam::PrimitivePatch
A list of faces which address into the list of points.
Definition: PrimitivePatch.H:79