Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-fempy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
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
Matthew Collins
dune-fempy
Commits
98fe97a7
Commit
98fe97a7
authored
8 years ago
by
Martin Nolte
Browse files
Options
Downloads
Patches
Plain Diff
add registry for grid part modules
parent
aabd17cf
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
demo/gridpart-demo.py
+3
-5
3 additions, 5 deletions
demo/gridpart-demo.py
python/dune/fem/gridpart/__init__.py
+16
-5
16 additions, 5 deletions
python/dune/fem/gridpart/__init__.py
with
19 additions
and
10 deletions
demo/gridpart-demo.py
+
3
−
5
View file @
98fe97a7
...
...
@@ -4,7 +4,7 @@ from mpi4py import MPI
import
dune.common
as
common
from
dune.fem
import
leafGrid
from
dune.fem.gridpart
import
create
as
grid
P
art
from
dune.fem.gridpart
import
create
as
grid
p
art
#from dune.fem.gridpart.geometry import create as geometryGridPart
#from dune.fem.gridpart.filtered import create as filteredGridPart
...
...
@@ -16,8 +16,7 @@ def testGeometryGridPart(grid, prefix):
gf
=
grid
.
function
(
"
expr_global
"
,
order
=
1
,
globalExpr
=
expr_global
)
df
=
grid
.
interpolate
(
gf
,
space
=
"
Lagrange
"
,
name
=
"
test
"
)
geogp
=
gridPart
(
"
geometry
"
,
df
)
#geogp = geometryGridPart(df)
geogp
=
gridpart
(
"
Geometry
"
,
df
)
vtk
=
geogp
.
vtkWriter
()
gfnew
=
geogp
.
function
(
"
global
"
,
order
=
1
,
globalExpr
=
expr_global
)
gfnew
.
addToVTKWriter
(
vtk
,
common
.
DataType
.
PointData
)
...
...
@@ -34,8 +33,7 @@ def testGridPart(gridtype):
grid
=
leafGrid
(
"
../data/unitcube-2d.dgf
"
,
gridtype
,
dimgrid
=
2
)
testGeometryGridPart
(
grid
,
"
gridpart_demo
"
)
#subGrid = filteredGridPart(grid, lambda e: (e.geometry.center - [0.5, 0.5]).two_norm < 0.25)
subGrid
=
gridPart
(
"
filtered
"
,
grid
,
lambda
e
:
(
e
.
geometry
.
center
-
[
0.5
,
0.5
]).
two_norm
<
0.25
)
subGrid
=
gridpart
(
"
Filtered
"
,
grid
,
lambda
e
:
(
e
.
geometry
.
center
-
[
0.5
,
0.5
]).
two_norm
<
0.25
)
testGeometryGridPart
(
subGrid
,
"
gridpart_demo_sub
"
)
print
(
"
YASPGRID B
"
)
...
...
This diff is collapsed.
Click to expand it.
python/dune/fem/gridpart/__init__.py
+
16
−
5
View file @
98fe97a7
...
...
@@ -106,12 +106,23 @@ def module(includes, typeName, constructors=None, methods=None):
addAttr
(
module
,
module
.
GridPart
)
return
module
_modules
=
dict
()
def
register
(
**
modules
):
_modules
.
update
(
modules
)
def
create
(
gridpart
,
*
args
,
**
kwargs
):
try
:
gridpart
=
importlib
.
import_module
(
"
dune.fem.gridpart.
"
+
gridpart
)
return
gridpart
.
create
(
*
args
,
**
kwargs
)
except
ImportError
:
raise
ValueError
(
"
No grid part named
"
+
gridpart
)
gridpart
=
importlib
.
import_module
(
_modules
[
gridpart
])
return
gridpart
.
create
(
*
args
,
**
kwargs
)
# register our own grid parts
register
(
Geometry
=
"
dune.fem.gridpart.geometry
"
)
register
(
Filtered
=
"
dune.fem.gridpart.filtered
"
)
# enable doc test
if
__name__
==
"
__main__
"
:
import
doctest
...
...
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