# PhasicFlow: src/phasicFlow/containers/pointField/internalField/internalField.hpp Source File
PhasicFlow is an open-source parallel DEM (discrete element method) package for simulating granular flow. It is developed in C++ and can be exectued on both GPU (like CUDA) and CPU.

internalField.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 __internalField_hpp__
#define __internalField_hpp__
#include "internalPoints.hpp"
#include "Field.hpp"
#include "observer.hpp"
#include "dataIO.hpp"
#include "anyList.hpp"
namespace pFlow
{
template<class T, class MemorySpace=void>
class internalField
:
public observer
{
public:
using InternalFieldType = internalField<T, MemorySpace>;
using FieldType = Field<T, MemorySpace>;
using FieldTypeHost = Field<T, HostSpace>;
using VectorType = typename FieldType::VectorType;
using memory_space = typename FieldType::memory_space;
using execution_space = typename FieldType::execution_space;
protected:
FieldType field_;
T defaultValue_;
const internalPoints& internalPoints_;
static inline
const message defaultMessage_ =
(
message::CAP_CHANGED+
message::SIZE_CHANGED+
message::ITEM_INSERT+
message::ITEM_REARRANGE+
message::ITEM_DELETE
);
bool insert(const anyList& varList);
bool rearrange(const anyList& varList);
public:
internalField(
const word& name,
const internalPoints& internal,
const T& defVal);
internalField(
const word& name,
const internalPoints& internal,
const T& defVal,
const T& val);
inline
const auto& deviceViewAll()const
{
return field_.deviceViewAll();
}
inline
auto deviceView()const
{
return field_.deviceView();
}
inline
auto hostView()const
{
return field_.hostView();
}
inline
const FieldType& field()const
{
return field_;
}
inline
FieldType& field()
{
return field_;
}
const pFlagTypeDevice& activePointsMaskDevice()const
{
return internalPoints_.activePointsMaskDevice();
}
const pFlagTypeHost& activePointsMaskHost()const
{
return internalPoints_.activePointsMaskHost();
}
FieldTypeHost activeValuesHost()const;
inline
auto size()const
{
return field_.size();
}
inline
auto capacity()const
{
return field_.capacity();
}
inline
word name()const
{
return field_.name();
}
inline
word fieldKey()const
{
return field_.fieldKey();
}
inline
const T& defaultValue()const
{
return defaultValue_;
}
inline
rangeU32 activeRange()const
{
return internalPoints_.activeRange();
}
inline
auto isAllActive()const
{
return internalPoints_.isAllActive();
}
inline
void fillInternal(const T& val)
{
field_.fillField(activeRange(), val);
}
inline
bool insertSetElement(uint32IndexContainer indices, const T& val)
{
return field_.insertSetElement(indices, val);
}
inline const Time& time()const
{
return internalPoints_.time();
}
bool hearChanges
(
real t,
real dt,
uint32 iter,
const message& msg,
const anyList& varList
) override;
bool write(iOstream& os, const IOPattern& iop)const;
};
template<class T, class MemorySpace>
inline
iOstream& operator<<
(
iOstream& os,
const internalField<T, MemorySpace>& ifeild
)
{
if( !ifeild.write(os, IOPattern::AllProcessorsDifferent) )
{
ioErrorInFile(os.name(), os.lineNumber());
fatalExit;
}
return os;
}
} // pFlow
#include "internalField.cpp"
#include "internalFieldAlgorithms.hpp"
#endif // __internalField_hpp__
pFlow::internalPoints::isAllActive
bool isAllActive() const
Definition: internalPoints.hpp:195
pFlow::internalField::defaultMessage_
static const message defaultMessage_
Definition: internalField.hpp:65
pFlow::observer
Definition: observer.hpp:33
pFlow::internalField::internalField
internalField(const word &name, const internalPoints &internal, const T &defVal)
Definition: internalField.cpp:80
anyList.hpp
pFlow::internalPoints
Definition: internalPoints.hpp:38
pFlow::message
Definition: message.hpp:33
pFlow::real
float real
Definition: builtinTypes.hpp:45
fatalExit
#define fatalExit
Fatal exit.
Definition: error.hpp:98
pFlow::internalField::deviceViewAll
const auto & deviceViewAll() const
Definition: internalField.hpp:92
observer.hpp
pFlow::internalField::size
auto size() const
Definition: internalField.hpp:133
pFlow::internalField::fieldKey
word fieldKey() const
Definition: internalField.hpp:151
pFlow::Field::fieldKey
word fieldKey() const
return field key
Definition: Field.hpp:177
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::internalField::hostView
auto hostView() const
Definition: internalField.hpp:103
pFlow::internalField::activePointsMaskDevice
const pFlagTypeDevice & activePointsMaskDevice() const
Definition: internalField.hpp:120
pFlow::internalField< realx3, void >::memory_space
typename FieldType::memory_space memory_space
Definition: internalField.hpp:49
pFlow::internalField::defaultValue_
T defaultValue_
value when a new item is added to field
Definition: internalField.hpp:59
pFlow::internalField::internalPoints_
const internalPoints & internalPoints_
const ref to internal points
Definition: internalField.hpp:62
pFlow::message::SIZE_CHANGED
@ SIZE_CHANGED
Definition: message.hpp:40
pFlow::Field< realx3, void >
pFlow::Field::name
word name() const
Definition: Field.hpp:182
pFlow::internalField::activeRange
rangeU32 activeRange() const
Definition: internalField.hpp:163
pFlow::message::ITEM_REARRANGE
@ ITEM_REARRANGE
Definition: message.hpp:44
pFlow::internalField::hearChanges
bool hearChanges(real t, real dt, uint32 iter, const message &msg, const anyList &varList) override
Definition: internalField.cpp:164
pFlow
Definition: demGeometry.hpp:27
pFlow::internalField::isAllActive
auto isAllActive() const
Definition: internalField.hpp:169
pFlow::internalField::fillInternal
void fillInternal(const T &val)
Definition: internalField.hpp:175
pFlow::VectorSingle::deviceView
INLINE_FUNCTION_H auto deviceView() const
Device view range [0, size)
Definition: VectorSingle.cpp:263
pFlow::internalField::field
FieldType & field()
Definition: internalField.hpp:115
pFlow::internalField::insertSetElement
bool insertSetElement(uint32IndexContainer indices, const T &val)
Definition: internalField.hpp:181
pFlow::internalField::field_
FieldType field_
Field.
Definition: internalField.hpp:56
pFlow::internalField::FieldTypeHost
Field< T, HostSpace > FieldTypeHost
Definition: internalField.hpp:45
pFlow::internalPoints::activeRange
auto activeRange() const
Definition: internalPoints.hpp:201
pFlow::anyList
Definition: anyList.hpp:35
pFlow::internalField::rearrange
bool rearrange(const anyList &varList)
Definition: internalField.cpp:58
internalFieldAlgorithms.hpp
pFlow::IOPattern::AllProcessorsDifferent
@ AllProcessorsDifferent
Definition: IOPattern.hpp:57
pFlow::internalPoints::activePointsMaskDevice
const pFlagTypeDevice & activePointsMaskDevice() const
Definition: internalPoints.cpp:194
pFlow::internalField< realx3, void >::VectorType
typename FieldType::VectorType VectorType
Definition: internalField.hpp:47
pFlow::internalField::field
const FieldType & field() const
Definition: internalField.hpp:109
pFlow::VectorSingle::hostView
INLINE_FUNCTION_H auto hostView() const
Return a view accessible on Host in range [0,size)
Definition: VectorSingle.cpp:281
pFlow::internalField< realx3, void >::execution_space
typename FieldType::execution_space execution_space
Definition: internalField.hpp:51
pFlow::internalField::time
const Time & time() const
Definition: internalField.hpp:186
pFlow::IOPattern
Definition: IOPattern.hpp:32
pFlow::internalPoints::time
virtual Time & time()=0
pFlow::message::ITEM_INSERT
@ ITEM_INSERT
Definition: message.hpp:42
pFlow::Range< uint32 >
pFlow::IOstream::name
virtual const word & name() const
Return the name of the stream.
Definition: IOstream.cpp:31
pFlow::internalField
Definition: internalField.hpp:34
pFlow::VectorSingle::deviceViewAll
INLINE_FUNCTION_H auto & deviceViewAll()
Device view range [0,capcity)
Definition: VectorSingle.cpp:249
dataIO.hpp
pFlow::internalField::defaultValue
const T & defaultValue() const
Definition: internalField.hpp:157
internalField.cpp
pFlow::message::ITEM_DELETE
@ ITEM_DELETE
Definition: message.hpp:41
Field.hpp
pFlow::message::CAP_CHANGED
@ CAP_CHANGED
Definition: message.hpp:39
pFlow::internalField::capacity
auto capacity() const
Definition: internalField.hpp:139
pFlow::internalField::insert
bool insert(const anyList &varList)
Definition: internalField.cpp:22
ioErrorInFile
#define ioErrorInFile(fileName, lineNumber)
Report an error in file operation with supplied fileName and lineNumber.
Definition: error.hpp:87
pFlow::internalField::write
bool write(iOstream &os, const IOPattern &iop) const
Definition: internalField.cpp:203
pFlow::VectorSingle::capacity
INLINE_FUNCTION_H uint32 capacity() const
Definition: VectorSingle.cpp:304
pFlow::IOstream::lineNumber
int32 lineNumber() const
Const access to the current stream line number.
Definition: IOstream.hpp:223
pFlow::internalField::activeValuesHost
FieldTypeHost activeValuesHost() const
Definition: internalField.cpp:134
pFlow::internalPoints::activePointsMaskHost
const pFlagTypeHost & activePointsMaskHost() const
Definition: internalPoints.cpp:201
pFlow::Field::memory_space
typename VectorType::memory_space memory_space
Definition: Field.hpp:48
pFlow::internalField::activePointsMaskHost
const pFlagTypeHost & activePointsMaskHost() const
Definition: internalField.hpp:125
pFlow::iOstream
Interface class for any output stream.
Definition: iOstream.hpp:59
internalPoints.hpp
pFlow::VectorSingle::insertSetElement
INLINE_FUNCTION_H bool insertSetElement(const uint32IndexContainer &indices, const T &val)
Definition: VectorSingle.cpp:583
pFlow::Field::VectorType
VectorSingle< T, MemorySpace > VectorType
Definition: Field.hpp:42
pFlow::Field::execution_space
typename VectorType::execution_space execution_space
Definition: Field.hpp:50
pFlow::pointFlag< DefaultExecutionSpace >
pFlow::indexContainer
It holds two vectors of indecis on Host and Device.
Definition: indexContainer.hpp:39
pFlow::internalField::deviceView
auto deviceView() const
Definition: internalField.hpp:97
pFlow::VectorSingle::size
INLINE_FUNCTION_H uint32 size() const
Size of the vector.
Definition: VectorSingle.cpp:297
pFlow::Field::fillField
void fillField(rangeU32 span, const T &val)
Definition: Field.hpp:188
pFlow::internalField::name
word name() const
Definition: internalField.hpp:145
pFlow::Time
Definition: Time.hpp:37