triSurfaceField refactored

This commit is contained in:
Hamidreza Norouzi 2024-02-05 01:29:45 -08:00
parent 80b61d4d73
commit 9dfe98eea2
6 changed files with 214 additions and 83 deletions

View File

@ -55,6 +55,7 @@ containers/VectorHD/VectorSingles.cpp
containers/Field/Fields.cpp containers/Field/Fields.cpp
containers/List/anyList/anyList.cpp containers/List/anyList/anyList.cpp
containers/pointField/pointFields.cpp containers/pointField/pointFields.cpp
containers/triSurfaceField/triSurfaceFields.cpp
setFieldList/setFieldList.cpp setFieldList/setFieldList.cpp
setFieldList/setFieldEntry.cpp setFieldList/setFieldEntry.cpp

View File

@ -106,6 +106,14 @@ public:
fieldKey_(fieldKey) fieldKey_(fieldKey)
{} {}
Field(const word& name, const word& fieldKey, size_t capacity, size_t len, const T& val)
:
VectorType(name, len, len, RESERVE()),
fieldKey_(fieldKey)
{
VectorType::fill(val);
}
/// Construct a field with name, fieldKey, capacity and len /// Construct a field with name, fieldKey, capacity and len
Field(const word& name, const word& fieldKey, size_t capacity, size_t len, RESERVE) Field(const word& name, const word& fieldKey, size_t capacity, size_t len, RESERVE)
: :

View File

@ -1,3 +1,4 @@
#include "triSurfaceField.hpp"
/*------------------------------- phasicFlow --------------------------------- /*------------------------------- phasicFlow ---------------------------------
O C enter of O C enter of
O O E ngineering and O O E ngineering and
@ -18,7 +19,153 @@ Licence:
-----------------------------------------------------------------------------*/ -----------------------------------------------------------------------------*/
template<template<class, class> class VectorField, class T, class MemorySpace> template<class T, class MemorySpace>
pFlow::triSurfaceField<T,MemorySpace>::triSurfaceField
(
const objectFile& objf,
multiTriSurface& surface,
const T& defVal
)
:
triSurfaceField
(
objf,
surface.owner(),
surface,
defVal
)
{
}
template<class T, class MemorySpace>
pFlow::triSurfaceField<T,MemorySpace>::triSurfaceField
(
const objectFile& objf,
repository* owner,
multiTriSurface& surface,
const T& defVal
)
:
IOobject
(
objf,
IOPattern::AllProcessorsSimilar,
owner
),
observer
(
&surface,
message::Default()
),
field_
(
objf.name(),
"value",
surface.capacity(),
surface.size(),
RESERVE()
),
surface_(surface),
defaultValue_(defVal)
{
if(IOobject::implyRead())
{
REPORT(1)<< "Reading triSurfaceField "<< Green_Text(IOobject::name())<<
" from "<<IOobject::path()<<END_REPORT;
}
else
{
REPORT(1)<< "Creating triSurfaceField "<< Green_Text(IOobject::name())<<END_REPORT;
}
if( !IOobject::readObject() )
{
fatalErrorInFunction<<
"Error in reading from file "<<IOobject::path()<<endl;
fatalExit;
}
}
template <class T, class MemorySpace>
pFlow::triSurfaceField<T, MemorySpace>::triSurfaceField
(
const objectFile &objf,
multiTriSurface &surface,
const T &val,
const T &defVal
)
:
triSurfaceField
(
objf,
surface.owner(),
surface,
val,
defVal
)
{}
template <class T, class MemorySpace>
pFlow::triSurfaceField<T, MemorySpace>::triSurfaceField
(
const objectFile &objf,
repository *owner,
multiTriSurface &surface,
const T &val,
const T &defVal
)
:
IOobject
(
objectFile
(
objf.name(),
objf.localPath(),
objectFile::READ_NEVER,
objf.wFlag()
),
IOPattern::AllProcessorsSimilar,
owner
),
observer
(
&surface,
message::Default()
),
field_
(
objf.name(),
"value",
surface.capacity(),
surface.size(),
val
),
surface_(surface),
defaultValue_(defVal)
{
}
template <class T, class MemorySpace>
bool pFlow::triSurfaceField<T, MemorySpace>::write
(
iOstream &is,
const IOPattern &iop
) const
{
return field_.write(is, iop);
}
template <class T, class MemorySpace>
bool pFlow::triSurfaceField<T, MemorySpace>::read
(
iIstream &is,
const IOPattern &iop
)
{
return field_.read(is, iop);
}
/*template<template<class, class> class VectorField, class T, class MemorySpace>
pFlow::triSurfaceField<VectorField, T, MemorySpace>::triSurfaceField pFlow::triSurfaceField<VectorField, T, MemorySpace>::triSurfaceField
( (
const triSurface& surface, const triSurface& surface,
@ -116,4 +263,4 @@ bool pFlow::triSurfaceField<VectorField, T, MemorySpace>::writeTriSurfaceField
)const )const
{ {
return FieldType::write(os); return FieldType::write(os);
} }*/

