Skip to content

File fdvecarray.hpp

File List > include > multigrid > fdvecarray.hpp

Go to the documentation of this file

#pragma once

#include "multigrid/fdarray.hpp"
#include "multigrid/field.hpp"
#include <cmath>

namespace mgrid {

struct FDVecArray : FDBase {
    FDArray first;
    FDArray second;

    FDVecArray() = default;

    FDVecArray(double aspect, int nx, int nz);

    void resize(double aspect, int nx, int nz);

    [[nodiscard]] int rows() const { return first.rows(); }
    [[nodiscard]] int cols() const { return first.cols(); }

    void write(std::string filestring);

    void magnitude(Field2D &out) const;

    void divergence(Field2D &out) const;

    FDVecArray &operator+=(const FDVecArray &o) {
        first += o.first;
        second += o.second;
        return *this;
    }

    FDVecArray &operator-=(const FDVecArray &o) {
        first -= o.first;
        second -= o.second;
        return *this;
    }
};

[[nodiscard]] Field2D dot(const FDVecArray &a, const FDVecArray &b);

} // namespace mgrid