# PhasicFlow: src/phasicFlow/containers/triSurfaceField/triSurfaceField.hpp Source File

triSurfaceField.hpp
Go to the documentation of this file.
/*------------------------------- phasicFlow ---------------------------------
O C enter of
O O E ngineering and
O O M ultiscale modeling of
OOOOOOO F luid flow
------------------------------------------------------------------------------
Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------
Licence:
This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-----------------------------------------------------------------------------*/
#ifndef __trieSurfaceField_hpp__
#define __trieSurfaceField_hpp__
#include "Field.hpp"
#include "triSurface.hpp"
#include "error.hpp"
namespace pFlow
{
template<template<class, class> class VectorField, class T, class MemorySpace=void>
class triSurfaceField
:
public eventObserver,
public Field<VectorField, T, MemorySpace>
{
public:
using triSurfaceFieldType = triSurfaceField<VectorField, T, MemorySpace>;
using FieldType = Field<VectorField, T, MemorySpace>;
using VectorType = typename FieldType::VectorType;
using iterator = typename FieldType::iterator;
using constIterator = typename FieldType::constIterator;
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:
const triSurface& surface_;
// - value when a new item is added to field
T defaultValue_;
public:
// - type info
TypeInfoTemplateNV2("triSurfaceField", T, VectorType::memoerySpaceName());
// - construct a field from tirSurface and set defaultValue_ and field value to defVal
triSurfaceField( const triSurface& surface, const T& defVal, bool subscribe = true);
// - construct from iIOEntity, tirSurface and a value
triSurfaceField( const triSurface& surface, const T& val, const T& defVal, bool subscribe = true);
// - construct from another triSurfaceField
// subscribe to events if true
triSurfaceField( const triSurfaceField& src, bool subscribe);
// - 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);
}
inline const triSurface& surface()const {
return surface_;
}
auto getTriangleAccessor()const
{
return surface_.getTriangleAccessor();
}
bool update(const eventMessage& msg);
bool readTriSurfacceField(iIstream& is);
bool writeTriSurfaceField(iOstream& os)const;
bool read(iIstream& is)
{
return readTriSurfacceField(is);
}
bool write(iOstream& os)const
{
return writeTriSurfaceField(os);
}
};
template<template<class, class> class VectorField, class T, class MemorySpace>
iIstream& operator >> (iIstream & is, triSurfaceField<VectorField, T, MemorySpace> & tsF )
{
if( !tsF.read(is))
{
ioErrorInFile( is.name(), is.lineNumber() ) <<
"error in reading triSurfaceField from file. \n"<<
"field name: "<< tsF.name()<<endl;
fatalExit;
}
return is;
}
template<template<class, class> class VectorField, class T, class MemorySpace>
iOstream& operator << (iOstream& os, const triSurfaceField<VectorField, T, MemorySpace>& tsF )
{
if(! tsF.write(os) )
{
ioErrorInFile( os.name(), os.lineNumber() )<<
"error in writing triSurfaceField into file. \n"<<
"field name: "<< tsF.name()<<endl;
fatalExit;
}
return os;
}
}
#include "triSurfaceField.cpp"
#endif //__trieSurfaceField_hpp__
pFlow::triSurfaceField::constReference
typename FieldType::constReference constReference
Definition: triSurfaceField.hpp:53
pFlow::triSurface::getTriangleAccessor
auto getTriangleAccessor() const
Definition: triSurface.hpp:174
pFlow::triSurfaceField::surface
const triSurface & surface() const
Definition: triSurfaceField.hpp:115
pFlow::triSurfaceField::read
bool read(iIstream &is)
Definition: triSurfaceField.hpp:133
pFlow::triSurfaceField::readTriSurfacceField
bool readTriSurfacceField(iIstream &is)
Definition: triSurfaceField.cpp:105
pFlow::Field::constReference
typename VectorType::constReference constReference
Definition: Field.hpp:50
pFlow::eventObserver::subscribe
bool subscribe(const eventSubscriber &subscriber)
Definition: eventObserver.cpp:50
fatalExit
#define fatalExit
Definition: error.hpp:57
pFlow::eventMessage
Definition: eventMessage.hpp:29
pFlow::triSurfaceField::writeTriSurfaceField
bool writeTriSurfaceField(iOstream &os) const
Definition: triSurfaceField.cpp:114
pFlow::triSurfaceField::clonePtr
triSurfaceFieldType * clonePtr() const
Definition: triSurfaceField.hpp:108
pFlow::triSurfaceField::clone
uniquePtr< triSurfaceFieldType > clone() const
Definition: triSurfaceField.hpp:103
pFlow::Field::constPointer
typename VectorType::constPointer constPointer
Definition: Field.hpp:56
pFlow::triSurfaceField::triSurfaceField
triSurfaceField(const triSurface &surface, const T &defVal, bool subscribe=true)
Definition: triSurfaceField.cpp:23
pFlow::eventObserver
Definition: eventObserver.hpp:33
pFlow::endl
iOstream & endl(iOstream &os)
Definition: iOstream.hpp:312
pFlow::triSurfaceField::write
bool write(iOstream &os) const
Definition: triSurfaceField.hpp:138
pFlow::Field
Definition: Field.hpp:33
pFlow::triSurfaceField::defaultValue_
T defaultValue_
Definition: triSurfaceField.hpp:67
pFlow
Definition: demComponent.hpp:28
pFlow::triSurfaceField::surface_
const triSurface & surface_
Definition: triSurfaceField.hpp:64
pFlow::triSurfaceField::operator=
triSurfaceField & operator=(const triSurfaceField &rhs)
Definition: triSurfaceField.cpp:82
pFlow::triSurfaceField
Definition: triSurfaceField.hpp:34
pFlow::iIstream
Definition: iIstream.hpp:33
pFlow::triSurfaceField::triSurfaceFieldType
triSurfaceField< VectorField, T, MemorySpace > triSurfaceFieldType
Definition: triSurfaceField.hpp:41
pFlow::triSurfaceField::constPointer
typename FieldType::constPointer constPointer
Definition: triSurfaceField.hpp:59
pFlow::triSurfaceField::VectorType
typename FieldType::VectorType VectorType
Definition: triSurfaceField.hpp:45
pFlow::operator>>
INLINE_FUNCTION iIstream & operator>>(iIstream &str, AB3History &ab3)
Definition: AdamsBashforth3.hpp:41
pFlow::triSurfaceField::reference
typename FieldType::reference reference
Definition: triSurfaceField.hpp:51
pFlow::triSurfaceField::getTriangleAccessor
auto getTriangleAccessor() const
Definition: triSurfaceField.hpp:119
pFlow::operator<<
INLINE_FUNCTION iOstream & operator<<(iOstream &str, const AB3History &ab3)
Definition: AdamsBashforth3.hpp:57
pFlow::triSurfaceField::constIterator
typename FieldType::constIterator constIterator
Definition: triSurfaceField.hpp:49
pFlow::IOstream::name
virtual const word & name() const
Definition: IOstream.cpp:31
pFlow::triSurfaceField::iterator
typename FieldType::iterator iterator
Definition: triSurfaceField.hpp:47
pFlow::triSurfaceField::TypeInfoTemplateNV2
TypeInfoTemplateNV2("triSurfaceField", T, VectorType::memoerySpaceName())
pFlow::Field::pointer
typename VectorType::pointer pointer
Definition: Field.hpp:54
pFlow::uniquePtr
Definition: uniquePtr.hpp:44
Field.hpp
ioErrorInFile
#define ioErrorInFile(fileName, lineNumber)
Definition: error.hpp:49
pFlow::Field::valueType
typename VectorType::valueType valueType
Definition: Field.hpp:52
pFlow::IOstream::lineNumber
int32 lineNumber() const
Definition: IOstream.hpp:187
triSurfaceField.cpp
pFlow::Field::iterator
typename VectorType::iterator iterator
Definition: Field.hpp:44
pFlow::triSurface
Definition: triSurface.hpp:38
pFlow::triSurfaceField::valueType
typename FieldType::valueType valueType
Definition: triSurfaceField.hpp:55
pFlow::Field::constIterator
typename VectorType::constIterator constIterator
Definition: Field.hpp:46
pFlow::triSurfaceField::pointer
typename FieldType::pointer pointer
Definition: triSurfaceField.hpp:57
pFlow::iOstream
Definition: iOstream.hpp:53
triSurface.hpp
pFlow::triSurfaceField::update
bool update(const eventMessage &msg)
Definition: triSurfaceField.cpp:94
pFlow::Field::VectorType
VectorField< T, PropType > VectorType
Definition: Field.hpp:40
pFlow::Field::reference
typename VectorType::reference reference
Definition: Field.hpp:48
error.hpp