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-------------------------------------------------------------------------------
10License
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"
31
32// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33
34template<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
90template<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
112template<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
129template<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()(),
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// ************************************************************************* //
Generic GeometricField class.
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field.
Boundary & boundaryFieldRef(const bool updateAccessTime=true)
Return a reference to the boundary field.
void correctBoundaryConditions()
Correct boundary field.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
A list of faces which address into the list of points.
const labelList & meshPoints() const
Return labelList of mesh points in patch.
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
Various mesh related information for a parallel run. Upon construction, constructs all info using par...
const mapDistribute & globalCoPointSlavesMap() const
const labelListList & globalCoPointSlaves() const
const indirectPrimitivePatch & coupledPatch() const
Return patch of all coupled faces.
label constructSize() const noexcept
Constructed data size.
Class containing processor-to-processor mapping information.
void reverseDistribute(const label constructSize, List< T > &fld, const bool dummyTransform=true, const int tag=UPstream::msgType()) const
Reverse distribute data using default commsType.
void distribute(List< T > &fld, const bool dummyTransform=true, const int tag=UPstream::msgType()) const
Distribute data using default commsType.
void constrain(GeometricField< Type, pointPatchField, pointMesh > &pf, const bool overrideValue=false) const
Apply boundary conditions (single-patch constraints) and.
static void setPatchFields(GeometricField< Type, pointPatchField, pointMesh > &)
Helper: set patchField values from internal values (on.
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.
const globalMeshData & globalData() const
Return parallel info.
Definition: pointMesh.H:120
Abstract base class for point-mesh patch fields.
tmp< Field< Type > > patchInternalField() const
Return field created from appropriate internal field values.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
Foam::valuePointPatchField.
dynamicFvMesh & mesh
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:536
const TargetType * isA(const Type &t)
Check if dynamic_cast to TargetType is possible.
Definition: typeInfo.H:197
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333