/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2023-2026 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see .
\*---------------------------------------------------------------------------*/
#include "GeometricFieldSources.H"
#include "error.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template class PrimitiveField>
Foam::GeometricFieldSources::
GeometricFieldSources()
:
HashPtrTable(),
errorLocation_()
{}
template class PrimitiveField>
Foam::GeometricFieldSources::
GeometricFieldSources
(
const DimensionedField& iF,
const HashPtrTable& mtf
)
:
HashPtrTable(mtf.capacity()),
errorLocation_()
{
forAllConstIter(typename HashPtrTable, mtf, iter)
{
this->set(iter.key(), iter()->clone(iF).ptr());
}
}
template class PrimitiveField>
Foam::GeometricFieldSources::
GeometricFieldSources
(
const DimensionedField& iF,
const GeometricFieldSources& mtf
)
:
HashPtrTable(mtf.capacity()),
errorLocation_(mtf.errorLocation_)
{
forAllConstIter(typename HashPtrTable, mtf, iter)
{
this->set(iter.key(), iter()->clone(iF).ptr());
}
}
template class PrimitiveField>
template class PrimitiveField2>
Foam::GeometricFieldSources::
GeometricFieldSources
(
const DimensionedField& iF,
const GeometricFieldSources& mtf
)
:
HashPtrTable(mtf.capacity()),
errorLocation_(mtf.errorLocation_)
{
forAllConstIter(typename HashPtrTable, mtf, iter)
{
this->set(iter.key(), iter()->clone(iF).ptr());
}
}
template class PrimitiveField>
Foam::GeometricFieldSources::
GeometricFieldSources
(
const DimensionedField& iF,
const dictionary& dict
)
:
HashPtrTable(),
errorLocation_()
{
readField(iF, dict);
}
template class PrimitiveField>
Foam::GeometricFieldSources::
GeometricFieldSources
(
const DimensionedField& iF,
const HashTable& types,
const IOerrorLocation& errorLocation
)
:
HashPtrTable(),
errorLocation_(errorLocation)
{
forAllConstIter(typename HashTable, types, iter)
{
this->set
(
iter.key(),
Source::New(iter(), iF).ptr()
);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template class PrimitiveField>
Foam::GeometricFieldSources::
~GeometricFieldSources()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
template class PrimitiveField>
const Foam::HashPtrTable
<
typename Foam::GeometricFieldSources::Source
>&
Foam::GeometricFieldSources::table() const
{
return *this;
}
template class PrimitiveField>
Foam::HashPtrTable
<
typename Foam::GeometricFieldSources::Source
>&
Foam::GeometricFieldSources::table()
{
return *this;
}
template class PrimitiveField>
const Foam::IOerrorLocation&
Foam::GeometricFieldSources::errorLocation()
const
{
return errorLocation_;
}
template class PrimitiveField>
Foam::HashTable
Foam::GeometricFieldSources::types() const
{
HashTable result;
forAllConstIter(typename HashPtrTable, *this, iter)
{
result.insert(iter.key(), iter()->type());
}
return result;
}
template class PrimitiveField>
void Foam::GeometricFieldSources::readField
(
const DimensionedField& field,
const dictionary& dict
)
{
this->clear();
errorLocation_ = IOerrorLocation(dict);
forAllConstIter(dictionary, dict, iter)
{
if (iter().isDict())
{
this->set
(
iter().keyword(),
Source::New(field, iter().dict()).ptr()
);
}
}
}
template class PrimitiveField>
void Foam::GeometricFieldSources::reset
(
const DimensionedField& field,
const GeometricFieldSources& mtf
)
{
this->clear();
errorLocation_ = mtf.errorLocation_;
forAllConstIter(typename HashPtrTable, mtf, iter)
{
this->set(iter.key(), iter()->clone(field).ptr());
}
}
template class PrimitiveField>
void Foam::GeometricFieldSources::writeEntry
(
const word& keyword,
Ostream& os
) const
{
os << keyword << nl << token::BEGIN_BLOCK << incrIndent << nl;
forAllConstIter(typename HashPtrTable, *this, iter)
{
os << indent << iter.key() << nl
<< indent << token::BEGIN_BLOCK << nl
<< incrIndent << *iter() << decrIndent
<< indent << token::END_BLOCK << endl;
}
os << decrIndent << token::END_BLOCK << endl;
// Check state of IOstream
os.check
(
"GeometricFieldSources::"
"writeEntry(const word& keyword, Ostream& os) const"
);
}
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
template class PrimitiveField>
const typename
Foam::GeometricFieldSources::Source&
Foam::GeometricFieldSources::operator[]
(
const word& sourceName
) const
{
typename HashPtrTable::const_iterator iter = this->find(sourceName);
if (iter == this->end())
{
FatalIOErrorInFunction(errorLocation_)
<< "Cannot find fieldSource entry for " << sourceName
<< exit(FatalIOError);
}
return **iter;
}
// * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * * //
template class PrimitiveField>
Foam::Ostream& Foam::operator<<
(
Ostream& os,
const GeometricFieldSources& bf
)
{
typedef typename GeoMesh::template FieldSource Source;
os << static_cast&>(bf);
return os;
}
// ************************************************************************* //