From a6421f5b5e1fcb00390babb1a29571b7954675de Mon Sep 17 00:00:00 2001 From: Matthew Collins <m.t.collins@warwick.ac.uk> Date: Wed, 8 Nov 2017 15:45:40 +0000 Subject: [PATCH] edited init file to start coding up block vectors --- __init__.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/__init__.py b/__init__.py index 1765b990..8d267aae 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 -- GitLab