21#ifndef S_MAGNETOSTATICS_HPP
22#define S_MAGNETOSTATICS_HPP
26#include <boost/math/constants/constants.hpp>
28#include <Eigen/Sparse>
29#include <unsupported/Eigen/SparseExtra>
66 std::ostream &
output = std::cout
86 return m_nloc_sc_H.sum();
149 const std::vector<Eigen::VectorXd> &
list_dofs
154 std::pair<Eigen::MatrixXd, Eigen::VectorXd>
155 _compute_local_contribution(
165 void _assemble_local_contribution(
167 const std::pair<Eigen::MatrixXd, Eigen::VectorXd> &
lsT,
168 std::list<Eigen::Triplet<double> > &
A1,
169 Eigen::VectorXd &
b1,
170 std::list<Eigen::Triplet<double> > &
A2,
176 std::ostream & m_output;
180 Eigen::VectorXi m_nloc_sc_H;
184 Eigen::VectorXd m_sc_b;
192 static const double PI = boost::math::constants::pi<double>();
199 constant_u = [](
const Eigen::Vector3d & x) -> Eigen::Vector3d {
200 return Eigen::Vector3d(1., 2., 3.);
205 return Eigen::Vector3d::Zero();
209 constant_f = [](
const Eigen::Vector3d & x) -> Eigen::Vector3d {
210 return Eigen::Vector3d::Zero();
219 linear_u = [](
const Eigen::Vector3d & x) -> Eigen::Vector3d {
220 return Eigen::Vector3d(
229 return Eigen::Vector3d(-3., 2., 1.);
233 linear_f = [](
const Eigen::Vector3d & x) -> Eigen::Vector3d {
234 return Eigen::Vector3d::Zero();
244 return Eigen::Vector3d(
245 cos(
PI*x(0)) * sin(
PI*x(1)) * sin(
PI*x(2)),
246 -2. * sin(
PI*x(0)) * cos(
PI*x(1)) * sin(
PI*x(2)),
247 sin(
PI*x(0)) * sin(
PI*x(1)) * cos(
PI*x(2))
253 return 3. *
PI * Eigen::Vector3d(
254 sin(
PI*x(0)) * cos(
PI*x(1)) * cos(
PI*x(2)),
256 -cos(
PI*x(0)) * cos(
PI*x(1)) * sin(
PI*x(2))
262 return 3. * std::pow(
PI, 2) * Eigen::Vector3d(
263 cos(
PI*x(0)) * sin(
PI*x(1)) * sin(
PI*x(2)),
264 -2. * sin(
PI*x(0)) * cos(
PI*x(1)) * sin(
PI*x(2)),
265 sin(
PI*x(0)) * sin(
PI*x(1)) * cos(
PI*x(2))
277 return Eigen::Vector3d(
278 cos(
PI*x(0)) * sin(
PI*x(1)) * sin(
PI*x(2)),
279 -2. * sin(
PI*x(0)) * cos(
PI*x(1)) * sin(
PI*x(2)),
280 sin(
PI*x(0)) * sin(
PI*x(1)) * cos(
PI*x(2))
286 return 3 *
PI / (1. + x(0) + x(1) + x(2))
288 sin(
PI*x(0)) * cos(
PI*x(1)) * cos(
PI*x(2)),
290 -cos(
PI*x(0)) * cos(
PI*x(1)) * sin(
PI*x(2))
296 double a = 3 *
PI / std::pow(1. + x(0) + x(1) + x(2), 2);
297 double b = 3 * std::pow(
PI, 2) / (1. + x(0) + x(1) + x(2));
299 -
b * sin(
PI*x(0)) * sin(
PI*x(1)) * cos(
PI*x(2));
301 -
b * sin(
PI*x(0)) * cos(
PI*x(1)) * sin(
PI*x(2));
304 +
b * sin(
PI*x(0)) * cos(
PI*x(1)) * sin(
PI*x(2));
307 +
b * cos(
PI*x(0)) * sin(
PI*x(1)) * sin(
PI*x(2));
309 return Eigen::Vector3d(
318 [](
const Cell & T,
const Eigen::Vector3d & x) ->
double {
return 1. + x(0) + x(1) + x(2); },
319 [](
const Cell & T) ->
size_t {
return 1; }
Construct all polynomial spaces for the DDR sequence.
Definition ddrcore.hpp:62
Discrete Serendipity Hcurl space: local operators, L2 product and global interpolator.
Definition sxcurl.hpp:21
Discrete Serendipity Hdiv space: local operators, L2 product and global interpolator.
Definition sxdiv.hpp:18
Construct all polynomial spaces for the DDR sequence.
Definition serendipity_problem.hpp:40
@ 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
size_t dimension() const
Returns the dimension of the global space (all DOFs for all geometric entities)
Definition variabledofspace.hpp:158
static const double PI
Definition ddr-magnetostatics.hpp:187
static Magnetostatics::SolutionPotentialType linear_u
Definition ddr-magnetostatics.hpp:214
static Magnetostatics::SolutionCurlType linear_sigma
Definition ddr-magnetostatics.hpp:223
static Magnetostatics::SolutionCurlType trigonometric_sigma
Definition ddr-magnetostatics.hpp:247
Eigen::SparseMatrix< double > SystemMatrixType
Definition sddr-magnetostatics.hpp:55
static Magnetostatics::PermeabilityType constant_mu
Definition ddr-magnetostatics.hpp:209
static Magnetostatics::PermeabilityType linear_mu
Definition ddr-magnetostatics.hpp:233
size_t nbSCDOFs() const
Returns the number of statically condensed DOFs (here, the cell magnetic field DOFs)
Definition ddr-magnetostatics.hpp:80
static Magnetostatics::SolutionPotentialType constant_u
Definition ddr-magnetostatics.hpp:194
static Magnetostatics::SolutionPotentialType trigonometric_u
Definition ddr-magnetostatics.hpp:238
static Magnetostatics::PermeabilityType variable_permeability_mu
Definition ddr-magnetostatics.hpp:312
static Magnetostatics::ForcingTermType constant_f
Definition ddr-magnetostatics.hpp:204
const SXCurl & sxCurl() const
Returns the space SXCurl.
Definition sddr-magnetostatics.hpp:96
size_t dimensionSpace() const
Returns the dimension of the magnetic field + potential space.
Definition ddr-magnetostatics.hpp:74
static Magnetostatics::SolutionCurlType constant_sigma
Definition ddr-magnetostatics.hpp:199
static Magnetostatics::PermeabilityType trigonometric_mu
Definition ddr-magnetostatics.hpp:265
std::function< Eigen::Vector3d(const Eigen::Vector3d &)> SolutionCurlType
Definition sddr-magnetostatics.hpp:59
IntegralWeight PermeabilityType
Definition sddr-magnetostatics.hpp:60
static Magnetostatics::SolutionCurlType variable_permeability_sigma
Definition ddr-magnetostatics.hpp:280
const SXDiv & sxDiv() const
Returns the space SXDiv.
Definition sddr-magnetostatics.hpp:102
std::function< Eigen::Vector3d(const Eigen::Vector3d &)> SolutionPotentialType
Definition sddr-magnetostatics.hpp:58
std::function< Eigen::Vector3d(const Eigen::Vector3d &)> ForcingTermType
Definition sddr-magnetostatics.hpp:57
static Magnetostatics::SolutionPotentialType variable_permeability_u
Definition ddr-magnetostatics.hpp:271
static Magnetostatics::ForcingTermType trigonometric_f
Definition ddr-magnetostatics.hpp:256
static Magnetostatics::ForcingTermType linear_f
Definition ddr-magnetostatics.hpp:228
static Magnetostatics::ForcingTermType variable_permeability_f
Definition ddr-magnetostatics.hpp:290
bool use_threads
Definition HHO_DiffAdvecReac.hpp:47
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
Eigen::VectorXd & scVector()
Returns the static condensation rhs.
Definition sddr-magnetostatics.hpp:143
double & stabilizationParameter()
Returns the stabilization parameter.
Definition sddr-magnetostatics.hpp:133
const double & stabilizationParameter() const
Returns the stabilization parameter.
Definition sddr-magnetostatics.hpp:128
SystemMatrixType & systemMatrix()
Returns the linear system matrix.
Definition sddr-magnetostatics.hpp:113
size_t nbSCDOFs() const
Returns the number of statically condensed DOFs (here, the cell magnetic field DOFs)
Definition sddr-magnetostatics.hpp:84
const SystemMatrixType & systemMatrix() const
Returns the linear system matrix.
Definition sddr-magnetostatics.hpp:108
size_t dimensionSpace() const
Returns the dimension of the magnetic field + potential space.
Definition sddr-magnetostatics.hpp:78
Magnetostatics(const DDRCore &ddrcore, bool use_threads, std::ostream &output=std::cout)
Constructor.
std::vector< double > computeNorms(const std::vector< Eigen::VectorXd > &list_dofs) const
Compute the discrete Hcurl \times Hdiv norm of a family of vectors representing the dofs.
size_t sizeSystem() const
Returns the size of the statically condensed system.
Definition sddr-magnetostatics.hpp:90
const Eigen::VectorXd & systemVector() const
Returns the linear system right-hand side vector.
Definition sddr-magnetostatics.hpp:118
Eigen::VectorXd & systemVector()
Returns the linear system right-hand side vector.
Definition sddr-magnetostatics.hpp:123
void assembleLinearSystem(const ForcingTermType &f, const PermeabilityType &mu, const SolutionPotentialType &u)
Assemble the global system
const SystemMatrixType & scMatrix() const
Returns the static condensation recovery operator.
Definition sddr-magnetostatics.hpp:138