Changeset ac6d04 for src/solver
- Timestamp:
- Apr 10, 2012, 1:55:49 PM (14 years ago)
- Children:
- a40eea
- Parents:
- d24c2f
- Location:
- src/solver
- Files:
-
- 9 edited
-
dgesv.hpp (modified) (1 diff)
-
dsysv.hpp (modified) (1 diff)
-
givens.hpp (modified) (1 diff)
-
solver.cpp (modified) (2 diffs)
-
solver.hpp (modified) (4 diffs)
-
solver_regular.cpp (modified) (5 diffs)
-
solver_regular.hpp (modified) (1 diff)
-
solver_singular.cpp (modified) (5 diffs)
-
solver_singular.hpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/solver/dgesv.hpp
rd24c2f rac6d04 48 48 {Init();} 49 49 50 DGESV(int size) : 51 T(size) 52 {Init();} 53 50 54 virtual ~DGESV(); 51 55 56 protected: 57 void Compute(); 58 52 59 private: 53 void Compute();54 60 void Init(); 55 61 void Realloc(); -
src/solver/dsysv.hpp
rd24c2f rac6d04 67 67 {Init();} 68 68 69 DSYSV(int size) : 70 T(size) 71 {Init();} 72 69 73 virtual ~DSYSV(); 74 75 protected: 76 void Compute(); 70 77 71 78 private: 72 79 void Init(); 73 80 void Realloc(); 74 void Compute();75 81 76 82 char la_uplo; -
src/solver/givens.hpp
rd24c2f rac6d04 22 22 class Givens : public T 23 23 { 24 private: 24 public: 25 Givens() : 26 T() 27 {} 28 29 Givens(int size) : 30 T(size) 31 {} 32 33 protected: 25 34 void Compute(); 26 35 }; -
src/solver/solver.cpp
rd24c2f rac6d04 27 27 #endif 28 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); 29 if (rhs.Global().LocalSize().Product() > 0) { 30 this->Realloc(rhs); 31 this->AssembleMatrix(rhs); 32 this->Compute(); 33 this->ExportSol(sol, rhs); 34 } 37 35 } 38 36 … … 54 52 void Solver::Realloc(Grid& sol) 55 53 { 56 this->Realloc(sol.Global(). SizeGlobal().Product());54 this->Realloc(sol.Global().GlobalSize().Product()); 57 55 } -
src/solver/solver.hpp
rd24c2f rac6d04 20 20 #include "mg.hpp" 21 21 22 namespace VMGTests23 {24 class SolverTestSuite;25 }26 27 22 namespace VMG 28 23 { … … 31 26 { 32 27 public: 33 friend class VMGTests::SolverTestSuite;34 35 28 Solver() 36 29 { 37 30 size = 0; 31 } 32 33 Solver(int size) : 34 size(size) 35 { 36 this->Realloc(size); 38 37 } 39 38 … … 44 43 void Run(Grid& sol, Grid& rhs); 45 44 46 private:47 48 virtual void Compute() = 0; ///< Solves the system of equations49 virtual void AssembleMatrix(const Grid& rhs) = 0; ///< Assembles all matrices and vectors.50 virtual void ExportSol(Grid& sol, Grid& rhs) = 0; ///< Exports the solution back to a given mesh.51 52 std::vector<vmg_float> A, b, x;53 int size;54 55 protected:56 45 void Realloc(int n); 57 46 void Realloc(Grid& x); … … 73 62 74 63 const int& Size() const {return size;} 64 65 protected: 66 virtual void Compute() = 0; ///< Solves the system of equations 67 68 private: 69 virtual void AssembleMatrix(const Grid& rhs) = 0; ///< Assembles all matrices and vectors. 70 virtual void ExportSol(Grid& sol, Grid& rhs) = 0; ///< Exports the solution back to a given mesh. 71 72 std::vector<vmg_float> A, b, x; 73 int size; 75 74 }; 76 75 -
src/solver/solver_regular.cpp
rd24c2f rac6d04 38 38 #endif 39 39 40 this->Realloc(rhs.Global(). SizeGlobal().Product());40 this->Realloc(rhs.Global().GlobalSize().Product()); 41 41 42 42 for (grid_iter = rhs.Iterators().Local().Begin(); grid_iter != rhs.Iterators().Local().End(); ++grid_iter) { 43 43 44 mat_index = rhs.GlobalLinearIndex(*grid_iter + rhs.Global(). BeginLocal());44 mat_index = rhs.GlobalLinearIndex(*grid_iter + rhs.Global().LocalBegin()); 45 45 46 46 assert(mat_index >= 0 && mat_index<this->Size()); … … 56 56 for (stencil_iter = A.begin(); stencil_iter != A.end(); ++stencil_iter) { 57 57 58 mat_index2 = rhs.GlobalLinearIndex(*grid_iter + rhs.Global(). BeginLocal() + stencil_iter->Disp());58 mat_index2 = rhs.GlobalLinearIndex(*grid_iter + rhs.Global().LocalBegin() + stencil_iter->Disp()); 59 59 60 60 assert(mat_index2 >= 0 && mat_index2<this->Size()); … … 69 69 for (grid_iter = rhs.Iterators().Boundary1()[i].Begin(); grid_iter != rhs.Iterators().Boundary1()[i].End(); ++grid_iter) { 70 70 71 mat_index = rhs.GlobalLinearIndex(*grid_iter + rhs.Global(). BeginLocal());71 mat_index = rhs.GlobalLinearIndex(*grid_iter + rhs.Global().LocalBegin()); 72 72 73 73 assert(mat_index >= 0 && mat_index<this->Size()); … … 84 84 for (grid_iter = rhs.Iterators().Boundary2()[i].Begin(); grid_iter != rhs.Iterators().Boundary2()[i].End(); ++grid_iter) { 85 85 86 mat_index = rhs.GlobalLinearIndex(*grid_iter + rhs.Global(). BeginLocal());86 mat_index = rhs.GlobalLinearIndex(*grid_iter + rhs.Global().LocalBegin()); 87 87 88 88 assert(mat_index >= 0 && mat_index<this->Size()); … … 110 110 111 111 for (Grid::iterator iter = sol.Iterators().CompleteGrid().Begin(); iter != sol.Iterators().CompleteGrid().End(); ++iter) { 112 index = sol.GlobalLinearIndex(sol.Global(). BeginLocal() + *iter - offset);112 index = sol.GlobalLinearIndex(sol.Global().LocalBegin() + *iter - offset); 113 113 sol(*iter) = this->Sol(index); 114 114 } -
src/solver/solver_regular.hpp
rd24c2f rac6d04 20 20 class SolverRegular : public Solver 21 21 { 22 public: 23 SolverRegular() : 24 Solver() 25 {} 26 27 SolverRegular(int size) : 28 Solver(size) 29 {} 30 22 31 private: 23 32 void AssembleMatrix(const Grid& rhs); ///< Assembles all matrices and vectors. -
src/solver/solver_singular.cpp
rd24c2f rac6d04 42 42 43 43 // Make sure that arrays are big enough to hold expanded system of equations 44 this->Realloc(rhs.Global(). SizeGlobal().Product() + 1);44 this->Realloc(rhs.Global().GlobalSize().Product() + 1); 45 45 46 46 for (grid_iter = rhs.Iterators().Local().Begin(); grid_iter != rhs.Iterators().Local().End(); ++grid_iter) { 47 47 48 48 // Compute 1-dimensional index from 3-dimensional grid 49 index = rhs.GlobalLinearIndex(*grid_iter - rhs.Local().Begin() + rhs.Global(). BeginLocal());49 index = rhs.GlobalLinearIndex(*grid_iter - rhs.Local().Begin() + rhs.Global().LocalBegin()); 50 50 51 51 // Check if we computed the index correctly … … 64 64 for (stencil_iter = A.begin(); stencil_iter != A.end(); ++stencil_iter) { 65 65 66 i = *grid_iter - rhs.Local().Begin() + rhs.Global(). BeginLocal() + stencil_iter->Disp();66 i = *grid_iter - rhs.Local().Begin() + rhs.Global().LocalBegin() + stencil_iter->Disp(); 67 67 68 68 for (int j=0; j<3; ++j) 69 69 if (comm->BoundaryConditions()[j] == Periodic) { 70 70 if (i[j] < 0) 71 i[j] += rhs.Global(). SizeGlobal()[j];72 else if (i[j] >= rhs.Global(). SizeGlobal()[j])73 i[j] -= rhs.Global(). SizeGlobal()[j];71 i[j] += rhs.Global().GlobalSize()[j]; 72 else if (i[j] >= rhs.Global().GlobalSize()[j]) 73 i[j] -= rhs.Global().GlobalSize()[j]; 74 74 } 75 75 … … 87 87 row_sum += iter->Val(); 88 88 89 if ( fabs(row_sum) <=std::numeric_limits<vmg_float>::epsilon()) {89 if (std::abs(row_sum) <= (A.size()+1) * std::numeric_limits<vmg_float>::epsilon()) { 90 90 91 91 // Expand equation system in order to make the system regular. … … 108 108 { 109 109 int index; 110 const vmg_float correction = this->Sol(this->Size()-1); 110 111 111 112 for (int i=0; i<sol.Local().Size().X(); i++) … … 114 115 115 116 // Compute global 1-dimensional index 116 index = sol.GlobalLinearIndex(sol.Global(). BeginLocal().X()+i,117 sol.Global(). BeginLocal().Y()+j,118 sol.Global(). BeginLocal().Z()+k);117 index = sol.GlobalLinearIndex(sol.Global().LocalBegin().X()+i, 118 sol.Global().LocalBegin().Y()+j, 119 sol.Global().LocalBegin().Z()+k); 119 120 120 121 // Set solution 121 sol(sol.Local().Begin().X()+i, sol.Local().Begin().Y()+j, sol.Local().Begin().Z()+k) = this->Sol(index) ;122 sol(sol.Local().Begin().X()+i, sol.Local().Begin().Y()+j, sol.Local().Begin().Z()+k) = this->Sol(index) - correction; 122 123 123 124 } -
src/solver/solver_singular.hpp
rd24c2f rac6d04 20 20 class SolverSingular : public Solver 21 21 { 22 public: 23 SolverSingular() : 24 Solver() 25 {} 26 27 SolverSingular(int size) : 28 Solver(size) 29 {} 30 22 31 private: 23 32 void AssembleMatrix(const Grid& rhs); ///< Assembles all matrices and vectors.
Note:
See TracChangeset
for help on using the changeset viewer.
