43 template<
class Type,
template<
class>
class GeoField>
44 void Foam::fvMeshStitcher::storeOldTimeFields()
49 iter()->storeOldTimes();
54 template<
template<
class>
class GeoField>
55 void Foam::fvMeshStitcher::storeOldTimeFields()
57 #define StoreOldTimeFields(Type, nullArg) \ 58 storeOldTimeFields<Type, GeoField>(); 60 #undef StoreOldTimeFields 64 template<
class Type,
template<
class>
class GeoField>
65 void Foam::fvMeshStitcher::resizePatchFields()
67 struct fvPatchFieldSetSizer
69 public fvPatchFieldMapper,
70 public setSizeFieldMapper
72 fvPatchFieldSetSizer(
const label size)
74 setSizeFieldMapper(size)
78 HashTable<GeoField<Type>*>
fields(mesh_.lookupClass<GeoField<Type>>());
83 typename GeoField<Type>::Patch& pf =
84 iter()->boundaryFieldRef()[
patchi];
86 if (isA<nonConformalFvPatch>(pf.patch()))
88 pf.autoMap(fvPatchFieldSetSizer(pf.patch().size()));
95 template<
template<
class>
class GeoField>
96 void Foam::fvMeshStitcher::resizePatchFields()
98 #define ResizePatchFields(Type, nullArg) \ 99 resizePatchFields<Type, GeoField>(); 101 #undef ResizePatchFields 106 void Foam::fvMeshStitcher::preConformSurfaceFields()
108 HashTable<SurfaceField<Type>*>
fields 110 mesh_.lookupClass<SurfaceField<Type>>()
120 SurfaceField<Type>& field = *iter();
124 &field == static_cast<const regIOobject*>(phiPtr)
128 autoPtr<SurfaceField<Type>> nccFieldPtr
130 new SurfaceField<Type>
134 nccFieldPrefix_ + field.name(),
135 mesh_.time().timeName(),
142 for (
label i = 0; i <= field.nOldTimes(); ++ i)
144 SurfaceField<Type>& field0 = field.oldTime(i);
146 nccFieldPtr->oldTime(i).boundaryFieldRef() =
147 conformalNccBoundaryField<Type>(field0.boundaryField());
149 field0.boundaryFieldRef() =
150 conformalOrigBoundaryField<Type>(field0.boundaryField());
153 nccFieldPtr.ptr()->store();
158 inline void Foam::fvMeshStitcher::preConformSurfaceFields()
160 #define PreConformSurfaceFields(Type, nullArg) \ 161 preConformSurfaceFields<Type>(); 163 #undef PreConformSurfaceFields 168 void Foam::fvMeshStitcher::postNonConformSurfaceFields()
170 HashTable<SurfaceField<Type>*>
fields 172 mesh_.lookupClass<SurfaceField<Type>>()
182 if (iter.key()(nccFieldPrefix_.size()) == nccFieldPrefix_)
continue;
184 SurfaceField<Type>& field = *iter();
188 &field == static_cast<const regIOobject*>(phiPtr)
190 || mesh_.topoChanged()
193 const word nccFieldName = nccFieldPrefix_ + field.name();
195 const SurfaceField<Type>& nccField =
196 mesh_.lookupObject<SurfaceField<Type>>(nccFieldName);
198 for (
label i = 0; i <= field.nOldTimes(); ++ i)
200 SurfaceField<Type>& field0 = field.oldTime(i);
202 field0.boundaryFieldRef() =
203 nonConformalBoundaryField<Type>
205 nccField.oldTime(i).boundaryField(),
206 field0.boundaryField()
209 field0.boundaryFieldRef() =
210 synchronisedBoundaryField<Type>(field0.boundaryField());
219 if (iter.key()(nccFieldPrefix_.size()) == nccFieldPrefix_)
continue;
221 SurfaceField<Type>& field = *iter();
225 &field == static_cast<const regIOobject*>(phiPtr)
229 const word nccFieldName = nccFieldPrefix_ + field.name();
231 SurfaceField<Type>& nccField =
232 mesh_.lookupObjectRef<SurfaceField<Type>>(nccFieldName);
238 fields = mesh_.lookupClass<SurfaceField<Type>>();
241 if (iter.key()(nccFieldPrefix_.size()) != nccFieldPrefix_)
continue;
244 <<
"Stitching mapping field \"" << iter()->name()
245 <<
"\" found, but the field it corresponds to no longer exists" 251 inline void Foam::fvMeshStitcher::postNonConformSurfaceFields()
253 #define PostNonConformSurfaceFields(Type, nullArg) \ 254 postNonConformSurfaceFields<Type>(); 256 #undef PostNonConformSurfaceFields 261 void Foam::fvMeshStitcher::evaluateVolFields()
263 HashTable<VolField<Type>*>
fields(mesh_.lookupClass<VolField<Type>>());
271 iter()->boundaryFieldRef()[
patchi];
273 if (isA<nonConformalFvPatch>(pf.patch()))
291 iter()->boundaryFieldRef()[
patchi];
293 if (isA<nonConformalFvPatch>(pf.patch()))
302 inline void Foam::fvMeshStitcher::evaluateVolFields()
304 #define EvaluateVolFields(Type, nullArg) \ 305 evaluateVolFields<Type>(); 307 #undef EvaluateVolFields 311 inline void Foam::fvMeshStitcher::postNonConformSurfaceVelocities()
313 if (mesh_.topoChanged())
315 HashTable<surfaceVectorField*> Ufs
320 forAllIter(HashTable<surfaceVectorField*>, Ufs, iter)
330 if (isA<nonConformalFvPatch>(mesh_.boundary()[
patchi]))
332 Uf.boundaryFieldRef()[
patchi] ==
333 U.boundaryField()[
patchi];
344 template<
class GeoBoundaryField>
348 GeoBoundaryField& fieldBf
351 struct fvPatchFieldSetSizer
356 fvPatchFieldSetSizer(
const label size)
362 forAll(polyFacesBf, nccPatchi)
364 if (isA<nonConformalFvPatch>(polyFacesBf[nccPatchi].patch()))
366 fieldBf[nccPatchi].autoMap
368 fvPatchFieldSetSizer(polyFacesBf[nccPatchi].size())
374 template<
class GeoField>
381 for (
label i = 0; i <= field.nOldTimes(); ++ i)
386 field.oldTime(i).boundaryFieldRef()
403 tresult.
ref()[addr[i]] += f[i];
447 const fvPatch& fvp = fvbm[nccPatchi];
449 if (isA<nonConformalCoupledFvPatch>(fvp))
452 refCast<const nonConformalCoupledFvPatch>(fvp);
460 origNccMagSfb[origPatchi] +=
470 return tOrigNccMagSfb;
481 const bool isFluxField =
isFlux(fieldb[0].internalField());
510 const fvPatch& fvp = fvbm[nccPatchi];
512 if (isA<nonConformalCoupledFvPatch>(fvp))
515 refCast<const nonConformalCoupledFvPatch>(fvbm[nccPatchi]);
526 nccFieldb[origPatchi] +=
538 nccFieldb[origPatchi] +=
541 fieldb[nccPatchi]*magSfb[nccPatchi],
555 const label origPatchi = origPatchIDs[i];
562 magSfb[origPatchi] + origNccMagSfb[origPatchi]
565 nccFieldb[origPatchi] *=
567 /
max(origNccMagSfb[origPatchi], small*origSumMagSf);
573 nccFieldb[origPatchi] /=
574 max(origNccMagSfb[origPatchi], vSmall);
589 const bool isFluxField =
isFlux(fieldb[0].internalField());
621 const label origPatchi = origPatchIDs[i];
625 magSfb[origPatchi] + origNccMagSfb[origPatchi]
628 origFieldb[origPatchi] *=
630 /
max(magSfb[origPatchi], small*origSumMagSf);
646 const bool isFluxField =
isFlux(origFieldb[0].internalField());
648 const fvBoundaryMesh& fvbm = origFieldb[0].patch().boundaryMesh();
667 const fvPatch& fvp = fvbm[nccPatchi];
669 if (isA<nonConformalCoupledFvPatch>(fvp))
672 refCast<const nonConformalCoupledFvPatch>(fvp);
682 Field<Type>(nccFieldb[origPatchi], nccOrigPatchFace);
697 const fvPatch& fvp = fvbm[nccPatchi];
699 if (isA<nonConformalCoupledFvPatch>(fvp))
702 refCast<const nonConformalCoupledFvPatch>(fvp);
712 magSfb[origPatchi] + origNccMagSfb[origPatchi]
714 const scalarField nccSumMagSf(origSumMagSf, nccOrigPatchFace);
716 fieldb[nccPatchi] *= magSfb[nccPatchi]/nccSumMagSf;
718 if (!isA<processorFvPatch>(fvp))
720 fieldb[origPatchi] *= magSfb[origPatchi]/origSumMagSf;
731 if (isA<nonConformalErrorFvPatch>(fvp))
736 refCast<const nonConformalErrorFvPatch>(fvp);
746 fieldb[errorPatchi] =
Zero;
750 fieldb[errorPatchi] =
751 Field<Type>(origFieldb[origPatchi], errorOrigPatchFace);
766 const scalar ownerWeight,
767 const scalar neighbourWeight
797 const scalar w = cfvp.
owner() ? ownerWeight : neighbourWeight;
798 const scalar v = cfvp.
owner() ? neighbourWeight : ownerWeight;
801 w*syncFieldb[
patchi] + (flip ? -v : +v)*fieldbNbr[
patchi];
816 const bool isFluxField =
isFlux(fieldb[0].internalField());
818 return synchronisedBoundaryField<Type>
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 > > conformalNccBoundaryField(const SurfaceFieldBoundary< Type > &fieldb) const
Extract the non-conformal-coupled parts of the boundary field.
Return the vol-field velocity corresponding to a given surface-field velocity.
Field sizing mapper which sets the field size and does not map values.
#define forAll(list, i)
Loop across all elements in list.
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
FvWallInfoData< WallInfo, label > label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
errorManipArg< error, int > exit(error &err, const int errNo=1)
virtual bool owner() const
Does this side own the patch ?
tmp< SurfaceFieldBoundary< Type > > nonConformalBoundaryField(const SurfaceFieldBoundary< Type > &nccFieldb, const SurfaceFieldBoundary< Type > &origFieldb) const
Combine non-conformal-coupled and original parts of the.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
virtual label start() const
Return start label of this patch in the polyMesh face list.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
T & ref() const
Return non-const reference or generate a fatal error.
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object of type.
An abstract base class for patches that couple regions of the computational domain e...
GeometricField< vector, fvsPatchField, surfaceMesh > surfaceVectorField
#define PreConformSurfaceFields(Type, nullArg)
const volVectorField & surfaceToVolVelocity(const surfaceVectorField &Uf)
Get the cell velocity field corresponding to a given face velocity, or a.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Traits class for primitives.
static label nRequests()
Get number of outstanding requests.
Generic GeometricField class.
GeometricField< vector, fvPatchField, volMesh > volVectorField
#define StoreOldTimeFields(Type, nullArg)
#define PostNonConformSurfaceFields(Type, nullArg)
tmp< SurfaceFieldBoundary< scalar > > getOrigNccMagSfb() const
Return the total non-conformal area associated with each.
void resizeBoundaryFieldPatchFields(const SurfaceFieldBoundary< label > &polyFacesBf, GeoBoundaryField &fieldBf)
Resize the patch field of a given field to match the mesh.
bool isNull(const T &t)
Return true if t is a reference to the nullObject of type T.
tmp< SurfaceFieldBoundary< Type > > conformalOrigBoundaryField(const SurfaceFieldBoundary< Type > &fieldb) const
Extract the original parts of the boundary field and store it.
static const DimensionedField< Type, GeoMesh > & null()
Return a null DimensionedField.
Pre-declare SubField and related Field type.
const fvMesh & mesh() const
Return the mesh reference.
void resizeFieldPatchFields(const SurfaceFieldBoundary< label > &polyFacesBf, GeoField &field)
Resize the patch field of a given field to match the mesh.
void clear()
Clear the list, i.e. set size to zero.
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.
Foam::fvPatchFieldMapper.
This boundary condition is not designed to be evaluated; it is assumed that the value is assigned via...
tmp< GeometricBoundaryField > boundaryNeighbourField() const
Return BoundaryField of the values on the other side of couples.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
virtual label size() const
Return size.
const surfaceScalarField & magSf() const
Return cell face area magnitudes.
#define ResizePatchFields(Type, nullArg)
static nonConformalBoundary & New(polyMesh &mesh)
static void waitRequests(const label start=0)
Wait until all requests (from start onwards) have finished.
Generic GeometricBoundaryField class.
bool isFlux(const DimensionedField< Type, surfaceMesh > &df)
Check if surfaceField is a flux.
#define EvaluateVolFields(Type, nullArg)
static commsTypes defaultCommsType
Default commsType.
static bool & parRun()
Is this a parallel run?
Info<< "Reading field p_rgh\"<< endl;volScalarField p_rgh(IOobject("p_rgh", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE), mesh);pressureReference pressureReference(p, p_rgh, pimple.dict(), thermo.incompressible());mesh.schemes().setFluxRequired(p_rgh.name());hydrostaticInitialisation(p_rgh, p, rho, U, gh, ghf, pRef, thermo, pimple.dict());Info<< "Creating field dpdt\"<< endl;volScalarField dpdt(IOobject("dpdt", runTime.timeName(), mesh), mesh, dimensionedScalar(p.dimensions()/dimTime, 0));Info<< "Creating field kinetic energy K\"<< endl;volScalarField K("K", 0.5 *magSqr(U));dimensionedScalar initialMass=fvc::domainIntegrate(rho);multivariateSurfaceInterpolationScheme< scalar >::fieldTable fields
PatchField< Type > Patch
Type of the patch field of which the Boundary is composed.
FOR_ALL_FIELD_TYPES(DefineFvWallInfoType)
A class for managing temporary objects.
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
virtual bool coupled() const
Return true if this patch is coupled.
HashTable< const Type * > lookupClass(const bool strict=false) const
Lookup and return all objects of the given Type.