VirtualFluids 0.2.0
Parallel CFD LBM Solver
Loading...
Searching...
No Matches
SimulationFileWriter.h
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//
33//=======================================================================================
34#ifndef SimulationFileWriter_H
35#define SimulationFileWriter_H
36
37#include <string>
38#include <vector>
39#include <fstream>
40#include <memory>
41#include <vector>
42#include <array>
43
45
46namespace vf::gpu {
47
49class GridBuilder;
50class Grid;
51namespace grid_generator
52{
53class BoundaryCondition;
54}
55
56enum class FILEFORMAT
57{
59};
60
62{
63public:
64 static void write(const std::string& folder, SPtr<GridBuilder> builder, FILEFORMAT format);
65
66private:
67 static void write(SPtr<GridBuilder> builder, FILEFORMAT format);
68 static void openFiles(SPtr<GridBuilder> builder);
69
70 static void writeNumberNodes(SPtr<GridBuilder> builder, uint level);
71 static void writeLBMvsSI(SPtr<GridBuilder> builder, uint level);
72
73 static void writeLevel(uint numberOfLevels);
74 static void writeLevelSize(uint numberOfNodes, FILEFORMAT format);
75 static void writeCoordFiles(SPtr<GridBuilder> builder, uint level, FILEFORMAT format);
76 static void writeCoordsNeighborsGeo(SPtr<GridBuilder> builder, int index, uint level, FILEFORMAT format);
77
78 static void writeLevelSizeGridInterface(uint sizeCF, uint sizeFC);
79 static void writeGridInterfaceToFile(SPtr<GridBuilder> builder, uint level);
80 static void writeGridInterfaceToFile(uint numberOfNodes, std::ofstream& coarseFile, uint* coarse, std::ofstream& fineFile, uint* fine);
81 static void writeGridInterfaceOffsetToFile(uint numberOfNodes, std::ofstream& offsetFile, real* cf_offset_X, real* cf_offset_Y, real* cf_offset_Z);
82
83 static void writeBoundaryQsFile(SPtr<GridBuilder> builder);
84 static std::vector<std::vector<std::vector<real> > > createBCVectors(SPtr<Grid> grid);
85 static void addShortQsToVector(int index, std::vector<std::vector<std::vector<real> > > &qs, SPtr<Grid> grid);
86 static void addQsToVector(int index, std::vector<std::vector<std::vector<real> > > &qs, SPtr<Grid> grid);
87 static void fillRBForNode(int index, int direction, int directionSign, int rb, std::vector<std::vector<std::vector<real> > > &qs, SPtr<Grid> grid);
88 static void writeBoundary(std::vector<real> boundary, int rb);
89 static void writeBoundaryShort(std::vector<real> boundary, int rb);
90 static void writeBoundaryShort(SPtr<Grid> grid, SPtr<grid_generator::BoundaryCondition> boundaryCondition, uint side);
91
92 static void writeCommunicationFiles(SPtr<GridBuilder> builder);
93
94 static void closeFiles();
95
96
97 static std::ofstream xCoordFile;
98 static std::ofstream yCoordFile;
99 static std::ofstream zCoordFile;
100 static std::ofstream xNeighborFile;
101 static std::ofstream yNeighborFile;
102 static std::ofstream zNeighborFile;
103 static std::ofstream wsbNeighborFile;
104 static std::ofstream geoVecFile;
105
106 static std::ofstream scaleCF_coarse_File;
107 static std::ofstream scaleCF_fine_File;
108 static std::ofstream scaleFC_coarse_File;
109 static std::ofstream scaleFC_fine_File;
110
111 static std::ofstream offsetVecCF_File;
112 static std::ofstream offsetVecFC_File;
113
114 static std::vector<SPtr<std::ofstream> > qStreams;
115 static std::vector<SPtr<std::ofstream> > valueStreams;
116
117 static std::vector<std::ofstream> qFiles;
118 static std::vector<std::ofstream> valueFiles;
119
120 static std::array<std::ofstream, 6> sendFiles;
121 static std::array<std::ofstream, 6> receiveFiles;
122
123 static std::ofstream numberNodes_File;
124 static std::ofstream LBMvsSI_File;
125
126 static std::string folder;
127};
128
129}
130
131#endif
132
static void write(const std::string &folder, SPtr< GridBuilder > builder, FILEFORMAT format)
std::shared_ptr< T > SPtr
float real
Definition DataTypes.h:42
unsigned int uint
Definition DataTypes.h:47