Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>

#include "absl/algorithm/container.h"
Expand Down Expand Up @@ -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_; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
62 changes: 62 additions & 0 deletions src/vmecpp/cpp/vmecpp/vmec/fourier_forces/fourier_forces.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "vmecpp/vmec/fourier_forces/fourier_forces.h"

#include <algorithm>
#include <utility>
#include <vector>

namespace vmecpp {
Expand All @@ -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) {
Expand Down
7 changes: 7 additions & 0 deletions src/vmecpp/cpp/vmecpp/vmec/fourier_forces/fourier_forces.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<double>& fRes, bool includeEdgeRZ) const;
Expand All @@ -34,6 +38,9 @@ class FourierForces : public FourierCoeffs {
std::span<double> flcs;
std::span<double> flcc;
std::span<double> flss;

private:
void BindSpans();
};

} // namespace vmecpp
Expand Down
66 changes: 66 additions & 0 deletions src/vmecpp/cpp/vmecpp/vmec/fourier_geometry/fourier_geometry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "vmecpp/vmec/fourier_geometry/fourier_geometry.h"

#include <algorithm>
#include <utility>
#include <vector>

#include "vmecpp/common/util/util.h"
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -87,6 +91,9 @@ class FourierGeometry : public FourierCoeffs {

// contrib to lambda ~ sin(m * theta) * sin(n * zeta)
std::span<double> lmnss;

private:
void BindSpans();
};

} // namespace vmecpp
Expand Down
63 changes: 63 additions & 0 deletions src/vmecpp/cpp/vmecpp/vmec/fourier_velocity/fourier_velocity.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
// SPDX-License-Identifier: MIT
#include "vmecpp/vmec/fourier_velocity/fourier_velocity.h"

#include <utility>

namespace vmecpp {

FourierVelocity::FourierVelocity(const Sizes* s, const RadialPartitioning* r,
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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<double> vrcc;
Expand All @@ -30,6 +34,9 @@ class FourierVelocity : public FourierCoeffs {
std::span<double> vlcs;
std::span<double> vlcc;
std::span<double> vlss;

private:
void BindSpans();
};

} // namespace vmecpp
Expand Down
Loading