57 lines
1.8 KiB
C++
Executable File
57 lines
1.8 KiB
C++
Executable File
#ifndef BEAM_HPP
|
|
#define BEAM_HPP
|
|
#include <assert.h>
|
|
#include <cmath>
|
|
#include <iostream>
|
|
#include <string>
|
|
|
|
struct RectangularBeamDimensions {
|
|
inline static std::string name{"Rectangular"};
|
|
double b;
|
|
double h;
|
|
RectangularBeamDimensions(const double &width, const double &height)
|
|
: b(width), h(height) {
|
|
assert(width > 0 && height > 0);
|
|
}
|
|
RectangularBeamDimensions() : b(0.002), h(0.002) {}
|
|
std::string toString() const {
|
|
return std::string("b=") + std::to_string(b) + std::string(" h=") +
|
|
std::to_string(h);
|
|
}
|
|
};
|
|
|
|
struct CylindricalBeamDimensions {
|
|
inline static std::string name{"Cylindrical"};
|
|
double od; // Cylinder outside diameter
|
|
double
|
|
id; // Cylinder inside diameter
|
|
// https://www.engineeringtoolbox.com/area-moment-inertia-d_1328.html
|
|
CylindricalBeamDimensions(const double &outsideDiameter,
|
|
const double &insideDiameter)
|
|
: od(outsideDiameter), id(insideDiameter) {
|
|
assert(outsideDiameter > 0 && insideDiameter > 0 &&
|
|
outsideDiameter > insideDiameter);
|
|
}
|
|
CylindricalBeamDimensions() : od(0.03), id(0.026) {}
|
|
};
|
|
|
|
struct ElementMaterial
|
|
{
|
|
double poissonsRatio;
|
|
double youngsModulus;
|
|
ElementMaterial(const double &poissonsRatio, const double &youngsModulus)
|
|
: poissonsRatio(poissonsRatio), youngsModulus(youngsModulus)
|
|
{
|
|
assert(poissonsRatio <= 0.5 && poissonsRatio >= -1);
|
|
}
|
|
ElementMaterial() : poissonsRatio(0.3), youngsModulus(200 * 1e9) {}
|
|
std::string toString() const
|
|
{
|
|
return std::string("Material:") + std::string("\nPoisson's ratio=")
|
|
+ std::to_string(poissonsRatio) + std::string("\nYoung's Modulus(GPa)=")
|
|
+ std::to_string(youngsModulus / 1e9);
|
|
}
|
|
};
|
|
|
|
#endif // BEAM_HPP
|