VirtualFluids 0.2.0
Parallel CFD LBM Solver
Loading...
Searching...
No Matches
WbWriterTecPlotASCII.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//
33//=======================================================================================
36
37using namespace std;
38
39/*===============================================================================*/
41 vector<UbTupleUInt8> &cells, vector<string> &datanames,
43{
44 string tecplotfilename = filename + getFileExtension();
45 UBLOG(logDEBUG1, "WbWriterTecPlotASCII::writeOctsWithNodeData to " << tecplotfilename << " - start");
46
48 if (!out) {
49 out.clear(); // flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
51 if (path.size() > 0) {
53 out.open(tecplotfilename.c_str());
54 }
55 if (!out)
56 throw UbException(UB_EXARGS, "couldn't open file " + tecplotfilename);
57 }
58
59 int nofNodes = (int)nodes.size();
60 int nofCells = (int)cells.size();
61
62 out << "TITLE = VirtualFluids OctGrid from " << ub_system::getTimeStamp() << endl;
63
64 out << "VARIABLES = \"X\", \"Y\", \"Z\"";
65 for (size_t d = 0; d < datanames.size(); d++)
66 out << ", \"" << datanames[d] << "\"";
67 out << endl;
68
69 out << "ZONE NODES=" << nofNodes << ", ELEMENTS=" << nofCells << ", DATAPACKING=POINT, ZONETYPE=FEBRICK" << endl;
70 for (size_t n = 0; n < nodes.size(); n++) {
71 UbTupleFloat3 &coords = nodes[n];
72 out << val<1>(coords) << " " << val<2>(coords) << " " << val<3>(coords);
73 for (size_t d = 0; d < datanames.size(); d++)
74 out << " " << nodedata[d][n];
75 out << endl;
76 }
77
78 for (size_t c = 0; c < cells.size(); c++) {
79 UbTupleUInt8 &cell = cells[c];
80 out << val<1>(cell) << " " << val<2>(cell) << " " << val<3>(cell) << " " << val<4>(cell) << " " << val<5>(cell)
81 << " " << val<6>(cell) << " " << val<7>(cell) << " " << val<8>(cell) << endl;
82 }
83
84 out.close();
85 UBLOG(logDEBUG1, "WbWriterTecPlotASCII::writeOctsWithNodeData to " << tecplotfilename << " - end");
86
87 return tecplotfilename;
88}
89/*===============================================================================*/
90string WbWriterTecPlotASCII::writeOctsU(const string &filename, vector<UbTupleFloat3> &nodes,
92{
93 vector<string> datanames;
95 return writeOctsWithNodeData(filename, nodes, cells, datanames, nodedata);
96}
97/*===============================================================================*/
98
std::string getFileExtension() override
std::shared_ptr< T > SPtr
#define UBLOG(level, logtext)
Definition UbLogger.h:327
#define UB_EXARGS
Definition UbException.h:73
@ logDEBUG1
Definition UbLogger.h:54
std::string writeOctsWithNodeData(const std::string &filename, std::vector< UbTupleFloat3 > &nodes, std::vector< UbTupleUInt8 > &cells, std::vector< std::string > &datanames, std::vector< std::vector< double > > &nodedata) override
std::string writeOctsU(const std::string &filename, std::vector< UbTupleFloat3 > &nodes, std::vector< UbTupleUInt8 > &cells)
bool makeDirectory(const std::string &dir)
Definition UbSystem.h:280
std::string getTimeStamp()
Definition UbSystem.h:420
std::string getPathFromString(const std::string &fileStringWithPath)
Definition UbSystem.h:345