ENH: add objectRegistry newIOobject() helper method

- creates an IOobject at the current time instance (timeName) with
  NO_READ/NO_WRITE/NO_REGISTER characteristics.
  This generalises and replaces the Cloud fieldIOobject() to simplify
  some common use.

  // Shorter version (new):
      volScalarField fld
      (
          mesh.newIOobject(name),
         ...
      );

  // Longer version:
      volScalarField fld
      (
          IOobject
          (
              name,
              mesh.time().timeName(),
              mesh,
              IOobject::NO_READ,
              IOobject::NO_WRITE
              IOobject::NO_REGISTER
           ),
           ...
      );
This commit is contained in:
Mark Olesen
2024-01-04 17:47:03 +01:00
parent 646b0aab36
commit 5d5f541dd6
20 changed files with 218 additions and 176 deletions

View File

@ -394,14 +394,14 @@ void Foam::streamLineParticle::readFields(Cloud<streamLineParticle>& c)
IOField<label> lifeTime
(
c.fieldIOobject("lifeTime", IOobject::MUST_READ),
c.newIOobject("lifeTime", IOobject::MUST_READ),
readOnProc
);
c.checkFieldIOobject(c, lifeTime);
vectorFieldIOField sampledPositions
(
c.fieldIOobject("sampledPositions", IOobject::MUST_READ),
c.newIOobject("sampledPositions", IOobject::MUST_READ),
readOnProc
);
c.checkFieldIOobject(c, sampledPositions);
@ -425,12 +425,12 @@ void Foam::streamLineParticle::writeFields(const Cloud<streamLineParticle>& c)
IOField<label> lifeTime
(
c.fieldIOobject("lifeTime", IOobject::NO_READ),
c.newIOobject("lifeTime", IOobject::NO_READ),
np
);
vectorFieldIOField sampledPositions
(
c.fieldIOobject("sampledPositions", IOobject::NO_READ),
c.newIOobject("sampledPositions", IOobject::NO_READ),
np
);

View File

@ -427,19 +427,19 @@ void Foam::wallBoundedParticle::readFields(TrackCloudType& c)
IOField<point> localPosition
(
c.fieldIOobject("position", IOobject::MUST_READ)
c.newIOobject("position", IOobject::MUST_READ)
);
c.checkFieldIOobject(c, localPosition);
IOField<label> meshEdgeStart
(
c.fieldIOobject("meshEdgeStart", IOobject::MUST_READ)
c.newIOobject("meshEdgeStart", IOobject::MUST_READ)
);
c.checkFieldIOobject(c, meshEdgeStart);
IOField<label> diagEdge
(
c.fieldIOobject("diagEdge", IOobject::MUST_READ)
c.newIOobject("diagEdge", IOobject::MUST_READ)
);
c.checkFieldIOobject(c, diagEdge);
@ -464,17 +464,17 @@ void Foam::wallBoundedParticle::writeFields(const TrackCloudType& c)
IOField<point> localPosition
(
c.fieldIOobject("position", IOobject::NO_READ),
c.newIOobject("position", IOobject::NO_READ),
np
);
IOField<label> meshEdgeStart
(
c.fieldIOobject("meshEdgeStart", IOobject::NO_READ),
c.newIOobject("meshEdgeStart", IOobject::NO_READ),
np
);
IOField<label> diagEdge
(
c.fieldIOobject("diagEdge", IOobject::NO_READ),
c.newIOobject("diagEdge", IOobject::NO_READ),
np
);

View File

@ -213,13 +213,13 @@ void Foam::wallBoundedStreamLineParticle::readFields
IOField<label> lifeTime
(
c.fieldIOobject("lifeTime", IOobject::MUST_READ)
c.newIOobject("lifeTime", IOobject::MUST_READ)
);
c.checkFieldIOobject(c, lifeTime);
vectorFieldIOField sampledPositions
(
c.fieldIOobject("sampledPositions", IOobject::MUST_READ)
c.newIOobject("sampledPositions", IOobject::MUST_READ)
);
c.checkFieldIOobject(c, sampledPositions);
@ -244,12 +244,12 @@ void Foam::wallBoundedStreamLineParticle::writeFields
IOField<label> lifeTime
(
c.fieldIOobject("lifeTime", IOobject::NO_READ),
c.newIOobject("lifeTime", IOobject::NO_READ),
np
);
vectorFieldIOField sampledPositions
(
c.fieldIOobject("sampledPositions", IOobject::NO_READ),
c.newIOobject("sampledPositions", IOobject::NO_READ),
np
);