MFEM v4.10.0
Finite element discretization library
Loading...
Searching...
No Matches
ds-common.hpp
Go to the documentation of this file.
1// Copyright (c) 2010-2026, Lawrence Livermore National Security, LLC. Produced
2// at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3// LICENSE and NOTICE for details. LLNL-CODE-806117.
4//
5// This file is part of the MFEM library. For more information and source code
6// availability visit https://mfem.org.
7//
8// MFEM is free software; you can redistribute it and/or modify it under the
9// terms of the BSD-3 license. We welcome feedback and contributions, see file
10// CONTRIBUTING.md for details.
11
12#ifndef MFEM_DS_COMMON_HPP
13#define MFEM_DS_COMMON_HPP
14
15#include "mfem.hpp"
17#include <fstream>
18#include <iostream>
19
20using namespace std;
21using namespace mfem;
22
23namespace ds_common
24{
25
26extern int MONITOR_DIGITS;
27extern int MG_MAX_ITER;
28extern real_t MG_REL_TOL;
29
30extern int dim;
31extern int space_dim;
32extern real_t freq;
33extern real_t kappa;
34
35// Enumerator for the different solvers to implement
37{
40 num_solvers, // last
41};
42
43// Enumerator for the different integrators to implement
51
52// Enumerator for the different types of preconditioners
60
61/// @brief Custom monitor that prints a csv-formatted file
63{
64private:
65 ofstream os;
66 int precision;
67public:
68 DataMonitor(string file_name, int ndigits);
69 void MonitorResidual(int it, real_t norm, const Vector &x, bool final);
70 void MonitorSolution(int it, real_t norm, const Vector &x, bool final);
71};
72
73
74/// @brief Abs-L(1)-Jacobi custom general geometric multigrid method.
75///
76/// Intermediate levels use Abs-L(1)-Jacobi preconditioner by applying the
77/// level matrix to the constant vector one. These are wrapped by an
78/// OperatorJacobiSmoother. Coarsest level uses a used-selected solver
79/// with an Abs-L(1)-Jacobi smoother. The assembly level is user-defined.
80///
81/// @warning The construction of the smoother is based on the application of
82/// AbsMult, which usually unfolds component-wise. E.g., if `A = B C`, then
83/// `|A|x = |B|(|C| x)`.
85{
86public:
88 Array<int>& ess_bdr,
90 SolverType st,
91 AssemblyLevel al);
92
93 ~AbsL1GeometricMultigrid() { delete coarse_pc; }
94
95 bool GetOwnershipLevelOperators() const { return mg_owned; }
96
97private:
98 IntegratorType integrator_type;
99 SolverType solver_type;
100 AssemblyLevel assembly_level;
101 bool mg_owned;
102 OperatorJacobiSmoother* coarse_pc;
104
105 void ConstructCoarseOperatorAndSolver(ParFiniteElementSpace& coarse_fespace);
106
107 void ConstructOperatorAndSmoother(ParFiniteElementSpace& fespace, int level);
108
109 void ConstructBilinearForm(ParFiniteElementSpace& fespace);
110
111};
112
114 Vector& diag);
115
118
119void maxwell_solution(const Vector &x, Vector &u);
120void maxwell_source(const Vector &x, Vector &f);
121
122} // namespace ds_common
123
124#endif // MFEM_DS_COMMON_HPP
Abs-L(1)-Jacobi custom general geometric multigrid method.
Definition ds-common.hpp:85
AbsL1GeometricMultigrid(ParFiniteElementSpaceHierarchy &fes_hierarchy, Array< int > &ess_bdr, IntegratorType it, SolverType st, AssemblyLevel al)
Definition ds-common.cpp:56
Custom monitor that prints a csv-formatted file.
Definition ds-common.hpp:63
void MonitorResidual(int it, real_t norm, const Vector &x, bool final)
Monitor the residual vector r.
Definition ds-common.cpp:42
DataMonitor(string file_name, int ndigits)
Definition ds-common.cpp:30
void MonitorSolution(int it, real_t norm, const Vector &x, bool final)
Monitor the solution vector x.
Definition ds-common.cpp:48
A coefficient that is constant across space and time.
Geometric multigrid associated with a hierarchy of finite element spaces.
Abstract base class for an iterative solver controller.
Definition solvers.hpp:37
Jacobi smoothing for a given bilinear form (no matrix necessary).
Definition solvers.hpp:422
Class for parallel bilinear form.
Abstract parallel finite element space.
Definition pfespace.hpp:31
Vector data type.
Definition vector.hpp:82
real_t f(const Vector &p)
real_t MG_REL_TOL
Definition ds-common.cpp:22
real_t diffusion_source(const Vector &x)
int space_dim
Definition ds-common.cpp:25
@ num_integrators
Definition ds-common.hpp:49
void maxwell_source(const Vector &x, Vector &f)
void maxwell_solution(const Vector &x, Vector &u)
int MG_MAX_ITER
Definition ds-common.cpp:21
void AssembleElementLpqJacobiDiag(ParBilinearForm &form, real_t p, real_t q, Vector &diag)
int MONITOR_DIGITS
Definition ds-common.cpp:20
real_t kappa
Definition ds-common.cpp:27
real_t diffusion_solution(const Vector &x)
real_t freq
Definition ds-common.cpp:26
real_t u(const Vector &xvec)
Definition lor_mms.hpp:22
AssemblyLevel
Enumeration defining the assembly level for bilinear and nonlinear form classes derived from Operator...
float real_t
Definition config.hpp:46
STL namespace.
real_t p(const Vector &x, real_t t)
MFEM_HOST_DEVICE real_t norm(const Complex &z)