icedb  version 0.5.1
Snow particle scattering database API
shapeIOtext.cpp
Go to the documentation of this file.
1 #include <map>
2 #include <fstream>
3 #include <iostream>
4 #include <iomanip>
5 #include <cstdio>
6 
7 #include "shape.hpp"
8 #include "shapeIOtext.hpp"
9 
10 namespace icedb {
11  namespace Examples {
12  namespace Shapes {
14  p.NC4_compat = this->NC4_compat;
20  }
22  // When applying these, check for the trivial cases. If these occur, then do not
23  // set the output field.
24 
25  // If p.particle_scattering_element_number is a linear sequence 1...N, then it is trivial
26  bool scat_elem_num_is_trivial = true;
27  for (size_t i = 0; i < this->particle_scattering_element_number.size(); ++i) {
28  if (this->particle_scattering_element_number[i] != i + 1) scat_elem_num_is_trivial = false;
29  }
30  if (!scat_elem_num_is_trivial)
31  p.particle_scattering_element_number = this->particle_scattering_element_number;
32  // Matters only if more than one constituent
33  if (this->particle_constituent_number.size() > 1)
34  p.particle_constituent_number = this->particle_constituent_number;
35 
36 
37  p.particle_scattering_element_radius = this->particle_scattering_element_radius;
38  p.particle_constituent_name = this->particle_constituent_name;
39  p.particle_constituent_single_name = this->particle_constituent_single_name;
40 
41  p.particle_scattering_element_composition_fractional = particle_scattering_element_composition_fractional;
42 
43  // If p.particle_scattering_element_composition_whole is specified, and it is all ones, then it is trivial.
44  bool comp_whole_is_trivial = false;
45  if (std::all_of(particle_scattering_element_composition_whole.begin(),
46  particle_scattering_element_composition_whole.end(),
47  [](uint8_t v)->bool { return (v == 1) ? true : false; }))
48  comp_whole_is_trivial = true;
49  if (!comp_whole_is_trivial)
50  p.particle_scattering_element_composition_whole = particle_scattering_element_composition_whole;
51 
52  p.particle_scattering_element_spacing = this->particle_scattering_element_spacing;
53  p.hint_max_scattering_element_dimension = this->hint_max_scattering_element_dimension;
54  }
56  const std::string &name, std::shared_ptr<H5::Group> grp) const
57  {
59  required.apply(nreq);
61  optional.apply(nopt);
62  return icedb::Shapes::Shape::createShape(grp, name, &nreq, &nopt);
63  }
64  }
65  }
66 }
gsl::span< const uint8_t > particle_scattering_element_composition_whole
Definition: shape.hpp:93
void apply(icedb::Shapes::NewShapeCommonOptionalProperties &) const
Definition: shapeIOtext.cpp:21
static Shape_Type createShape(Groups::Group &grpshp, const std::string &uid, gsl::not_null< const NewShapeRequiredProperties *> required, const NewShapeCommonOptionalProperties *optional=nullptr)
Create a new shape.
Definition: Shapes.cpp:231
uint8_t particle_scattering_element_coordinates_are_integral
Definition: shape.hpp:21
Strucure containing a list of all of the required data needed to create a new shape in the database...
Definition: shape.hpp:12
std::string particle_id
ATTRIBUTE: Unique Particle Identifier.
Definition: shape.hpp:48
gsl::span< const float > particle_scattering_element_radius
Definition: shape.hpp:69
void apply(icedb::Shapes::NewShapeRequiredProperties &) const
Definition: shapeIOtext.cpp:13
float particle_scattering_element_spacing
OPTIONAL ATTRIBUTE: Physical spacing between adjacent grid points (in meters). Used in DDA...
Definition: shape.hpp:96
float hint_max_scattering_element_dimension
EXPERIMENTAL HINT: Specify the maximum scattering element dimension.
Definition: shape.hpp:100
icedb::Shapes::Shape::Shape_Type toShape(const std::string &name, std::shared_ptr< H5::Group >) const
Make a new shape under the group.
Definition: shapeIOtext.cpp:55
Structure containing a list of all of the common optional data for creating a new shape in the databa...
Definition: shape.hpp:60
gsl::span< const float > particle_scattering_element_coordinates
Definition: shape.hpp:37
gsl::span< const uint64_t > particle_scattering_element_number
DIMENSION: The id number for each scattering element. Single dimension.
Definition: shape.hpp:62
uint64_t particle_scattering_element_coordinates_are_integral
Definition: shape.hpp:42
gsl::span< const float > particle_scattering_element_composition_fractional
Definition: shape.hpp:88
std::unique_ptr< Shape > Shape_Type
The preferred C++ type for referencing a shape.
Definition: shape.hpp:145
gsl::span< const std::string > particle_constituent_name
Definition: shape.hpp:77
gsl::span< const uint8_t > particle_constituent_number
DIMENSION: The id number of each particle&#39;s constituent. Single dimension.
Definition: shape.hpp:64