DEFEATURE: remove mixed precision support for streaming particles (#3412)

- since direct streaming of particles is only ever used internally and
  never for disk I/O (which is collated by property), mixed precision
  will never occur when constructing a particle from a stream.

  Due to padding issues, the previous code would have been faulty anyhow.
  Thus remove that code and replace with a simple sanity check.
This commit is contained in:
Mark Olesen
2025-08-13 12:52:56 +02:00
committed by Andrew Heather
parent 14b68a7f05
commit 3a78203863
15 changed files with 48 additions and 233 deletions

View File

@ -63,23 +63,11 @@ Foam::DTRMParticle::DTRMParticle
{ {
is >> p0_ >> p1_ >> I0_ >> I_ >> dA_ >> transmissiveId_; is >> p0_ >> p1_ >> I0_ >> I_ >> dA_ >> transmissiveId_;
} }
else if (!is.checkLabelSize<>() || !is.checkScalarSize<>())
{
// Non-native label or scalar size
is.beginRawRead();
readRawScalar(is, p0_.data(), vector::nComponents);
readRawScalar(is, p1_.data(), vector::nComponents);
readRawScalar(is, &I0_);
readRawScalar(is, &I_);
readRawScalar(is, &dA_);
readRawLabel(is, &transmissiveId_);
is.endRawRead();
}
else else
{ {
// No non-native streaming
is.fatalCheckNativeSizes(FUNCTION_NAME);
is.read(reinterpret_cast<char*>(&p0_), sizeofFields_); is.read(reinterpret_cast<char*>(&p0_), sizeofFields_);
} }
} }

View File

@ -80,19 +80,11 @@ Foam::findCellParticle::findCellParticle
{ {
is >> start_ >> end_ >> data_; is >> start_ >> end_ >> data_;
} }
else if (!is.checkLabelSize<>() || !is.checkScalarSize<>())
{
// Non-native label or scalar size
is.beginRawRead();
readRawScalar(is, start_.data(), vector::nComponents);
readRawScalar(is, end_.data(), vector::nComponents);
readRawLabel(is, &data_);
is.endRawRead();
}
else else
{ {
// No non-native streaming
is.fatalCheckNativeSizes(FUNCTION_NAME);
is.read is.read
( (
reinterpret_cast<char*>(&start_), reinterpret_cast<char*>(&start_),

View File

@ -442,20 +442,11 @@ Foam::wallBoundedParticle::wallBoundedParticle
{ {
is >> localPosition_ >> meshEdgeStart_ >> diagEdge_; is >> localPosition_ >> meshEdgeStart_ >> diagEdge_;
} }
if (!is.checkLabelSize<>() || !is.checkScalarSize<>())
{
// Non-native label or scalar size
is.beginRawRead();
readRawScalar(is, localPosition_.data(), vector::nComponents);
readRawLabel(is, &meshEdgeStart_);
readRawLabel(is, &diagEdge_);
is.endRawRead();
}
else else
{ {
// No non-native streaming
is.fatalCheckNativeSizes(FUNCTION_NAME);
is.read(reinterpret_cast<char*>(&localPosition_), sizeofFields_); is.read(reinterpret_cast<char*>(&localPosition_), sizeofFields_);
} }
} }

View File

@ -62,20 +62,11 @@ Foam::DSMCParcel<ParcelType>::DSMCParcel
{ {
is >> U_ >> Ei_ >> typeId_; is >> U_ >> Ei_ >> typeId_;
} }
else if (!is.checkLabelSize<>() || !is.checkScalarSize<>())
{
// Non-native label or scalar size
is.beginRawRead();
readRawScalar(is, U_.data(), vector::nComponents);
readRawScalar(is, &Ei_);
readRawLabel(is, &typeId_);
is.endRawRead();
}
else else
{ {
// No non-native streaming
is.fatalCheckNativeSizes(FUNCTION_NAME);
is.read(reinterpret_cast<char*>(&U_), sizeofFields); is.read(reinterpret_cast<char*>(&U_), sizeofFields);
} }
} }

View File

@ -71,20 +71,11 @@ Foam::injectedParticle::injectedParticle
{ {
is >> tag_ >> soi_ >> d_ >> U_; is >> tag_ >> soi_ >> d_ >> U_;
} }
else if (!is.checkLabelSize<>() || !is.checkScalarSize<>())
{
// Non-native label or scalar size
is.beginRawRead();
readRawLabel(is, &tag_);
readRawScalar(is, &soi_);
readRawScalar(is, &d_);
readRawScalar(is, U_.data(), vector::nComponents);
is.endRawRead();
}
else else
{ {
// No non-native streaming
is.fatalCheckNativeSizes(FUNCTION_NAME);
is.read(reinterpret_cast<char*>(&tag_), sizeofFields); is.read(reinterpret_cast<char*>(&tag_), sizeofFields);
} }
} }

View File

