From afc5c00104f357d720f0e6160259d37745a00c61 Mon Sep 17 00:00:00 2001 From: Will Bainbridge Date: Tue, 3 Jan 2023 08:46:47 +0000 Subject: [PATCH] IOPosition: Extended to use with primitive lists of particles --- src/lagrangian/basic/Cloud/Cloud.H | 1 + src/lagrangian/basic/IOPosition/IOPosition.C | 22 ++++++++++++++++---- src/lagrangian/basic/IOPosition/IOPosition.H | 10 +++++++-- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/lagrangian/basic/Cloud/Cloud.H b/src/lagrangian/basic/Cloud/Cloud.H index 6de9ba420e..4b38855a6c 100644 --- a/src/lagrangian/basic/Cloud/Cloud.H +++ b/src/lagrangian/basic/Cloud/Cloud.H @@ -128,6 +128,7 @@ public: typedef ParticleType particleType; + typedef typename IDLList::value_type value_type; typedef typename IDLList::iterator iterator; typedef typename IDLList::const_iterator const_iterator; diff --git a/src/lagrangian/basic/IOPosition/IOPosition.C b/src/lagrangian/basic/IOPosition/IOPosition.C index 0804a44152..035a051ef6 100644 --- a/src/lagrangian/basic/IOPosition/IOPosition.C +++ b/src/lagrangian/basic/IOPosition/IOPosition.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -24,10 +24,23 @@ License \*---------------------------------------------------------------------------*/ #include "IOPosition.H" -#include "polyMesh.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // +template +Foam::IOPosition::IOPosition +( + const IOobject& io, + const polyMesh& mesh, + const CloudType& c +) +: + regIOobject(io), + mesh_(mesh), + cloud_(c) +{} + + template Foam::IOPosition::IOPosition(const CloudType& c) : @@ -42,6 +55,7 @@ Foam::IOPosition::IOPosition(const CloudType& c) IOobject::NO_WRITE ) ), + mesh_(c.pMesh()), cloud_(c) {} @@ -90,7 +104,7 @@ void Foam::IOPosition::readData(Istream& is, CloudType& c) for (label i=0; i::readData(Istream& is, CloudType& c) is.putBack(lastToken); // Read position only - c.append(new typename CloudType::particleType(is, false)); + c.append(new typename CloudType::value_type(is, false)); is >> lastToken; } } diff --git a/src/lagrangian/basic/IOPosition/IOPosition.H b/src/lagrangian/basic/IOPosition/IOPosition.H index 9e52c45132..5857bc1ff1 100644 --- a/src/lagrangian/basic/IOPosition/IOPosition.H +++ b/src/lagrangian/basic/IOPosition/IOPosition.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -35,7 +35,7 @@ SourceFiles #ifndef IOPosition_H #define IOPosition_H -#include "regIOobject.H" +#include "polyMesh.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -62,6 +62,9 @@ class IOPosition // Private Data + //- Reference to the mesh + const polyMesh& mesh_; + //- Reference to the cloud const CloudType& cloud_; @@ -80,6 +83,9 @@ public: // Constructors + //- Construct from components + IOPosition(const IOobject&, const polyMesh&, const CloudType&); + //- Construct from cloud IOPosition(const CloudType&);