Skip to content

Commit bcf9341

Browse files
committed
Code cleanup.
1 parent c05cca0 commit bcf9341

32 files changed

+91
-99
lines changed

.clang-format

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Generated from CLion C/C++ Code Style settings
2-
BasedOnStyle: LLVM
2+
BasedOnStyle: Microsoft
33
AccessModifierOffset: -4
44
AlignAfterOpenBracket: Align
55
AlignConsecutiveAssignments: None

LibTrussSolver/include/Truss/Common/Constants.hpp

+13-13
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,28 @@
55
namespace Truss
66
{
77
#ifdef TRUSS_DOUBLE_PRECISION
8-
using Numeric = double;
8+
using Numeric = double;
99
#else
10-
using Numeric = float;
10+
using Numeric = float;
1111
#endif
1212

1313
using ID = int;
1414

15-
constexpr ID INVALID_ID = -1;
15+
constexpr ID INVALID_ID = -1;
1616

17-
constexpr double PI_d = 3.1415926535897932384626;
17+
constexpr double PI_d = 3.1415926535897932384626;
1818

1919
constexpr float PI_f = static_cast<float>(PI_d);
2020

2121
constexpr int ALL_DOF = 6;
2222

2323
const static Eigen::Array<int, 6, 1> DOF_INDEX{0, 1, 2, 3, 4, 5};
2424

25-
template<typename T>
26-
using MatrixX = Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>;
25+
template<typename T>
26+
using MatrixX = Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>;
2727

28-
template<typename T>
29-
using VectorX = Eigen::Vector<T, Eigen::Dynamic>;
28+
template<typename T>
29+
using VectorX = Eigen::Vector<T, Eigen::Dynamic>;
3030

3131
template<typename T>
3232
using Vector3 = Eigen::Vector<T, 3>;
@@ -43,9 +43,9 @@ namespace Truss
4343

4444
template<typename T>
4545
Matrix3x3<T> GetTransformationMatrix(
46-
const Vector3<T>& XAxis,
47-
const Vector3<T>& YAxis = Vector3<T>::Zero(),
48-
const Vector3<T>& ZAxis = Vector3<T>::Zero())
46+
const Vector3<T>& XAxis,
47+
const Vector3<T>& YAxis = Vector3<T>::Zero(),
48+
const Vector3<T>& ZAxis = Vector3<T>::Zero())
4949
{
5050
Matrix3x3<T> result = Matrix3x3<T>::Zero();
5151
result.row(0) = XAxis.normalized();
@@ -67,7 +67,7 @@ namespace Truss
6767
return result;
6868
}
6969

70-
template <typename T, typename Derived>
70+
template<typename T, typename Derived>
7171
MatrixX<T> BlockDiagonal(const Eigen::MatrixBase<Derived>& mat, int count)
7272
{
7373
MatrixX<T> result = MatrixX<T>::Zero(mat.rows() * count, mat.cols() * count);
@@ -83,4 +83,4 @@ namespace Truss
8383
*/
8484
class Resources;
8585

86-
}
86+
}// namespace Truss

LibTrussSolver/include/Truss/Common/DegreeOfFreedom.hpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,11 @@ namespace Truss
3636
}
3737

3838

39-
struct DofBitField {
40-
bool X : 1 {false};
41-
bool Y : 1 {false};
42-
bool Z : 1 {false};
39+
struct DofBitField
40+
{
41+
bool X : 1 {false};
42+
bool Y : 1 {false};
43+
bool Z : 1 {false};
4344
bool RX : 1 {false};
4445
bool RY : 1 {false};
4546
bool RZ : 1 {false};

LibTrussSolver/include/Truss/Common/IComponent.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ namespace Truss
1414
virtual ~IComponent() = default;
1515
};
1616

17-
}
17+
}// namespace Truss

LibTrussSolver/include/Truss/Common/Node.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace Truss
1515
template<typename T>
1616
Vector3<T> MakeVector(const Node& node1, const Node& node2)
1717
{
18-
return { node2.X - node1.X, node2.Y - node1.Y, node2.Z - node1.Z };
18+
return {node2.X - node1.X, node2.Y - node1.Y, node2.Z - node1.Z};
1919
}
2020

2121
/**
@@ -25,4 +25,4 @@ namespace Truss
2525
* @return Length between node1 and node2.
2626
*/
2727
Numeric GetLength(const Node& node1, const Node& node2);
28-
}
28+
}// namespace Truss
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
#pragma once
22