@ -91,29 +91,11 @@ void Foam::particle::readData
is >> facei_ >> stepFraction_ >> origProc_ >> origId_; is >> facei_ >> stepFraction_ >> origProc_ >> origId_;
} }
} }
else if (!is.checkLabelSize<>() || !is.checkScalarSize<>())
{
// Non-native label or scalar size
is.beginRawRead();
readRawScalar(is, coordinates_.data(), barycentric::nComponents);
readRawLabel(is, &celli_);
readRawLabel(is, &tetFacei_);
readRawLabel(is, &tetPti_);
if (readFields)
{
readRawLabel(is, &facei_);
readRawScalar(is, &stepFraction_);
readRawLabel(is, &origProc_);
readRawLabel(is, &origId_);
}
is.endRawRead();
}
else else
{ {
// No non-native streaming
is.fatalCheckNativeSizes(FUNCTION_NAME);
if (readFields) if (readFields)
{ {
is.read(reinterpret_cast<char*>(&coordinates_), sizeofFields); is.read(reinterpret_cast<char*>(&coordinates_), sizeofFields);
@ -142,29 +124,11 @@ void Foam::particle::readData
>> p.origId; >> p.origId;
} }
} }
else if (!is.checkLabelSize<>() || !is.checkScalarSize<>())
{
// Non-native label or scalar size
is.beginRawRead();
readRawScalar(is, p.position.data(), vector::nComponents);
readRawLabel(is, &p.celli);
if (readFields)
{
readRawLabel(is, &p.facei);
readRawScalar(is, &p.stepFraction);
readRawLabel(is, &p.tetFacei);
readRawLabel(is, &p.tetPti);
readRawLabel(is, &p.origProc);
readRawLabel(is, &p.origId);
}
is.endRawRead();
}
else else
{ {
// No non-native streaming
is.fatalCheckNativeSizes(FUNCTION_NAME);
if (readFields) if (readFields)
{ {
// Read whole struct // Read whole struct

View File

@ -69,20 +69,11 @@ Foam::CollidingParcel<ParcelType>::CollidingParcel
is >> angularMomentum_; is >> angularMomentum_;
is >> torque_; is >> torque_;
} }
else if (!is.checkLabelSize<>() || !is.checkScalarSize<>())
{
// Non-native label or scalar size
is.beginRawRead();
readRawScalar(is, f_.data(), vector::nComponents);
readRawScalar(is, angularMomentum_.data(), vector::nComponents);
readRawScalar(is, torque_.data(), vector::nComponents);
is.endRawRead();
}
else else
{ {
// No non-native streaming
is.fatalCheckNativeSizes(FUNCTION_NAME);
is.read(reinterpret_cast<char*>(&f_), sizeofFields); is.read(reinterpret_cast<char*>(&f_), sizeofFields);
} }

View File

@ -86,28 +86,11 @@ Foam::KinematicParcel<ParcelType>::KinematicParcel
>> UTurb_ >> UTurb_
>> UCorrect_; >> UCorrect_;
} }
else if (!is.checkLabelSize<>() || !is.checkScalarSize<>())
{
// Non-native label or scalar size
is.beginRawRead();
readRawLabel(is, &active_);
readRawLabel(is, &typeId_);
readRawScalar(is, &nParticle_);
readRawScalar(is, &d_);
readRawScalar(is, &dTarget_);
readRawScalar(is, U_.data(), vector::nComponents);
readRawScalar(is, &rho_);
readRawScalar(is, &age_);
readRawScalar(is, &tTurb_);
readRawScalar(is, UTurb_.data(), vector::nComponents);
readRawScalar(is, UCorrect_.data(), vector::nComponents);
is.endRawRead();
}
else else
{ {
// No non-native streaming
is.fatalCheckNativeSizes(FUNCTION_NAME);
is.read(reinterpret_cast<char*>(&active_), sizeofFields); is.read(reinterpret_cast<char*>(&active_), sizeofFields);
} }
} }

View File

@ -64,18 +64,11 @@ Foam::MPPICParcel<ParcelType>::MPPICParcel
{ {
is >> UCorrect_; is >> UCorrect_;
} }
else if (!is.checkLabelSize<>() || !is.checkScalarSize<>())
{
// Non-native label or scalar size
is.beginRawRead();
readRawScalar(is, UCorrect_.data(), vector::nComponents);
is.endRawRead();
}
else else
{ {
// No non-native streaming
is.fatalCheckNativeSizes(FUNCTION_NAME);
is.read(reinterpret_cast<char*>(&UCorrect_), sizeofFields); is.read(reinterpret_cast<char*>(&UCorrect_), sizeofFields);
} }
} }

View File

