# PhasicFlow: src/phasicFlow/structuredData/domain/regularSimulationDomain.cpp 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.

regularSimulationDomain.cpp
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.
-----------------------------------------------------------------------------*/
#include "regularSimulationDomain.hpp"
#include "processors.hpp"
#include "streams.hpp"
bool pFlow::regularSimulationDomain::createBoundaryDicts()
{
dictionary& thisBoundaries = this->subDict(thisBoundariesDictName());
for(uint32 i=0; i<sizeOfBoundaries(); i++)
{
word bName = bundaryName(i);
dictionary& bDict = thisBoundaries.subDict(bName);
if(!bDict.add("neighborProcessorNo",(uint32) processors::globalRank()))
{
fatalErrorInFunction<<"error in adding neighborProcessorNo to "<< bName <<
" in dictionary "<< thisBoundaries.globalName()<<endl;
return false;
}
auto bType = bDict.getVal<word>("type");
uint32 mirrorIndex = 0;
if(bType == "periodic")
{
if(bName == bundaryName(0)) mirrorIndex = 1;
if(bName == bundaryName(1)) mirrorIndex = 0;
if(bName == bundaryName(2)) mirrorIndex = 3;
if(bName == bundaryName(3)) mirrorIndex = 2;
if(bName == bundaryName(4)) mirrorIndex = 5;
if(bName == bundaryName(5)) mirrorIndex = 4;
if(! bDict.addOrReplace("mirrorBoundaryIndex", mirrorIndex))
{
fatalErrorInFunction<<
"canno add entry mirroBoundaryIndex to dictionary "<<
bDict.globalName()<<endl;
return false;
}
}
}
return true;
}
bool pFlow::regularSimulationDomain::setThisDomain()
{
thisDomain_ = domain(globalBox());
return true;
}
pFlow::regularSimulationDomain::regularSimulationDomain
(
systemControl& control
)
:
simulationDomain(control)
{}
bool pFlow::regularSimulationDomain::initialUpdateDomains(span<realx3> pointPos)
{
initialNumPoints_ = pointPos.size();
if(!setThisDomain()) return false;
if(!createBoundaryDicts()) return false;
return true;
}
pFlow::uint32 pFlow::regularSimulationDomain::initialNumberInThis() const
{
return initialNumPoints_;
}
/*bool pFlow::regularSimulationDomain::updateDomains(
span<realx3> pointPos,
pFlagTypeHost flags)
{
return true;
}*/
pFlow::uint32 pFlow::regularSimulationDomain::numberToBeImported() const
{
return 0;
}
pFlow::uint32 pFlow::regularSimulationDomain::numberToBeExported() const
{
return 0;
}
bool
pFlow::regularSimulationDomain::domainActive() const
{
return true;
}
const pFlow::domain&
pFlow::regularSimulationDomain::thisDomain() const
{
return thisDomain_;
}
bool
pFlow::regularSimulationDomain::initialTransferBlockData(
span<char> src,
span<char> dst,
size_t sizeOfElement
) const
{
size_t requiredSize = sizeOfElement*initialNumberInThis();
if(dst.size() < requiredSize)
{
fatalErrorInFunction<<
"size of destination data block [in byte]"<< dst.size()<<
"is smaller than the required size [in byte]"<< requiredSize<<endl;
return false;
}
if(src.size() < requiredSize )
{
fatalErrorInFunction<<
"size of source data block [in byte]"<< src.size()<<
"is smaller than the required size [in byte]"<< requiredSize<<endl;
return false;
}
std::memcpy(dst.data(), src.data(), requiredSize);
return true;
}
bool pFlow::regularSimulationDomain::initialTransferBlockData
(
span<realx3> src,
span<realx3> dst
) const
{
return initialTransferBlockData(
charSpan(src),
charSpan(dst),
sizeof(realx3));
}
bool pFlow::regularSimulationDomain::initialTransferBlockData
(
span<real> src,
span<real> dst
) const
{
return initialTransferBlockData(
charSpan(src),
charSpan(dst),
sizeof(real));
}
bool pFlow::regularSimulationDomain::initialTransferBlockData
(
span<uint32> src,
span<uint32> dst
) const
{
return initialTransferBlockData(
charSpan(src),
charSpan(dst),
sizeof(uint32));
}
bool pFlow::regularSimulationDomain::initialTransferBlockData
(
span<int32> src,
span<int32> dst
) const
{
return initialTransferBlockData(
charSpan(src),
charSpan(dst),
sizeof(int32));
}
pFlow::regularSimulationDomain::regularSimulationDomain
regularSimulationDomain(systemControl &control)
Definition: regularSimulationDomain.cpp:74
pFlow::span
Definition: span.hpp:31
pFlow::regularSimulationDomain::domainActive
bool domainActive() const final
Is this domain active? Active mean, there is particle in it and boundaries and other entities of simu...
Definition: regularSimulationDomain.cpp:112
pFlow::regularSimulationDomain::initialUpdateDomains
bool initialUpdateDomains(span< realx3 > pointPos) final
Definition: regularSimulationDomain.cpp:81
pFlow::real
float real
Definition: builtinTypes.hpp:45
processors.hpp
pFlow::simulationDomain::thisBoundariesDictName
word thisBoundariesDictName() const
Definition: simulationDomain.hpp:105
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::processors::globalRank
static int globalRank()
Rank of the processor in the global MPI.
Definition: processors.hpp:139
pFlow::span::size
INLINE_FUNCTION_HD uint32 size() const
Returns the number of elements in the span.
Definition: span.hpp:101
pFlow::simulationDomain::sizeOfBoundaries
static uint32 sizeOfBoundaries()
Definition: simulationDomain.hpp:204
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::systemControl
Definition: systemControl.hpp:41
pFlow::dictionary::globalName
virtual word globalName() const
global name of entry, separated with dots
Definition: dictionary.cpp:356
pFlow::regularSimulationDomain::thisDomain
const domain & thisDomain() const final
return the simulation domain of this processor
Definition: regularSimulationDomain.cpp:118
pFlow::dictionary::add
bool add(const word &keyword, const float &v)
add a float dataEntry
Definition: dictionary.cpp:435
pFlow::regularSimulationDomain::numberToBeExported
uint32 numberToBeExported() const final
Definition: regularSimulationDomain.cpp:106
pFlow::endl
iOstream & endl(iOstream &os)
Add newline and flush stream.
Definition: iOstream.hpp:341
pFlow::regularSimulationDomain::setThisDomain
bool setThisDomain() final
Definition: regularSimulationDomain.cpp:67
fatalErrorInFunction
#define fatalErrorInFunction
Report a fatal error and function name and exit the application.
Definition: error.hpp:77
pFlow::int32
int int32
Definition: builtinTypes.hpp:50
pFlow::regularSimulationDomain::initialTransferBlockData
bool initialTransferBlockData(span< char > src, span< char > dst, size_t sizeOfElement) const final
Definition: regularSimulationDomain.cpp:124
pFlow::regularSimulationDomain::createBoundaryDicts
bool createBoundaryDicts() final
Definition: regularSimulationDomain.cpp:25
pFlow::regularSimulationDomain::numberToBeImported
uint32 numberToBeImported() const final
Number of points to be imported after updating domains.
Definition: regularSimulationDomain.cpp:101
pFlow::dictionary::subDict
dictionary & subDict(const word &keyword)
ref to a subdictioanry fatalExit if not found
Definition: dictionary.cpp:560
streams.hpp
pFlow::span::data
INLINE_FUNCTION_HD T * data() const
Definition: span.hpp:94
pFlow::dictionary::getVal
T getVal(const word &keyword) const
get the value of data entry
Definition: dictionary.hpp:379
pFlow::charSpan
span< char > charSpan(span< T > s)
Definition: span.hpp:177
pFlow::dictionary::addOrReplace
bool addOrReplace(const word &keyword, const T &v)
Definition: dictionary.hpp:445
pFlow::simulationDomain
Definition: simulationDomain.hpp:38
pFlow::domain
Definition: domain.hpp:31
pFlow::simulationDomain::bundaryName
static const word & bundaryName(uint32 i)
Boundary name based on boundary index.
Definition: simulationDomain.hpp:198
regularSimulationDomain.hpp
pFlow::regularSimulationDomain::initialNumberInThis
uint32 initialNumberInThis() const final
Definition: regularSimulationDomain.cpp:89
pFlow::triple< real >
pFlow::dictionary
Dictionary holds a set of data entries or sub-dictionaries that are enclosed in a curely braces or ar...
Definition: dictionary.hpp:67