Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-istl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Core Modules
dune-istl
Commits
7719d1be
Commit
7719d1be
authored
7 years ago
by
Andreas Dedner
Committed by
Matthew Collins
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
some clean up
parent
16b4b397
No related branches found
No related tags found
1 merge request
!369
Feature/add python bindings
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bvector.hh
+19
-37
19 additions, 37 deletions
bvector.hh
with
19 additions
and
37 deletions
bvector.hh
+
19
−
37
View file @
7719d1be
...
...
@@ -181,42 +181,6 @@ namespace Dune
// registserBlockVector
// --------------------
//the auto class is needed so that run.algorithm can properly work
template
<
class
BlockVector
>
inline
pybind11
::
class_
<
BlockVector
>
registerBlockVector
(
pybind11
::
handle
scope
,
const
char
*
clsName
=
"BlockVector"
)
{
typedef
typename
BlockVector
::
size_type
size_type
;
using
pybind11
::
operator
""
_a
;
//pybind11::class_< BlockVector > cls( scope, clsName );
int
rows
=
BlockVector
::
block_type
::
dimension
;
std
::
string
vectorTypename
=
"Dune::BlockVector< Dune::FieldVector< double, "
+
std
::
to_string
(
rows
)
+
" > >"
;
auto
cls
=
Dune
::
Python
::
insertClass
<
BlockVector
>
(
scope
,
clsName
,
Dune
::
Python
::
GenerateTypeName
(
vectorTypename
),
Dune
::
Python
::
IncludeFiles
{
"dune/istl/bvector.hh"
,
"dune/python/istl/bvector.hh"
}).
first
;
//can't find insertClass not loaded yet?
registerBlockVector
(
cls
);
cls
.
def
(
pybind11
::
init
(
[]
()
{
return
new
BlockVector
();
}
)
);
cls
.
def
(
pybind11
::
init
(
[]
(
size_type
size
)
{
return
new
BlockVector
(
size
);
}
),
"size"
_a
);
cls
.
def
(
pybind11
::
init
(
[]
(
pybind11
::
buffer
buffer
)
{
BlockVector
*
self
=
new
BlockVector
();
detail
::
copy
(
buffer
,
*
self
);
return
self
;
}
)
);
cls
.
def
(
"__str__"
,
[]
(
const
BlockVector
&
self
)
{
return
to_string
(
self
);
}
);
cls
.
def
(
"assign"
,
[]
(
BlockVector
&
self
,
pybind11
::
buffer
buffer
)
{
detail
::
copy
(
buffer
,
self
);
},
"buffer"
_a
);
cls
.
def_property_readonly
(
"capacity"
,
[]
(
const
BlockVector
&
self
)
{
return
self
.
capacity
();
}
);
cls
.
def
(
"resize"
,
[]
(
BlockVector
&
self
,
size_type
size
)
{
self
.
resize
(
size
);
},
"size"
_a
);
return
cls
;
}
//for the new bindings and arbitrary block size haven't
//the generator acutally takes the scope into account which is why we do nothing with it here
//so when doing a dune.istl blockvector it doesn't actually define any of the rest ofthe bindings
...
...
@@ -238,7 +202,7 @@ namespace Dune
}
)
);
//cls.def( "__str__", [] ( const BlockVector &self ) { return to_string( self ); } );
//
cls.def( "__str__", [] ( const BlockVector &self ) { return to_string( self ); } );
cls
.
def
(
"assign"
,
[]
(
BlockVector
&
self
,
pybind11
::
buffer
buffer
)
{
detail
::
copy
(
buffer
,
self
);
},
"buffer"
_a
);
...
...
@@ -248,6 +212,24 @@ namespace Dune
}
//the auto class is needed so that run.algorithm can properly work
template
<
class
BlockVector
>
inline
pybind11
::
class_
<
BlockVector
>
registerBlockVector
(
pybind11
::
handle
scope
,
const
char
*
clsName
=
"BlockVector"
)
{
typedef
typename
BlockVector
::
size_type
size_type
;
using
pybind11
::
operator
""
_a
;
int
rows
=
BlockVector
::
block_type
::
dimension
;
std
::
string
vectorTypename
=
"Dune::BlockVector< Dune::FieldVector< double, "
+
std
::
to_string
(
rows
)
+
" > >"
;
auto
cls
=
Dune
::
Python
::
insertClass
<
BlockVector
>
(
scope
,
clsName
,
Dune
::
Python
::
GenerateTypeName
(
vectorTypename
),
Dune
::
Python
::
IncludeFiles
{
"dune/istl/bvector.hh"
,
"dune/python/istl/bvector.hh"
});
//can't find insertClass not loaded yet?
if
(
cls
.
second
)
registerBlockVector
(
scope
,
cls
.
first
);
return
cls
.
first
;
}
}
// namespace Python
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment