Grid partitioning into MFThreads.
15 struct nodeForAutoThreading {
16 uint64_t NodeEncodedID = 1;
17 uint32_t NodeNumber = 0;
20 nodeForAutoThreading newNode;
21 auto NodeArray_Ptr = std::make_unique<std::vector<nodeForAutoThreading>>(1);
27 int32_t &i = xyz[0], &j = xyz[1], &h = xyz[2];
30 for (
auto iter = VDBGrid_Ptr->beginValueOn(); iter; ++iter) {
32 nodeEID = iter.getValue();
33 for (
auto & it : *NodeArray_Ptr) {
34 if (it.NodeEncodedID == nodeEID) {
40 newNode.NodeNumber = 1;
41 newNode.NodeEncodedID = nodeEID;
42 NodeArray_Ptr->push_back(newNode);
45 std::cout <<
"AutoThreading Error" << std::endl;
51 for (
auto & it : *NodeArray_Ptr) {
52 ThreadArray_Ptr->NewThread(it.NodeEncodedID,it.NodeNumber);
56 for (
auto & thread1 : *ThreadArray_Ptr->m_ThreadsTable_Ptr){
58 nodeTMP.
node_id.
Node.nodeType = thread1->m_NodeType;
59 nodeTMP.
node_id.
Node.uidThreadNr = thread1->m_uidThreadNr;
60 nodeTMP.
node_id.
Node.ThreadCount = thread1->m_ThreadCount;
61 nodeTMP.
node_id.
Node.ComponentNr = thread1->m_ComponentNr;
63 auto iter2 = VDBGrid_Ptr->beginValueOn();
64 for (
size_t node = 0; node < thread1->m_NodeArray_Ptr->size(); node++) {
65 for (
auto iter = iter2; iter; ++iter) {
67 xyz = iter.getCoord();
68 thread1->setNodeCoordX(node, i);
69 thread1->setNodeCoordY(node, j);
70 thread1->setNodeCoordZ(node, h);
79 NodeArray_Ptr.reset();
82 using PointersTree = openvdb::tree::Tree4<uintptr_t, 5, 4, 3 >::Type;
83 using PointersGrid = openvdb::Grid<PointersTree>;
86 auto PointersGrid_Ptr = PointersGrid::create(0);
87 auto accessor2 = PointersGrid_Ptr->getAccessor();
90 for (
auto & thread2 : *ThreadArray_Ptr->m_ThreadsTable_Ptr){
91 for (
size_t node = 0; node < thread2->m_NodeArray_Ptr->size(); node++) {
92 i = thread2->getNodeCoordX(node);
93 j = thread2->getNodeCoordY(node);
94 h = thread2->getNodeCoordZ(node);
95 auto address1 =
reinterpret_cast<uintptr_t
>(thread2->getNodePointer(node));
96 accessor2.setValue(xyz,address1);
100 openvdb::CoordBBox its_bbox;
101 VDBGrid_Ptr->treePtr()->evalActiveVoxelBoundingBox(its_bbox);
102 auto Nx = its_bbox.dim().x();
103 auto Ny = its_bbox.dim().y();
104 auto Nz = its_bbox.dim().z();
105 auto minX = its_bbox.min().x();
106 auto maxX = its_bbox.max().x();
107 auto minY = its_bbox.min().y();
108 auto maxY = its_bbox.max().y();
109 auto minZ = its_bbox.min().z();
110 auto maxZ = its_bbox.max().z();
113 for (
auto & thread : *ThreadArray_Ptr->m_ThreadsTable_Ptr) {
114 for (
size_t node = 0; node < thread->m_NodeArray_Ptr->size(); node++) {
115 thread->getNodeRef(node).pMyThread_Ptr = &thread;
116 for (uint8_t ik = 0; ik <
MFQ19_H ; ik++) {
121 auto value = accessor2.getValue(xyz);
123 thread->setNodePtrInPropTable(node,ik, reinterpret_cast<Node *>(accessor2.getValue(xyz)));
125 else if (thread->m_NodeType != 4 && thread->m_NodeType != 5) {
126 thread->setNodePtrInPropTable(node,ik,
nullptr);
141 value = accessor2.getValue(xyz);
143 thread->setNodePtrInPropTable(node,ik, reinterpret_cast<Node *>(accessor2.getValue(xyz)));
146 std::cout <<
"Lack of consistence of periodic boundary " << thread->m_NodeType <<
" nodeForAutoThreading: " <<
" (" << i <<
"," << j <<
"," << h <<
") " << std::endl;
154 for (
auto & thread : *ThreadArray_Ptr->m_ThreadsTable_Ptr) {
155 for (
size_t node = 0; node < thread->m_NodeArray_Ptr->size(); node++) {
156 for (uint8_t ik = 0; ik <
MFQ19_H ; ik++) {
161 auto value = accessor2.getValue(xyz);
163 thread->setNodePtrInSecondPropTable(node,ik, reinterpret_cast<Node *>(accessor2.getValue(xyz)));
165 else if (thread->m_NodeType != 4 && thread->m_NodeType != 5) {
166 thread->setNodePtrInSecondPropTable(node, ik,
nullptr);
181 value = accessor2.getValue(xyz);
183 thread->setNodePtrInSecondPropTable(node,ik, reinterpret_cast<Node *>(accessor2.getValue(xyz)));
186 std::cout <<
"Lack of consistence of periodic boundary " << thread->m_NodeType <<
" nodeForAutoThreading: " <<
" (" << i <<
"," << j <<
"," << h <<
") " << std::endl;
struct MF::GB::NodeID::@0::@1 Node
A class that allows to determine the proper NodeID from combined nodeType, uidThreadNr, ThreadCount, ComponentNr and PhaseNr.
static constexpr int8_t DirectionVectorComponent_Cx[MFQ27]
The x direction vector component of all D3Q19 lattice directions plus additional nodes of the Q27 lat...
static constexpr int8_t DirectionVectorComponent_Cy[MFQ27]
The y direction vector component of all D3Q19 lattice directions plus additional nodes of the Q27 lat...
static constexpr int8_t DirectionVectorComponent_Cz[MFQ27]
The z direction vector component of all D3Q19 lattice directions plus additional nodes of the Q27 lat...
union MF::GB::NodeID::@0 node_id
#define MFQ19_H
Number of elements (linked directions) in propagation table for one node.
static constexpr uint8_t SwapDirections[MFQ19_H][2]
Indexes of swap directions of f(i) in D3Q19.