36 void Foam::motionSmoother::checkConstraints
38 GeometricField<Type, pointPatchField, pointMesh>& pf
41 typedef GeometricField<Type, pointPatchField, pointMesh> FldType;
43 const polyMesh&
mesh = pf.mesh();
49 label nPatchPatchPoints = 0;
53 if(!isA<emptyPolyPatch>(bm[
patchi]))
55 nPatchPatchPoints += bm[
patchi].boundaryPoints().size();
60 typename FldType::GeometricBoundaryField& bFld = pf.boundaryField();
78 Field<Type> boundaryPointValues(nPatchPatchPoints);
79 nPatchPatchPoints = 0;
83 if(!isA<emptyPolyPatch>(bm[patchi]))
90 label ppp = meshPoints[bp[pointi]];
91 boundaryPointValues[nPatchPatchPoints++] = pf[ppp];
104 nPatchPatchPoints = 0;
108 if(!isA<emptyPolyPatch>(bm[patchi]))
115 label ppp = meshPoints[bp[pointi]];
117 const Type& savedVal = boundaryPointValues[nPatchPatchPoints++];
119 if (savedVal != pf[ppp])
123 "motionSmoother::checkConstraints"
124 "(GeometricField<Type, pointPatchField, pointMesh>&)"
125 ) <<
"Patch fields are not consistent on mesh point "
126 << ppp <<
" coordinate " << mesh.points()[ppp]
127 <<
" at patch " << bm[
patchi].name() <<
'.'
129 <<
"Reverse evaluation gives value " << savedVal
130 <<
" , forward evaluation gives value " << pf[ppp]
140 void Foam::motionSmoother::applyCornerConstraints
142 GeometricField<Type, pointPatchField, pointMesh>& pf
145 forAll(patchPatchPointConstraintPoints_, pointi)
147 pf[patchPatchPointConstraintPoints_[pointi]] =
transform
149 patchPatchPointConstraintTensors_[pointi],
150 pf[patchPatchPointConstraintPoints_[pointi]]
157 template <
class Type>
159 Foam::motionSmoother::avg
161 const GeometricField<Type, pointPatchField, pointMesh>& fld,
163 const bool separation
166 tmp<GeometricField<Type, pointPatchField, pointMesh> > tres
168 new GeometricField<Type, pointPatchField, pointMesh>
172 "avg("+fld.name()+
')',
173 fld.time().timeName(),
179 dimensioned<Type>(
"zero", fld.dimensions(), pTraits<Type>::zero)
182 GeometricField<Type, pointPatchField, pointMesh>& res = tres();
184 const polyMesh& mesh = fld.mesh()();
195 const edgeList& edges = mesh.edges();
199 if (isMasterEdge_.get(edgeI) == 1)
201 const edge&
e = edges[edgeI];
202 const scalar w = edgeWeight[edgeI];
204 res[e[0]] += w*fld[e[1]];
205 sumWeight[e[0]] += w;
207 res[e[1]] += w*fld[e[0]];
208 sumWeight[e[1]] += w;
240 if (
mag(sumWeight[pointI]) < VSMALL)
243 res[pointI] = fld[pointI];
247 res[pointI] /= sumWeight[pointI];
251 res.correctBoundaryConditions();
252 applyCornerConstraints(res);
259 template <
class Type>
264 const bool separation,
278 if (isInternalPoint(pointI))
280 newFld[pointI] = 0.5*fld[pointI] + 0.5*avgFld[pointI];
285 applyCornerConstraints(newFld);
290 template<
class Type,
class CombineOp>
291 void Foam::motionSmoother::testSyncField
294 const CombineOp& cop,
296 const bool separation,
302 Pout<<
"testSyncField : testing synchronisation of Field<Type>."
306 Field<Type> syncedFld(fld);
319 if (
mag(syncedFld[i] - fld[i]) > maxMag)
323 "motionSmoother::testSyncField"
324 "(const Field<Type>&, const CombineOp&"
325 ", const Type&, const bool)"
326 ) <<
"On element " << i <<
" value:" << fld[i]
327 <<
" synchronised value:" << syncedFld[i]