GCC Code Coverage Report


Directory: ./
File: Model/heatParametricModel.cpp
Date: 2024-04-14 07:32:34
Exec Total Coverage
Lines: 0 34 0.0%
Branches: 0 20 0.0%

Line Branch Exec Source
1 // ______ ______ _ _ _____ ______
2 // | ____| ____| | (_)/ ____| | ____|
3 // | |__ | |__ | | _| (___ ___| |__
4 // | __| | __| | | | |\___ \ / __| __|
5 // | | | |____| |____| |____) | (__| |____
6 // |_| |______|______|_|_____/ \___|______|
7 // Finite Elements for Life Sciences and Engineering
8 //
9 // License: LGL2.1 License
10 // FELiScE default license: LICENSE in root folder
11 //
12 // Main authors:
13 //
14
15 // System includes
16
17 // External includes
18
19 // Project includes
20 #include "Model/heatParametricModel.hpp"
21
22 namespace felisce {
23 HeatParametricModel::HeatParametricModel():Model(),
24 Kparameter(1.),
25 RHSparameter(1.) {
26 m_name = "HeatParametric";
27 }
28
29 HeatParametricModel::~HeatParametricModel()
30 = default;
31
32 void HeatParametricModel::initializeDerivedModel() {
33 Kparameter = FelisceParam::instance().Kparameter;
34 RHSparameter = FelisceParam::instance().RHSparameter;
35 }
36
37 void HeatParametricModel::preAssemblingMatrixRHS(std::size_t iProblem) {
38 IGNORE_UNUSED_ARGUMENT(iProblem)
39
40 // First assembly loop in iteration 0 to build static matrix.
41 m_linearProblem[0]->assembleMatrixRHS(MpiInfo::rankProc());
42
43 // save static matrix in matrix _A and the F std::vector.
44 m_linearProblem[0]->copyMatrixRHS();
45 }
46
47
48 void HeatParametricModel::postAssemblingMatrixRHS(std::size_t iProblem) {
49 IGNORE_UNUSED_ARGUMENT(iProblem)
50
51 // complete matrix of the system
52 m_linearProblem[0]->addScaleMatrix(Kparameter);
53 m_linearProblem[0]->addScaleRHS(RHSparameter);
54 }
55
56 void HeatParametricModel::forward() {
57 PetscPrintf(MpiInfo::petscComm(),"\n\n\tTimestep: %d \n\n", m_fstransient->iteration);
58
59 //Assembly llop on elements.
60 m_linearProblem[0]->assembleMatrixRHS(MpiInfo::rankProc());
61
62 //Specific operations before solve the system.
63 postAssemblingMatrixRHS();
64
65 //Apply boundary conditions.
66 m_linearProblem[0]->finalizeEssBCTransient();
67 m_linearProblem[0]->applyBC(FelisceParam::instance().essentialBoundaryConditionsMethod, MpiInfo::rankProc());
68
69 //Solve linear system.
70 m_linearProblem[0]->solve(MpiInfo::rankProc(), MpiInfo::numProc());
71
72 //Advance time step.
73 updateTime();
74
75 //Write solution with ensight.
76 writeSolution();
77 }
78
79 int HeatParametricModel::getNstate() const {
80 return m_linearProblem[0]->numDof()+1;
81 }
82
83 void HeatParametricModel::getState(double* & state) {
84 double * solution;
85 m_linearProblem[0]->getSolution(solution, MpiInfo::numProc(), MpiInfo::rankProc());
86 state = new double[getNstate()];
87
88 for (int i = 0; i < getNstate() - 1; i++ )
89 state[i] = solution[i];
90 state[getNstate() - 1] = RHSparameter;
91
92 /*for (int i = 0; i < getNstate(); i++)
93 std::cout << state[i] << std::endl;
94 std::cout << std::endl << std::endl;*/
95 }
96
97 void HeatParametricModel::setState(double* & state) {
98 m_linearProblem[0]->setSolution(state, MpiInfo::numProc(), MpiInfo::rankProc());
99 RHSparameter = state[getNstate() - 1];
100 }
101 }
102