www.cemf.ir
particleIdHandler.cpp
Go to the documentation of this file.
1 /*------------------------------- phasicFlow ---------------------------------
2  O C enter of
3  O O E ngineering and
4  O O M ultiscale modeling of
5  OOOOOOO F luid flow
6 ------------------------------------------------------------------------------
7  Copyright (C): www.cemf.ir
8  email: hamid.r.norouzi AT gmail.com
9 ------------------------------------------------------------------------------
10 Licence:
11  This file is part of phasicFlow code. It is a free software for simulating
12  granular and multiphase flows. You can redistribute it and/or modify it under
13  the terms of GNU General Public License v3 or any other later versions.
14 
15  phasicFlow is distributed to help others in their research in the field of
16  granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
17  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 
19 -----------------------------------------------------------------------------*/
20 
21 #include "particleIdHandler.hpp"
22 
24 :
26  (
28  (
29  "id",
30  "",
31  objectFile::READ_IF_PRESENT,
32  objectFile::WRITE_ALWAYS
33  ),
34  pStruct,
35  static_cast<uint32>(-1),
36  static_cast<uint32>(-1)
37  )
38 {
39 
40 }
41 
42 bool
44  real t,
45  real dt,
46  uint32 iter,
47  const message& msg,
48  const anyList& varList
49 )
50 {
52  {
53  const word eventName = message::eventName(message::ITEM_INSERT);
54 
55  const auto& indices = varList.getObject<uint32IndexContainer>(
56  eventName);
57 
58  uint32 numNew = indices.size();
59  if(numNew == 0u)return true;
60 
61  auto idRange = getIdRange(numNew);
62  uint32Vector newId("newId",numNew,numNew,RESERVE());
63  fillSequence(newId, idRange.first);
64 
65  return this->field().insertSetElement(indices, newId);
66  }
67  else
68  {
69  return uint32PointField_D::hearChanges(t,dt,iter, msg,varList);
70  }
71 }
72 
75 {
76  word idHType = angleBracketsNames(
77  "particleIdHandler",
78  pFlowProcessors().localRunTypeName());
79 
80 
81  if( pointStructurevCtorSelector_.search(idHType) )
82  {
83  REPORT(1)<<"Creating particle id handler "<<
84  Green_Text(idHType)<<END_REPORT;
85  return pointStructurevCtorSelector_[idHType] (pStruct);
86  }
87  else
88  {
89  printKeys
90  (
91  fatalError << "Ctor Selector "<< idHType << " dose not exist. \n"
92  <<"Avaiable ones are: \n\n"
93  ,
94  pointStructurevCtorSelector_
95  );
96  fatalExit;
97  }
98  return nullptr;
99 }
pFlow::message::equivalentTo
bool equivalentTo(EVENT evnt) const
Definition: message.hpp:131
Green_Text
#define Green_Text(text)
Definition: iOstream.hpp:42
pFlow::message
Definition: message.hpp:33
pFlow::real
float real
Definition: builtinTypes.hpp:45
fatalExit
#define fatalExit
Fatal exit.
Definition: error.hpp:98
pFlow::anyList::getObject
T & getObject(size_t i)
Get the reference to variable by index.
Definition: anyList.hpp:134
REPORT
#define REPORT(n)
Definition: streams.hpp:39
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::printKeys
iOstream & printKeys(iOstream &os, const wordHashMap< T > &m)
pFlow::internalField< T, void >::hearChanges
bool hearChanges(real t, real dt, uint32 iter, const message &msg, const anyList &varList) override
Definition: internalField.cpp:164
RESERVE
Definition: Vector.hpp:40
pFlow::pointField
Definition: pointField.hpp:33
pFlow::pointStructure
Definition: pointStructure.hpp:34
pFlow::anyList
Definition: anyList.hpp:35
pFlow::angleBracketsNames
word angleBracketsNames(const word &w1, const word &w2)
Output <w1,w2>
Definition: bTypesFunctions.cpp:156
END_REPORT
#define END_REPORT
Definition: streams.hpp:40
pFlow::particleIdHandler::particleIdHandler
particleIdHandler(pointStructure &pStruct)
Definition: particleIdHandler.cpp:23
pFlow::objectFile
Definition: objectFile.hpp:30
pFlow::message::ITEM_INSERT
@ ITEM_INSERT
Definition: message.hpp:42
fatalError
#define fatalError
Report a fatal error and exit the applicaiton.
Definition: error.hpp:70
pStruct
auto & pStruct
Definition: setPointStructure.hpp:24
pFlow::pFlowProcessors
localProcessors & pFlowProcessors()
Definition: pFlowProcessors.cpp:5
pFlow::uniquePtr< pFlow::particleIdHandler >
pFlow::particleIdHandler::hearChanges
bool hearChanges(real t, real dt, uint32 iter, const message &msg, const anyList &varList) override
Definition: particleIdHandler.cpp:43
pFlow::indexContainer::size
INLINE_FUNCTION_HD auto size() const
Size.
Definition: indexContainer.hpp:175
pFlow::fillSequence
void fillSequence(internalField< T, MemorySpace > &iField, const T &startVal)
Definition: internalFieldAlgorithms.hpp:198
particleIdHandler.hpp
pFlow::Vector< uint32 >
pFlow::particleIdHandler::create
static uniquePtr< particleIdHandler > create(pointStructure &pStruct)
Definition: particleIdHandler.cpp:74
pFlow::indexContainer
It holds two vectors of indecis on Host and Device.
Definition: indexContainer.hpp:39
pFlow::message::eventName
static const word & eventName(size_t event)
Definition: message.hpp:196