mirror of
https://codeberg.org/vcbferreira/NuFI_deal.ii
synced 2026-08-12 14:33:18 +02:00
field history added
This commit is contained in:
+4
-71
@@ -2,7 +2,7 @@
|
||||
#define FIELDS_H
|
||||
|
||||
#include "nufi/parameters.h"
|
||||
#include "poisson_problem.h"
|
||||
#include "nufi/poisson_problem.h"
|
||||
#include <cmath>
|
||||
#include <deal.II/base/function.h>
|
||||
#include <deal.II/base/point.h>
|
||||
@@ -68,27 +68,14 @@ inline double f0(const double x, const double v,
|
||||
return prefactor * gaussian;
|
||||
}
|
||||
|
||||
inline double compute_rho(const double x,
|
||||
const unsigned int Nv = Parameters::NV) {
|
||||
const double dv =
|
||||
(Parameters::V_DOMAIN_RIGHT - Parameters::V_DOMAIN_LEFT) / Nv;
|
||||
|
||||
double integral = 0.0;
|
||||
|
||||
for (unsigned int i = 0; i < Nv; ++i) {
|
||||
const double v = Parameters::V_DOMAIN_LEFT + (i + 0.5) * dv;
|
||||
integral += f0(x, v) * dv;
|
||||
}
|
||||
|
||||
return 1.0 - integral;
|
||||
}
|
||||
|
||||
// wrapper for eval_point() { VectorTools::point_values() }
|
||||
inline double eval(double x, const PoissonProblem<1> &poisson,
|
||||
const Vector<double> &solution) noexcept {
|
||||
|
||||
x -= Parameters::X_DOMAIN_LEFT;
|
||||
|
||||
x = x - Parameters::LX * std::floor(x * Parameters::LX_INV);
|
||||
x = x - Parameters::LX * std::floor(x * Parameters::LX_INV); // in domain
|
||||
|
||||
return eval_point<1>(poisson.get_mapping(), poisson.get_dof_handler(),
|
||||
solution, Point<1>(x));
|
||||
}
|
||||
@@ -122,58 +109,4 @@ inline double integral_space_vector_squared(const PoissonProblem<1> &poisson,
|
||||
return integral * dx;
|
||||
};
|
||||
|
||||
// class Gradient {
|
||||
// public:
|
||||
// Gradient(double xmin, double xmax, unsigned int Nx)
|
||||
// : xmin_(xmin), xmax_(xmax), Nx_(Nx) {
|
||||
// if (xmax_ <= xmin_) {
|
||||
// throw std::invalid_argument("xmax must be greater than xmin");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// std::vector<double> compute(const std::vector<double> &values) const {
|
||||
// size_t n = values.size();
|
||||
// if (n < 2) {
|
||||
// throw std::invalid_argument("Need at least 2 points");
|
||||
// }
|
||||
//
|
||||
// std::vector<double> grad(n);
|
||||
//
|
||||
// double dx = (xmax_ - xmin_) / (n - 1);
|
||||
// // periodic boundaries
|
||||
// grad[0] = -(values[1] - values[n - 1]) / (2.0 * dx);
|
||||
// grad[n - 1] = -(values[0] - values[n - 2]) / (2.0 * dx);
|
||||
//
|
||||
// for (size_t i = 1; i < n - 1; ++i) {
|
||||
// grad[i] = -(values[i + 1] - values[i - 1]) / (2.0 * dx);
|
||||
// }
|
||||
//
|
||||
// return grad;
|
||||
// }
|
||||
//
|
||||
// private:
|
||||
// double xmin_;
|
||||
// double xmax_;
|
||||
// [[maybe_unused]] unsigned int Nx_;
|
||||
// };
|
||||
|
||||
template <int dim>
|
||||
class ChargeDensity : public Function<dim> // only uses f0
|
||||
{
|
||||
public:
|
||||
ChargeDensity(double eps, double k, unsigned int Nv)
|
||||
: Function<dim>(1), eps(eps), k(k), Nv(Nv) {}
|
||||
|
||||
virtual double
|
||||
value(const Point<dim> &p,
|
||||
[[maybe_unused]] const unsigned int component = 0) const override {
|
||||
return compute_rho(p[0], Nv);
|
||||
}
|
||||
|
||||
private:
|
||||
const double eps;
|
||||
const double k;
|
||||
const unsigned int Nv;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user