Changeset dfed1c for src/solver
- Timestamp:
- Nov 22, 2011, 9:22:10 PM (14 years ago)
- Children:
- facba0
- Parents:
- 66f24d
- Location:
- src/solver
- Files:
-
- 2 added
- 2 deleted
- 3 edited
- 2 moved
-
dsysv.hpp (modified) (1 diff)
-
solver.cpp (modified) (1 diff)
-
solver.hpp (modified) (5 diffs)
-
solver_dirichlet.cpp (deleted)
-
solver_periodic.cpp (deleted)
-
solver_regular.cpp (added)
-
solver_regular.hpp (moved) (moved from src/solver/solver_dirichlet.hpp ) (3 diffs)
-
solver_singular.cpp (added)
-
solver_singular.hpp (moved) (moved from src/solver/solver_periodic.hpp ) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/solver/dsysv.hpp
r66f24d rdfed1c 78 78 vmg_float *la_A, *la_A_orig, *la_B, *la_B_orig, *la_work, *la_work2; 79 79 80 int cur_lapack_size, max_lapack_size; ;80 int cur_lapack_size, max_lapack_size; 81 81 }; 82 82 -
src/solver/solver.cpp
r66f24d rdfed1c 16 16 using namespace VMG; 17 17 18 void Solver::Run(Grid& sol, Grid& rhs) 19 { 20 #ifdef DEBUG_MATRIX_CHECKS 21 sol.IsConsistent(); 22 rhs.IsConsistent(); 23 #endif 24 25 #ifdef DEBUG 26 sol.IsCompatible(rhs); 27 #endif 28 29 Comm* comm = MG::GetComm(); 30 31 Grid& rhsGlobal = comm->GetGlobalCoarseGrid(*rhs.Father()); 32 33 this->Realloc(rhsGlobal); 34 this->AssembleMatrix(rhsGlobal); 35 this->Compute(); 36 this->ExportSol(sol, rhs); 37 } 38 18 39 void Solver::Realloc(int n) 19 40 { 20 41 //Reallocate memory if necessary 21 this-> vec_size = n;42 this->size = n; 22 43 23 if (n > this->max_size) { 44 if (static_cast<int>(A.size()) < n*n) 45 A.resize(n*n); 24 46 25 delete [] b; 26 delete [] x; 27 for (int i=0; i<this->max_size; i++) 28 delete [] A[i]; 29 delete [] A; 47 if (static_cast<int>(b.size()) < n) 48 b.resize(n); 30 49 31 b = new vmg_float[n]; 32 x = new vmg_float[n]; 33 A = new vmg_float*[n]; 34 for (int i=0; i<n; i++) 35 A[i] = new vmg_float[n]; 36 37 this->max_size = n; 38 39 } 50 if (static_cast<int>(x.size()) < n) 51 x.resize(n); 40 52 } 41 53 42 54 void Solver::Realloc(Grid& sol) 43 55 { 44 this->Realloc(sol.Global().Size ().Product());56 this->Realloc(sol.Global().SizeGlobal().Product()); 45 57 } -
src/solver/solver.hpp
r66f24d rdfed1c 10 10 #ifndef SOLVER_HPP_ 11 11 #define SOLVER_HPP_ 12 13 #include <vector> 12 14 13 15 #include "base/discretization.hpp" … … 33 35 Solver() 34 36 { 35 max_size = 0; 36 vec_size = 0; 37 b = NULL; 38 x = NULL; 39 A = NULL; 37 size = 0; 40 38 } 41 39 42 40 virtual ~Solver() 43 41 { 44 delete [] b;45 delete [] x;46 for (int i=0; i<max_size; i++)47 delete [] A[i];48 delete [] A;49 42 } 50 43 51 void Run(Grid& sol, Grid& rhs) 52 { 53 #ifdef DEBUG 54 sol.IsConsistent(); 55 rhs.IsConsistent(); 56 sol.IsCompatible(rhs); 57 #endif 58 59 Grid *rhsGlobal = MG::GetComm()->CommMergeGrids(rhs); 60 61 this->Realloc(*rhsGlobal); 62 this->AssembleMatrix(*rhsGlobal); 63 this->Compute(); 64 this->ExportSol(sol, rhs); 65 } 44 void Run(Grid& sol, Grid& rhs); 66 45 67 46 private: … … 71 50 virtual void ExportSol(Grid& sol, Grid& rhs) = 0; ///< Exports the solution back to a given mesh. 72 51 73 vmg_float **A, *b, *x;74 int max_size, vec_size;52 std::vector<vmg_float> A, b, x; 53 int size; 75 54 76 55 protected: … … 80 59 vmg_float& Mat(int i, int j) 81 60 { 82 return A[ i][j];61 return A[j+size*i]; 83 62 } 84 63 … … 93 72 } 94 73 95 const int& Size() const {return vec_size;} 96 const int& MemSize() const {return max_size;} 74 const int& Size() const {return size;} 97 75 }; 98 76 -
src/solver/solver_regular.hpp
r66f24d rdfed1c 1 1 /** 2 * @file solver_ dirichlet.hpp2 * @file solver_regular.hpp 3 3 * @author Julian Iseringhausen <isering@ins.uni-bonn.de> 4 4 * @date Mon Apr 18 13:11:47 2011 5 5 * 6 * @brief VMG::Solver Dirichlet6 * @brief VMG::SolverRegular 7 7 * 8 8 */ 9 9 10 #ifndef SOLVER_ DIRICHLET_HPP_11 #define SOLVER_ DIRICHLET_HPP_10 #ifndef SOLVER_REGULAR_HPP_ 11 #define SOLVER_REGULAR_HPP_ 12 12 13 13 #include "solver.hpp" … … 18 18 class Multigrid; 19 19 20 class Solver Dirichlet: public Solver20 class SolverRegular : public Solver 21 21 { 22 22 private: … … 27 27 } 28 28 29 #endif /* SOLVER_ DIRICHLET_HPP_ */29 #endif /* SOLVER_REGULAR_HPP_ */ -
src/solver/solver_singular.hpp
r66f24d rdfed1c 1 1 /** 2 * @file solver_ periodic.hpp2 * @file solver_singular.hpp 3 3 * @author Julian Iseringhausen <isering@ins.uni-bonn.de> 4 4 * @date Mon Apr 18 13:12:18 2011 5 5 * 6 * @brief VMG::Solver Periodic6 * @brief VMG::SolverSingular 7 7 * 8 8 */ 9 9 10 #ifndef SOLVER_ PERIODIC_HPP_11 #define SOLVER_ PERIODIC_HPP_10 #ifndef SOLVER_SINGULAR_HPP_ 11 #define SOLVER_SINGULAR_HPP_ 12 12 13 13 #include "solver/solver.hpp" … … 18 18 class Multigrid; 19 19 20 class Solver Periodic: public Solver20 class SolverSingular : public Solver 21 21 { 22 22 private: … … 27 27 } 28 28 29 #endif /* SOLVER_ PERIODIC_HPP_ */29 #endif /* SOLVER_SINGULAR_HPP_ */
Note:
See TracChangeset
for help on using the changeset viewer.
