mirror of
https://codeberg.org/vcbferreira/NuFI_deal.ii
synced 2026-08-12 14:33:18 +02:00
started infrastructure for f0 choice
This commit is contained in:
+19
-12
@@ -1,9 +1,9 @@
|
|||||||
#ifndef FIELDS_H
|
#ifndef NUFI_FIELDS_H_
|
||||||
#define FIELDS_H
|
#define NUFI_FIELDS_H_
|
||||||
|
|
||||||
#include "grids.h"
|
#include "nufi/grids.h"
|
||||||
#include "nufi/parameters.h"
|
#include "nufi/parameters.h"
|
||||||
#include "nufi/poisson_problem.h"
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <deal.II/base/function.h>
|
#include <deal.II/base/function.h>
|
||||||
@@ -13,7 +13,6 @@
|
|||||||
using namespace dealii;
|
using namespace dealii;
|
||||||
|
|
||||||
inline std::vector<double> make_x_eval(size_t Nx) {
|
inline std::vector<double> make_x_eval(size_t Nx) {
|
||||||
|
|
||||||
std::vector<double> x_eval_E;
|
std::vector<double> x_eval_E;
|
||||||
|
|
||||||
double dx = (Parameters::X_DOMAIN_RIGHT - Parameters::X_DOMAIN_LEFT) / Nx;
|
double dx = (Parameters::X_DOMAIN_RIGHT - Parameters::X_DOMAIN_LEFT) / Nx;
|
||||||
@@ -36,20 +35,28 @@ inline void reset_x_eval(std::vector<double> &x_vals) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
inline double f0(const double x, const double v,
|
inline double f0(const double x, const double v,
|
||||||
const double eps = Parameters::EPS,
|
const size_t f0_type = Parameters::f0_TYPE) {
|
||||||
const double k = Parameters::WAVE_NR) {
|
const double eps = Parameters::EPS;
|
||||||
|
const double k = Parameters::WAVE_NR;
|
||||||
|
|
||||||
|
double result;
|
||||||
|
|
||||||
|
switch (f0_type) {
|
||||||
|
case 0:
|
||||||
|
|
||||||
const double prefactor =
|
const double prefactor =
|
||||||
Parameters::F0_FACTOR * (1.0 + eps * std::cos(k * x));
|
Parameters::F0_FACTOR * (1.0 + eps * std::cos(k * x));
|
||||||
const double gaussian = v * v * std::exp(-0.5 * v * v);
|
const double gaussian = v * v * std::exp(-0.5 * v * v);
|
||||||
|
result = prefactor * gaussian;
|
||||||
|
}
|
||||||
|
|
||||||
return prefactor * gaussian;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// wrapper for eval_point() { VectorTools::point_values() }
|
// wrapper for eval_point() { VectorTools::point_values() }
|
||||||
inline std::vector<double> eval(std::vector<double> &X,
|
inline std::vector<double> eval(std::vector<double> &X,
|
||||||
const GridStructure<1> &grid,
|
const GridStructure<1> &grid,
|
||||||
const Vector<double> &solution) noexcept {
|
const Vector<double> &solution) noexcept {
|
||||||
|
|
||||||
AssertThrow(grid.dof_handler->n_dofs() == solution.size(),
|
AssertThrow(grid.dof_handler->n_dofs() == solution.size(),
|
||||||
ExcMessage("@ eval(...) grid's number of DoFs doesn't correspond "
|
ExcMessage("@ eval(...) grid's number of DoFs doesn't correspond "
|
||||||
"to solution's size"));
|
"to solution's size"));
|
||||||
@@ -80,7 +87,7 @@ inline double integral_space_vector(const GridStructure<1> &grid,
|
|||||||
for (size_t i = 0; i < Nx; ++i)
|
for (size_t i = 0; i < Nx; ++i)
|
||||||
integral += tmp[i];
|
integral += tmp[i];
|
||||||
return integral * dx;
|
return integral * dx;
|
||||||
};
|
}
|
||||||
|
|
||||||
inline double integral_space_vector_squared(const GridStructure<1> &grid,
|
inline double integral_space_vector_squared(const GridStructure<1> &grid,
|
||||||
const Vector<double> &solution,
|
const Vector<double> &solution,
|
||||||
@@ -96,7 +103,7 @@ inline double integral_space_vector_squared(const GridStructure<1> &grid,
|
|||||||
for (size_t i = 0; i < Nx; ++i)
|
for (size_t i = 0; i < Nx; ++i)
|
||||||
integral += tmp[i] * tmp[i];
|
integral += tmp[i] * tmp[i];
|
||||||
return integral * dx;
|
return integral * dx;
|
||||||
};
|
}
|
||||||
|
|
||||||
inline std::vector<double>
|
inline std::vector<double>
|
||||||
Point_vector_to_double_vector(const std::vector<Point<1>> &Points) {
|
Point_vector_to_double_vector(const std::vector<Point<1>> &Points) {
|
||||||
@@ -108,4 +115,4 @@ Point_vector_to_double_vector(const std::vector<Point<1>> &Points) {
|
|||||||
|
|
||||||
return vector;
|
return vector;
|
||||||
}
|
}
|
||||||
#endif
|
#endif // NUFI_FIELDS_H_
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#define PARAMETERS_H
|
#define PARAMETERS_H
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <cstddef>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@@ -22,6 +23,8 @@ constexpr double V_DOMAIN_RIGHT = 10.;
|
|||||||
constexpr unsigned int NV = 128;
|
constexpr unsigned int NV = 128;
|
||||||
constexpr double DV = std::abs(V_DOMAIN_RIGHT - V_DOMAIN_LEFT) / NV;
|
constexpr double DV = std::abs(V_DOMAIN_RIGHT - V_DOMAIN_LEFT) / NV;
|
||||||
|
|
||||||
|
constexpr size_t f0_TYPE = 0; // for switch case
|
||||||
|
|
||||||
// deal.ii options
|
// deal.ii options
|
||||||
constexpr unsigned int GLOBAL_REFINEMENT = 6;
|
constexpr unsigned int GLOBAL_REFINEMENT = 6;
|
||||||
constexpr unsigned int FE_DEGREE = 3;
|
constexpr unsigned int FE_DEGREE = 3;
|
||||||
|
|||||||
Reference in New Issue
Block a user