Skip to content
Snippets Groups Projects
Commit 8982155a authored by Andreas Dedner's avatar Andreas Dedner
Browse files

Merge branch 'bugfix/removeGeneratedFilesFromGit' into 'master'

fix an issue caused by generated files being added to source tree - move to a temporary location

Closes #111

See merge request !529
parents 0eac47eb 1184becc
No related branches found
No related tags found
1 merge request!529fix an issue caused by generated files being added to source tree - move to a temporary location
Pipeline #66032 passed
%%MatrixMarket matrix coordinate real general
% SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
% SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
% ISTL_STRUCT blocked 1 1
5 5 5
1 1 1.000000e+00
2 2 1.000000e+00
3 3 1.000000e+00
4 4 1.000000e+00
5 5 1.000000e+00
# SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root # SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root
# SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception # SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
import tempfile,os
import dune.common import dune.common
from dune.istl import blockVector, BlockVector, bcrsMatrix, BCRSMatrix, SeqJacobi, CGSolver, BuildMode from dune.istl import blockVector, BlockVector, bcrsMatrix, BCRSMatrix, SeqJacobi, CGSolver, BuildMode
...@@ -55,37 +56,40 @@ if mat.shape != (5, 5) or mat.nonZeroes != 5 or mat.buildMode != BuildMode.impli ...@@ -55,37 +56,40 @@ if mat.shape != (5, 5) or mat.nonZeroes != 5 or mat.buildMode != BuildMode.impli
# BMatrix = BCRSMatrix(Matrix) # BMatrix = BCRSMatrix(Matrix)
# mat = BMatrix((5,5), 5, BuildMode.implicit) # mat = BMatrix((5,5), 5, BuildMode.implicit)
# store identity matrix # generate a temporary directory to test 'store', 'load':
mat = identity(5)
if not isIdentity(mat): with tempfile.TemporaryDirectory() as tmpDir:
raise Exception("Identity matrix not setup correctly") # store identity matrix
mat.store("bcrsmatrix.mm", "matrixmarket") mat = identity(5)
if not isIdentity(mat):
for i, row in mat.enumerate: raise Exception("Identity matrix not setup correctly")
for j, col in row.enumerate: mat.store(os.path.join(tmpDir,"bcrsmatrix.mm"), "matrixmarket")
if i != j:
raise Exception("Wrong sparsity pattern") for i, row in mat.enumerate:
if col != 1: for j, col in row.enumerate:
raise Exception("Diagonal entry is not 1") if i != j:
raise Exception("Wrong sparsity pattern")
mat = identity(5, BuildMode.implicit) if col != 1:
if not isIdentity(mat): raise Exception("Diagonal entry is not 1")
raise Exception("Identity matrix not setup correctly")
mat = identity(5, BuildMode.implicit)
# manipulate diagonal to 2 if not isIdentity(mat):
for i in range(mat.rows): raise Exception("Identity matrix not setup correctly")
mat[i, i] *= 2
if isIdentity(mat): # manipulate diagonal to 2
raise Exception("Matrix not manipulated") for i in range(mat.rows):
mat[i, i] *= 2
# reload identity matrix if isIdentity(mat):
mat = bcrsMatrix() raise Exception("Matrix not manipulated")
mat.load("bcrsmatrix.mm", "matrixmarket")
if not isIdentity(mat): # reload identity matrix
raise Exception("Matrix not loaded correctly") mat = bcrsMatrix()
mat.load(os.path.join(tmpDir,"bcrsmatrix.mm"), "matrixmarket")
# store in matlab format if not isIdentity(mat):
mat.store("bcrsmatrix.txt", "matlab") raise Exception("Matrix not loaded correctly")
# store in matlab format
mat.store(os.path.join(tmpDir,"bcrsmatrix.txt"), "matlab")
# solve trivial linear system # solve trivial linear system
x = blockVector(5) x = blockVector(5)
......
1 1 1
2 2 1
3 3 1
4 4 1
5 5 1
SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment