connected kind of

This commit is contained in:
robin committed 2024-05-05 20:41:59 +02:00
1 parent d7201962a5
commit 1643157fe8
21 files changed
+100 -139

No files matched your search

+44
View File
@@ -0,0 +1,44 @@
#ifndef ADVECTION_VEL_H
#define ADVECTION_VEL_H
#include <utility>
#include <stdexcept>
#include <iostream>
#include <format>
class Vel {
public:
double u; // Eastward Current Velocity in the Water Column
double v; // Northward Current Velocity in the Water Column
Vel(double u, double v);
Vel(const std::pair<double, double>& p); // Conversion constructor
Vel& operator=(const std::pair<double, double>& p);
// Operator + to add two Vel objects
Vel operator+(const Vel& other) const;
// Operator += to add another Vel object to this object
Vel& operator+=(const Vel& other);
// Operator * to multiply Vel by a scalar, defined as a member template
template<typename Scalar>
Vel operator*(Scalar scalar) const {
return Vel(u * scalar, v * scalar);
}
// Operator / to divide Vel by a scalar, defined as a member template
template<typename Scalar>
Vel operator/(Scalar scalar) const;
// Friend declaration for the stream insertion operator
friend std::ostream& operator<<(std::ostream& os, const Vel& vel);
};
// Non-member function for scalar multiplication on the left
template<typename Scalar>
Vel operator*(Scalar scalar, const Vel& p) {
return Vel(p.u * scalar, p.v * scalar);
}
#endif //ADVECTION_VEL_H
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.