Loading...
Searching...
No Matches
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
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(
93 GeometricField<Type, pointPatchField, pointMesh>& pf
94)
95{
96 typename GeometricField<Type, pointPatchField, pointMesh>::
97 Boundary& pfbf = pf.boundaryFieldRef();
98
99 forAll(pfbf, patchi)
100 {
101 pointPatchField<Type>& ppf = pfbf[patchi];
102
103 if (isA<valuePointPatchField<Type>>(ppf))
104 {
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(
132 GeometricField<Type, pointPatchField, pointMesh>& pf,
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
139 pf.correctBoundaryConditions();
140
141 // Sync any dangling points
142 syncUntransformedData
143 (
144 mesh()(),
145 pf.primitiveFieldRef(),
146 maxMagSqrEqOp<Type>()
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 values.
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:72
const labelList & meshPoints() const
Return labelList of mesh points in patch.
void size(const label n)
Older name for setAddressableSize.
Definition UList.H:118
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 List data using default commsType, default flip/negate operator.
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.
Abstract base class for point-mesh patch fields.
void patchInternalField(const UList< Type1 > &internalData, const labelUList &addressing, UList< Type1 > &pfld) const
Extract field using specified addressing.
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
Foam::valuePointPatchField.
dynamicFvMesh & mesh
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
Definition typeInfo.H:172
List< labelList > labelListList
List of labelList.
Definition labelList.H:38
List< label > labelList
A List of labels.
Definition List.H:62
refinementData transform(const tensor &, const refinementData val)
No-op rotational transform for base types.
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
Definition typeInfo.H:87
PrimitivePatch< IndirectList< face >, const pointField & > indirectPrimitivePatch
A PrimitivePatch with an IndirectList for the faces, const reference for the point field.
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299