View File

@ -22,7 +22,8 @@ Licence:
#define __trieSurfaceField_hpp__ #define __trieSurfaceField_hpp__
#include "Field.hpp" #include "Field.hpp"
#include "triSurface.hpp" #include "multiTriSurface.hpp"
#include "observer.hpp"
#include "error.hpp" #include "error.hpp"
@ -30,119 +31,93 @@ namespace pFlow
{ {
template<template<class, class> class VectorField, class T, class MemorySpace=void> template<class T, class MemorySpace=void>
class triSurfaceField class triSurfaceField
: :
public eventObserver, public IOobject,
public Field<VectorField, T, MemorySpace> public observer
{ {
public: public:
using triSurfaceFieldType = triSurfaceField<VectorField, T, MemorySpace>; using triSurfaceFieldType = triSurfaceField<T, MemorySpace>;
using FieldType = Field<VectorField, T, MemorySpace>; using FieldType = Field<T, MemorySpace>;
using VectorType = typename FieldType::VectorType; using VectorType = typename FieldType::VectorType;
using iterator = typename FieldType::iterator; using memory_space = typename FieldType::memory_space;
using constIterator = typename FieldType::constIterator; using execution_space = typename FieldType::execution_space;
using reference = typename FieldType::reference; private:
using constReference = typename FieldType::constReference;
using valueType = typename FieldType::valueType;
using pointer = typename FieldType::pointer;
using constPointer = typename FieldType::constPointer;
protected:
////- data members ////- data members
const triSurface& surface_;
FieldType field_;
const multiTriSurface& surface_;
// - value when a new item is added to field // - value when a new item is added to field
T defaultValue_; T defaultValue_;
public: public:
// - type info // - type info
TypeInfoTemplateNV2("triSurfaceField", T, VectorType::memoerySpaceName()); TypeInfoTemplate111("triSurfaceField", T, VectorType::memoerySpaceName());
//// CONSTRUCTORS //// CONSTRUCTORS
// - construct a field from tirSurface and set defaultValue_ and field value to defVal // - construct a field from tirSurface and set defaultValue_ and field value to defVal
triSurfaceField( const triSurface& surface, const T& defVal, bool subscribe = true); triSurfaceField(
const objectFile& objf,
multiTriSurface& surface,
const T& defVal);
triSurfaceField(
const objectFile& objf,
repository* owner,
multiTriSurface& surface,
const T& defVal);
// - construct from iIOEntity, tirSurface and a value // - construct from iIOEntity, tirSurface and a value
triSurfaceField( const triSurface& surface, const T& val, const T& defVal, bool subscribe = true); triSurfaceField(
const objectFile& objf,
multiTriSurface& surface,
const T& val,
const T& defVal);
// - construct from another triSurfaceField triSurfaceField(
// subscribe to events if true const objectFile& objf,
triSurfaceField( const triSurfaceField& src, bool subscribe); repository* owner,
multiTriSurface& surface,
const T& val,
const T& defVal);
~triSurfaceField()override = default;
// - copy construct
triSurfaceField(const triSurfaceField& src);
// - no move construct
triSurfaceField(triSurfaceField&& src) = delete;
// assignment, only assign the VectorField and preserve other parts of this
triSurfaceField& operator = (const triSurfaceField& rhs);
// no move assignment
triSurfaceField& operator = (triSurfaceField&&) = delete;
inline uniquePtr<triSurfaceFieldType> clone() const
{
return makeUnique<triSurfaceFieldType>(*this);
}
inline triSurfaceFieldType* clonePtr()const
{
return new triSurfaceFieldType(*this);
}
//// - Methods //// - Methods
inline const triSurface& surface()const { inline
const auto& surface()const
{
return surface_; return surface_;
} }
auto getTriangleAccessor()const
{
return surface_.getTriangleAccessor();
}
bool update(const eventMessage& msg);
//// - IO operations //// - IO operations
bool readTriSurfacceField(iIstream& is); bool write(iOstream& is, const IOPattern& iop)const override;
bool writeTriSurfaceField(iOstream& os)const;
bool read(iIstream& is) bool read(iIstream& is, const IOPattern& iop) override;
{
return readTriSurfacceField(is);
}
bool write(iOstream& os)const
{
return writeTriSurfaceField(os);
}
}; };
template<template<class, class> class VectorField, class T, class MemorySpace> /*template<template<class, class> class VectorField, class T, class MemorySpace>
iIstream& operator >> (iIstream & is, triSurfaceField<VectorField, T, MemorySpace> & tsF ) iIstream& operator >> (iIstream & is, triSurfaceField<VectorField, T, MemorySpace> & tsF )
{ {
if( !tsF.read(is)) if( !tsF.read(is))
@ -168,7 +143,7 @@ iOstream& operator << (iOstream& os, const triSurfaceField<VectorField, T, Memor
} }
return os; return os;
} }*/
} }

