Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XDMF Scripts: Fix Replacements & Offset #2309

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/tools/bin/pic2xdmf.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
NAME_DELIM = "/"

# PIC-specific names
NAME_GLOBALCELLIDX = "globalCellIdx"
NAME_GLOBALCELLIDX = "positionOffset"
NAME_POSITION = "position"


Expand Down Expand Up @@ -151,8 +151,8 @@ def join_references_from_components(node_list, original_nodes_map, prefix,
extra_grid = "Grid[@Name='{}']/".format(
parent_node.getAttribute("Name"))

node_text = "/Xdmf/Domain/Grid/{}Attribute[@Name='{}']/" + \
"DataItem[1]".format(extra_grid, orig_name)
node_text = ("/Xdmf/Domain/Grid/{}Attribute[@Name='{}']/"
"DataItem[1]").format(extra_grid, orig_name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OPTIONAL:
A plus sign + is optional here but would improve readability of the code to emphasize that here the second string is attached.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same below

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not add it since it is superfluous like additional brackets.
the way it is now is the common way to do it properly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay

reference_text = doc.createTextNode(node_text)
reference.appendChild(reference_text)
join_base.appendChild(reference)
Expand Down Expand Up @@ -437,13 +437,14 @@ def merge_poly_attributes(base_node):
return

if len(gcellidx_vector_list) < 2 or len(gcellidx_vector_list) > 3:
print("Error: Attributes for '{}' in group '{}' are not a 2/3 " +
"component vector".format(NAME_GLOBALCELLIDX, groupName))
print(("Error: Attributes for '{}' in group '{}' are not a 2/3 "
"component vector").format(NAME_GLOBALCELLIDX, groupName))
return

if len(gcellidx_vector_list) != len(pos_vector_list):
print("Error: Vectors for '{}' and '{}' in group '{}' do not " +
"match".format(NAME_GLOBALCELLIDX, NAME_POSITION, groupName))
print(("Error: Vectors for '{}' and '{}' in group '{}' do not "
"match").format(NAME_GLOBALCELLIDX, NAME_POSITION,
groupName))
return

combined_pos_nodes = list()
Expand Down