mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Cloud - added function to read cloud fields from disk to obr
This commit is contained in:
committed by
Mark Olesen
parent
f5f93e81d8
commit
79fafda22c
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -45,6 +45,7 @@ SourceFiles
|
||||
#include "CompactIOField.H"
|
||||
#include "polyMesh.H"
|
||||
#include "bitSet.H"
|
||||
#include "wordRes.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -240,6 +241,21 @@ public:
|
||||
const CompactIOField<Field<DataType>, DataType>& data
|
||||
) const;
|
||||
|
||||
//- Helper function to store a cloud field on its registry
|
||||
template<class Type>
|
||||
bool readStoreFile
|
||||
(
|
||||
const IOobject& io,
|
||||
const IOobject& ioNew
|
||||
) const;
|
||||
|
||||
//- Read from files into objectRegistry
|
||||
void readFromFiles
|
||||
(
|
||||
objectRegistry& obr,
|
||||
const wordRes& selectFields
|
||||
) const;
|
||||
|
||||
|
||||
// Write
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017, 2020 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -30,6 +30,7 @@ License
|
||||
#include "Time.H"
|
||||
#include "IOPosition.H"
|
||||
#include "IOdictionary.H"
|
||||
#include "IOobjectList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -243,6 +244,80 @@ void Foam::Cloud<ParticleType>::checkFieldFieldIOobject
|
||||
}
|
||||
|
||||
|
||||
template<class ParticleType>
|
||||
template<class Type>
|
||||
bool Foam::Cloud<ParticleType>::readStoreFile
|
||||
(
|
||||
const IOobject& io,
|
||||
const IOobject& ioNew
|
||||
) const
|
||||
{
|
||||
if (io.headerClassName() == IOField<Type>::typeName)
|
||||
{
|
||||
IOField<Type> fld(io);
|
||||
auto* fldNewPtr = new IOField<Type>(ioNew, std::move(fld));
|
||||
return fldNewPtr->store();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
template<class ParticleType>
|
||||
void Foam::Cloud<ParticleType>::readFromFiles
|
||||
(
|
||||
objectRegistry& obr,
|
||||
const wordRes& selectFields
|
||||
) const
|
||||
{
|
||||
IOobjectList cloudObjects
|
||||
(
|
||||
*this,
|
||||
time().timeName(),
|
||||
"",
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
);
|
||||
|
||||
forAllIters(cloudObjects, iter)
|
||||
{
|
||||
if (selectFields.size() && !selectFields.match(iter()->name()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
IOobject ioNew
|
||||
(
|
||||
iter()->name(),
|
||||
time().timeName(),
|
||||
obr,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
);
|
||||
|
||||
auto& object = *iter();
|
||||
|
||||
const bool stored
|
||||
(
|
||||
readStoreFile<label>(object, ioNew)
|
||||
|| readStoreFile<scalar>(object, ioNew)
|
||||
|| readStoreFile<vector>(object, ioNew)
|
||||
|| readStoreFile<sphericalTensor>(object, ioNew)
|
||||
|| readStoreFile<symmTensor>(object, ioNew)
|
||||
|| readStoreFile<tensor>(object, ioNew)
|
||||
);
|
||||
|
||||
if (!stored)
|
||||
{
|
||||
DebugInfo
|
||||
<< "Unhandled field type " << iter()->headerClassName()
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class ParticleType>
|
||||
void Foam::Cloud<ParticleType>::writeFields() const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user