39 void Foam::motionSmootherAlgo::checkConstraints
41 GeometricField<Type, pointPatchField, pointMesh>& pf
44 typedef GeometricField<Type, pointPatchField, pointMesh> FldType;
46 const polyMesh&
mesh = pf.mesh();
52 label nPatchPatchPoints = 0;
54 for (
const polyPatch& pp : bm)
56 if (!isA<emptyPolyPatch>(pp))
58 nPatchPatchPoints += pp.boundaryPoints().
size();
63 typename FldType::Boundary& bFld = pf.boundaryFieldRef();
81 Field<Type> boundaryPointValues(nPatchPatchPoints);
82 nPatchPatchPoints = 0;
86 if (!isA<emptyPolyPatch>(bm[patchi]))
88 const labelList& bp = bm[patchi].boundaryPoints();
89 const labelList& meshPoints = bm[patchi].meshPoints();
93 label ppp = meshPoints[bp[pointi]];
94 boundaryPointValues[nPatchPatchPoints++] = pf[ppp];
107 nPatchPatchPoints = 0;
111 if (!isA<emptyPolyPatch>(bm[patchi]))
113 const labelList& bp = bm[patchi].boundaryPoints();
114 const labelList& meshPoints = bm[patchi].meshPoints();
116 for (
const label pointi : bp)
118 const label ppp = meshPoints[pointi];
120 const Type& savedVal = boundaryPointValues[nPatchPatchPoints++];
122 if (savedVal != pf[ppp])
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]
141 Foam::motionSmootherAlgo::avg
143 const GeometricField<Type, pointPatchField, pointMesh>&
fld,
147 auto tres = tmp<GeometricField<Type, pointPatchField, pointMesh>>
::New 151 "avg("+
fld.name()+
')',
152 fld.time().timeName(),
159 dimensioned<Type>(
fld.dimensions(),
Zero)
161 auto& res = tres.ref();
163 const polyMesh&
mesh =
fld.mesh()();
176 for (
const label edgei : isMasterEdge_)
178 const edge&
e = edges[edgei];
179 const scalar w = edgeWeight[edgei];
181 res[
e[0]] += w*
fld[
e[1]];
182 sumWeight[
e[0]] += w;
184 res[
e[1]] += w*
fld[
e[0]];
185 sumWeight[
e[1]] += w;
213 if (
mag(sumWeight[pointi]) < VSMALL)
216 res[pointi] =
fld[pointi];
220 res[pointi] /= sumWeight[pointi];
244 if (isInternalPoint_.test(pointi))
246 newFld[pointi] = 0.5*
fld[pointi] + 0.5*avgFld[pointi];
255 template<
class Type,
class CombineOp>
256 void Foam::motionSmootherAlgo::testSyncField
258 const Field<Type>&
fld,
259 const CombineOp& cop,
266 Pout<<
"testSyncField : testing synchronisation of Field<Type>." 270 Field<Type> syncedFld(
fld);
282 if (
mag(syncedFld[i] -
fld[i]) > maxMag)
285 <<
"On element " << i <<
" value:" <<
fld[i]
286 <<
" synchronised value:" << syncedFld[i]
296 const dictionary&
dict,
300 const Type& defaultValue
310 Type val(defaultValue);
315 <<
"Entry '" << keyword <<
"' not found in dictionary " const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
"blocking" : (MPI_Bsend, MPI_Recv)
const polyMesh & mesh() const
Reference to mesh.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
label nPoints() const noexcept
Number of mesh points.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
static const pointConstraints & New(const pointMesh &mesh, Args &&... args)
Get existing or create a new MeshObject.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Ignore writing from objectRegistry::writeObject()
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
const fileName & name() const noexcept
The dictionary name.
virtual const pointField & points() const
Return raw points.
#define forAll(list, i)
Loop across all elements in list.
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, IOobjectOption::readOption readOpt=IOobjectOption::MUST_READ) const
Find entry and assign to T val. FatalIOError if it is found and the number of tokens is incorrect...
const dimensionedScalar e
Elementary charge.
List< edge > edgeList
A List of edges.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
label size() const noexcept
The number of elements in the list.
errorManip< error > abort(error &err)
void smooth(const GeometricField< Type, pointPatchField, pointMesh > &fld, const scalarField &edgeWeight, GeometricField< Type, pointPatchField, pointMesh > &newFld) const
Fully explicit smoothing of fields (not positions)
int debug
Static debugging option.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
static Type get(const dictionary &dict, const word &keyword, const bool noExit, enum keyType::option matchOpt, const Type &defaultValue=Zero)
Wrapper around dictionary::get which does not exit.
option
Enumeration for the data type and search/match modes (bitmask)
#define forAllReverse(list, i)
Reverse loop across all elements in list.
List< label > labelList
A List of labels.
A class for managing temporary objects.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
static constexpr const zero Zero
Global zero (0)
readOption
Enumeration defining read preferences.