Commit 0490a8f4 authored by Erik Strand's avatar Erik Strand

Work on error assessment

parent ac063d4e
#include "glut_grapher.h"
#include <iostream>
#include <iomanip>
#include <thread>
namespace simucene {
//--------------------------------------------------------------------------------------------------
template <typename T>
void print_vector(VectorX<T> const& vec) {
std::cout << std::fixed << std::setprecision(3);
for (uint32_t i = 0; i < vec.size() - 1; ++i) {
std::cout << std::setw(5) << vec[i] << ", ";
}
std::cout << vec[vec.size() - 1] << '\n';
}
//..................................................................................................
void GlutGrapher::initialize(
VectorX<Scalar>&& state,
......
#include "matrix_builder.h"
#include "glut_grapher.h"
#include <iostream>
using namespace simucene;
......@@ -44,10 +43,10 @@ Scalar normal_pdf(Scalar x, Scalar mean, Scalar std_dev)
int main(int, char**) {
// primary parameters of the simulation
Scalar const max_x = 1;
int32_t const dim = 1000;
Scalar const h = 1e-8;
Scalar const advection_coefficient = -1e3;
Scalar const diffusion_coefficient = 1e1;
int32_t const dim = 100;
Scalar const h = 1e-3;
Scalar const advection_coefficient = 1;
Scalar const diffusion_coefficient = 0;
VectorX<Scalar> reaction_coefficients = VectorX<Scalar>::Zero(dim);
// derived quantities
......@@ -84,12 +83,13 @@ int main(int, char**) {
// iterate
/*
for (uint32_t i = 0; i < 100; ++i) {
uint32_t n_iterations = 100;
for (uint32_t i = 0; i < n_iterations; ++i) {
std::cout << i << ": ";
print_vector(state);
state += transport_matrix * state;
}
std::cout << 100 << ": ";
std::cout << n_iterations << ": ";
print_vector(state);
*/
......
......@@ -3,6 +3,8 @@
#include <Eigen/Core>
#include <Eigen/Sparse>
#include <iostream>
#include <iomanip>
namespace simucene {
......@@ -38,6 +40,16 @@ using MatrixX = Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>;
template <typename T>
using SparseMatrix = Eigen::SparseMatrix<T>;
//--------------------------------------------------------------------------------------------------
template <typename T>
void print_vector(VectorX<T> const& vec) {
std::cout << std::fixed << std::setprecision(3);
for (uint32_t i = 0; i < vec.size() - 1; ++i) {
std::cout << std::setw(5) << vec[i] << ", ";
}
std::cout << vec[vec.size() - 1] << '\n';
}
}
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment