39void Foam::motionSmootherAlgo::checkConstraints
41 GeometricField<Type, pointPatchField, pointMesh>& pf
44 typedef GeometricField<Type, pointPatchField, pointMesh> FldType;
46 const polyMesh&
mesh = pf.mesh();
48 const polyBoundaryMesh& bm =
mesh.boundaryMesh();
52 label nPatchPatchPoints = 0;
54 for (
const polyPatch&
pp : bm)
58 nPatchPatchPoints +=
pp.boundaryPoints().size();
63 typename FldType::Boundary& bFld = pf.boundaryFieldRef();
81 Field<Type> boundaryPointValues(nPatchPatchPoints);
82 nPatchPatchPoints = 0;
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;
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]
140Foam::tmp<Foam::GeometricField<Type, Foam::pointPatchField, Foam::pointMesh>>
141Foam::motionSmootherAlgo::avg
151 "avg("+
fld.name()+
')',
152 fld.time().timeName(),
161 auto& res = tres.ref();
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];
255template<
class Type,
class CombineOp>
256void Foam::motionSmootherAlgo::testSyncField
259 const CombineOp& cop,
266 Pout<<
"testSyncField : testing synchronisation of Field<Type>."
282 if (
mag(syncedFld[i] -
fld[i]) > maxMag)
285 <<
"On element " << i <<
" value:" <<
fld[i]
286 <<
" synchronised value:" << syncedFld[i]
300 const Type& defaultValue
310 Type val(defaultValue);
315 <<
"Entry '" << keyword <<
"' not found in dictionary "
Info<< nl;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edges")));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Generic GeometricField class.
@ NO_REGISTER
Do not request registration (bool: false).
readOption
Enumeration defining read preferences.
@ NO_READ
Nothing to be read.
@ READ_IF_PRESENT
Reading is optional [identical to LAZY_READ].
@ MUST_READ
Reading required.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
static FOAM_NO_DANGLING_REFERENCE const pointConstraints & New(const pointMesh &mesh, Args &&... args)
@ buffered
"buffered" : (MPI_Bsend, MPI_Recv)
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
const fileName & name() const noexcept
The dictionary name.
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,...
Generic dimensioned Type class.
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
option
Enumeration for the data type and search/match modes (bitmask).
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.
const polyMesh & mesh() const
Reference to mesh.
void smooth(const GeometricField< Type, pointPatchField, pointMesh > &fld, const scalarField &edgeWeight, GeometricField< Type, pointPatchField, pointMesh > &newFld) const
Fully explicit smoothing of fields (not positions).
void constrain(GeometricField< Type, pointPatchField, pointMesh > &pf, const bool overrideValue=false) const
Apply boundary conditions (single-patch constraints) and.
Mesh consisting of general polyhedral cells.
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
label nPoints() const noexcept
Number of mesh points.
A class for managing temporary objects.
A class for handling words, derived from Foam::string.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Namespace for handling debugging switches.
List< edge > edgeList
List of edge.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
List< label > labelList
A List of labels.
GeometricField< vector, pointPatchField, pointMesh > pointVectorField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
errorManip< error > abort(error &err)
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).
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
#define forAll(list, i)
Loop across all elements in list.
#define forAllReverse(list, i)
Reverse loop across all elements in list.