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,
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 // ************************************************************************* //
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
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::GeometricField::boundaryField
GeometricBoundaryField & boundaryField()
Return reference to GeometricBoundaryField.
Definition: GeometricField.C:735
valuePointPatchFields.H
Foam::pointPatchField::patchInternalField
tmp< Field< Type > > patchInternalField() const
Return field created from appropriate internal field values.
Foam::maxMagSqrEqOp
Definition: ops.H:80
Foam::pointData
Variant of pointEdgePoint with some transported additional data. WIP - should be templated on data li...
Definition: pointData.H:53
Foam::pointPatchField< Type >
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::transform
dimensionSet transform(const dimensionSet &)
Definition: dimensionSet.C:465
Foam::pointConstraints::setPatchFields
static void setPatchFields(GeometricField< Type, pointPatchField, pointMesh > &)
Helper: set patchField values from internal values (on.
Definition: pointConstraintsTemplates.C:95
pointConstraints.H
Foam::mapDistribute
Class containing processor-to-processor mapping information.
Definition: mapDistribute.H:152
Foam::GeometricField::internalField
InternalField & internalField()
Return internal field.
Definition: GeometricField.C:724
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:155
Foam::globalMeshData
Various mesh related information for a parallel run. Upon construction, constructs all info using par...
Definition: globalMeshData.H:106
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::GeometricField::correctBoundaryConditions
void correctBoundaryConditions()
Correct boundary field.
Definition: GeometricField.C:885
Foam::mapDistributeBase::constructSize
label constructSize() const
Constructed data size.
Definition: mapDistributeBase.H:244
Foam::valuePointPatchField
Foam::valuePointPatchField.
Definition: valuePointPatchField.H:49
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:39
Foam::isA
bool isA(const Type &t)
Check if a dynamic_cast to typeid is possible.
Definition: typeInfo.H:134
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:187
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::List::size
void size(const label)
Override size to be inconsistent with allocated storage.
Foam::polyMesh::globalData
const globalMeshData & globalData() const
Return parallel info.
Definition: polyMesh.C:1143
Foam::PrimitivePatch::meshPoints
const labelList & meshPoints() const
Return labelList of mesh points in patch.
Definition: PrimitivePatchTemplate.C:392
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
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: PrimitivePatchTemplate.H:88