VirtualFluids 0.2.0
Parallel CFD LBM Solver
Loading...
Searching...
No Matches
YAML_MetaData.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//=======================================================================================
34#include "YAML_MetaData.h"
35
36#include <fstream>
37
38#include <yaml-cpp/yaml.h>
39
40#include "MetaData.h"
41
42namespace YAML
43{
44
45template <>
46struct convert<vf::basics::MetaData::BuildInfo>
47{
49 {
50 Node root;
51 root["git_commit_hash"] = rhs.git_commit_hash;
52 root["git_branch"] = rhs.git_branch;
53 root["build_type"] = rhs.build_type;
54 root["remote"] = rhs.remote;
55 root["precision"] = rhs.precision;
56 root["compiler"] = rhs.compiler;
57 root["compiler_version"] = rhs.compiler_version;
58 root["compiler_flags"] = rhs.compiler_flags;
59 root["compiler_definitions"] = rhs.compiler_definitions;
60#ifdef VF_MPI
61 root["mpi_library"] = rhs.mpi_library;
62 root["mpi_version"] = rhs.mpi_version;
63#endif
64#ifdef VF_OPENMP
65 root["openmp_library"] = rhs.openmp_library;
66 root["openmp_version"] = rhs.openmp_version;
67#endif
68 return root;
69 }
70};
71
72template <>
73struct convert<vf::basics::MetaData::Discretization>
74{
76 {
77 Node root;
78 root["dt"] = rhs.dt;
79 root["dx"] = rhs.dx;
80 root["totalNumberOfNodes"] = rhs.totalNumberOfNodes;
81 root["numberOfLevels"] = rhs.numberOfLevels;
82
83 Node node;
84 for (const auto& nodes : rhs.numberOfNodesPerLevel)
85 node.push_back(nodes);
86
87 root["numberOfNodesPerLevel"] = node;
88
89 return root;
90 }
91};
92
93template <>
94struct convert<vf::basics::MetaData::World>
95{
97 {
98 Node root;
99 root["length"] = rhs.length;
100 root["velocity"] = rhs.velocity;
101 return root;
102 }
103};
104
105template <>
106struct convert<vf::basics::MetaData::Simulation>
107{
109 {
110 Node root;
111 root["startDateTime"] = rhs.startDateTime;
112 root["runtimeSeconds"] = rhs.runtimeSeconds;
113 root["nups"] = rhs.nups;
114 root["numberOfTimeSteps"] = rhs.numberOfTimeSteps;
115
116 root["collisionKernel"] = rhs.collisionKernel;
117 root["reynoldsNumber"] = rhs.reynoldsNumber;
118 root["lb_velocity"] = rhs.lb_velocity;
119 root["lb_viscosity"] = rhs.lb_viscosity;
120 root["quadricLimiter"] = rhs.quadricLimiters;
121
122 return root;
123 }
124};
125
126template <>
127struct convert<vf::basics::MetaData::GPU>
128{
130 {
131 Node root;
132 root["name"] = rhs.name;
133 root["compute_capability"] = rhs.compute_capability;
134 return root;
135 }
136};
137
138template <>
139struct convert<vf::basics::MetaData>
140{
141 static Node encode(const vf::basics::MetaData& rhs)
142 {
143 Node root;
144 root["name"] = rhs.name;
145 root["number_of_processes"] = rhs.numberOfProcesses;
146 root["number_of_threads"] = rhs.numberOfThreads;
147 root["vf_hardware"] = rhs.vf_hardware;
148
149 root["simulation"] = rhs.simulation;
150
151 root["world"] = rhs.world;
152
153 root["discretization"] = rhs.discretization;
154
155 root["build_info"] = rhs.buildInfo;
156
157 if (rhs.vf_hardware == "GPU") {
158 Node node;
159 for (const auto& nodes : rhs.gpus)
160 node.push_back(nodes);
161
162 root["gpus"] = node;
163 }
164
165 return root;
166 }
167};
168
169} // namespace YAML
170
171namespace vf::basics
172{
173
174void writeYAML(const MetaData& meta_data, const std::string& filename)
175{
176 YAML::Node node;
177 node = meta_data;
178 std::ofstream fout(filename);
179 fout << node;
180}
181
182} // namespace vf::basics
183
std::shared_ptr< T > SPtr
Simple configuration file.
void writeYAML(const MetaData &meta_data, const std::string &filename)
static Node encode(const vf::basics::MetaData &rhs)
static Node encode(const vf::basics::MetaData::BuildInfo &rhs)
static Node encode(const vf::basics::MetaData::Discretization &rhs)
static Node encode(const vf::basics::MetaData::GPU &rhs)
static Node encode(const vf::basics::MetaData::Simulation &rhs)
static Node encode(const vf::basics::MetaData::World &rhs)