Microflow 3D  v1.0
BoundaryFromThread.cpp
Go to the documentation of this file.
1 // ==============================================================================================
2 // Microflow 3D, http://www.microflow.pwr.edu.pl/
3 // Created by Roman Szafran on 18.05.19.
4 // Copyright (c) 2019 Wroclaw University of Science and Technology.
5 // Distributed under the Apache License, Version 2.0. You may obtain a copy of the License at
6 // http://www.apache.org/licenses/LICENSE-2.0 or see accompanying file license.txt.
7 // Redistributions of source code must retain the above copyright and license notice.
8 // ==============================================================================================
9 
10 #include "BoundaryFromThread.h"
11 #include "NodeID.h"
12 
13 void MF::GB::BoundaryFromThread::VDBBoundaryAdd(const openvdb::Int64Grid::Ptr& VDBGrid, const std::shared_ptr<MF::Database::ConfigData> & ConfigData_Ptr) {
14  MF::GB::NodeID nodeTMP, PresentNodeID;
15  nodeTMP.node_id.NodeID = {0};
16  for (unsigned int iter = 0; iter < ConfigData_Ptr->getThreadsNumber(); iter++) {
17  if (ConfigData_Ptr->getThreadStringParam(iter, "GridType") == "VDB") {
18  if (ConfigData_Ptr->getThreadParamLength(iter, "NodeFilePath") > 0) {
19  if (ConfigData_Ptr->getThreadIntParam(iter, "NodeTypeID") >= 20) { //process only threads with definition of boundary nodes
20  auto nodeID = (int16_t) ConfigData_Ptr->getThreadIntParam(iter, "NodeTypeID");
21  std::string FilePath =
22  ConfigData_Ptr->CaseFolder + ConfigData_Ptr->getProgramStringParam("GeometryFolder") +
23  ConfigData_Ptr->getThreadStringParam(iter, "NodeFilePath");
24  auto data_Ptr = std::make_unique<std::vector<double>>();
25  std::vector<std::string> VariableNameList{
26  ConfigData_Ptr->getThreadStringVectorParam(0, iter, "NodeCoordinateFileColumnNames"),
27  ConfigData_Ptr->getThreadStringVectorParam(1, iter, "NodeCoordinateFileColumnNames"),
28  ConfigData_Ptr->getThreadStringVectorParam(2, iter, "NodeCoordinateFileColumnNames")};
29  MF::RW::CSVReader::DataReadFromCSVFile(FilePath, VariableNameList, data_Ptr.get());
30  auto accessor = VDBGrid->getAccessor();
31  openvdb::Coord xyz;
32  int32_t &i = xyz[0], &j = xyz[1], &h = xyz[2];
33 
34  for (auto it = data_Ptr->begin(); it < data_Ptr->end(); it += 3) {
35  i = int32_t(*it);
36  j = int32_t(*(it + 1));
37  h = int32_t(*(it + 2));
38  PresentNodeID.node_id.NodeID = accessor.getValue(xyz);
39  if (PresentNodeID.node_id.Node.nodeType == 3) { // only changes node type for boundary nodes
40  nodeTMP.node_id.Node.nodeType = nodeID;
41  nodeTMP.node_id.Node.uidThreadNr = (uint16_t) iter + 1; // uidThreadNr added from the thread_params.cfg starts from 1 because automatically created threads have uidThreadNr = 0;
42  accessor.setValue(xyz, nodeTMP.node_id.NodeID);
43  }
44  }
45  data_Ptr.reset();
46  }
47  }
48  }
49  }
50 }
struct MF::GB::NodeID::@0::@1 Node
static void VDBBoundaryAdd(const openvdb::Int64Grid::Ptr &VDBGrid, const std::shared_ptr< MF::Database::ConfigData > &ConfigData_Ptr)
A class that allows to determine the proper NodeID from combined nodeType, uidThreadNr, ThreadCount, ComponentNr and PhaseNr.
Definition: NodeID.h:18
static void DataReadFromCSVFile(const std::string &DataFilePath, const std::vector< std::string > &VariableNameList, std::vector< double > *pDataArray)
Reads data from text file.
Definition: CSVReader.cpp:13
uint64_t NodeID
Definition: NodeID.h:29
union MF::GB::NodeID::@0 node_id