Skip to content

Commit

Permalink
minor bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
EamonnGlynn committed Jul 14, 2024
1 parent 65298f1 commit f982cc7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
1 change: 1 addition & 0 deletions src/pmpo_MPMesh_assembly.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ void MPMesh::assemblyVtx1() {
auto elm2VtxConn = p_mesh->getElm2VtxConn();
auto mpData = p_MPs->getData<mpfIndex>();
const int numEntries = mpSliceToNumEntries<mpfIndex>();
auto weight = p_MPs->getData<MPF_Basis_Vals>();

p_mesh->fillMeshField<meshFieldIndex>(0.0);
auto meshField = p_mesh->getMeshField<meshFieldIndex>();
Expand Down
30 changes: 15 additions & 15 deletions src/pmpo_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,55 +216,55 @@ class Matrix {
| v3[0] v3[1] v3[2] v3[3] |
*/
private:
Kokkos::View<double**> data_;
std::vector<std::vector<double>> data_;
int rows_;
int cols_;

public:

KOKKOS_INLINE_FUNCTION
Matrix(Vec4d v0, Vec4d v1, Vec4d v2, Vec4d v3){
data_ = Kokkos::View<double**>("Matrix", 4, 4);
data_ = std::vector<std::vector<double>>(4, std::vector<double>(4, 0));
rows_ = 4;
cols_ = 4;

for (int i=0; i<4; i++){
data_(0, i) = v0[i];
data_(1, i) = v1[i];
data_(2, i) = v2[i];
data_(3, i) = v3[i];
data_[0][i] = v0[i];
data_[1][i] = v1[i];
data_[2][i] = v2[i];
data_[3][i] = v3[i];
}
}

KOKKOS_INLINE_FUNCTION
Kokkos::View<double*> solve(Kokkos::View<double*> b){
std::vector<double> solve(std::vector<double> b){
//create a view to store the solution x, initialize to 0
Kokkos::View<double*> x("x", rows_);
std::vector<double> x(rows_, 0);
for(int i=0; i<rows_; i++){
x(i) = 0;
x[i] = 0;
}
for (int i=0; i<rows_; i++){
double pivot = data_(i, i);
double pivot = data_[i][i];
for( int j = i+1; j<rows_; j++){
double ratio = data_(j, i) / pivot;
double ratio = data_[j, i] / pivot;
for(int k = i; k<cols_; k++){
data_(j, k) -= ratio * data_(i, k);
data_[j, k] -= ratio * data_[i, k];
}
b(j) -= ratio * b(i);
}
}
for(int i = rows_-1; i>=0; i--){
double sum = 0;
for(int j = i+1; j<cols_; j++){
sum += data_(i, j) * x(j);
sum += data_[i, j] * x[j];
}
x(i) = (b(i) - sum) / data_(i, i);
x[i] = (b[i] - sum) / data_[i, i];
}
return x;
}

KOKKOS_INLINE_FUNCTION
double operator()(int i, int j) const { return data_(i, j); }
double operator()(int i, int j) const { return data_[i][j];}


};
Expand Down

0 comments on commit f982cc7

Please sign in to comment.