# PhasicFlow: src/phasicFlow/containers/triSurfaceField/triSurfaceField.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.

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 "multiTriSurface.hpp"
#include "observer.hpp"
#include "error.hpp"
namespace pFlow
{
template<class T, class MemorySpace=void>
class triSurfaceField
:
public IOobject,
public observer
{
public:
using triSurfaceFieldType = triSurfaceField<T, MemorySpace>;
using FieldType = Field<T, MemorySpace>;
using VectorType = typename FieldType::VectorType;
using memory_space = typename FieldType::memory_space;
using execution_space = typename FieldType::execution_space;
private:
FieldType field_;
const multiTriSurface& surface_;
// - value when a new item is added to field
T defaultValue_;
public:
// - type info
TypeInfoTemplate111("triSurfaceField", T, VectorType::memoerySpaceName());
// - construct a field from tirSurface and set defaultValue_ and field value to defVal
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 objectFile& objf,
multiTriSurface& surface,
const T& val,
const T& defVal);
triSurfaceField(
const objectFile& objf,
repository* owner,
multiTriSurface& surface,
const T& val,
const T& defVal);
~triSurfaceField()override = default;
inline
const auto& surface()const
{
return surface_;
}
inline
auto size()const
{
return field_.size();
}
inline
auto capacity()const
{
return field_.capacity();
}
inline
void assign(const std::vector<T>& vals)
{
if(vals.size() != surface_.size())
{
fatalErrorInFunction;
fatalExit;
}
field_.assign(vals, surface_.capacity());
}
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_;
}
inline
void fill(const T& val)
{
field_.fillField(val);
}
bool hearChanges(
real t,
real dt,
uint32 iter,
const message& msg,
const anyList& varList) override
{
notImplementedFunction;
return false;
}
bool write(iOstream& is, const IOPattern& iop)const override;
bool read(iIstream& is, const IOPattern& iop) override;
};
/*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::observer
Definition: observer.hpp:33
pFlow::triSurfaceField::field
FieldType & field()
Definition: triSurfaceField.hpp:157
notImplementedFunction
#define notImplementedFunction
Report that a function is yet not implemented.
Definition: error.hpp:84
pFlow::triSurface::capacity
uint32 capacity() const
Definition: triSurface.hpp:167
pFlow::message
Definition: message.hpp:33
pFlow::real
float real
Definition: builtinTypes.hpp:45
fatalExit
#define fatalExit
Fatal exit.
Definition: error.hpp:98
pFlow::triSurfaceField::hostView
auto hostView() const
Definition: triSurfaceField.hpp:145
pFlow::triSurfaceField::hearChanges
bool hearChanges(real t, real dt, uint32 iter, const message &msg, const anyList &varList) override
Definition: triSurfaceField.hpp:168
observer.hpp
pFlow::triSurfaceField::field
const FieldType & field() const
Definition: triSurfaceField.hpp:151
pFlow::triSurfaceField::~triSurfaceField
~triSurfaceField() override=default
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::triSurfaceField::read
bool read(iIstream &is, const IOPattern &iop) override
Definition: triSurfaceField.cpp:160
pFlow::triSurfaceField::size
auto size() const
Definition: triSurfaceField.hpp:111
pFlow::triSurfaceField::deviceView
auto deviceView() const
Definition: triSurfaceField.hpp:139
pFlow::triSurfaceField::write
bool write(iOstream &is, const IOPattern &iop) const override
Definition: triSurfaceField.cpp:150
pFlow::Field< uint32, void >
pFlow::triSurfaceField::defaultValue_
T defaultValue_
Definition: triSurfaceField.hpp:61
pFlow
Definition: demGeometry.hpp:27
pFlow::multiTriSurface
Definition: multiTriSurface.hpp:32
pFlow::IOobject
Definition: IOobject.hpp:35
pFlow::VectorSingle::deviceView
INLINE_FUNCTION_H auto deviceView() const
Device view range [0, size)
Definition: VectorSingle.cpp:263
pFlow::anyList
Definition: anyList.hpp:35
pFlow::triSurfaceField
Definition: triSurfaceField.hpp:35
pFlow::iIstream
Interface class for any input stream
Definition: iIstream.hpp:37
pFlow::triSurface::size
uint32 size() const
Definition: triSurface.hpp:162
fatalErrorInFunction
#define fatalErrorInFunction
Report a fatal error and function name and exit the application.
Definition: error.hpp:77
pFlow::triSurfaceField::surface
const auto & surface() const
Definition: triSurfaceField.hpp:105
multiTriSurface.hpp
pFlow::triSurfaceField::deviceViewAll
const auto & deviceViewAll() const
Definition: triSurfaceField.hpp:134
pFlow::VectorSingle::hostView
INLINE_FUNCTION_H auto hostView() const
Return a view accessible on Host in range [0,size)
Definition: VectorSingle.cpp:281
pFlow::triSurfaceField::field_
FieldType field_
Definition: triSurfaceField.hpp:56
pFlow::triSurfaceField< uint32 >::VectorType
typename FieldType::VectorType VectorType
Definition: triSurfaceField.hpp:46
pFlow::IOPattern
Definition: IOPattern.hpp:32
pFlow::IOobject::owner
const repository * owner() const override
Definition: IOobject.hpp:76
pFlow::objectFile
Definition: objectFile.hpp:30
pFlow::triSurfaceField< uint32 >::execution_space
typename FieldType::execution_space execution_space
Definition: triSurfaceField.hpp:50
pFlow::triSurfaceField::triSurfaceField
triSurfaceField(const objectFile &objf, multiTriSurface &surface, const T &defVal)
Definition: triSurfaceField.cpp:24
pFlow::VectorSingle::deviceViewAll
INLINE_FUNCTION_H auto & deviceViewAll()
Device view range [0,capcity)
Definition: VectorSingle.cpp:249
pFlow::triSurfaceField::fill
void fill(const T &val)
Definition: triSurfaceField.hpp:163
pFlow::triSurfaceField::capacity
auto capacity() const
Definition: triSurfaceField.hpp:117
Field.hpp
pFlow::VectorSingle::assign
INLINE_FUNCTION_H void assign(size_t n, const T &val)
Change size of the vector and assign val to vector and.
Definition: VectorSingle.cpp:386
pFlow::triSurfaceField::assign
void assign(const std::vector< T > &vals)
Definition: triSurfaceField.hpp:123
pFlow::VectorSingle::capacity
INLINE_FUNCTION_H uint32 capacity() const
Definition: VectorSingle.cpp:304
pFlow::triSurfaceField::TypeInfoTemplate111
TypeInfoTemplate111("triSurfaceField", T, VectorType::memoerySpaceName())
pFlow::repository
Definition: repository.hpp:34
triSurfaceField.cpp
pFlow::triSurfaceField::surface_
const multiTriSurface & surface_
Definition: triSurfaceField.hpp:58
pFlow::Field::memory_space
typename VectorType::memory_space memory_space
Definition: Field.hpp:48
pFlow::iOstream
Interface class for any output stream.
Definition: iOstream.hpp:59
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::triSurfaceField< uint32 >::memory_space
typename FieldType::memory_space memory_space
Definition: triSurfaceField.hpp:48
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
error.hpp