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

pointField.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 __pointField_hpp__
#define __pointField_hpp__
#include "Field.hpp"
#include "pointStructure.hpp"
#include "error.hpp"
namespace pFlow
{
template<template<class, class> class VectorField, class T, class MemorySpace=void>
class pointField
:
public eventObserver,
public Field<VectorField, T, MemorySpace>
{
public:
using pointFieldType = pointField<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 pointStructure& pStruct_;
// - value when a new item is added to field
T defaultValue_;
public:
// - type info
TypeInfoTemplateNV2("pointField", T, VectorType::memoerySpaceName());
// - construct a field from pointStructure and set defaultValue_ and field value to defVal
pointField( const pointStructure& pStruct, const T& defVal, bool subscribe = true);
// - construct from iIOEntity, pointStructure and a value
pointField( const pointStructure& pStruct, const T& val, const T& defVal, bool subscribe = true);
// - construct from another pointField
// subscribe to events if true
pointField( const pointField& src, bool subscribe);
// - copy construct
pointField(const pointField& src);
// - no move construct
pointField(pointField&& src) = delete;
// assignment, only assign the VectorField and preserve other parts of this
pointField& operator = (const pointField& rhs);
// no move assignment
pointField& operator = (pointField&&) = delete;
inline uniquePtr<pointFieldType> clone() const
{
return makeUnique<pointFieldType>(*this);
}
inline pointFieldType* clonePtr()const
{
return new pointFieldType(*this);
}
// - reference to pointStructure
inline const pointStructure& pStruct()const {
return pStruct_;
}
// if all points are active
INLINE_FUNCTION_H
bool allActive()const {
return pStruct_.allActive();
}
INLINE_FUNCTION_H
bool isActive(label i)const {
return pStruct_.isActive(i);
}
const auto& pointFlag()const
{
return pStruct_.pointFlag();
}
range activeRange()const
{
return pStruct_.activeRange();
}
// - update the field if any changes occure in pStruct
// for now it checks for deleted points
bool update(const eventMessage& msg);
bool readPointField(iIstream& is);
bool writePointField(iOstream& os)const;
bool read(iIstream& is)
{
return readPointField(is);
}
bool write(iOstream& os)const
{
return writePointField(os);
}
};
template<template<class, class> class VectorField, class T, class MemorySpace>
iIstream& operator >> (iIstream & is, pointField<VectorField, T, MemorySpace> & pF )
{
if( !pF.read(is))
{
ioErrorInFile( is.name(), is.lineNumber() ) <<
"error in reading pointField from file. \n";
fatalExit;
}
return is;
}
template<template<class, class> class VectorField, class T, class MemorySpace>
iOstream& operator << (iOstream& os, const pointField<VectorField, T, MemorySpace>& pF )
{
if(! pF.write(os) )
{
ioErrorInFile( os.name(), os.lineNumber() )<<
"error in writing pointField into file. \n";
fatalExit;
}
return os;
}
}
#include "pointField.cpp"
#include "pointFieldAlgorithms.hpp"
#endif // __pointField_hpp__
pFlow::pointField::writePointField
bool writePointField(iOstream &os) const
Definition: pointField.cpp:34
pFlow::Field< T, T, void >::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::pointField::isActive
INLINE_FUNCTION_H bool isActive(label i) const
Definition: pointField.hpp:129
pFlow::pointField::pStruct
const pointStructure & pStruct() const
Definition: pointField.hpp:117
pFlow::pointStructure::pointFlag
FUNCTION_H int8Field_HD & pointFlag()
Definition: pointStructure.cpp:70
pFlow::Field< T, T, void >::constPointer
typename VectorType::constPointer constPointer
Definition: Field.hpp:56
pFlow::pointStructure::activeRange
INLINE_FUNCTION_H range activeRange() const
Definition: pointStructure.hpp:281
pFlow::pointField::TypeInfoTemplateNV2
TypeInfoTemplateNV2("pointField", T, VectorType::memoerySpaceName())
pFlow::pointField::defaultValue_
T defaultValue_
Definition: pointField.hpp:68
pFlow::eventObserver
Definition: eventObserver.hpp:33
pFlow::pointField::read
bool read(iIstream &is)
Definition: pointField.hpp:154
pFlow::Field
Definition: Field.hpp:33
pFlow
Definition: demComponent.hpp:28
pFlow::pointField::pointFieldType
pointField< VectorField, T, MemorySpace > pointFieldType
Definition: pointField.hpp:42
pFlow::pointStructure::isActive
INLINE_FUNCTION_H bool isActive(label i) const
Definition: pointStructure.hpp:287
pFlow::pointStructure::allActive
FUNCTION_H bool allActive() const
Definition: pointStructure.cpp:228
pFlow::pointField
Definition: pointField.hpp:35
pFlow::pointStructure
Definition: pointStructure.hpp:44
pFlow::iIstream
Definition: iIstream.hpp:33
pFlow::pointField::clonePtr
pointFieldType * clonePtr() const
Definition: pointField.hpp:109
pFlow::operator>>
INLINE_FUNCTION iIstream & operator>>(iIstream &str, AB3History &ab3)
Definition: AdamsBashforth3.hpp:41
pFlow::pointField::write
bool write(iOstream &os) const
Definition: pointField.hpp:159
INLINE_FUNCTION_H
#define INLINE_FUNCTION_H
Definition: pFlowMacros.hpp:53
pFlow::pointField::activeRange
range activeRange() const
Definition: pointField.hpp:138
pFlow::operator<<
INLINE_FUNCTION iOstream & operator<<(iOstream &str, const AB3History &ab3)
Definition: AdamsBashforth3.hpp:57
pFlow::pointField::allActive
INLINE_FUNCTION_H bool allActive() const
Definition: pointField.hpp:123
pFlow::pointField::readPointField
bool readPointField(iIstream &is)
Definition: pointField.cpp:24
pFlow::IOstream::name
virtual const word & name() const
Definition: IOstream.cpp:31
pFlow::Field< T, T, void >::pointer
typename VectorType::pointer pointer
Definition: Field.hpp:54
pFlow::uniquePtr
Definition: uniquePtr.hpp:44
Field.hpp
pFlow::pointField::clone
uniquePtr< pointFieldType > clone() const
Definition: pointField.hpp:104
ioErrorInFile
#define ioErrorInFile(fileName, lineNumber)
Definition: error.hpp:49
pFlow::Field< T, T, void >::valueType
typename VectorType::valueType valueType
Definition: Field.hpp:52
pFlow::label
std::size_t label
Definition: builtinTypes.hpp:61
pFlow::pointField::operator=
pointField & operator=(const pointField &rhs)
Definition: pointField.cpp:99
pFlow::IOstream::lineNumber
int32 lineNumber() const
Definition: IOstream.hpp:187
pFlow::Field< T, T, void >::iterator
typename VectorType::iterator iterator
Definition: Field.hpp:44
pointField.cpp
pFlow::pointField::update
bool update(const eventMessage &msg)
Definition: pointField.cpp:111
pFlow::pointField::pointField
pointField(const pointStructure &pStruct, const T &defVal, bool subscribe=true)
Definition: pointField.cpp:45
pointFieldAlgorithms.hpp
pFlow::Field< T, T, void >::constIterator
typename VectorType::constIterator constIterator
Definition: Field.hpp:46
pointStructure.hpp
pFlow::iOstream
Definition: iOstream.hpp:53
pFlow::pointField::pStruct_
const pointStructure & pStruct_
Definition: pointField.hpp:65
pFlow::range
kPair< int, int > range
Definition: KokkosTypes.hpp:54
pFlow::Field< T, T, void >::VectorType
T< T, void > VectorType
Definition: Field.hpp:40
pFlow::pointField::pointFlag
const auto & pointFlag() const
Definition: pointField.hpp:133
pFlow::Field< T, T, void >::reference
typename VectorType::reference reference
Definition: Field.hpp:48
error.hpp