TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
YAML_data.h
1/****************************************************************************
2* Copyright (c) 2025, CEA
3* All rights reserved.
4*
5* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9*
10* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
11* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
12* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13*
14*****************************************************************************/
15
16#ifndef YAML_data_included
17#define YAML_data_included
18
19#include <string>
20#include <vector>
21
22/*! @brief classe YAML_data : collection of all needed information for data to save/restore in order to write the YAML file used to initialize PDI
23 *
24 */
26{
27public:
29 YAML_data(const std::string& name, const std::string& type) : name_(name), type_(type), dimension_(0), hdf_name_(name) { }
30 YAML_data(const std::string& name, const std::string& type, int nb_dim) : name_(name), type_(type), dimension_(nb_dim), hdf_name_(name) { }
31 YAML_data(const std::string& name, const std::string& type, int nb_dim, bool loc) : name_(name), type_(type), dimension_(nb_dim), local_(loc), hdf_name_(name) { }
32 YAML_data(const std::string& name, const std::string& type, int nb_dim, bool loc, bool is_ds) : name_(name), type_(type), dimension_(nb_dim), local_(loc), is_dataset_(is_ds), hdf_name_(name) { }
33
34 // Setters
35 void set_local(bool l) { local_ = l; }
36 void set_conditions(const std::string& cond) { conditions_ = cond; }
37 void add_attribute(const std::string& attr) { attributes_.push_back(attr); }
38 void set_dataset(bool d) { is_dataset_ = d; }
39 void set_hdf_name(const std::string& n) { hdf_name_ = n; }
40 void set_save_field_type(bool b) { save_field_type_ = b; }
41
42 // Getters
43 const std::string& get_name() const { return name_; }
44 const std::string& get_type() const { return type_; }
45 int get_dims() const { return dimension_; }
46 bool is_local() const { return local_; }
47 const std::string& get_conditions() const { return conditions_; }
48 const std::vector<std::string>& get_attributes() const { return attributes_; }
49 bool is_dataset() const { return is_dataset_; }
50 const std::string& get_hdf_name() const { return hdf_name_; }
51 bool save_field_type() const { return save_field_type_; }
52
53private:
54 // name of the data
55 std::string name_;
56 // type of the data (careful, for arrays, the type refers to the type of the data it contains)
57 std::string type_;
58 // dimension of the data (0 for scalars)
59 int dimension_;
60 // are my data local to each processor (in which case, they will be written by everyone and local_=true)
61 // or are they global (only master needs to write, local_= false)?
62 bool local_ = true;
63 // conditions to respect in order to read/write the data
64 std::string conditions_;
65 // list of attributes of the data
66 std::vector<std::string> attributes_;
67 // am I to be written as a dataset (must be set to false for attributes!)?
68 bool is_dataset_ = true;
69 // name of the HDF5 object it will be stored in (by default, same name as the data)
70 std::string hdf_name_;
71 // do we save the type of the field into the HDF file ?
72 bool save_field_type_ = false;
73};
74
75
76#endif
YAML_data(const std::string &name, const std::string &type, int nb_dim, bool loc)
Definition YAML_data.h:31
void set_dataset(bool d)
Definition YAML_data.h:38
YAML_data(const std::string &name, const std::string &type, int nb_dim)
Definition YAML_data.h:30
void set_conditions(const std::string &cond)
Definition YAML_data.h:36
const std::string & get_conditions() const
Definition YAML_data.h:47
const std::string & get_hdf_name() const
Definition YAML_data.h:50
void set_hdf_name(const std::string &n)
Definition YAML_data.h:39
bool save_field_type() const
Definition YAML_data.h:51
int get_dims() const
Definition YAML_data.h:45
bool is_local() const
Definition YAML_data.h:46
const std::string & get_name() const
Definition YAML_data.h:43
YAML_data(const std::string &name, const std::string &type)
Definition YAML_data.h:29
void add_attribute(const std::string &attr)
Definition YAML_data.h:37
const std::vector< std::string > & get_attributes() const
Definition YAML_data.h:48
void set_local(bool l)
Definition YAML_data.h:35
bool is_dataset() const
Definition YAML_data.h:49
const std::string & get_type() const
Definition YAML_data.h:44
void set_save_field_type(bool b)
Definition YAML_data.h:40
YAML_data(const std::string &name, const std::string &type, int nb_dim, bool loc, bool is_ds)
Definition YAML_data.h:32