VirtualFluids 0.2.0
Parallel CFD LBM Solver
Loading...
Searching...
No Matches
CoordNeighborGeoV.cpp
Go to the documentation of this file.
1//=======================================================================================
2// ____ ____ __ ______ __________ __ __ __ __
3// \ \ | | | | | _ \ |___ ___| | | | | / \ | |
4// \ \ | | | | | |_) | | | | | | | / \ | |
5// \ \ | | | | | _ / | | | | | | / /\ \ | |
6// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____
7// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______|
8// \ \ | | ________________________________________________________________
9// \ \ | | | ______________________________________________________________|
10// \ \| | | | __ __ __ __ ______ _______
11// \ | | |_____ | | | | | | | | | _ \ / _____)
12// \ | | _____| | | | | | | | | | | \ \ \_______
13// \ | | | | |_____ | \_/ | | | | |_/ / _____ |
14// \ _____| |__| |________| \_______/ |__| |______/ (_______/
15//
16// This file is part of VirtualFluids. VirtualFluids is free software: you can
17// redistribute it and/or modify it under the terms of the GNU General Public
18// License as published by the Free Software Foundation, either version 3 of
19// the License, or (at your option) any later version.
20//
21// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT
22// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
23// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24// for more details.
25//
26// SPDX-License-Identifier: GPL-3.0-or-later
27// SPDX-FileCopyrightText: Copyright © VirtualFluids Project contributors, see AUTHORS.md in root folder
28//
32//=======================================================================================
33#include "CoordNeighborGeoV.h"
34
35#include <iostream>
36#include <iomanip>
37#include <stdio.h>
38#include <stdlib.h>
39
40namespace vf::gpu {
41
46
47CoordNeighborGeoV::CoordNeighborGeoV(std::string path, bool binaer, bool coord)
48{
49 file.open(path.c_str(), std::ios::in | std::ios::binary);
50 if (!file)
51 {
52 std::cerr << "error: can not open file CoordNeighborGeo: " << path << std::endl;
53 exit(1);
54 }
55 if(binaer)
57 else
58 init(coord);
59}
60
65
67{
68 this->readLevel();
70
71 for (unsigned int i = 0; i <= maxLevel; i++)
72 {
74 if (isCoord)
75 {
76 coordinates[i].resize(levelSizes[i] + 1);
77 for (unsigned int j = 0; j <= levelSizes[i]; j++)
78 file >> coordinates[i][j];
79 }
80 else
81 {
82 neighbors[i].resize(levelSizes[i] + 1);
83 for (unsigned int j = 0; j <= levelSizes[i]; j++)
84 file >> neighbors[i][j];
85 }
86 }
87}
88
89
91{
92 levelSizes.resize(maxLevel + 1);
93 coordinates.resize(maxLevel + 1);
94 neighbors.resize(maxLevel + 1);
95}
96
98{
99 file >> this->maxLevel;
100}
101
103{
104 this->readLevel();
105 this->resizeVectors();
106
107 readLevelSize(0);
108
109 for(unsigned int level = 0; level <= maxLevel; level++)
110 {
111 //readLevelSize(level);
112 if(isCoord)
113 readCoordinates(level);
114 else
115 readNeighbors(level);
116
117 if(level == maxLevel) break;
118
119 skipSpace();
120 readLevelSize(level+1);
121 }
122}
123
124void CoordNeighborGeoV::readLevelSize(unsigned int level)
125{
126 file >> levelSizes[level];
127}
128
129void CoordNeighborGeoV::readNeighbors(unsigned int level)
130{
131 unsigned int bufferInt;
132 neighbors[level].resize(levelSizes[level] + 1);
133 file >> neighbors[level][0];
134 skipSpace();
135
136 for (unsigned int j = 0; j < levelSizes[level]; j++)
137 {
138 file.read((char*)&bufferInt, sizeof(unsigned int));
139 neighbors[level][j + 1] = bufferInt;
140 }
141}
142
144{
145 double bufferDouble;
146 coordinates[level].resize(levelSizes[level] + 1);
147 file >> coordinates[level][0];
148 skipSpace();
149
150 for (unsigned int j = 0; j < levelSizes[level]; j++)
151 {
152 file.read((char*)&bufferDouble, sizeof(double));
153 coordinates[level][j + 1] = (real)bufferDouble;
154 }
155}
156
158{
159 return maxLevel;
160}
161
162unsigned int CoordNeighborGeoV::getSize(unsigned int level)
163{
164 return this->levelSizes[level];
165}
166
167
168std::vector<unsigned int> CoordNeighborGeoV::getVec(unsigned int level)
169{
170 return this->neighbors[level];
171}
172
173void CoordNeighborGeoV::setVec(unsigned int level, std::vector<unsigned int> vec) {
174 this->neighbors[level]=vec;
175 //for (int i=0; i<=2200; i++) {
176 //std::cout <<"Test im Setter: "<< i <<": " << vec[i] << std::endl;
177 //}
178}
179
180
181void CoordNeighborGeoV::initalCoords(real *data, unsigned int level) const
182{
183 for (std::size_t index = 0; index < coordinates[level].size(); index++)
184 data[index] = coordinates[level][index];
185}
186
187void CoordNeighborGeoV::initalNeighbors(unsigned int *data, unsigned int level) const
188{
189 for (std::size_t index = 0; index < neighbors[level].size(); index++)
190 data[index] = neighbors[level][index];
191}
192
194{
195 char c;
196 file.get(c);
197}
198
199}
200
void initalCoords(real *int_ptr, unsigned int level) const
std::vector< unsigned int > getVec(unsigned int level)
std::vector< unsigned int > levelSizes
void initalNeighbors(unsigned int *int_ptr, unsigned int level) const
void readNeighbors(unsigned int level)
void readCoordinates(unsigned int level)
std::vector< std::vector< real > > coordinates
unsigned int getSize(unsigned int level)
void readLevelSize(unsigned int level)
void setVec(unsigned int level, std::vector< unsigned int > vec)
std::vector< std::vector< unsigned int > > neighbors
std::shared_ptr< T > SPtr
float real
Definition DataTypes.h:42