mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: add data/cdata to VectorSpace for consistency with FixedList etc
This commit is contained in:
committed by
Andrew Heather
parent
c28d785a73
commit
0cfd019b92
@ -87,6 +87,25 @@ void testIterator(const VecSpace& vs)
|
||||
}
|
||||
|
||||
|
||||
template<class VecSpace>
|
||||
void testData(const VecSpace& vs)
|
||||
{
|
||||
Info<< "size: " << vs.size() << " for:";
|
||||
|
||||
const auto* data = vs.cdata();
|
||||
for
|
||||
(
|
||||
const auto* endData = data + VecSpace::nComponents;
|
||||
data != endData;
|
||||
++data
|
||||
)
|
||||
{
|
||||
Info<< " " << *data;
|
||||
}
|
||||
Info<< nl;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Main program:
|
||||
|
||||
@ -105,6 +124,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
testIterator(vec1);
|
||||
testIterator(vec2);
|
||||
testData(vec2);
|
||||
|
||||
// Use STL algorithm(s)
|
||||
|
||||
|
||||
@ -178,6 +178,12 @@ public:
|
||||
inline void component(Cmpt&, const direction) const;
|
||||
inline void replace(const direction, const Cmpt&);
|
||||
|
||||
//- Return const pointer to the first data element
|
||||
inline const Cmpt* cdata() const noexcept;
|
||||
|
||||
//- Return pointer to the first data element
|
||||
inline Cmpt* data() noexcept;
|
||||
|
||||
//- Return a VectorSpace with all elements = s
|
||||
inline static Form uniform(const Cmpt& s);
|
||||
|
||||
@ -213,7 +219,7 @@ public:
|
||||
//- Return an iterator to begin of VectorSpace
|
||||
inline iterator begin();
|
||||
|
||||
//- Return an iterator to end of UListVectorSpace
|
||||
//- Return an iterator to end of VectorSpace
|
||||
inline iterator end();
|
||||
|
||||
|
||||
|
||||
@ -193,6 +193,20 @@ Foam::VectorSpace<Form, Cmpt, Ncmpts>::block() const
|
||||
|
||||
// * * * * * * * * * * * * * * * * Iterator * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Form, class Cmpt, Foam::direction Ncmpts>
|
||||
inline Cmpt* Foam::VectorSpace<Form, Cmpt, Ncmpts>::data() noexcept
|
||||
{
|
||||
return v_;
|
||||
}
|
||||
|
||||
|
||||
template<class Form, class Cmpt, Foam::direction Ncmpts>
|
||||
inline const Cmpt* Foam::VectorSpace<Form, Cmpt, Ncmpts>::cdata() const noexcept
|
||||
{
|
||||
return v_;
|
||||
}
|
||||
|
||||
|
||||
template<class Form, class Cmpt, Foam::direction Ncmpts>
|
||||
inline Cmpt* Foam::VectorSpace<Form, Cmpt, Ncmpts>::begin()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user