Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pairs
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
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
software
pairs
Commits
af50711f
Commit
af50711f
authored
4 years ago
by
Rafael Ravedutti Lucio Machado
Browse files
Options
Downloads
Patches
Plain Diff
Fix linter warnings for lifting
Signed-off-by:
Rafael Ravedutti Lucio Machado
<
rafael.r.ravedutti@fau.de
>
parent
56a5af5c
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
coupling/parse_cpp.py
+34
-15
34 additions, 15 deletions
coupling/parse_cpp.py
lift.py
+2
-2
2 additions, 2 deletions
lift.py
with
36 additions
and
17 deletions
coupling/parse_cpp.py
+
34
−
15
View file @
af50711f
...
@@ -17,6 +17,7 @@ def print_tree(node, indent=0):
...
@@ -17,6 +17,7 @@ def print_tree(node, indent=0):
for
child
in
node
.
get_children
():
for
child
in
node
.
get_children
():
print_tree
(
child
,
indent
+
2
)
print_tree
(
child
,
indent
+
2
)
def
get_subtree
(
node
,
ref
):
def
get_subtree
(
node
,
ref
):
splitted_ref
=
ref
.
split
(
"
::
"
,
1
)
splitted_ref
=
ref
.
split
(
"
::
"
,
1
)
if
len
(
splitted_ref
)
==
2
:
if
len
(
splitted_ref
)
==
2
:
...
@@ -32,11 +33,11 @@ def get_subtree(node, ref):
...
@@ -32,11 +33,11 @@ def get_subtree(node, ref):
child
.
spelling
==
look_for
child
.
spelling
==
look_for
cond_func
=
remaining
is
None
and
\
cond_func
=
remaining
is
None
and
\
(
child
.
kind
==
kind
.
FUNCTION_TEMPLATE
or
\
(
child
.
kind
==
kind
.
FUNCTION_TEMPLATE
or
child
.
kind
==
kind
.
CXX_METHOD
or
\
child
.
kind
==
kind
.
CXX_METHOD
or
child
.
kind
==
kind
.
NAMESPACE
or
\
child
.
kind
==
kind
.
NAMESPACE
or
child
.
kind
==
kind
.
CLASS_DECL
)
and
\
child
.
kind
==
kind
.
CLASS_DECL
)
and
\
child
.
spelling
==
look_for
child
.
spelling
==
look_for
if
cond_namespace
or
cond_func
:
if
cond_namespace
or
cond_func
:
if
remaining
is
None
:
if
remaining
is
None
:
...
@@ -48,14 +49,15 @@ def get_subtree(node, ref):
...
@@ -48,14 +49,15 @@ def get_subtree(node, ref):
return
None
return
None
def
get_class_method
(
node
,
class_ref
,
function_name
):
def
get_class_method
(
node
,
class_ref
,
function_name
):
class_ref_
=
class_ref
if
class_ref
.
startswith
(
"
class
"
)
\
class_ref_
=
class_ref
if
class_ref
.
startswith
(
"
class
"
)
\
else
"
class
"
+
class_ref
else
"
class
"
+
class_ref
for
child
in
node
.
get_children
():
for
child
in
node
.
get_children
():
if
child
.
spelling
==
function_name
and
\
if
child
.
spelling
==
function_name
and
\
(
child
.
kind
==
kind
.
CXX_METHOD
or
\
(
child
.
kind
==
kind
.
CXX_METHOD
or
child
.
kind
==
kind
.
FUNCTION_TEMPLATE
):
child
.
kind
==
kind
.
FUNCTION_TEMPLATE
):
for
grandchild
in
child
.
get_children
():
for
grandchild
in
child
.
get_children
():
if
grandchild
.
kind
==
kind
.
TYPE_REF
and
\
if
grandchild
.
kind
==
kind
.
TYPE_REF
and
\
grandchild
.
spelling
==
class_ref_
:
grandchild
.
spelling
==
class_ref_
:
...
@@ -67,19 +69,21 @@ def get_class_method(node, class_ref, function_name):
...
@@ -67,19 +69,21 @@ def get_class_method(node, class_ref, function_name):
return
None
return
None
def
getVelocityAtWFPoint
(
sim
,
params
):
def
getVelocityAtWFPoint
(
sim
,
params
):
p_idx
=
params
[
0
]
p_idx
=
params
[
0
]
#ac = params[1]
#
ac = params[1]
wf_pt
=
params
[
2
]
wf_pt
=
params
[
2
]
lin_vel
=
sim
.
property
(
'
velocity
'
)
lin_vel
=
sim
.
property
(
'
velocity
'
)
ang_vel
=
sim
.
property
(
'
angular_velocity
'
)
ang_vel
=
sim
.
property
(
'
angular_velocity
'
)
position
=
sim
.
property
(
'
position
'
)
position
=
sim
.
property
(
'
position
'
)
return
lin_vel
[
p_idx
]
+
ang_vel
[
p_idx
]
*
(
wf_pt
-
position
[
p_idx
])
return
lin_vel
[
p_idx
]
+
ang_vel
[
p_idx
]
*
(
wf_pt
-
position
[
p_idx
])
def
addForceAtWFPosAtomic
(
sim
,
params
):
def
addForceAtWFPosAtomic
(
sim
,
params
):
p_idx
=
params
[
0
]
p_idx
=
params
[
0
]
#ac = params[1]
#
ac = params[1]
f
=
params
[
2
]
f
=
params
[
2
]
wf_pt
=
params
[
3
]
wf_pt
=
params
[
3
]
force
=
sim
.
property
(
'
force
'
)
force
=
sim
.
property
(
'
force
'
)
torque
=
sim
.
property
(
'
torque
'
)
torque
=
sim
.
property
(
'
torque
'
)
...
@@ -87,33 +91,39 @@ def addForceAtWFPosAtomic(sim, params):
...
@@ -87,33 +91,39 @@ def addForceAtWFPosAtomic(sim, params):
force
[
p_idx
].
add
(
f
)
force
[
p_idx
].
add
(
f
)
torque
[
p_idx
].
add
((
wf_pt
-
position
[
p_idx
])
*
f
)
torque
[
p_idx
].
add
((
wf_pt
-
position
[
p_idx
])
*
f
)
def
getType
(
sim
,
params
):
def
getType
(
sim
,
params
):
return
sim
.
property
(
'
type
'
)[
params
[
0
]]
return
sim
.
property
(
'
type
'
)[
params
[
0
]]
def
getStiffness
(
sim
,
params
):
def
getStiffness
(
sim
,
params
):
type_a
=
params
[
0
]
type_a
=
params
[
0
]
type_b
=
params
[
1
]
type_b
=
params
[
1
]
ntypes
=
sim
.
var
(
'
ntypes
'
)
ntypes
=
sim
.
var
(
'
ntypes
'
)
return
sim
.
array
(
'
stiffness
'
)[
type_a
*
ntypes
+
type_b
]
return
sim
.
array
(
'
stiffness
'
)[
type_a
*
ntypes
+
type_b
]
def
getDampingN
(
sim
,
params
):
def
getDampingN
(
sim
,
params
):
type_a
=
params
[
0
]
type_a
=
params
[
0
]
type_b
=
params
[
1
]
type_b
=
params
[
1
]
ntypes
=
sim
.
var
(
'
ntypes
'
)
ntypes
=
sim
.
var
(
'
ntypes
'
)
return
sim
.
array
(
'
damping_n
'
)[
type_a
*
ntypes
+
type_b
]
return
sim
.
array
(
'
damping_n
'
)[
type_a
*
ntypes
+
type_b
]
def
getDampingT
(
sim
,
params
):
def
getDampingT
(
sim
,
params
):
type_a
=
params
[
0
]
type_a
=
params
[
0
]
type_b
=
params
[
1
]
type_b
=
params
[
1
]
ntypes
=
sim
.
var
(
'
ntypes
'
)
ntypes
=
sim
.
var
(
'
ntypes
'
)
return
sim
.
array
(
'
damping_t
'
)[
type_a
*
ntypes
+
type_b
]
return
sim
.
array
(
'
damping_t
'
)[
type_a
*
ntypes
+
type_b
]
def
getFriction
(
sim
,
params
):
def
getFriction
(
sim
,
params
):
type_a
=
params
[
0
]
type_a
=
params
[
0
]
type_b
=
params
[
1
]
type_b
=
params
[
1
]
ntypes
=
sim
.
var
(
'
ntypes
'
)
ntypes
=
sim
.
var
(
'
ntypes
'
)
return
sim
.
array
(
'
friction
'
)[
type_a
*
ntypes
+
type_b
]
return
sim
.
array
(
'
friction
'
)[
type_a
*
ntypes
+
type_b
]
def
getNormalizedOrZero
(
sim
,
params
):
def
getNormalizedOrZero
(
sim
,
params
):
vec
=
params
[
0
]
vec
=
params
[
0
]
sqr_length
=
vec
[
0
]
*
vec
[
0
]
+
vec
[
1
]
*
vec
[
1
]
+
vec
[
2
]
*
vec
[
2
]
sqr_length
=
vec
[
0
]
*
vec
[
0
]
+
vec
[
1
]
*
vec
[
1
]
+
vec
[
2
]
*
vec
[
2
]
...
@@ -123,15 +133,18 @@ def getNormalizedOrZero(sim, params):
...
@@ -123,15 +133,18 @@ def getNormalizedOrZero(sim, params):
sqr_length
<
epsilon
*
epsilon
,
sqr_length
<
epsilon
*
epsilon
,
vec
,
vec
*
(
1.0
/
Sqrt
(
sqr_length
)))
vec
,
vec
*
(
1.0
/
Sqrt
(
sqr_length
)))
def
length
(
sim
,
params
):
def
length
(
sim
,
params
):
vec
=
params
[
0
]
vec
=
params
[
0
]
return
Sqrt
(
vec
[
0
]
*
vec
[
0
]
+
vec
[
1
]
*
vec
[
1
]
+
vec
[
2
]
*
vec
[
2
])
return
Sqrt
(
vec
[
0
]
*
vec
[
0
]
+
vec
[
1
]
*
vec
[
1
]
+
vec
[
2
]
*
vec
[
2
])
def
dot
(
sim
,
params
):
def
dot
(
sim
,
params
):
vec1
=
params
[
0
]
vec1
=
params
[
0
]
vec2
=
params
[
1
]
vec2
=
params
[
1
]
return
vec1
[
0
]
*
vec2
[
0
]
+
vec1
[
1
]
*
vec2
[
1
]
+
vec1
[
2
]
*
vec2
[
2
]
return
vec1
[
0
]
*
vec2
[
0
]
+
vec1
[
1
]
*
vec2
[
1
]
+
vec1
[
2
]
*
vec2
[
2
]
def
map_kernel_to_simulation
(
sim
,
node
):
def
map_kernel_to_simulation
(
sim
,
node
):
contactPoint
=
sim
.
add_var
(
'
contactPoint
'
,
Type_Vector
)
contactPoint
=
sim
.
add_var
(
'
contactPoint
'
,
Type_Vector
)
contactNormal
=
sim
.
add_var
(
'
contactNormal
'
,
Type_Vector
)
contactNormal
=
sim
.
add_var
(
'
contactNormal
'
,
Type_Vector
)
...
@@ -160,6 +173,7 @@ def map_kernel_to_simulation(sim, node):
...
@@ -160,6 +173,7 @@ def map_kernel_to_simulation(sim, node):
}
}
})
})
def
map_method_tree
(
sim
,
node
,
assignments
=
{},
mappings
=
{}):
def
map_method_tree
(
sim
,
node
,
assignments
=
{},
mappings
=
{}):
if
node
is
not
None
:
if
node
is
not
None
:
if
node
.
kind
==
kind
.
FUNCTION_TEMPLATE
:
if
node
.
kind
==
kind
.
FUNCTION_TEMPLATE
:
...
@@ -184,7 +198,7 @@ def map_method_tree(sim, node, assignments={}, mappings={}):
...
@@ -184,7 +198,7 @@ def map_method_tree(sim, node, assignments={}, mappings={}):
if
node
.
kind
==
kind
.
DECL_STMT
:
if
node
.
kind
==
kind
.
DECL_STMT
:
child
=
node
.
get_children
()[
0
]
child
=
node
.
get_children
()[
0
]
if
child
.
kind
==
kind
.
VAR_DECL
:
if
child
.
kind
==
kind
.
VAR_DECL
:
#decl_type = child.get_children()[0]
#
decl_type = child.get_children()[0]
decl_expr
=
child
.
get_children
()[
1
]
decl_expr
=
child
.
get_children
()[
1
]
assignments
[
child
.
spelling
]
=
\
assignments
[
child
.
spelling
]
=
\
map_expression
(
sim
,
decl_expr
,
assignments
,
mappings
)
map_expression
(
sim
,
decl_expr
,
assignments
,
mappings
)
...
@@ -206,6 +220,7 @@ def map_method_tree(sim, node, assignments={}, mappings={}):
...
@@ -206,6 +220,7 @@ def map_method_tree(sim, node, assignments={}, mappings={}):
return
None
return
None
def
map_call
(
sim
,
node
,
assignments
,
mappings
):
def
map_call
(
sim
,
node
,
assignments
,
mappings
):
func_name
=
None
func_name
=
None
params
=
[]
params
=
[]
...
@@ -214,8 +229,9 @@ def map_call(sim, node, assignments, mappings):
...
@@ -214,8 +229,9 @@ def map_call(sim, node, assignments, mappings):
if
child
.
kind
==
kind
.
DECL_REF_EXPR
:
if
child
.
kind
==
kind
.
DECL_REF_EXPR
:
grandchild
=
child
.
get_children
()[
0
]
grandchild
=
child
.
get_children
()[
0
]
namespace
=
map_namespace
(
grandchild
)
namespace
=
map_namespace
(
grandchild
)
func_name
=
grandchild
.
spelling
if
namespace
is
None
\
func_name
=
\
else
f
"
{
namespace
}
::
{
grandchild
.
spelling
}
"
grandchild
.
spelling
if
namespace
is
None
\
else
f
"
{
namespace
}
::
{
grandchild
.
spelling
}
"
if
child
.
kind
==
kind
.
MEMBER_REF_EXPR
:
if
child
.
kind
==
kind
.
MEMBER_REF_EXPR
:
params
.
append
(
map_expression
(
params
.
append
(
map_expression
(
...
@@ -228,6 +244,7 @@ def map_call(sim, node, assignments, mappings):
...
@@ -228,6 +244,7 @@ def map_call(sim, node, assignments, mappings):
f
"
No mapping for function:
{
func_name
}
"
f
"
No mapping for function:
{
func_name
}
"
return
mappings
[
'
function_mappings
'
][
func_name
](
sim
,
params
)
return
mappings
[
'
function_mappings
'
][
func_name
](
sim
,
params
)
def
map_namespace
(
node
):
def
map_namespace
(
node
):
namespace
=
None
namespace
=
None
children
=
node
.
get_children
()
children
=
node
.
get_children
()
...
@@ -241,6 +258,7 @@ def map_namespace(node):
...
@@ -241,6 +258,7 @@ def map_namespace(node):
return
namespace
return
namespace
def
map_expression
(
sim
,
node
,
assignments
,
mappings
):
def
map_expression
(
sim
,
node
,
assignments
,
mappings
):
if
node
.
kind
==
kind
.
UNEXPOSED_EXPR
:
if
node
.
kind
==
kind
.
UNEXPOSED_EXPR
:
return
map_expression
(
return
map_expression
(
...
@@ -258,17 +276,18 @@ def map_expression(sim, node, assignments, mappings):
...
@@ -258,17 +276,18 @@ def map_expression(sim, node, assignments, mappings):
return
None
return
None
def
parse_walberla_file
(
filename
):
def
parse_walberla_file
(
filename
):
walberla_path
=
"
/home/rzlin/az16ahoq/repositories/walberla
"
walberla_path
=
"
/home/rzlin/az16ahoq/repositories/walberla
"
walberla_src
=
f
"
{
walberla_path
}
/src
"
walberla_src
=
f
"
{
walberla_path
}
/src
"
walberla_build_src
=
f
"
{
walberla_path
}
/build/src
"
walberla_build_src
=
f
"
{
walberla_path
}
/build/src
"
clang_include_path
=
"
/software/anydsl/llvm_build/lib/clang/7.0.1/include
"
clang_include_path
=
"
/software/anydsl/llvm_build/lib/clang/7.0.1/include
"
mpi_include_path
=
"
/software/openmpi/4.0.0-llvm/include
"
mpi_include_path
=
"
/software/openmpi/4.0.0-llvm/include
"
index
=
clang
.
cindex
.
Index
.
create
()
index
=
clang
.
cindex
.
Index
.
create
()
tu
=
index
.
parse
(
tu
=
index
.
parse
(
f
"
{
walberla_src
}
/
{
filename
}
"
,
f
"
{
walberla_src
}
/
{
filename
}
"
,
args
=
[
args
=
[
"
-Wall
"
,
"
-Wall
"
,
f
"
-I
{
walberla_src
}
"
,
f
"
-I
{
walberla_src
}
"
,
f
"
-I
{
walberla_build_src
}
"
,
f
"
-I
{
walberla_build_src
}
"
,
...
...
This diff is collapsed.
Click to expand it.
lift.py
+
2
−
2
View file @
af50711f
...
@@ -4,8 +4,8 @@ from coupling.parse_cpp import get_class_method, print_tree
...
@@ -4,8 +4,8 @@ from coupling.parse_cpp import get_class_method, print_tree
filename
=
"
mesa_pd/kernel/SpringDashpot.hpp
"
filename
=
"
mesa_pd/kernel/SpringDashpot.hpp
"
translation_unit
=
parse_walberla_file
(
filename
)
translation_unit
=
parse_walberla_file
(
filename
)
#subtree = get_subtree(tu.cursor, "walberla::mesa_pd::kernel")
#
subtree = get_subtree(tu.cursor, "walberla::mesa_pd::kernel")
#print_tree(subtree)
#
print_tree(subtree)
kernel
=
get_class_method
(
kernel
=
get_class_method
(
translation_unit
.
cursor
,
translation_unit
.
cursor
,
...
...
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