Minimum, messy code
This commit is contained in:
@@ -12,21 +12,34 @@
|
||||
#ifndef __WAVE_SIMULATION__
|
||||
#define __WAVE_SIMULATION__
|
||||
|
||||
#include "constants.hpp"
|
||||
#include "literals.hpp"
|
||||
|
||||
#include <armadillo>
|
||||
#include <cstdint>
|
||||
|
||||
class WaveSimulation {
|
||||
protected:
|
||||
int M;
|
||||
arma::cx_mat U;
|
||||
arma::cx_mat V;
|
||||
arma::cx_mat A;
|
||||
arma::cx_mat B;
|
||||
uint32_t M;
|
||||
arma::sp_cx_mat B;
|
||||
double h;
|
||||
double dt;
|
||||
double T;
|
||||
|
||||
public:
|
||||
virtual void solve() = 0;
|
||||
void build_A(arma::cx_vec A_vec);
|
||||
void build_B(arma::cx_vec B_vec);
|
||||
int32_t N;
|
||||
arma::cx_mat V;
|
||||
arma::cx_mat U;
|
||||
arma::sp_cx_mat A;
|
||||
WaveSimulation(double h, double dt, double T);
|
||||
virtual void solve(std::ofstream& ofile);
|
||||
void build_A();
|
||||
void build_B();
|
||||
void initialize_U(double x_c, double y_c, double sigma_x, double sigma_y,
|
||||
double p_x, double p_y);
|
||||
void write_U(std::ofstream &ofile);
|
||||
void step();
|
||||
void build_V(double thickness, double pos_x, double aperture_sparation, double aperture, uint32_t slits);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
17
include/constants.hpp
Normal file
17
include/constants.hpp
Normal file
@@ -0,0 +1,17 @@
|
||||
/** @file constants.hpp
|
||||
*
|
||||
* @author Cory Alexander Balaton (coryab)
|
||||
* @author Janita Ovidie Sandtrøen Willumsen (janitaws)
|
||||
*
|
||||
* @version 1.0
|
||||
*
|
||||
* @brief Library of constants
|
||||
*
|
||||
* @bug No known bugs
|
||||
* */
|
||||
#ifndef __CONST__
|
||||
#define __CONST__
|
||||
|
||||
#define I std::complex<double>{0., 1.}
|
||||
|
||||
#endif
|
||||
19
include/literals.hpp
Normal file
19
include/literals.hpp
Normal file
@@ -0,0 +1,19 @@
|
||||
/** @file literals.hpp
|
||||
*
|
||||
* @author Cory Alexander Balaton (coryab)
|
||||
* @author Janita Ovidie Sandtrøen Willumsen (janitaws)
|
||||
*
|
||||
* @version 1.0
|
||||
*
|
||||
* @brief Useful literals
|
||||
*
|
||||
* @bug No known bugs
|
||||
* */
|
||||
#ifndef __LITERALS__
|
||||
#define __LITERALS__
|
||||
|
||||
#include <complex>
|
||||
|
||||
std::complex<double> operator ""_i(long double magnitude);
|
||||
|
||||
#endif
|
||||
@@ -117,10 +117,10 @@ std::string dirname(const std::string &path);
|
||||
/** @brief Take 2 strings and concatenate them and make sure there is a
|
||||
* directory separator (/) between them.
|
||||
*
|
||||
* @details This function doesn't care whether or not the values given as
|
||||
* parameters are valid path strings. It is the responsibility of the user to make
|
||||
* sure that the values given are valid path strings.
|
||||
* The function only guarantees that the output string is a valid path string.
|
||||
* @details This function doesn't care whether or not the values given as
|
||||
* parameters are valid path strings. It is the responsibility of the user to
|
||||
* make sure that the values given are valid path strings. The function only
|
||||
* guarantees that the output string is a valid path string.
|
||||
*
|
||||
* @param left The left hand side of the result string
|
||||
* @param right The right hand side of the result string
|
||||
@@ -129,6 +129,8 @@ std::string dirname(const std::string &path);
|
||||
* */
|
||||
std::string concatpath(const std::string &left, const std::string &right);
|
||||
|
||||
// A function that prints the structure of a sparse matrix to screen.
|
||||
void print_sp_matrix_structure(const arma::sp_cx_mat &A);
|
||||
} // namespace utils
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user