www.cemf.ir
grainParticlesKernels.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 
21 
22 using policy = Kokkos::RangePolicy<
24  Kokkos::Schedule<Kokkos::Static>,
25  Kokkos::IndexType<pFlow::uint32>>;
26 
28 (
29  deviceViewType1D<uint32> shapeIndex,
31  deviceViewType1D<real> diameter,
32  deviceViewType1D<real> coarseGrainFactor,
34  deviceViewType1D<uint32> propertyId,
35  pFlagTypeDevice incld,
36  deviceViewType1D<real> src_mass,
37  deviceViewType1D<real> src_diameter,
39  deviceViewType1D<uint32> src_propertyId
40 )
41 {
42  auto aRange = incld.activeRange();
43 
44  Kokkos::parallel_for(
45  "particles::initInertia",
46  policy(aRange.start(), aRange.end()),
47  LAMBDA_HD(uint32 i)
48  {
49  if(incld(i))
50  {
51  uint32 index = shapeIndex[i];
52  I[i] = src_I[index];
53  diameter[i] = src_diameter[index];
54  mass[i] = src_mass[index];
55  propertyId[i] = src_propertyId[index];
56  }
57  });
58 
59 }
60 
62 (
63  const realx3& g,
64  const deviceViewType1D<real>& mass,
65  const deviceViewType1D<realx3>& force,
66  const deviceViewType1D<real>& I,
67  const deviceViewType1D<realx3>& torque,
68  const pFlagTypeDevice& incld,
71 )
72 {
73 
74  auto activeRange = incld.activeRange();
75  if(incld.isAllActive())
76  {
77  Kokkos::parallel_for(
78  "pFlow::grainParticlesKernels::acceleration",
79  policy(activeRange.start(), activeRange.end()),
80  LAMBDA_HD(uint32 i){
81  lAcc[i] = force[i]/mass[i] + g;
82  rAcc[i] = torque[i]/I[i];
83  });
84  }
85  else
86  {
87  Kokkos::parallel_for(
88  "pFlow::grainParticlesKernels::acceleration",
89  policy(activeRange.start(), activeRange.end()),
90  LAMBDA_HD(uint32 i){
91  if(incld(i))
92  {
93  lAcc[i] = force[i]/mass[i] + g;
94  rAcc[i] = torque[i]/I[i];
95  }
96  });
97 
98  }
99 
100  Kokkos::fence();
101 }
pFlow::grainParticlesKernels::acceleration
void acceleration(const realx3 &g, const deviceViewType1D< real > &mass, const deviceViewType1D< realx3 > &force, const deviceViewType1D< real > &I, const deviceViewType1D< realx3 > &torque, const pFlagTypeDevice &incld, deviceViewType1D< realx3 > lAcc, deviceViewType1D< realx3 > rAcc)
Definition: grainParticlesKernels.cpp:62
grainParticlesKernels.hpp
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::DefaultExecutionSpace
Kokkos::DefaultExecutionSpace DefaultExecutionSpace
Default execution space, it can be device exe.
Definition: KokkosTypes.hpp:61
pFlow::deviceViewType1D
Kokkos::View< T * > deviceViewType1D
1D array (vector) with default device (memory space and execution space)
Definition: KokkosTypes.hpp:121
policy
Kokkos::RangePolicy< pFlow::DefaultExecutionSpace, Kokkos::Schedule< Kokkos::Static >, Kokkos::IndexType< pFlow::uint32 > > policy
Definition: grainParticlesKernels.cpp:25
pFlow::grainParticlesKernels::addMassDiamInertiaProp
void addMassDiamInertiaProp(deviceViewType1D< uint32 > shapeIndex, deviceViewType1D< real > mass, deviceViewType1D< real > diameter, deviceViewType1D< real > coarseGrainFactor, deviceViewType1D< real > I, deviceViewType1D< uint32 > propertyId, pFlagTypeDevice incld, deviceViewType1D< real > src_mass, deviceViewType1D< real > src_grainDiameter, deviceViewType1D< real > src_I, deviceViewType1D< uint32 > src_propertyId)
Definition: grainParticlesKernels.cpp:28
pFlow::pointFlag::isAllActive
INLINE_FUNCTION_HD bool isAllActive() const
Definition: pointFlag.hpp:173
pFlow::pointFlag::activeRange
const INLINE_FUNCTION_HD auto & activeRange() const
Definition: pointFlag.hpp:179
LAMBDA_HD
#define LAMBDA_HD
Definition: pFlowMacros.hpp:58
pFlow::triple< real >
pFlow::pointFlag< DefaultExecutionSpace >