Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-codegen
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Christian Heinigk
dune-codegen
Commits
8b9121bd
Commit
8b9121bd
authored
8 years ago
by
René Heß
Browse files
Options
Downloads
Patches
Plain Diff
Global imports in compile.py
parent
81d066bb
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
python/dune/perftool/compile.py
+30
-17
30 additions, 17 deletions
python/dune/perftool/compile.py
with
30 additions
and
17 deletions
python/dune/perftool/compile.py
+
30
−
17
View file @
8b9121bd
...
...
@@ -4,24 +4,46 @@ The methods to run the parts of the form compiler
Should also contain the entrypoint methods.
"""
from
__future__
import
absolute_import
from
os.path
import
splitext
from
os.path
import
basename
,
splitext
# Disable loopy caching before we do anything else!
import
loopy
from
ufl.algorithms
import
compute_form_data
,
read_ufl_file
from
ufl.algorithms.formfiles
import
interpret_ufl_namespace
from
dune.perftool.generation
import
delete_cache_items
,
global_context
from
dune.perftool.interactive
import
start_interactive_session
from
dune.perftool.options
import
get_option
from
dune.perftool.pdelab.driver
import
generate_driver
from
dune.perftool.pdelab.localoperator
import
(
generate_localoperator_basefile
,
generate_localoperator_file
,
generate_localoperator_kernels
,
name_localoperator_file
)
from
dune.perftool.ufl.preprocess
import
preprocess_form
# Disable loopy caching before we do anything else!
loopy
.
CACHING_ENABLED
=
False
def
read_ufl
(
uflfile
):
from
ufl.algorithms.formfiles
import
read_ufl_file
,
interpret_ufl_namespace
from
ufl.algorithms
import
compute_form_data
"""
Read uflfile file, extract and preprocess forms
Arguments:
----------
uflfile: Path to ufl file.
Returns:
--------
formdatas: List of formdatas found in uflfile.
forms: List of forms found in uflfile.
"""
# Read the given ufl file and execute it
uflcode
=
read_ufl_file
(
uflfile
)
namespace
=
globals
()
try
:
exec
(
"
from dune.perftool.ufl.execution import *
\n
"
+
uflcode
,
namespace
)
except
:
import
os
basename
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
uflfile
))[
0
]
basename
=
"
{}_debug
"
.
format
(
basename
)
pyname
=
"
{}.py
"
.
format
(
basename
)
...
...
@@ -31,12 +53,11 @@ def read_ufl(uflfile):
f
.
write
(
pycode
)
raise
SyntaxError
(
"
Not a valid ufl file, dumped a debug script: {}
"
.
format
(
pyname
))
# Extract
the form from the given data
# Extract
and preprocess the forms
data
=
interpret_ufl_namespace
(
namespace
)
formdatas
=
[]
forms
=
data
.
forms
for
index
,
form
in
enumerate
(
forms
):
from
dune.perftool.ufl.preprocess
import
preprocess_form
formdatas
.
append
(
preprocess_form
(
form
))
forms
[
index
]
=
formdatas
[
index
].
preprocessed_form
...
...
@@ -48,40 +69,32 @@ def read_ufl(uflfile):
# This function is the entrypoint of the ufl2pdelab executable
def
compile_form
():
from
dune.perftool.options
import
get_option
formdatas
,
data
=
read_ufl
(
get_option
(
"
uflfile
"
))
from
dune.perftool.generation
import
global_context
with
global_context
(
data
=
data
,
formdatas
=
formdatas
):
# Generate driver file
if
get_option
(
"
driver_file
"
):
from
dune.perftool.pdelab.driver
import
generate_driver
generate_driver
(
formdatas
,
data
)
# In case of multiple forms: Genarate one file that includes all localoperator files
if
len
(
formdatas
)
>
1
:
from
dune.perftool.pdelab.localoperator
import
generate_localoperator_basefile
generate_localoperator_basefile
(
formdatas
,
data
)
# Generate local operator files
for
formdata
in
formdatas
:
with
global_context
(
data
=
data
,
formdata
=
formdata
):
# Make sure cache is empty
from
dune.perftool.generation
import
delete_cache_items
delete_cache_items
()
# Create localoperator kernels
if
get_option
(
"
operator_file
"
):
from
dune.perftool.pdelab.localoperator
import
generate_localoperator_kernels
kernels
=
generate_localoperator_kernels
(
formdata
,
data
)
# TODO insert sophisticated analysis/feedback loops here
if
get_option
(
"
interactive
"
):
from
dune.perftool.interactive
import
start_interactive_session
start_interactive_session
(
kernels
)
# Create c++ file from kernels
if
get_option
(
"
operator_file
"
):
from
dune.perftool.pdelab.localoperator
import
name_localoperator_file
filename
=
name_localoperator_file
(
formdata
,
data
)
from
dune.perftool.pdelab.localoperator
import
generate_localoperator_file
generate_localoperator_file
(
formdata
,
kernels
,
filename
)
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