3-
#include <map>
4-
#include <memory>
5-
#include "Node.hpp"
63
#include "Node.hpp"
7-
#include "Truss/Material/Elastic.hpp"
4+
#include "Truss/Constraint/ConstraintBase.hpp"
85
#include "Truss/Element/ElementBase.hpp"
96
#include "Truss/Load/LoadBase.hpp"
10-
#include "Truss/Constraint/ConstraintBase.hpp"
7+
#include "Truss/Material/Elastic.hpp"
118
#include "Truss/Section/SectionBase.hpp"
9+
#include <map>
10+
#include <memory>
1211

1312
namespace Truss
1413
{
@@ -22,4 +21,4 @@ namespace Truss
2221
std::map<ID, std::shared_ptr<Constraint::ConstraintBase>> Constraints;
2322
std::map<ID, std::shared_ptr<Section::SectionBase>> Sections;
2423
};
25-
}
24+
}// namespace Truss

LibTrussSolver/include/Truss/Constraint/ConstraintBase.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#pragma once
22

3-
#include "Truss/Common/IComponent.hpp"
43
#include "Truss/Common/DegreeOfFreedom.hpp"
4+
#include "Truss/Common/IComponent.hpp"
55
#include <vector>
66
namespace Truss::Constraint
77
{
@@ -15,4 +15,4 @@ namespace Truss::Constraint
1515
[[nodiscard]] virtual DegreeOfFreedom GetDegreeOfFreedom() const = 0;
1616
};
1717

18-
}
18+
}// namespace Truss::Constraint

LibTrussSolver/include/Truss/Constraint/NodeConstraint.hpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#pragma once
22

3+
#include "ConstraintBase.hpp"
34
#include "Truss/Common/Constants.hpp"
45
#include "Truss/Common/Node.hpp"
5-
#include "ConstraintBase.hpp"
66
#include "Truss/Common/Resources.hpp"
77

88
namespace Truss::Constraint
@@ -38,6 +38,5 @@ namespace Truss::Constraint
3838
DofBitField dof(!XDisplacement, !YDisplacement, !ZDisplacement, !XRotation, !YRotation, !ZRotation);
3939
return *reinterpret_cast<DegreeOfFreedom*>(&dof);
4040
}
41-
4241
};
43-
}
42+
}// namespace Truss::Constraint

LibTrussSolver/include/Truss/Element/Bar.hpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#pragma once
22

3+
#include "ElementBase.hpp"
34
#include "Truss/Common/Constants.hpp"
4-
#include "Truss/Common/Node.hpp"
55
#include "Truss/Common/DegreeOfFreedom.hpp"
6+
#include "Truss/Common/Node.hpp"
67
#include "Truss/Material/Elastic.hpp"
78
#include "Truss/Section/Section_Bar.hpp"
8-
#include "ElementBase.hpp"
99

1010
namespace Truss::Element
1111
{
@@ -53,6 +53,5 @@ namespace Truss::Element
5353
[[nodiscard]] MatrixX<Numeric> GetStiffnessGlobal() const override;
5454

5555
[[nodiscard]] std::vector<ID> GetNodeIds() const override;
56-
5756
};
58-
}
57+
}// namespace Truss::Element

LibTrussSolver/include/Truss/Element/Beam.hpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ namespace Truss::Element
4747
[[nodiscard]] MatrixX<Numeric> GetStiffnessGlobal() const override;
4848

4949
~Beam() override = default;
50-
5150
};
5251

53-
}
54-
52+
}// namespace Truss::Element

LibTrussSolver/include/Truss/Element/ElementBase.hpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#pragma once
22

3-
#include "Truss/Common/IComponent.hpp"
43
#include "Truss/Common/DegreeOfFreedom.hpp"
4+
#include "Truss/Common/IComponent.hpp"
55
#include <bit>
66

77
namespace Truss::Element
@@ -31,7 +31,6 @@ namespace Truss::Element
3131
[[nodiscard]] virtual std::vector<ID> GetNodeIds() const = 0;
3232

3333
[[nodiscard]] virtual MatrixX<Numeric> GetStiffnessGlobal() const = 0;
34-
3534
};
3635

37-
}
36+
}// namespace Truss::Element

LibTrussSolver/include/Truss/Load/LoadBase.hpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,4 @@ namespace Truss::Load
1414
[[nodiscard]] virtual Eigen::Vector<Numeric, ALL_DOF> GetLoad() const = 0;
1515
};
1616

17-
}
18-
17+
}// namespace Truss::Load

LibTrussSolver/include/Truss/Load/NodeLoad.hpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#pragma once
22

