diff --git a/__init__.py b/__init__.py index 1765b990cbd0079e1fefb0ff014d020c70762a22..8d267aae64dbb85772fba087f0d9a08a457cba6b 100644 --- a/__init__.py +++ b/__init__.py @@ -1,11 +1,14 @@ from .. import common from .._istl import BCRSMatrix as BCRSMatrix11 +from .._istl import BlockVector as BlockVector1 from .._istl import * from dune.generator.generator import SimpleGenerator from dune.common.hashit import hashIt generator = SimpleGenerator("BCRSMatrix","Dune::Python") +generatorvec = SimpleGenerator("BlockVector","Dune::Python") + def load(includes ,typeName ,constructors=None, methods=None): #this contains the registration functions for the class @@ -13,12 +16,32 @@ def load(includes ,typeName ,constructors=None, methods=None): typeHash = "istlbcrsmatrix_" + hashIt(typeName) return generator.load(includes ,typeName ,typeHash ,constructors ,methods) + +def loadvec(includes ,typeName ,constructors=None, methods=None): + + #this contains the registration functions for the class + includes = includes + ["dune/python/istl/bvector.hh"] + typeHash = "istlbvector_" + hashIt(typeName) + return generatorvec.load(includes ,typeName ,typeHash ,constructors ,methods) + + def BCRSMatrix(blockSize): if blockSize[0] == blockSize[1] == 1: + print("returning singular object") return BCRSMatrix11 typeName = "Dune::BCRSMatrix< Dune::FieldMatrix< double,"\ + str(blockSize[0]) + "," + str(blockSize[1]) \ + " > >" includes = ["dune/istl/bcrsmatrix.hh"] + print("returning bigger object") # todo: provide other constructors return load(includes, typeName).BCRSMatrix + + +def BlockVector(blockSize): + if blockSize == 1: + return BlockVector1 + typeName = "Dune::BlockVector< Dune::FieldVector< double," + str(blockSize) + " > >" + includes = ["dune/istl/bvector.hh"] + # todo: provide other constructors + return loadvec(includes, typeName).BlockVector