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>
65 std::ostream & output = std::cout
85 return m_nloc_sc_H.sum();
148 const std::vector<Eigen::VectorXd> & list_dofs
153 std::pair<Eigen::MatrixXd, Eigen::VectorXd>
154 _compute_local_contribution(
164 void _assemble_local_contribution(
166 const std::pair<Eigen::MatrixXd, Eigen::VectorXd> & lsT,
167 std::list<Eigen::Triplet<double> > & A1,
168 Eigen::VectorXd & b1,
169 std::list<Eigen::Triplet<double> > & A2,
175 std::ostream & m_output;
179 Eigen::VectorXd m_nloc_sc_H;
183 Eigen::VectorXd m_sc_b;
191 static const double PI = boost::math::constants::pi<double>();
198 constant_u = [](
const Eigen::Vector3d & x) -> Eigen::Vector3d {
199 return Eigen::Vector3d(1., 2., 3.);
204 return Eigen::Vector3d::Zero();
208 constant_f = [](
const Eigen::Vector3d & x) -> Eigen::Vector3d {
209 return Eigen::Vector3d::Zero();
218 linear_u = [](
const Eigen::Vector3d & x) -> Eigen::Vector3d {
219 return Eigen::Vector3d(
228 return Eigen::Vector3d(-3., 2., 1.);
232 linear_f = [](
const Eigen::Vector3d & x) -> Eigen::Vector3d {
233 return Eigen::Vector3d::Zero();
243 return Eigen::Vector3d(
244 cos(
PI*x(0)) * sin(
PI*x(1)) * sin(
PI*x(2)),
245 -2. * sin(
PI*x(0)) * cos(
PI*x(1)) * sin(
PI*x(2)),
246 sin(
PI*x(0)) * sin(
PI*x(1)) * cos(
PI*x(2))
252 return 3. *
PI * Eigen::Vector3d(
253 sin(
PI*x(0)) * cos(
PI*x(1)) * cos(
PI*x(2)),
255 -cos(
PI*x(0)) * cos(
PI*x(1)) * sin(
PI*x(2))
261 return 3. * std::pow(
PI, 2) * Eigen::Vector3d(
262 cos(
PI*x(0)) * sin(
PI*x(1)) * sin(
PI*x(2)),
263 -2. * sin(
PI*x(0)) * cos(
PI*x(1)) * sin(
PI*x(2)),
264 sin(
PI*x(0)) * sin(
PI*x(1)) * cos(
PI*x(2))
276 return Eigen::Vector3d(
277 cos(
PI*x(0)) * sin(
PI*x(1)) * sin(
PI*x(2)),
278 -2. * sin(
PI*x(0)) * cos(
PI*x(1)) * sin(
PI*x(2)),
279 sin(
PI*x(0)) * sin(
PI*x(1)) * cos(
PI*x(2))
285 return 3 *
PI / (1. + x(0) + x(1) + x(2))
287 sin(
PI*x(0)) * cos(
PI*x(1)) * cos(
PI*x(2)),
289 -cos(
PI*x(0)) * cos(
PI*x(1)) * sin(
PI*x(2))
295 double a = 3 *
PI / std::pow(1. + x(0) + x(1) + x(2), 2);
296 double b = 3 * std::pow(
PI, 2) / (1. + x(0) + x(1) + x(2));
297 double dy_sigmax = -a * sin(
PI*x(0)) * cos(
PI*x(1)) * cos(
PI*x(2))
298 - b * sin(
PI*x(0)) * sin(
PI*x(1)) * cos(
PI*x(2));
299 double dz_sigmax = -a * sin(
PI*x(0)) * cos(
PI*x(1)) * cos(
PI*x(2))
300 - b * sin(
PI*x(0)) * cos(
PI*x(1)) * sin(
PI*x(2));
302 double dx_sigmaz = a * cos(
PI*x(0)) * cos(
PI*x(1)) * sin(
PI*x(2))
303 + b * sin(
PI*x(0)) * cos(
PI*x(1)) * sin(
PI*x(2));
305 double dy_sigmaz = a * cos(
PI*x(0)) * cos(
PI*x(1)) * sin(
PI*x(2))
306 + b * cos(
PI*x(0)) * sin(
PI*x(1)) * sin(
PI*x(2));
308 return Eigen::Vector3d(
310 dz_sigmax - dx_sigmaz,
317 [](
const Cell & T,
const Eigen::Vector3d & x) ->
double {
return 1. + x(0) + x(1) + x(2); },
318 [](
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
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:186
static Magnetostatics::SolutionPotentialType linear_u
Definition: ddr-magnetostatics.hpp:213
static Magnetostatics::SolutionCurlType linear_sigma
Definition: ddr-magnetostatics.hpp:222
static Magnetostatics::SolutionCurlType trigonometric_sigma
Definition: ddr-magnetostatics.hpp:246
Eigen::SparseMatrix< double > SystemMatrixType
Definition: sddr-magnetostatics.hpp:54
const SXCurl & sxCurl() const
Returns the space SXCurl.
Definition: sddr-magnetostatics.hpp:95
static Magnetostatics::PermeabilityType constant_mu
Definition: ddr-magnetostatics.hpp:208
static Magnetostatics::PermeabilityType linear_mu
Definition: ddr-magnetostatics.hpp:232
size_t nbSCDOFs() const
Returns the number of statically condensed DOFs (here, the cell magnetic field DOFs)
Definition: ddr-magnetostatics.hpp:79
static Magnetostatics::SolutionPotentialType constant_u
Definition: ddr-magnetostatics.hpp:193
static Magnetostatics::SolutionPotentialType trigonometric_u
Definition: ddr-magnetostatics.hpp:237
static Magnetostatics::PermeabilityType variable_permeability_mu
Definition: ddr-magnetostatics.hpp:311
static Magnetostatics::ForcingTermType constant_f
Definition: ddr-magnetostatics.hpp:203
size_t dimensionSpace() const
Returns the dimension of the magnetic field + potential space.
Definition: ddr-magnetostatics.hpp:73
static Magnetostatics::SolutionCurlType constant_sigma
Definition: ddr-magnetostatics.hpp:198
static Magnetostatics::PermeabilityType trigonometric_mu
Definition: ddr-magnetostatics.hpp:264
std::function< Eigen::Vector3d(const Eigen::Vector3d &)> SolutionCurlType
Definition: sddr-magnetostatics.hpp:58
IntegralWeight PermeabilityType
Definition: sddr-magnetostatics.hpp:59
const SXDiv & sxDiv() const
Returns the space SXDiv.
Definition: sddr-magnetostatics.hpp:101
static Magnetostatics::SolutionCurlType variable_permeability_sigma
Definition: ddr-magnetostatics.hpp:279
std::function< Eigen::Vector3d(const Eigen::Vector3d &)> SolutionPotentialType
Definition: sddr-magnetostatics.hpp:57
std::function< Eigen::Vector3d(const Eigen::Vector3d &)> ForcingTermType
Definition: sddr-magnetostatics.hpp:56
static Magnetostatics::SolutionPotentialType variable_permeability_u
Definition: ddr-magnetostatics.hpp:270
static Magnetostatics::ForcingTermType trigonometric_f
Definition: ddr-magnetostatics.hpp:255
static Magnetostatics::ForcingTermType linear_f
Definition: ddr-magnetostatics.hpp:227
static Magnetostatics::ForcingTermType variable_permeability_f
Definition: ddr-magnetostatics.hpp:289
bool use_threads
Definition: HHO_DiffAdvecReac.hpp:47
Definition: ddr-magnetostatics.hpp:40
MeshND::Cell< 2 > Cell
Definition: Mesh2D.hpp:13
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
const Eigen::VectorXd & systemVector() const
Returns the linear system right-hand side vector.
Definition: sddr-magnetostatics.hpp:117
double & stabilizationParameter()
Returns the stabilization parameter.
Definition: sddr-magnetostatics.hpp:132
size_t nbSCDOFs() const
Returns the number of statically condensed DOFs (here, the cell magnetic field DOFs)
Definition: sddr-magnetostatics.hpp:83
Eigen::VectorXd & systemVector()
Returns the linear system right-hand side vector.
Definition: sddr-magnetostatics.hpp:122
const SystemMatrixType & scMatrix() const
Returns the static condensation recovery operator.
Definition: sddr-magnetostatics.hpp:137
size_t dimensionSpace() const
Returns the dimension of the magnetic field + potential space.
Definition: sddr-magnetostatics.hpp:77
Magnetostatics(const DDRCore &ddrcore, bool use_threads, std::ostream &output=std::cout)
Constructor.
const double & stabilizationParameter() const
Returns the stabilization parameter.
Definition: sddr-magnetostatics.hpp:127
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.
SystemMatrixType & systemMatrix()
Returns the linear system matrix.
Definition: sddr-magnetostatics.hpp:112
size_t sizeSystem() const
Returns the size of the statically condensed system.
Definition: sddr-magnetostatics.hpp:89
Eigen::VectorXd & scVector()
Returns the static condensation rhs.
Definition: sddr-magnetostatics.hpp:142
void assembleLinearSystem(const ForcingTermType &f, const PermeabilityType &mu, const SolutionPotentialType &u)
Assemble the global system
const SystemMatrixType & systemMatrix() const
Returns the linear system matrix.
Definition: sddr-magnetostatics.hpp:107