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/List/anyList/anyList.cpp
containers/pointField/pointFields.cpp
containers/triSurfaceField/triSurfaceFields.cpp
setFieldList/setFieldList.cpp
setFieldList/setFieldEntry.cpp

View File

@ -106,6 +106,14 @@ public:
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
Field(const word& name, const word& fieldKey, size_t capacity, size_t len, RESERVE)
:

View File

@ -1,3 +1,4 @@
#include "triSurfaceField.hpp"
/*------------------------------- phasicFlow ---------------------------------
O C enter of
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
(
const triSurface& surface,
@ -116,4 +263,4 @@ bool pFlow::triSurfaceField<VectorField, T, MemorySpace>::writeTriSurfaceField
)const
{
return FieldType::write(os);
}
}*/

View File

@ -22,7 +22,8 @@ Licence:
#define __trieSurfaceField_hpp__
#include "Field.hpp"
#include "triSurface.hpp"
#include "multiTriSurface.hpp"
#include "observer.hpp"
#include "error.hpp"
@ -30,38 +31,31 @@ namespace pFlow
{
template<template<class, class> class VectorField, class T, class MemorySpace=void>
template<class T, class MemorySpace=void>
class triSurfaceField
:
public eventObserver,
public Field<VectorField, T, MemorySpace>
public IOobject,
public observer
{
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 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;
using constReference = typename FieldType::constReference;
using valueType = typename FieldType::valueType;
using pointer = typename FieldType::pointer;
using constPointer = typename FieldType::constPointer;
protected:
private:
////- data members
const triSurface& surface_;
FieldType field_;
const multiTriSurface& surface_;
// - value when a new item is added to field
T defaultValue_;
@ -70,79 +64,60 @@ protected:
public:
// - type info
TypeInfoTemplateNV2("triSurfaceField", T, VectorType::memoerySpaceName());
TypeInfoTemplate111("triSurfaceField", T, VectorType::memoerySpaceName());
//// CONSTRUCTORS
// - 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
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
// subscribe to events if true
triSurfaceField( const triSurfaceField& src, bool subscribe);
triSurfaceField(
const objectFile& objf,
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
inline const triSurface& surface()const {
inline
const auto& surface()const
{
return surface_;
}
auto getTriangleAccessor()const
{
return surface_.getTriangleAccessor();
}
bool update(const eventMessage& msg);
//// - IO operations
bool readTriSurfacceField(iIstream& is);
bool writeTriSurfaceField(iOstream& os)const;
bool write(iOstream& is, const IOPattern& iop)const override;
bool read(iIstream& is)
{
return readTriSurfacceField(is);
}
bool write(iOstream& os)const
{
return writeTriSurfaceField(os);
}
bool read(iIstream& is, const IOPattern& iop) override;
};
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 )
{
if( !tsF.read(is))
@ -168,7 +143,7 @@ iOstream& operator << (iOstream& os, const triSurfaceField<VectorField, T, Memor
}
return os;
}
}*/
}

View File

@ -21,9 +21,9 @@ Licence:
#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>;
@ -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::realx3>;
template class pFlow::triSurfaceField<pFlow::VectorDual, pFlow::realx3>;*/

View File

@ -21,15 +21,15 @@ Licence:
#ifndef __triSurfaceFields_hpp__
#define __triSurfaceFields_hpp__
#include "VectorSingle.hpp"
#include "VectorDual.hpp"
#include "triSurfaceField.hpp"
#include "types.hpp"
#include "VectorSingle.hpp"
#include "triSurfaceField.hpp"
namespace pFlow
{
using realTriSurfaceField_D = triSurfaceField<VectorSingle, real> ;
/*using realTriSurfaceField_D = triSurfaceField<VectorSingle, real> ;
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 = triSurfaceField<Vector, int8, vecAllocator<real>> ;
*/
}