TransFlow  0.1.0
A transient pipeline flow simulation library
pipewall.hpp
1 #pragma once
2 
3 #include <vector>
4 #include <armadillo>
5 
6 #include "material.hpp"
7 
12 class PipeWall
13 {
14 public:
15  class Layer;
16 
21  explicit PipeWall(const arma::uword nWallLayers):
22  m_layers(std::vector<Layer>(nWallLayers))
23  {}
24 
29  explicit PipeWall(const std::vector<Layer>& wallLayers):
30  m_layers(wallLayers)
31  {}
32 
34  const Layer& layer(const arma::uword i) const
35  {
36  return m_layers.at(i);
37  }
38 
40  Layer& layer(const arma::uword i)
41  {
42  return m_layers.at(i);
43  }
44 
46  const std::vector<Layer>& layers() const { return m_layers; }
47 
49  arma::uword size() const { return m_layers.size(); }
50 
51  // initialized in .cpp
52  static const PipeWall defaultPipeWall;
53 
54 private:
56  std::vector<Layer> m_layers;
57 };
58 
63 class PipeWall::Layer : public Material
64 {
65 public:
69  constexpr Layer():
70  Material(-1, -1, -1),
71  m_thickness(-1)
72  {}
73 
81  constexpr Layer(
82  const double thickness,
83  const double conductivity,
84  const double density,
85  const double heatCapacity):
88  {}
89 
95  constexpr Layer(
96  const double thickness,
97  const Material& material):
98  Material(material),
100  {}
101 
102  double thickness() const { return m_thickness; }
103  double conductivity() const { return m_conductivity; }
104  double density() const { return m_density; }
105  double heatCapacity() const { return m_heatCapacity; }
106 
107  // setters
108  double& thickness() { return m_thickness; }
109  double& conductivity() { return m_conductivity; }
110  double& density() { return m_density; }
111  double& heatCapacity() { return m_heatCapacity; }
112 
113 private:
114  double m_thickness;
115 };
PipeWall::defaultPipeWall
static const PipeWall defaultPipeWall
Predefined pipe wall.
Definition: pipewall.hpp:52
PipeWall::layer
Layer & layer(const arma::uword i)
Get layer with index i. Returns (non-const) reference to member.
Definition: pipewall.hpp:40
PipeWall::Layer::Layer
constexpr Layer(const double thickness, const Material &material)
Construct from thickness and Material instance.
Definition: pipewall.hpp:95
PipeWall::Layer::conductivity
double conductivity() const
Conductivity getter.
Definition: pipewall.hpp:103
PipeWall::Layer::Layer
constexpr Layer()
Default constructor, sets all properties to -1.
Definition: pipewall.hpp:69
PipeWall::PipeWall
PipeWall(const arma::uword nWallLayers)
Construct PipeWall with a given number of layers.
Definition: pipewall.hpp:21
PipeWall::Layer::conductivity
double & conductivity()
Conductivity setter.
Definition: pipewall.hpp:109
PipeWall
The PipeWall class is a container class that defines the thickness and Material properties of each la...
Definition: pipewall.hpp:12
Material
The Material class is a simple container class that defines the conductivity, density and heat capaci...
Definition: material.hpp:7
Material::m_conductivity
double m_conductivity
Thermal conductivity [W/(m K)].
Definition: material.hpp:39
PipeWall::layers
const std::vector< Layer > & layers() const
Get all pipe wall layers. Returns const reference to member.
Definition: pipewall.hpp:46
PipeWall::Layer::density
double & density()
Density setter.
Definition: pipewall.hpp:110
PipeWall::size
arma::uword size() const
Get number of layers in the pipe wall.
Definition: pipewall.hpp:49
Material::m_density
double m_density
Density [kg/m3].
Definition: material.hpp:40
PipeWall::Layer::thickness
double thickness() const
Thickness getter.
Definition: pipewall.hpp:102
PipeWall::PipeWall
PipeWall(const std::vector< Layer > &wallLayers)
Construct PipeWall from a vector of PipeWall::Layer.
Definition: pipewall.hpp:29
PipeWall::Layer::density
double density() const
Density getter.
Definition: pipewall.hpp:104
PipeWall::Layer::heatCapacity
double & heatCapacity()
Heat capacity setter.
Definition: pipewall.hpp:111
PipeWall::Layer
The PipeWall::Layer class is a simple container class that defines the thickness and all other materi...
Definition: pipewall.hpp:63
PipeWall::Layer::thickness
double & thickness()
Thickness setter.
Definition: pipewall.hpp:108
PipeWall::Layer::m_thickness
double m_thickness
Layer wall thickness [m].
Definition: pipewall.hpp:114
PipeWall::m_layers
std::vector< Layer > m_layers
m_layers Vector of PipeWall::Layer that the wall consists of.
Definition: pipewall.hpp:56
Material::m_heatCapacity
double m_heatCapacity
Heat capacity at constant pressure ( ) [J/(kg K)].
Definition: material.hpp:41
PipeWall::layer
const Layer & layer(const arma::uword i) const
Get layer with index i. Returns const reference to member.
Definition: pipewall.hpp:34
PipeWall::Layer::Layer
constexpr Layer(const double thickness, const double conductivity, const double density, const double heatCapacity)
Basic constructor that requires all material properties.
Definition: pipewall.hpp:81
PipeWall::Layer::heatCapacity
double heatCapacity() const
Heat capacity getter.
Definition: pipewall.hpp:105