View File

@ -21,9 +21,9 @@ Licence:
#include "triSurfaceFields.hpp" #include "triSurfaceFields.hpp"
template class pFlow::triSurfaceField<pFlow::VectorSingle, pFlow::real>; template class pFlow::triSurfaceField<pFlow::real>;
template class pFlow::triSurfaceField<pFlow::VectorSingle, pFlow::real, pFlow::HostSpace>; /*template class pFlow::triSurfaceField<pFlow::VectorSingle, pFlow::real, pFlow::HostSpace>;
template class pFlow::triSurfaceField<pFlow::VectorSingle, pFlow::realx3>; template class pFlow::triSurfaceField<pFlow::VectorSingle, pFlow::realx3>;
@ -31,4 +31,4 @@ template class pFlow::triSurfaceField<pFlow::VectorSingle, pFlow::realx3, pFlow:
template class pFlow::triSurfaceField<pFlow::VectorDual, pFlow::real>; template class pFlow::triSurfaceField<pFlow::VectorDual, pFlow::real>;
template class pFlow::triSurfaceField<pFlow::VectorDual, pFlow::realx3>; template class pFlow::triSurfaceField<pFlow::VectorDual, pFlow::realx3>;*/

View File

@ -21,15 +21,15 @@ Licence:
#ifndef __triSurfaceFields_hpp__ #ifndef __triSurfaceFields_hpp__
#define __triSurfaceFields_hpp__ #define __triSurfaceFields_hpp__
#include "VectorSingle.hpp"
#include "VectorDual.hpp"
#include "triSurfaceField.hpp"
#include "types.hpp" #include "types.hpp"
#include "VectorSingle.hpp"
#include "triSurfaceField.hpp"
namespace pFlow namespace pFlow
{ {
using realTriSurfaceField_D = triSurfaceField<VectorSingle, real> ; /*using realTriSurfaceField_D = triSurfaceField<VectorSingle, real> ;
using realTriSurfaceField_H = triSurfaceField<VectorSingle, real, HostSpace> ; using realTriSurfaceField_H = triSurfaceField<VectorSingle, real, HostSpace> ;
@ -52,7 +52,7 @@ using int8TriSurfaceField_H = triSurfaceField<VectorSingle, int8, HostSpace> ;
using int8TriSurfaceField_HD = triSurfaceField<VectorDual, int8> ; using int8TriSurfaceField_HD = triSurfaceField<VectorDual, int8> ;
using int8TriSurfaceField = triSurfaceField<Vector, int8, vecAllocator<real>> ; using int8TriSurfaceField = triSurfaceField<Vector, int8, vecAllocator<real>> ;
*/
} }