diff --git a/src/vmecpp/cpp/vmecpp/vmec/fourier_coefficients/fourier_coefficients.cc b/src/vmecpp/cpp/vmecpp/vmec/fourier_coefficients/fourier_coefficients.cc index 8620e320b..93a31929f 100644 --- a/src/vmecpp/cpp/vmecpp/vmec/fourier_coefficients/fourier_coefficients.cc +++ b/src/vmecpp/cpp/vmecpp/vmec/fourier_coefficients/fourier_coefficients.cc @@ -6,6 +6,7 @@ #include #include +#include #include #include "absl/algorithm/container.h" @@ -45,6 +46,42 @@ FourierCoeffs::FourierCoeffs(const Sizes* s, const RadialPartitioning* r, } } +FourierCoeffs& FourierCoeffs::operator=(const FourierCoeffs& other) { + if (this != &other) { + rcc = other.rcc; + rss = other.rss; + rsc = other.rsc; + rcs = other.rcs; + zsc = other.zsc; + zcs = other.zcs; + zcc = other.zcc; + zss = other.zss; + lsc = other.lsc; + lcs = other.lcs; + lcc = other.lcc; + lss = other.lss; + } + return *this; +} + +FourierCoeffs& FourierCoeffs::operator=(FourierCoeffs&& other) noexcept { + if (this != &other) { + rcc = std::move(other.rcc); + rss = std::move(other.rss); + rsc = std::move(other.rsc); + rcs = std::move(other.rcs); + zsc = std::move(other.zsc); + zcs = std::move(other.zcs); + zcc = std::move(other.zcc); + zss = std::move(other.zss); + lsc = std::move(other.lsc); + lcs = std::move(other.lcs); + lcc = std::move(other.lcc); + lss = std::move(other.lss); + } + return *this; +} + int FourierCoeffs::nsMin() const { return nsMin_; } int FourierCoeffs::nsMax() const { return nsMax_; } diff --git a/src/vmecpp/cpp/vmecpp/vmec/fourier_coefficients/fourier_coefficients.h b/src/vmecpp/cpp/vmecpp/vmec/fourier_coefficients/fourier_coefficients.h index ba38b8ae3..9986e57a9 100644 --- a/src/vmecpp/cpp/vmecpp/vmec/fourier_coefficients/fourier_coefficients.h +++ b/src/vmecpp/cpp/vmecpp/vmec/fourier_coefficients/fourier_coefficients.h @@ -19,6 +19,10 @@ class FourierCoeffs { public: FourierCoeffs(const Sizes* s, const RadialPartitioning* r, int nsMin, int nsMax, int ns); + FourierCoeffs(const FourierCoeffs& other) = default; + FourierCoeffs(FourierCoeffs&& other) noexcept = default; + FourierCoeffs& operator=(const FourierCoeffs& other); + FourierCoeffs& operator=(FourierCoeffs&& other) noexcept; void setZero(); diff --git a/src/vmecpp/cpp/vmecpp/vmec/fourier_forces/fourier_forces.cc b/src/vmecpp/cpp/vmecpp/vmec/fourier_forces/fourier_forces.cc index 3bd20d80a..50088aec1 100644 --- a/src/vmecpp/cpp/vmecpp/vmec/fourier_forces/fourier_forces.cc +++ b/src/vmecpp/cpp/vmecpp/vmec/fourier_forces/fourier_forces.cc @@ -5,6 +5,7 @@ #include "vmecpp/vmec/fourier_forces/fourier_forces.h" #include +#include #include namespace vmecpp { @@ -25,6 +26,67 @@ FourierForces::FourierForces(const Sizes* s, const RadialPartitioning* r, flcc(lcc), flss(lss) {} +FourierForces::FourierForces(const FourierForces& other) + : FourierCoeffs(other), + frcc(rcc), + frss(rss), + frsc(rsc), + frcs(rcs), + fzsc(zsc), + fzcs(zcs), + fzcc(zcc), + fzss(zss), + flsc(lsc), + flcs(lcs), + flcc(lcc), + flss(lss) {} + +void FourierForces::BindSpans() { + frcc = rcc; + frss = rss; + frsc = rsc; + frcs = rcs; + fzsc = zsc; + fzcs = zcs; + fzcc = zcc; + fzss = zss; + flsc = lsc; + flcs = lcs; + flcc = lcc; + flss = lss; +} + +FourierForces& FourierForces::operator=(const FourierForces& other) { + if (this != &other) { + FourierCoeffs::operator=(other); + BindSpans(); + } + return *this; +} + +FourierForces::FourierForces(FourierForces&& other) noexcept + : FourierCoeffs(std::move(other)), + frcc(rcc), + frss(rss), + frsc(rsc), + frcs(rcs), + fzsc(zsc), + fzcs(zcs), + fzcc(zcc), + fzss(zss), + flsc(lsc), + flcs(lcs), + flcc(lcc), + flss(lss) {} + +FourierForces& FourierForces::operator=(FourierForces&& other) noexcept { + if (this != &other) { + FourierCoeffs::operator=(std::move(other)); + BindSpans(); + } + return *this; +} + void FourierForces::zeroZForceForM1() { for (int jF = nsMin_; jF < nsMax_; ++jF) { for (int n = 0; n < s_.ntor + 1; ++n) { diff --git a/src/vmecpp/cpp/vmecpp/vmec/fourier_forces/fourier_forces.h b/src/vmecpp/cpp/vmecpp/vmec/fourier_forces/fourier_forces.h index 3c5074248..12615dcec 100644 --- a/src/vmecpp/cpp/vmecpp/vmec/fourier_forces/fourier_forces.h +++ b/src/vmecpp/cpp/vmecpp/vmec/fourier_forces/fourier_forces.h @@ -15,6 +15,10 @@ namespace vmecpp { class FourierForces : public FourierCoeffs { public: FourierForces(const Sizes* s, const RadialPartitioning* r, int ns); + FourierForces(const FourierForces& other); + FourierForces& operator=(const FourierForces& other); + FourierForces(FourierForces&& other) noexcept; + FourierForces& operator=(FourierForces&& other) noexcept; void zeroZForceForM1(); void residuals(std::vector& fRes, bool includeEdgeRZ) const; @@ -34,6 +38,9 @@ class FourierForces : public FourierCoeffs { std::span flcs; std::span flcc; std::span flss; + + private: + void BindSpans(); }; } // namespace vmecpp diff --git a/src/vmecpp/cpp/vmecpp/vmec/fourier_geometry/fourier_geometry.cc b/src/vmecpp/cpp/vmecpp/vmec/fourier_geometry/fourier_geometry.cc index 5b017f257..a98a5eb1d 100644 --- a/src/vmecpp/cpp/vmecpp/vmec/fourier_geometry/fourier_geometry.cc +++ b/src/vmecpp/cpp/vmecpp/vmec/fourier_geometry/fourier_geometry.cc @@ -5,6 +5,7 @@ #include "vmecpp/vmec/fourier_geometry/fourier_geometry.h" #include +#include #include #include "vmecpp/common/util/util.h" @@ -29,6 +30,71 @@ FourierGeometry::FourierGeometry(const Sizes* s, const RadialPartitioning* r, lmncc(lcc), lmnss(lss) {} +FourierGeometry::FourierGeometry(const FourierGeometry& other) + : FourierCoeffs(other), + rmncc(rcc), + rmnss(rss), + rmnsc(rsc), + rmncs(rcs), + + zmnsc(zsc), + zmncs(zcs), + zmncc(zcc), + zmnss(zss), + + lmnsc(lsc), + lmncs(lcs), + lmncc(lcc), + lmnss(lss) {} + +void FourierGeometry::BindSpans() { + rmncc = rcc; + rmnss = rss; + rmnsc = rsc; + rmncs = rcs; + zmnsc = zsc; + zmncs = zcs; + zmncc = zcc; + zmnss = zss; + lmnsc = lsc; + lmncs = lcs; + lmncc = lcc; + lmnss = lss; +} + +FourierGeometry& FourierGeometry::operator=(const FourierGeometry& other) { + if (this != &other) { + FourierCoeffs::operator=(other); + BindSpans(); + } + return *this; +} + +FourierGeometry::FourierGeometry(FourierGeometry&& other) noexcept + : FourierCoeffs(std::move(other)), + rmncc(rcc), + rmnss(rss), + rmnsc(rsc), + rmncs(rcs), + + zmnsc(zsc), + zmncs(zcs), + zmncc(zcc), + zmnss(zss), + + lmnsc(lsc), + lmncs(lcs), + lmncc(lcc), + lmnss(lss) {} + +FourierGeometry& FourierGeometry::operator=(FourierGeometry&& other) noexcept { + if (this != &other) { + FourierCoeffs::operator=(std::move(other)); + BindSpans(); + } + return *this; +} + void FourierGeometry::interpFromBoundaryAndAxis( const FourierBasisFastPoloidal& t, const Boundaries& b, const RadialProfiles& p) { diff --git a/src/vmecpp/cpp/vmecpp/vmec/fourier_geometry/fourier_geometry.h b/src/vmecpp/cpp/vmecpp/vmec/fourier_geometry/fourier_geometry.h index d17be05b6..7e6cd3321 100644 --- a/src/vmecpp/cpp/vmecpp/vmec/fourier_geometry/fourier_geometry.h +++ b/src/vmecpp/cpp/vmecpp/vmec/fourier_geometry/fourier_geometry.h @@ -18,6 +18,10 @@ namespace vmecpp { class FourierGeometry : public FourierCoeffs { public: FourierGeometry(const Sizes *s, const RadialPartitioning *r, int ns); + FourierGeometry(const FourierGeometry &other); + FourierGeometry &operator=(const FourierGeometry &other); + FourierGeometry(FourierGeometry &&other) noexcept; + FourierGeometry &operator=(FourierGeometry &&other) noexcept; void interpFromBoundaryAndAxis(const FourierBasisFastPoloidal &t, const Boundaries &b, const RadialProfiles &p); @@ -87,6 +91,9 @@ class FourierGeometry : public FourierCoeffs { // contrib to lambda ~ sin(m * theta) * sin(n * zeta) std::span lmnss; + + private: + void BindSpans(); }; } // namespace vmecpp diff --git a/src/vmecpp/cpp/vmecpp/vmec/fourier_velocity/fourier_velocity.cc b/src/vmecpp/cpp/vmecpp/vmec/fourier_velocity/fourier_velocity.cc index 6de18c391..f3b2f4537 100644 --- a/src/vmecpp/cpp/vmecpp/vmec/fourier_velocity/fourier_velocity.cc +++ b/src/vmecpp/cpp/vmecpp/vmec/fourier_velocity/fourier_velocity.cc @@ -4,6 +4,8 @@ // SPDX-License-Identifier: MIT #include "vmecpp/vmec/fourier_velocity/fourier_velocity.h" +#include + namespace vmecpp { FourierVelocity::FourierVelocity(const Sizes* s, const RadialPartitioning* r, @@ -22,4 +24,65 @@ FourierVelocity::FourierVelocity(const Sizes* s, const RadialPartitioning* r, vlcc(lcc), vlss(lss) {} +FourierVelocity::FourierVelocity(const FourierVelocity& other) + : FourierCoeffs(other), + vrcc(rcc), + vrss(rss), + vrsc(rsc), + vrcs(rcs), + vzsc(zsc), + vzcs(zcs), + vzcc(zcc), + vzss(zss), + vlsc(lsc), + vlcs(lcs), + vlcc(lcc), + vlss(lss) {} + +void FourierVelocity::BindSpans() { + vrcc = rcc; + vrss = rss; + vrsc = rsc; + vrcs = rcs; + vzsc = zsc; + vzcs = zcs; + vzcc = zcc; + vzss = zss; + vlsc = lsc; + vlcs = lcs; + vlcc = lcc; + vlss = lss; +} + +FourierVelocity& FourierVelocity::operator=(const FourierVelocity& other) { + if (this != &other) { + FourierCoeffs::operator=(other); + BindSpans(); + } + return *this; +} + +FourierVelocity::FourierVelocity(FourierVelocity&& other) noexcept + : FourierCoeffs(std::move(other)), + vrcc(rcc), + vrss(rss), + vrsc(rsc), + vrcs(rcs), + vzsc(zsc), + vzcs(zcs), + vzcc(zcc), + vzss(zss), + vlsc(lsc), + vlcs(lcs), + vlcc(lcc), + vlss(lss) {} + +FourierVelocity& FourierVelocity::operator=(FourierVelocity&& other) noexcept { + if (this != &other) { + FourierCoeffs::operator=(std::move(other)); + BindSpans(); + } + return *this; +} + } // namespace vmecpp diff --git a/src/vmecpp/cpp/vmecpp/vmec/fourier_velocity/fourier_velocity.h b/src/vmecpp/cpp/vmecpp/vmec/fourier_velocity/fourier_velocity.h index 1b922eb6a..4d6bcd60a 100644 --- a/src/vmecpp/cpp/vmecpp/vmec/fourier_velocity/fourier_velocity.h +++ b/src/vmecpp/cpp/vmecpp/vmec/fourier_velocity/fourier_velocity.h @@ -14,6 +14,10 @@ namespace vmecpp { class FourierVelocity : public FourierCoeffs { public: FourierVelocity(const Sizes* s, const RadialPartitioning* r, int ns); + FourierVelocity(const FourierVelocity& other); + FourierVelocity& operator=(const FourierVelocity& other); + FourierVelocity(FourierVelocity&& other) noexcept; + FourierVelocity& operator=(FourierVelocity&& other) noexcept; // appropriately-named variables for the data in FourierCoeffs std::span vrcc; @@ -30,6 +34,9 @@ class FourierVelocity : public FourierCoeffs { std::span vlcs; std::span vlcc; std::span vlss; + + private: + void BindSpans(); }; } // namespace vmecpp