@ -66,18 +66,11 @@ Foam::ReactingParcel<ParcelType>::ReactingParcel
{ {
is >> mass0_; is >> mass0_;
} }
else if (!is.checkLabelSize<>() || !is.checkScalarSize<>())
{
// Non-native label or scalar size
is.beginRawRead();
readRawScalar(is, &mass0_);
is.endRawRead();
}
else else
{ {
// No non-native streaming
is.fatalCheckNativeSizes(FUNCTION_NAME);
is.read(reinterpret_cast<char*>(&mass0_), sizeofFields); is.read(reinterpret_cast<char*>(&mass0_), sizeofFields);
} }

View File

@ -65,19 +65,11 @@ Foam::ThermoParcel<ParcelType>::ThermoParcel
{ {
is >> T_ >> Cp_; is >> T_ >> Cp_;
} }
else if (!is.checkLabelSize<>() || !is.checkScalarSize<>())
{
// Non-native label or scalar size
is.beginRawRead();
readRawScalar(is, &T_);
readRawScalar(is, &Cp_);
is.endRawRead();
}
else else
{ {
// No non-native streaming
is.fatalCheckNativeSizes(FUNCTION_NAME);
is.read(reinterpret_cast<char*>(&T_), sizeofFields); is.read(reinterpret_cast<char*>(&T_), sizeofFields);
} }
} }

View File

@ -77,27 +77,11 @@ Foam::molecule::molecule
>> special_ >> special_
>> id_; >> id_;
} }
else if (!is.checkLabelSize<>() || !is.checkScalarSize<>())
{
// Non-native label or scalar size
is.beginRawRead();
readRawScalar(is, Q_.data(), tensor::nComponents);
readRawScalar(is, v_.data(), vector::nComponents);
readRawScalar(is, a_.data(), vector::nComponents);
readRawScalar(is, pi_.data(), vector::nComponents);
readRawScalar(is, tau_.data(), vector::nComponents);
readRawScalar(is, specialPosition_.data(), vector::nComponents);
readRawScalar(is, &potentialEnergy_);
readRawScalar(is, rf_.data(), tensor::nComponents);
readRawLabel(is, &special_);
readRawLabel(is, &id_);
is.endRawRead();
}
else else
{ {
// No non-native streaming
is.fatalCheckNativeSizes(FUNCTION_NAME);
is.read(reinterpret_cast<char*>(&Q_), sizeofFields); is.read(reinterpret_cast<char*>(&Q_), sizeofFields);
} }

View File

@ -55,19 +55,11 @@ Foam::solidParticle::solidParticle
{ {
is >> d_ >> U_; is >> d_ >> U_;
} }
else if (!is.checkLabelSize<>() || !is.checkScalarSize<>())
{
// Non-native label or scalar size
is.beginRawRead();
readRawScalar(is, &d_);
readRawScalar(is, U_.data(), vector::nComponents);
is.endRawRead();
}
else else
{ {
// No non-native streaming
is.fatalCheckNativeSizes(FUNCTION_NAME);
is.read(reinterpret_cast<char*>(&d_), sizeofFields); is.read(reinterpret_cast<char*>(&d_), sizeofFields);
} }
} }

View File

@ -87,30 +87,11 @@ Foam::SprayParcel<ParcelType>::SprayParcel
>> tMom_ >> tMom_
>> user_; >> user_;
} }
else if (!is.checkLabelSize<>() || !is.checkScalarSize<>())
{
// Non-native label or scalar size
is.beginRawRead();
readRawScalar(is, &d0_);
readRawScalar(is, position0_.data(), vector::nComponents);
readRawScalar(is, &sigma_);
readRawScalar(is, &mu_);
readRawScalar(is, &liquidCore_);
readRawScalar(is, &KHindex_);
readRawScalar(is, &y_);
readRawScalar(is, &yDot_);
readRawScalar(is, &tc_);
readRawScalar(is, &ms_);
readRawScalar(is, &injector_);
readRawScalar(is, &tMom_);
readRawScalar(is, &user_);
is.endRawRead();
}
else else
{ {
// No non-native streaming
is.fatalCheckNativeSizes(FUNCTION_NAME);
is.read(reinterpret_cast<char*>(&d0_), sizeofFields); is.read(reinterpret_cast<char*>(&d0_), sizeofFields);
} }
} }

View File

@ -100,22 +100,11 @@ Foam::trackedParticle::trackedParticle
{ {
is >> start_ >> end_ >> level_ >> i_ >> j_ >> k_; is >> start_ >> end_ >> level_ >> i_ >> j_ >> k_;
} }
else if (!is.checkLabelSize<>() || !is.checkScalarSize<>())
{
// Non-native label or scalar size
is.beginRawRead();
readRawScalar(is, start_.data(), vector::nComponents);
readRawScalar(is, end_.data(), vector::nComponents);
readRawLabel(is, &level_);
readRawLabel(is, &i_);
readRawLabel(is, &j_);
readRawLabel(is, &k_);
is.endRawRead();
}
else else
{ {
// No non-native streaming
is.fatalCheckNativeSizes(FUNCTION_NAME);
is.read is.read
( (
reinterpret_cast<char*>(&start_), reinterpret_cast<char*>(&start_),