BELFEM 0.9.0
Berkeley Lab Finite Element Framework
Loading...
Searching...
No Matches
cl_Solver.hpp
Go to the documentation of this file.
1/*
2 * BELFEM -- The Berkeley Lab Finite Element Framework
3 * Copyright (c) 2026, The Regents of the University of California,
4 * through Lawrence Berkeley National Laboratory (subject to receipt of any required
5 * approvals from the U.S. Dept. of Energy). All rights reserved.
6 *
7 * Developers: Christian Messe, Gregory Giard
8 *
9 * See the top-level LICENSE file for the complete license and disclaimer.
10 */
11
12#ifndef BELFEM_CL_SOLVER_HPP
13#define BELFEM_CL_SOLVER_HPP
14#include "typedefs.hpp"
15#include "cl_Vector.hpp"
16#include "cl_Matrix.hpp"
18#include "cl_SpMatrix.hpp"
19
20#include "en_SolverEnums.hpp"
21#include "cl_SolverWrapper.hpp"
22
23namespace belfem
24{
25//------------------------------------------------------------------------------
26
33 class Solver
34 {
35 // the type of the chosen solver
36 const SolverType mType ;
37
38 SolverParameters mParams ;
39
40 // symmetry mode
42
43 solver::Wrapper * mWrapper ;
44
45//------------------------------------------------------------------------------
46 public :
47//------------------------------------------------------------------------------
48
49 Solver( const SolverType aSolverType = gDefaultSolver ) ;
50
51 Solver( const SolverParameters aParams ) ;
52
53//------------------------------------------------------------------------------
54
55 ~Solver() ;
56
57 // NON-COPYABLE, NON-MOVABLE. This class owns the raw pointer
58 // mWrapper and deletes it in its destructor, so the implicit copy
59 // would be a shallow pointer copy and the second destructor a
60 // double free. Copy assignment was already implicitly deleted by
61 // the const mType member, and the user-declared destructor
62 // suppressed the implicit moves -- which is why a move request
63 // used to bind to the implicit COPY constructor, the same hazard
64 // under another name. Nothing copies a Solver, which is exactly
65 // why this was latent rather than loud.
66 //
67 // Same shape and same remedy as EigenValues
68 // ( cl_FEM_DofMgr_EigenValues.hpp ). NOT the SpMatrix pattern:
69 // that one deletes the constructors but keeps assignment on
70 // purpose, because an empty SpMatrix is a usable target
71 Solver( const Solver & ) = delete ;
72 Solver( Solver && ) = delete ;
73 Solver & operator=( const Solver & ) = delete ;
74 Solver & operator=( Solver && ) = delete ;
75
76//------------------------------------------------------------------------------
77
82 type() const ;
83
84//------------------------------------------------------------------------------
85
91 const SolverParameters &
92 parameters() const ;
93
94//------------------------------------------------------------------------------
95
100 void
101 set_symmetry_mode( const SymmetryMode & aMode ) ;
102
103//------------------------------------------------------------------------------
104
111 void
112 solve( SpMatrix & aMatrix,
113 Vector< real > & aLHS,
114 Vector< real > & aRHS );
115
116//------------------------------------------------------------------------------
117
124 void
125 solve( SpMatrix & aMatrix,
126 Matrix< real > & aLHS,
127 Matrix< real > & aRHS );
128
129//------------------------------------------------------------------------------
130
138 void
139 set_petsc(
140 const Preconditioner aPreconditioner,
141 const KrylovMethod aKrylovMethod,
142 const real aEpsilon = 1e-8 );
143
144//------------------------------------------------------------------------------
145
149 void
151 const MumpsSerialReodrdering aSerial,
152 const MumpsParallelReodrdering aParallel );
153
154 void
156 const MumpsBlockLowRanking aBlr,
157 const real aEpsilon );
158
159 void
161 const MumpsErrorAnalysis aSetting );
162
163//------------------------------------------------------------------------------
164
169/* void
170 set_pardiso(
171 const PardisoMode aMode ) ; */
172
173//------------------------------------------------------------------------------
174
178 void
179 free() ;
180
181//------------------------------------------------------------------------------
182
187 wrapper() ;
188
189//------------------------------------------------------------------------------
190 private:
191//------------------------------------------------------------------------------
192
193 void
194 create_wrapper();
195
196//------------------------------------------------------------------------------
197 };
198
199//------------------------------------------------------------------------------
200
201 inline solver::Wrapper *
203 {
204 return mWrapper ;
205 }
206
207//------------------------------------------------------------------------------
208}
209#endif //BELFEM_CL_SOLVER_HPP
Solver(Solver &&)=delete
void set_mumps_reordering(const MumpsSerialReodrdering aSerial, const MumpsParallelReodrdering aParallel)
mumps only
Definition cl_Solver.cpp:257
void set_symmetry_mode(const SymmetryMode &aMode)
symmetry mode, needed for some solvers
Definition cl_Solver.cpp:164
const SolverParameters & parameters() const
read-only view of the parameters this solver was built with ( e.g.
Definition cl_Solver.cpp:156
Solver(const SolverType aSolverType=gDefaultSolver)
Definition cl_Solver.cpp:29
void solve(SpMatrix &aMatrix, Vector< real > &aLHS, Vector< real > &aRHS)
solves the system
Definition cl_Solver.cpp:172
Solver & operator=(const Solver &)=delete
Solver & operator=(Solver &&)=delete
void set_mumps_error_analysis(const MumpsErrorAnalysis aSetting)
Definition cl_Solver.cpp:303
void free()
this does only do something if PARDISO is used
Definition cl_Solver.cpp:229
void set_mumps_blr(const MumpsBlockLowRanking aBlr, const real aEpsilon)
Definition cl_Solver.cpp:275
solver::Wrapper * wrapper()
expose wrapper object
Definition cl_Solver.hpp:202
void set_petsc(const Preconditioner aPreconditioner, const KrylovMethod aKrylovMethod, const real aEpsilon=1e-8)
this does only do something if PETSc is used
Definition cl_Solver.cpp:237
Solver(const Solver &)=delete
SolverType type() const
return the type of the solver
Definition cl_Solver.cpp:148
Configuration for a Solver.
Definition cl_SolverParameters.hpp:27
Sparse matrix in CSR or CSC format.
Definition cl_SpMatrix.hpp:52
parent class for solver specific data
Definition cl_SolverWrapper.hpp:31
USER GUIDES:
Definition cl_Capacitor.cpp:16
MumpsSerialReodrdering
MUMPS only.
Definition en_SolverEnums.hpp:142
MumpsErrorAnalysis
MUMPS only.
Definition en_SolverEnums.hpp:187
const SolverType gDefaultSolver
Definition en_SolverEnums.hpp:209
SolverType
Definition en_SolverEnums.hpp:23
KrylovMethod
PETSC only.
Definition en_SolverEnums.hpp:101
SymmetryMode
Definition en_SolverEnums.hpp:36
@ Unsymmetric
Definition en_SolverEnums.hpp:37
Preconditioner
PETSC only.
Definition en_SolverEnums.hpp:79
double real
Definition typedefs.hpp:36
MumpsBlockLowRanking
MUMPS only.
Definition en_SolverEnums.hpp:173
MumpsParallelReodrdering
MUMPS only.
Definition en_SolverEnums.hpp:160