waves
Basic FE playground
wSolver.h
Go to the documentation of this file.
1 /*
2  * Copyright 2022 University of Liège
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef WSOLVER_H
18 #define WSOLVER_H
19 
20 #include "heat.h"
21 #include "wObject.h"
22 #include "wTimer.h"
23 #include "wTimers.h"
24 #include "wElement.h"
25 #include <iostream>
26 #include <vector>
27 #include <memory>
28 #include <Eigen/Sparse>
29 
30 using namespace tbox;
31 
32 namespace heat
33 {
34 
39 class HEAT_API Solver : public fwk::wSharedObject
40 {
41 public:
42  int verbose;
43 #ifndef SWIG
45 
46 #endif
47  std::shared_ptr<Problem> pbl;
48  std::shared_ptr<tbox::LinearSolver> linsol;
49 
50  bool stopit;
51  int nthreads;
52  fwk::Timers tms;
53  std::vector<double> T1;
54  double restol;
55  int itmax;
56  bool save;
57 public:
58  Solver(std::shared_ptr<Problem> _pbl, std::shared_ptr<tbox::LinearSolver> _linsol);
59  virtual ~Solver();
60 
61  virtual void start(MshExport *mshWriter);
62 
63  void setGUI(DisplayHook &hook) { dhook = &hook; }
64 
65  void stop() { stopit = true; }
66 #ifndef SWIG
67  virtual void write(std::ostream &out) const override;
68 #endif
69 
70 private:
71  void buildK(Eigen::SparseMatrix<double, Eigen::RowMajor> &K2, Eigen::Map<Eigen::VectorXd> &rhs);
72  void builds(Eigen::Map<Eigen::VectorXd> &s);
73  void buildq(Eigen::Map<Eigen::VectorXd> &s);
74  void buildqint(Eigen::VectorXd &qint);
75 };
76 
77 } // namespace heat
78 
79 #endif //WSOLVER_H
HEAT_API
#define HEAT_API
Definition: heat.h:29
heat::Solver::pbl
std::shared_ptr< Problem > pbl
Definition: wSolver.h:47
heat::Solver
heat solver
Definition: wSolver.h:39
heat::Solver::stopit
bool stopit
stop the calculation
Definition: wSolver.h:50
heat
this namespace avoids conflicts with similar names in 'waves'
Definition: heat.h:38
heat::Solver::nthreads
int nthreads
Definition: wSolver.h:51
heat::Solver::restol
double restol
tolerance on the residual
Definition: wSolver.h:54
heat::Solver::verbose
int verbose
Definition: wSolver.h:42
heat::DisplayHook
quad element
Definition: wDisplayHook.h:31
heat::Solver::tms
fwk::Timers tms
timers
Definition: wSolver.h:52
heat::Solver::setGUI
void setGUI(DisplayHook &hook)
Definition: wSolver.h:63
heat::Solver::linsol
std::shared_ptr< tbox::LinearSolver > linsol
linear solver
Definition: wSolver.h:48
heat::Solver::save
bool save
calculate all results
Definition: wSolver.h:56
heat.h
heat::Solver::dhook
DisplayHook * dhook
Definition: wSolver.h:44
heat::Solver::stop
void stop()
Definition: wSolver.h:65
heat::Solver::itmax
int itmax
max number of iterations
Definition: wSolver.h:55
heat::Solver::T1
std::vector< double > T1
nodal temperatures
Definition: wSolver.h:53