3+
#include "LoadBase.hpp"
34
#include "Truss/Common/Constants.hpp"
45
#include "Truss/Common/Node.hpp"
56
#include "Truss/Common/Resources.hpp"
6-
#include "LoadBase.hpp"
77

88

99
namespace Truss::Load
@@ -22,17 +22,17 @@ namespace Truss::Load
2222

2323
void Build(Resources& resources) override
2424
{
25-
Node = &resources.Nodes.at(NodeKey);
25+
Node = &resources.Nodes.at(NodeKey);
2626
}
2727

2828
[[nodiscard]] std::vector<ID> GetNodeIds() const override
2929
{
30-
return { Node->Id };
30+
return {Node->Id};
3131
}
3232

33-
[[nodiscard]] Eigen::Vector<Numeric,6> GetLoad() const override
33+
[[nodiscard]] Eigen::Vector<Numeric, 6> GetLoad() const override
3434
{
35-
return { XForce, YForce, ZForce, XMoment, YMoment, ZMoment };
35+
return {XForce, YForce, ZForce, XMoment, YMoment, ZMoment};
3636
}
3737
};
38-
}
38+
}// namespace Truss::Load

LibTrussSolver/include/Truss/Material/Elastic.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#pragma once
22

3-
#include "Truss/Common/Constants.hpp"
43
#include "MaterialBase.hpp"
4+
#include "Truss/Common/Constants.hpp"
55

66
namespace Truss::Material
77
{
@@ -16,4 +16,4 @@ namespace Truss::Material
1616
return YoungsModules / (2 * (1 + PoissonRation));
1717
}
1818
};
19-
}
19+
}// namespace Truss::Material

LibTrussSolver/include/Truss/Material/MaterialBase.hpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ namespace Truss::Material
99
class MaterialBase : public IComponent
1010
{
1111
public:
12-
1312
};
1413

15-
}
16-
14+
}// namespace Truss::Material

LibTrussSolver/include/Truss/Section/SectionBase.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ namespace Truss::Section
1111
virtual void Build(Resources&) = 0;
1212
};
1313

14-
}
14+
}// namespace Truss::Section

LibTrussSolver/include/Truss/Section/Section_Bar.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#pragma once
22

3+
#include "SectionBase.hpp"
34
#include "Truss/Common/Constants.hpp"
45
#include "Truss/Material/Elastic.hpp"
5-
#include "SectionBase.hpp"
66

77
namespace Truss::Section
88
{
@@ -14,4 +14,4 @@ namespace Truss::Section
1414

1515
void Build(Resources& resources) override;
1616
};
17-
}
17+
}// namespace Truss::Section

LibTrussSolver/include/Truss/Section/Section_Beam.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ namespace Truss::Section
1717

1818
void Build(Resources& resources) override;
1919
};
20-
}
20+
}// namespace Truss::Section

LibTrussSolver/include/Truss/Serializer/Serializers.hpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,4 @@ namespace Truss
2323

2424

2525
SimpleReflection& GetCompomentReflection();
26-
}
27-
26+
}// namespace Truss

LibTrussSolver/include/Truss/Solver.hpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ namespace Truss
5151
void LoadSections(const TrussDocument& doc);
5252

5353
void BuildAllComponents();
54-
5554
};
5655

57-
}
56+
}// namespace Truss

LibTrussSolver/include/Truss/Utils/FunctionPointer.hpp

+11-9
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,23 @@
22

33
namespace Truss
44
{
5-
template<typename TResult, typename...TArgs>
6-
struct IsFunctionPointer {};
5+
template<typename TResult, typename... TArgs>
6+
struct IsFunctionPointer
7+
{
8+
};
79

8-
template<typename TResult, typename...TArgs>
9-
struct IsFunctionPointer<TResult(&)(TArgs...)>
10+
template<typename TResult, typename... TArgs>
11+
struct IsFunctionPointer<TResult (&)(TArgs...)>
1012
{
11-
const static bool value{ true };
13+
const static bool value{true};
1214
};
1315

14-
template<typename TResult, typename...TArgs>
15-
struct IsFunctionPointer<TResult(*)(TArgs...)>
16+
template<typename TResult, typename... TArgs>
17+
struct IsFunctionPointer<TResult (*)(TArgs...)>
1618
{
17-
const static bool value{ true };
19+
const static bool value{true};
1820
};
1921

2022
template<typename TFunc>
2123
concept FunctionPointer = IsFunctionPointer<TFunc>::value;
22-
}
24+
}// namespace Truss

0 commit comments

Comments
 (0)