www.cemf.ir
triSurfaceKernels.hpp
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 
22 #ifndef __triSurfaceKernels_hpp__
23 #define __triSurfaceKernels_hpp__
24 
25 #include "Fields.hpp"
26 #include "triangleFunctions.hpp"
27 
29 {
30 
33  const realx3Field_D& points,
34  const uint32x3Field_D& vertices,
35  realField_D& area)
36 {
37  auto numTri = vertices.size();
38  auto& areaD = area.deviceViewAll();
39  auto& pointsD = points.deviceViewAll();
40  auto& verticesD = vertices.deviceViewAll();
41 
42  Kokkos::parallel_for(
43  "pFlow::triSurfaceKernels::calculateArea",
44  numTri,
45  LAMBDA_HD(uint32 i){
46  auto v = verticesD[i];
47  areaD[i] = pFlow::triangle::surface(
48  pointsD[v.x()],
49  pointsD[v.y()],
50  pointsD[v.z()]);
51  });
52 
53  return true;
54 }
55 
58  const realx3Field_D& points,
59  const uint32x3Field_D& vertices,
60  realx3Field_D& normals)
61 {
62  auto numTri = vertices.size();
63  auto& normalsD = normals.deviceViewAll();
64  auto& pointsD = points.deviceViewAll();
65  auto& verticesD = vertices.deviceViewAll();
66 
67  Kokkos::parallel_for(
68  "pFlow::triSurfaceKernels::calculateNormals",
69  numTri,
70  LAMBDA_HD(uint32 i){
71  auto v = verticesD[i];
72  normalsD[i] = pFlow::triangle::normal(
73  pointsD[v.x()],
74  pointsD[v.y()],
75  pointsD[v.z()]);
76  });
77 
78  return true;
79 }
80 
81 
82 }
83 
84 #endif
pFlow::triSurfaceKernels::calculateNormals
INLINE_FUNCTION_H bool calculateNormals(const realx3Field_D &points, const uint32x3Field_D &vertices, realx3Field_D &normals)
Definition: triSurfaceKernels.hpp:57
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
triangleFunctions.hpp
pFlow::triangle::normal
INLINE_FUNCTION_HD realx3 normal(const realx3 &p1, const realx3 &p2, const realx3 &p3)
Definition: triangleFunctions.hpp:38
pFlow::Field< realx3 >
pFlow::triSurfaceKernels
Definition: triSurfaceKernels.hpp:28
Fields.hpp
INLINE_FUNCTION_H
#define INLINE_FUNCTION_H
Definition: pFlowMacros.hpp:57
pFlow::VectorSingle::deviceViewAll
INLINE_FUNCTION_H auto & deviceViewAll()
Device view range [0,capcity)
Definition: VectorSingle.cpp:249
pFlow::triSurfaceKernels::calculateArea
INLINE_FUNCTION_H bool calculateArea(const realx3Field_D &points, const uint32x3Field_D &vertices, realField_D &area)
Definition: triSurfaceKernels.hpp:32
LAMBDA_HD
#define LAMBDA_HD
Definition: pFlowMacros.hpp:58
pFlow::triangle::surface
INLINE_FUNCTION_HD real surface(const realx3 &p1, const realx3 &p2, const realx3 &p3)
Definition: triangleFunctions.hpp:30
pFlow::VectorSingle::size
INLINE_FUNCTION_H uint32 size() const
Size of the vector.
Definition: VectorSingle.cpp:297