11#include <boost/math/constants/constants.hpp>
13#include <Eigen/Sparse>
14#include <unsupported/Eigen/SparseExtra>
67 typedef std::function<Eigen::Vector3d(
const Eigen::Vector3d &)>
VelocityType;
68 typedef std::function<Eigen::Vector3d(
const Eigen::Vector3d &)>
VorticityType;
77 std::ostream &
output = std::cout
110 return m_vemcore.
mesh().
n_cells() * (m_nloc_sc_u + m_nloc_sc_p);
178 const std::vector<Eigen::VectorXd> &
list_dofs
183 const Eigen::VectorXd &
v,
193 std::pair<Eigen::MatrixXd, Eigen::VectorXd>
194 _compute_local_contribution(
204 void _assemble_local_contribution(
206 const std::pair<Eigen::MatrixXd, Eigen::VectorXd> &
lsT,
207 std::list<Eigen::Triplet<double> > &
A1,
208 Eigen::VectorXd &
b1,
209 std::list<Eigen::Triplet<double> > &
A2,
215 std::ostream & m_output;
219 const size_t m_nloc_sc_u;
220 const size_t m_nloc_sc_p;
224 Eigen::VectorXd m_sc_b;
232 static const double PI = boost::math::constants::pi<double>();
244 return Eigen::Vector3d(
245 0.5 * sin(2. *
PI * x(0)) * cos(2. *
PI * x(1)) * cos(2. *
PI * x(2)),
246 0.5 * cos(2. *
PI * x(0)) * sin(2. *
PI * x(1)) * cos(2. *
PI * x(2)),
247 -cos(2. *
PI * x(0)) * cos(2. *
PI * x(1)) * sin(2. *
PI * x(2))
253 return 3. *
PI * Eigen::Vector3d(
254 cos(2. *
PI * x(0)) * sin(2. *
PI * x(1)) * sin(2. *
PI * x(2)),
255 -sin(2. *
PI * x(0)) * cos(2. *
PI * x(1)) * sin(2. *
PI * x(2)),
268 cos(2. *
PI * x(0)) * sin(2. *
PI * x(1)) * sin(2. *
PI * x(2)),
269 sin(2. *
PI * x(0)) * cos(2. *
PI * x(1)) * sin(2. *
PI * x(2)),
270 sin(2. *
PI * x(0)) * sin(2. *
PI * x(1)) * cos(2. *
PI * x(2))
276 return 6. * std::pow(
PI, 2) * Eigen::Vector3d(
277 sin(2. *
PI * x(0)) * cos(2. *
PI * x(1)) * cos(2. *
PI * x(2)),
278 cos(2. *
PI * x(0)) * sin(2. *
PI * x(1)) * cos(2. *
PI * x(2)),
279 -2. * cos(2. *
PI * x(0)) * cos(2. *
PI * x(1)) * sin(2. *
PI * x(2))
286 return 36. * std::pow(
PI, 3) * Eigen::Vector3d(
287 cos(2. *
PI * x(0)) * sin(2. *
PI * x(1)) * sin(2. *
PI * x(2)),
288 -sin(2. *
PI * x(0)) * cos(2. *
PI * x(1)) * sin(2. *
PI * x(2)),
301 linear_u = [](
const Eigen::Vector3d & x) -> Eigen::Vector3d {
302 return Eigen::Vector3d(x(0), -x(1), 0.);
307 return Eigen::Vector3d::Zero();
311 linear_p = [](
const Eigen::Vector3d & x) ->
double {
321 linear_f = [](
const Eigen::Vector3d & x) -> Eigen::Vector3d {
327 return Eigen::Vector3d::Zero();
342 field_u = [](
const Eigen::Vector3d & x) -> Eigen::Vector3d {
343 double ux =
PI*cos(
PI*x(1))*pow(sin(
PI*x(0)),3.0)*pow(sin(
PI*x(1)),2.0)*pow(sin(
PI*x(2)),3.0)*3.0;
344 double uy =
PI*cos(
PI*x(0))*pow(sin(
PI*x(0)),2.0)*pow(sin(
PI*x(1)),3.0)*pow(sin(
PI*x(2)),3.0)*(-3.0);
345 return Eigen::Vector3d(
ux,
uy, 0.);
350 double cux = (
PI*
PI)*cos(
PI*x(0))*cos(
PI*x(2))*pow(sin(
PI*x(0)),2.0)*pow(sin(
PI*x(1)),3.0)*pow(sin(
PI*x(2)),2.0)*9.0;
351 double cuy = (
PI*
PI)*cos(
PI*x(1))*cos(
PI*x(2))*pow(sin(
PI*x(0)),3.0)*pow(sin(
PI*x(1)),2.0)*pow(sin(
PI*x(2)),2.0)*9.0;
352 double cuz = (
PI*
PI)*pow(sin(
PI*x(0)),3.0)*pow(sin(
PI*x(1)),3.0)*pow(sin(
PI*x(2)),3.0)*6.0-(
PI*
PI)*pow(cos(
PI*x(0)),2.0)*sin(
PI*x(0))*pow(sin(
PI*x(1)),3.0)*pow(sin(
PI*x(2)),3.0)*6.0-(
PI*
PI)*pow(cos(
PI*x(1)),2.0)*pow(sin(
PI*x(0)),3.0)*sin(
PI*x(1))*pow(sin(
PI*x(2)),3.0)*6.0;
358 field_p = [](
const Eigen::Vector3d & x) ->
double {
364 return Eigen::Vector3d(0., 0., 0.);
368 field_f = [](
const Eigen::Vector3d & x) -> Eigen::Vector3d {
369 double fx = (
PI*
PI*
PI)*pow(cos(
PI*x(1)),3.0)*pow(sin(
PI*x(0)),3.0)*pow(sin(
PI*x(2)),3.0)*-6.0+(
PI*
PI*
PI)*cos(
PI*x(1))*pow(sin(
PI*x(0)),3.0)*pow(sin(
PI*x(1)),2.0)*pow(sin(
PI*x(2)),3.0)*3.9E+1-(
PI*
PI*
PI)*pow(cos(
PI*x(0)),2.0)*cos(
PI*x(1))*sin(
PI*x(0))*pow(sin(
PI*x(1)),2.0)*pow(sin(
PI*x(2)),3.0)*1.8E+1-(
PI*
PI*
PI)*cos(
PI*x(1))*pow(cos(
PI*x(2)),2.0)*pow(sin(
PI*x(0)),3.0)*pow(sin(
PI*x(1)),2.0)*sin(
PI*x(2))*1.8E+1;
371 double fy = (
PI*
PI*
PI)*pow(cos(
PI*x(0)),3.0)*pow(sin(
PI*x(1)),3.0)*pow(sin(
PI*x(2)),3.0)*6.0-(
PI*
PI*
PI)*cos(
PI*x(0))*pow(sin(
PI*x(0)),2.0)*pow(sin(
PI*x(1)),3.0)*pow(sin(
PI*x(2)),3.0)*3.9E+1+(
PI*
PI*
PI)*cos(
PI*x(0))*pow(cos(
PI*x(1)),2.0)*pow(sin(
PI*x(0)),2.0)*sin(
PI*x(1))*pow(sin(
PI*x(2)),3.0)*1.8E+1+(
PI*
PI*
PI)*cos(
PI*x(0))*pow(cos(
PI*x(2)),2.0)*pow(sin(
PI*x(0)),2.0)*pow(sin(
PI*x(1)),3.0)*sin(
PI*x(2))*1.8E+1;
374 return Eigen::Vector3d(
fx,
fy,
fz);
379 double curl_fx = (
PI*
PI*
PI*
PI)*cos(
PI*x(0))*pow(cos(
PI*x(2)),3.0)*pow(sin(
PI*x(0)),2.0)*pow(sin(
PI*x(1)),3.0)*-1.8E+1-(
PI*
PI*
PI*
PI)*pow(cos(
PI*x(0)),3.0)*cos(
PI*x(2))*pow(sin(
PI*x(1)),3.0)*pow(sin(
PI*x(2)),2.0)*1.8E+1+(
PI*
PI*
PI*
PI)*cos(
PI*x(0))*cos(
PI*x(2))*pow(sin(
PI*x(0)),2.0)*pow(sin(
PI*x(1)),3.0)*pow(sin(
PI*x(2)),2.0)*1.53E+2-(
PI*
PI*
PI*
PI)*cos(
PI*x(0))*pow(cos(
PI*x(1)),2.0)*cos(
PI*x(2))*pow(sin(
PI*x(0)),2.0)*sin(
PI*x(1))*pow(sin(
PI*x(2)),2.0)*5.4E+1;
382 double curl_fy = (
PI*
PI*
PI*
PI)*cos(
PI*x(1))*pow(cos(
PI*x(2)),3.0)*pow(sin(
PI*x(0)),3.0)*pow(sin(
PI*x(1)),2.0)*-1.8E+1-(
PI*
PI*
PI*
PI)*pow(cos(
PI*x(1)),3.0)*cos(
PI*x(2))*pow(sin(
PI*x(0)),3.0)*pow(sin(
PI*x(2)),2.0)*1.8E+1+(
PI*
PI*
PI*
PI)*cos(
PI*x(1))*cos(
PI*x(2))*pow(sin(
PI*x(0)),3.0)*pow(sin(
PI*x(1)),2.0)*pow(sin(
PI*x(2)),2.0)*1.53E+2-(
PI*
PI*
PI*
PI)*pow(cos(
PI*x(0)),2.0)*cos(
PI*x(1))*cos(
PI*x(2))*sin(
PI*x(0))*pow(sin(
PI*x(1)),2.0)*pow(sin(
PI*x(2)),2.0)*5.4E+1;
385 double curl_fz = (
PI*
PI*
PI*
PI)*pow(sin(
PI*x(0)),3.0)*pow(sin(
PI*x(1)),3.0)*pow(sin(
PI*x(2)),3.0)*7.8E+1-(
PI*
PI*
PI*
PI)*pow(cos(
PI*x(0)),2.0)*sin(
PI*x(0))*pow(sin(
PI*x(1)),3.0)*pow(sin(
PI*x(2)),3.0)*1.14E+2-(
PI*
PI*
PI*
PI)*pow(cos(
PI*x(1)),2.0)*pow(sin(
PI*x(0)),3.0)*sin(
PI*x(1))*pow(sin(
PI*x(2)),3.0)*1.14E+2-(
PI*
PI*
PI*
PI)*pow(cos(
PI*x(2)),2.0)*pow(sin(
PI*x(0)),3.0)*pow(sin(
PI*x(1)),3.0)*sin(
PI*x(2))*3.6E+1+(
PI*
PI*
PI*
PI)*pow(cos(
PI*x(0)),2.0)*pow(cos(
PI*x(1)),2.0)*sin(
PI*x(0))*sin(
PI*x(1))*pow(sin(
PI*x(2)),3.0)*7.2E+1+(
PI*
PI*
PI*
PI)*pow(cos(
PI*x(0)),2.0)*pow(cos(
PI*x(2)),2.0)*sin(
PI*x(0))*pow(sin(
PI*x(1)),3.0)*sin(
PI*x(2))*3.6E+1+(
PI*
PI*
PI*
PI)*pow(cos(
PI*x(1)),2.0)*pow(cos(
PI*x(2)),2.0)*pow(sin(
PI*x(0)),3.0)*sin(
PI*x(1))*sin(
PI*x(2))*3.6E+1;
Virtual Hcurl space: local operators, L2 product and global interpolator.
Definition vcurl.hpp:28
Virtual Hdiv space: local operators, L2 product and global interpolator.
Definition vdiv.hpp:26
Construct all polynomial spaces for the VEM sequence.
Definition vemcore.hpp:39
Virtual H1 space: local operators, L2 product and global interpolator.
Definition vgrad.hpp:27
@ Matrix
Definition basis.hpp:67
size_t dimension() const
Returns the dimension of the global space (all DOFs for all geometric entities)
Definition localdofspace.hpp:80
static const double PI
Definition ddr-magnetostatics.hpp:187
static Magnetostatics::SolutionPotentialType linear_u
Definition ddr-magnetostatics.hpp:214
static Magnetostatics::SolutionPotentialType trigonometric_u
Definition ddr-magnetostatics.hpp:238
static Magnetostatics::ForcingTermType trigonometric_f
Definition ddr-magnetostatics.hpp:256
static Magnetostatics::ForcingTermType linear_f
Definition ddr-magnetostatics.hpp:228
static NavierStokes::PressureType linear_p
Definition sddr-navier-stokes.hpp:577
static NavierStokes::PressureGradientType linear_grad_p
Definition sddr-navier-stokes.hpp:582
static NavierStokes::VorticityType trigonometric_curl_u
Definition sddr-navier-stokes.hpp:482
static NavierStokes::PressureGradientType trigonometric_grad_p
Definition sddr-navier-stokes.hpp:496
static NavierStokes::PressureType trigonometric_p
Definition sddr-navier-stokes.hpp:491
static NavierStokes::VorticityType linear_curl_u
Definition sddr-navier-stokes.hpp:567
double pressure_scaling
Definition sddr-navier-stokes.hpp:464
double grad_p
Norm of grad of pressure.
Definition sddr-navier-stokes.hpp:81
static Stokes::ForcingTermType field_f
Definition ddr-stokes.hpp:365
void assembleLinearSystem(const ForcingTermType &f, const VelocityType &u, const VorticityType &omega, const ViscosityType &nu)
Assemble the global system
Definition ddr-stokes.cpp:298
static Stokes::ViscosityType field_nu
Definition ddr-stokes.hpp:375
static Stokes::ViscosityType trigonometric_nu
Definition ddr-stokes.hpp:296
Eigen::SparseMatrix< double > SystemMatrixType
Definition ddr-stokes.hpp:69
double hgrad_p
Hgrad norm of p.
Definition sddr-navier-stokes.hpp:83
static Stokes::VelocityType field_u
Definition ddr-stokes.hpp:339
static Stokes::PressureGradientType field_grad_p
Definition ddr-stokes.hpp:360
double hcurl_u
Hcurl norm of u.
Definition sddr-navier-stokes.hpp:82
static Stokes::ViscosityType linear_nu
Definition ddr-stokes.hpp:328
std::function< Eigen::Vector3d(const Eigen::Vector3d &)> VelocityType
Definition ddr-stokes.hpp:72
size_t nbSCDOFs() const
Returns the number of statically condensed DOFs (both velocity and pressure)
Definition ddr-stokes.hpp:112
std::function< Eigen::Vector3d(const Eigen::Vector3d &)> PressureGradientType
Definition ddr-stokes.hpp:75
std::function< Eigen::Vector3d(const Eigen::Vector3d &)> VorticityType
Definition ddr-stokes.hpp:73
double u
Norm of velocity.
Definition sddr-navier-stokes.hpp:78
std::function< double(const Eigen::Vector3d &)> PressureType
Definition ddr-stokes.hpp:74
size_t dimension() const
Returns the global problem dimension (without Lagrange multiplier, just velocity & pressure)
Definition ddr-stokes.hpp:94
IntegralWeight ViscosityType
Definition ddr-stokes.hpp:76
double p
Norm of pressure.
Definition sddr-navier-stokes.hpp:80
static Stokes::VorticityType field_curl_u
Definition ddr-stokes.hpp:346
std::function< Eigen::Vector3d(const Eigen::Vector3d &)> ForcingTermType
Definition ddr-stokes.hpp:71
double curl_u
Norm of curl of velocity (vorticity)
Definition sddr-navier-stokes.hpp:79
static Stokes::PressureType field_p
Definition ddr-stokes.hpp:355
bool use_threads
Definition HHO_DiffAdvecReac.hpp:47
std::size_t n_cells() const
number of cells in the mesh.
Definition MeshND.hpp:60
const Mesh & mesh() const
Return a const reference to the mesh.
Definition vemcore.hpp:117
double & stabilizationParameter()
Returns the stabilization parameter.
Definition vem-stokes.hpp:172
size_t nbSCDOFs_u() const
Returns the number of statically condensed DOFs (velocity)
Definition vem-stokes.hpp:96
const VCurl & vCurl() const
Returns the space VCurl.
Definition vem-stokes.hpp:125
Eigen::SparseMatrix< double > SystemMatrixType
Definition vem-stokes.hpp:64
size_t nbSCDOFs_p() const
Returns the number of statically condensed DOFs (pressure)
Definition vem-stokes.hpp:102
const double & stabilizationParameter() const
Returns the stabilization parameter.
Definition vem-stokes.hpp:167
static Stokes::ForcingTermType linear_curl_f
Definition vem-stokes.hpp:326
const SystemMatrixType & systemMatrix() const
Returns the linear system matrix.
Definition vem-stokes.hpp:137
static Stokes::ForcingTermType field_curl_f
Definition vem-stokes.hpp:378
std::function< Eigen::Vector3d(const Eigen::Vector3d &)> VelocityType
Definition vem-stokes.hpp:67
std::vector< StokesNorms > computeStokesNorms(const std::vector< Eigen::VectorXd > &list_dofs) const
Compute the discrete L2 norms, for a family of Eigen::VectorXd representing velocities & pressures,...
size_t nbSCDOFs() const
Returns the number of statically condensed DOFs (both velocity and pressure)
Definition vem-stokes.hpp:108
size_t sizeSystem() const
Returns the size of the statically condensed system (with Lagrange multiplier)
Definition vem-stokes.hpp:114
std::function< Eigen::Vector3d(const Eigen::Vector3d &)> PressureGradientType
Definition vem-stokes.hpp:70
Eigen::VectorXd & scVector()
Returns the static condensation rhs.
Definition vem-stokes.hpp:162
std::function< Eigen::Vector3d(const Eigen::Vector3d &)> VorticityType
Definition vem-stokes.hpp:68
const VGrad & vGrad() const
Returns the space VGrad.
Definition vem-stokes.hpp:119
std::function< double(const Eigen::Vector3d &)> PressureType
Definition vem-stokes.hpp:69
Eigen::VectorXd & systemVector()
Returns the linear system right-hand side vector.
Definition vem-stokes.hpp:152
size_t dimension() const
Returns the global problem dimension (without Lagrange multiplier, just velocity & pressure)
Definition vem-stokes.hpp:90
IntegralWeight ViscosityType
Definition vem-stokes.hpp:71
const VDiv & vDiv() const
Returns the space VDiv.
Definition vem-stokes.hpp:131
StokesNorms(double norm_u, double norm_curl_u, double norm_p, double norm_grad_p)
Constructor.
Definition vem-stokes.hpp:41
const SystemMatrixType & scMatrix() const
Returns the static condensation recovery operator.
Definition vem-stokes.hpp:157
static Stokes::ForcingTermType trigonometric_curl_f
Definition vem-stokes.hpp:285
std::pair< StokesNorms, StokesNorms > computeContinuousErrorsNorms(const Eigen::VectorXd &v, const VelocityType &u, const VorticityType &curl_u, const PressureType &p, const PressureGradientType &grad_p) const
Compute the continuous Hcurl errors in u and Hgrad error in p (1st component), and same with continuo...
const Eigen::VectorXd & systemVector() const
Returns the linear system right-hand side vector.
Definition vem-stokes.hpp:147
std::function< Eigen::Vector3d(const Eigen::Vector3d &)> ForcingTermType
Definition vem-stokes.hpp:66
SystemMatrixType & systemMatrix()
Returns the linear system matrix.
Definition vem-stokes.hpp:142
Definition ddr-magnetostatics.hpp:41
Structure for weights (scalar, at the moment) in integral.
Definition integralweight.hpp:36
Structure to store information for, and perform, local static condensation.
Definition local_static_condensation.hpp:25
Assemble a Stokes problem.
Definition ddr-stokes.hpp:68