43 template<
class Type,
template<
class>
class GeoField>
44 void Foam::fvMeshStitcher::resizePatchFields()
51 typename GeoField<Type>::Patch& pf =
52 iter()->boundaryFieldRef()[
patchi];
54 if (isA<nonConformalFvPatch>(pf.patch()))
56 pf.map(pf, setSizeFvPatchFieldMapper(pf.patch().size()));
63 template<
template<
class>
class GeoField>
64 void Foam::fvMeshStitcher::resizePatchFields()
66 #define ResizePatchFields(Type, nullArg) \
67 resizePatchFields<Type, GeoField>();
69 #undef ResizePatchFields
74 void Foam::fvMeshStitcher::preConformSurfaceFields()
76 HashTable<SurfaceField<Type>*>
fields
78 mesh_.lookupClass<SurfaceField<Type>>()
88 SurfaceField<Type>& field = *iter();
92 &field ==
static_cast<const regIOobject*
>(phiPtr)
96 autoPtr<SurfaceField<Type>> nccFieldPtr
98 new SurfaceField<Type>
102 nccFieldPrefix_ + field.name(),
110 for (
label i = 0; i <= field.nOldTimes(); ++ i)
112 SurfaceField<Type>& field0 = field.oldTime(i);
114 nccFieldPtr->oldTime(i).boundaryFieldRef() =
115 conformalNccBoundaryField<Type>(field0.boundaryField());
117 field0.boundaryFieldRef() =
118 conformalOrigBoundaryField<Type>(field0.boundaryField());
121 nccFieldPtr.ptr()->store();
126 inline void Foam::fvMeshStitcher::preConformSurfaceFields()
128 #define PreConformSurfaceFields(Type, nullArg) \
129 preConformSurfaceFields<Type>();
131 #undef PreConformSurfaceFields
136 void Foam::fvMeshStitcher::postNonConformSurfaceFields()
138 HashTable<SurfaceField<Type>*>
fields
140 mesh_.lookupClass<SurfaceField<Type>>()
150 if (iter.key()(nccFieldPrefix_.size()) == nccFieldPrefix_)
continue;
152 SurfaceField<Type>& field = *iter();
156 &field ==
static_cast<const regIOobject*
>(phiPtr)
158 || mesh_.topoChanged()
161 const word nccFieldName = nccFieldPrefix_ + field.name();
163 const SurfaceField<Type>& nccField =
164 mesh_.lookupObject<SurfaceField<Type>>(nccFieldName);
166 for (
label i = 0; i <= field.nOldTimes(); ++ i)
168 SurfaceField<Type>& field0 = field.oldTime(i);
170 field0.boundaryFieldRef() =
171 nonConformalBoundaryField<Type>
173 nccField.oldTime(i).boundaryField(),
174 field0.boundaryField()
177 field0.boundaryFieldRef() =
178 synchronisedBoundaryField<Type>(field0.boundaryField());
187 if (iter.key()(nccFieldPrefix_.size()) == nccFieldPrefix_)
continue;
189 SurfaceField<Type>& field = *iter();
193 &field ==
static_cast<const regIOobject*
>(phiPtr)
197 const word nccFieldName = nccFieldPrefix_ + field.name();
199 SurfaceField<Type>& nccField =
200 mesh_.lookupObjectRef<SurfaceField<Type>>(nccFieldName);
206 fields = mesh_.lookupClass<SurfaceField<Type>>();
209 if (iter.key()(nccFieldPrefix_.size()) != nccFieldPrefix_)
continue;
212 <<
"Stitching mapping field \"" << iter()->name()
213 <<
"\" found, but the field it corresponds to no longer exists"
219 inline void Foam::fvMeshStitcher::postNonConformSurfaceFields()
221 #define PostNonConformSurfaceFields(Type, nullArg) \
222 postNonConformSurfaceFields<Type>();
224 #undef PostNonConformSurfaceFields
229 void Foam::fvMeshStitcher::evaluateVolFields()
231 HashTable<VolField<Type>*>
fields(mesh_.lookupClass<VolField<Type>>());
239 iter()->boundaryFieldRef()[
patchi];
241 if (isA<nonConformalFvPatch>(pf.patch()))
259 iter()->boundaryFieldRef()[
patchi];
261 if (isA<nonConformalFvPatch>(pf.patch()))
270 inline void Foam::fvMeshStitcher::evaluateVolFields()
272 #define EvaluateVolFields(Type, nullArg) \
273 evaluateVolFields<Type>();
275 #undef EvaluateVolFields
279 inline void Foam::fvMeshStitcher::postNonConformSurfaceVelocities()
281 if (mesh_.topoChanged())
283 HashTable<surfaceVectorField*> Ufs
288 forAllIter(HashTable<surfaceVectorField*>, Ufs, iter)
298 if (isA<nonConformalFvPatch>(mesh_.boundary()[
patchi]))
300 Uf.boundaryFieldRef()[
patchi] ==
312 template<
class GeoBoundaryField>
316 GeoBoundaryField& fieldBf
319 forAll(polyFacesBf, nccPatchi)
321 if (isA<nonConformalFvPatch>(polyFacesBf[nccPatchi].patch()))
323 fieldBf[nccPatchi].map
332 template<
class GeoField>
339 for (
label i = 0; i <= field.nOldTimes(); ++ i)
341 resizeBoundaryFieldPatchFields
344 field.oldTime(i).boundaryFieldRef()
361 tresult.
ref()[addr[i]] +=
f[i];
405 const fvPatch& fvp = fvbm[nccPatchi];
407 if (isA<nonConformalCoupledFvPatch>(fvp))
410 refCast<const nonConformalCoupledFvPatch>(fvp);
418 origNccMagSfb[origPatchi] +=
428 return tOrigNccMagSfb;
439 const bool isFluxField =
isFlux(fieldb[0].internalField());
468 const fvPatch& fvp = fvbm[nccPatchi];
470 if (isA<nonConformalCoupledFvPatch>(fvp))
473 refCast<const nonConformalCoupledFvPatch>(fvbm[nccPatchi]);
484 nccFieldb[origPatchi] +=
496 nccFieldb[origPatchi] +=
499 fieldb[nccPatchi]*magSfb[nccPatchi],
513 const label origPatchi = origPatchIDs[i];
520 magSfb[origPatchi] + origNccMagSfb[origPatchi]
523 nccFieldb[origPatchi] *=
525 /
max(origNccMagSfb[origPatchi], small*origSumMagSf);
531 nccFieldb[origPatchi] /=
532 max(origNccMagSfb[origPatchi], vSmall);
547 const bool isFluxField =
isFlux(fieldb[0].internalField());
579 const label origPatchi = origPatchIDs[i];
583 magSfb[origPatchi] + origNccMagSfb[origPatchi]
586 origFieldb[origPatchi] *=
588 /
max(magSfb[origPatchi], small*origSumMagSf);
604 const bool isFluxField =
isFlux(origFieldb[0].internalField());
606 const fvBoundaryMesh& fvbm = origFieldb[0].patch().boundaryMesh();
625 const fvPatch& fvp = fvbm[nccPatchi];
627 if (isA<nonConformalCoupledFvPatch>(fvp))
630 refCast<const nonConformalCoupledFvPatch>(fvp);
640 Field<Type>(nccFieldb[origPatchi], nccOrigPatchFace);
655 const fvPatch& fvp = fvbm[nccPatchi];
657 if (isA<nonConformalCoupledFvPatch>(fvp))
660 refCast<const nonConformalCoupledFvPatch>(fvp);
670 magSfb[origPatchi] + origNccMagSfb[origPatchi]
672 const scalarField nccSumMagSf(origSumMagSf, nccOrigPatchFace);
674 fieldb[nccPatchi] *= magSfb[nccPatchi]/nccSumMagSf;
676 if (!isA<processorFvPatch>(fvp))
678 fieldb[origPatchi] *= magSfb[origPatchi]/origSumMagSf;
689 if (isA<nonConformalErrorFvPatch>(fvp))
694 refCast<const nonConformalErrorFvPatch>(fvp);
704 fieldb[errorPatchi] =
Zero;
708 fieldb[errorPatchi] =
709 Field<Type>(origFieldb[origPatchi], errorOrigPatchFace);
724 const scalar ownerWeight,
725 const scalar neighbourWeight
755 const scalar w = cfvp.
owner() ? ownerWeight : neighbourWeight;
756 const scalar v = cfvp.
owner() ? neighbourWeight : ownerWeight;
759 w*syncFieldb[
patchi] + (flip ? -v : +v)*fieldbNbr[
patchi];
774 const bool isFluxField =
isFlux(fieldb[0].internalField());
776 return synchronisedBoundaryField<Type>
#define forAll(list, i)
Loop across all elements in list.
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object of type.
static nonConformalBoundary & New(const polyMesh &mesh)
static const DimensionedField< Type, GeoMesh > & null()
Return a null DimensionedField.
Pre-declare SubField and related Field type.
Generic GeometricBoundaryField class.
tmp< GeometricBoundaryField > boundaryNeighbourField() const
Return BoundaryField of the values on the other side of couples.
Generic GeometricField class.
PatchField< Type > Patch
Type of the patch field of which the Boundary is composed.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
void clear()
Clear the list, i.e. set size to zero.
static label nRequests()
Get number of outstanding requests.
static void waitRequests(const label start=0)
Wait until all requests (from start onwards) have finished.
static bool & parRun()
Is this a parallel run?
static commsTypes defaultCommsType
Default commsType.
This boundary condition is not designed to be evaluated; it is assumed that the value is assigned via...
An abstract base class for patches that couple regions of the computational domain e....
virtual bool owner() const
Does this side own the patch ?
const fvMesh & mesh() const
Return the mesh reference.
tmp< SurfaceFieldBoundary< Type > > conformalNccBoundaryField(const SurfaceFieldBoundary< Type > &fieldb) const
Extract the non-conformal-coupled parts of the boundary field.
tmp< SurfaceFieldBoundary< Type > > nonConformalBoundaryField(const SurfaceFieldBoundary< Type > &nccFieldb, const SurfaceFieldBoundary< Type > &origFieldb) const
Combine non-conformal-coupled and original parts of the.
static tmp< Field< Type > > fieldRMapSum(const Field< Type > &f, const label size, const labelUList &addr)
Reverse-map sum the values of a field.
tmp< SurfaceFieldBoundary< Type > > conformalOrigBoundaryField(const SurfaceFieldBoundary< Type > &fieldb) const
Extract the original parts of the boundary field and store it.
void resizeBoundaryFieldPatchFields(const SurfaceFieldBoundary< label > &polyFacesBf, GeoBoundaryField &fieldBf)
Resize the patch field of a given field to match the mesh.
tmp< SurfaceFieldBoundary< Type > > synchronisedBoundaryField(const SurfaceFieldBoundary< Type > &fieldb, const bool flip, const scalar ownerWeight, const scalar neighbourWeight) const
Synchronise the boundary field by combining corresponding.
tmp< SurfaceFieldBoundary< scalar > > getOrigNccMagSfb() const
Return the total non-conformal area associated with each.
void resizeFieldPatchFields(const SurfaceFieldBoundary< label > &polyFacesBf, GeoField &field)
Resize the patch field of a given field to match the mesh.
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
const surfaceScalarField & magSf() const
Return cell face area magnitudes.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
virtual label size() const
Return size.
virtual bool coupled() const
Return true if this patch is coupled.
virtual label start() const
Return start label of this patch in the polyMesh face list.
HashTable< const Type * > lookupClass(const bool strict=false) const
Lookup and return all objects of the given Type.
Traits class for primitives.
Set size fvPatchFieldMapper.
A class for managing temporary objects.
T & ref() const
Return non-const reference or generate a fatal error.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define PostNonConformSurfaceFields(Type, nullArg)
#define PreConformSurfaceFields(Type, nullArg)
#define ResizePatchFields(Type, nullArg)
#define EvaluateVolFields(Type, nullArg)
Info<< "Calculating turbulent flame speed field St\n"<< endl;volScalarField St(IOobject("St", runTime.name(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE), flameWrinkling->Xi() *Su);multivariateSurfaceInterpolationScheme< scalar >::fieldTable fields
errorManipArg< error, int > exit(error &err, const int errNo=1)
VolField< vector > volVectorField
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
SurfaceField< scalar > surfaceScalarField
bool isFlux(const DimensionedField< Type, surfaceMesh > &df)
Check if surfaceField is a flux.
FOR_ALL_FIELD_TYPES(DefineContiguousFvWallLocationDataType)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
bool isNull(const T &t)
Return true if t is a reference to the nullObject of type T.
SurfaceField< vector > surfaceVectorField
const volVectorField & surfaceToVolVelocity(const surfaceVectorField &Uf)
Get the cell velocity field corresponding to a given face velocity, or a.
Return the vol-field velocity corresponding to a given surface-field velocity.