Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs-utils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
ogs
OpenGeoSys Tools
ogs-utils
Commits
84e1ccb0
Commit
84e1ccb0
authored
7 years ago
by
Christoph Lehmann
Browse files
Options
Downloads
Patches
Plain Diff
added mapping to from boundary to bulk
parent
f34be1ce
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pre/BCs/map-boundary-mesh-to-bulk-mesh/README.md
+18
-0
18 additions, 0 deletions
pre/BCs/map-boundary-mesh-to-bulk-mesh/README.md
pre/BCs/map-boundary-mesh-to-bulk-mesh/map-boundary-to-bulk.py
+87
-0
87 additions, 0 deletions
...Cs/map-boundary-mesh-to-bulk-mesh/map-boundary-to-bulk.py
with
105 additions
and
0 deletions
pre/BCs/map-boundary-mesh-to-bulk-mesh/README.md
0 → 100644
+
18
−
0
View file @
84e1ccb0
# Map the nodes of a boundary mesh to the corresponding nodes of the given bulk mesh
## Requirements
*
Both meshes have to be conforming, i.e., the coordinates of the boundary mesh
must exactly coincide with the coordinates of some bulk mesh nodes
*
Put more explicitly: The coordinates in bulk and boundary must exactly match,
i.e., bit-wise, because this script does not apply any tolerances.
## What is output?
*
A nodal field
`bulk_mesh_node_ids`
is added to the given
`--boundary`
mesh.
This nodal field maps the nodes of the boundary mesh to the corresponding
nodes of the
`--bulk`
mesh.
*
The generated
`--output`
mesh can be used with OGS to specify (inhomogeneous)
Boundary conditions along arbitrary surfaces.
This diff is collapsed.
Click to expand it.
pre/BCs/map-boundary-mesh-to-bulk-mesh/map-boundary-to-bulk.py
0 → 100755
+
87
−
0
View file @
84e1ccb0
#!/usr/bin/env pvpython
import
inspect
import
argparse
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"
--bulk
"
,
type
=
str
,
required
=
True
)
parser
.
add_argument
(
"
--boundary
"
,
type
=
str
,
required
=
True
)
parser
.
add_argument
(
"
--output
"
,
type
=
str
,
required
=
True
)
args
=
parser
.
parse_args
()
#### import the simple module from the paraview
from
paraview.simple
import
*
#### disable automatic camera reset on 'Show'
paraview
.
simple
.
_DisableFirstRenderCameraReset
()
# create a new 'XML Unstructured Grid Reader'
reader_bulk
=
XMLUnstructuredGridReader
(
FileName
=
[
args
.
bulk
])
reader_boundary
=
XMLUnstructuredGridReader
(
FileName
=
[
args
.
boundary
])
def
do_mapping
():
bulk
=
self
.
GetInputDataObject
(
0
,
1
)
boundary
=
self
.
GetInputDataObject
(
0
,
0
)
points_bulk
=
bulk
.
GetPoints
()
points_boundary
=
boundary
.
GetPoints
()
N_boundary
=
points_boundary
.
GetNumberOfPoints
()
N_bulk
=
points_bulk
.
GetNumberOfPoints
()
# point_ids = vtk.vtkIdTypeArray() ## TODO why does that not work?
# point_ids = vtk.vtkLongArray()
point_ids
=
vtk
.
vtkUnsignedLongArray
()
point_ids
.
SetName
(
"
bulk_mesh_node_ids
"
)
point_ids
.
SetNumberOfComponents
(
1
)
point_ids
.
SetNumberOfTuples
(
N_boundary
)
i_bulk
=
0
map_coords_to_bulk_point_ids
=
{}
for
i_boundary
in
range
(
N_boundary
):
coords_boundary
=
points_boundary
.
GetPoint
(
i_boundary
)
try
:
point_id_bulk
=
map_coords_to_bulk_point_ids
[
coords_boundary
]
except
KeyError
:
# If point has not been mapped yet, search for it
# Note: This approach is not very efficient, and in the worst case
# it copies all bulk mesh nodes.
for
i_bulk
in
range
(
i_bulk
,
N_bulk
):
coords_bulk
=
points_bulk
.
GetPoint
(
i_bulk
)
if
coords_bulk
==
coords_boundary
:
point_id_bulk
=
i_bulk
# Breaking here makes sure that duplicate nodes are not
# found and an error message will be generated
break
map_coords_to_bulk_point_ids
[
coords_bulk
]
=
i_bulk
else
:
raise
ValueError
(
"
The boundary coordinates
"
+
str
(
coords_boundary
)
+
"
have not been found in the bulk mesh. Reasons might be
"
+
"
(i) those coordinates do not match any in the bulk mesh, or
"
+
"
(ii) those coordinates are duplicate in the boundary mesh
"
)
point_ids
.
SetComponent
(
i_boundary
,
0
,
point_id_bulk
)
self
.
GetOutputDataObject
(
0
).
GetPointData
().
AddArray
(
point_ids
)
# TODO map cells
boundary_bulk_mapping
=
ProgrammableFilter
(
Input
=
[
reader_boundary
,
reader_bulk
])
boundary_bulk_mapping
.
Script
=
inspect
.
getsource
(
do_mapping
)
+
"
\n\n
do_mapping()
"
boundary_bulk_mapping
.
RequestInformationScript
=
''
boundary_bulk_mapping
.
RequestUpdateExtentScript
=
''
boundary_bulk_mapping
.
PythonPath
=
''
boundary_bulk_mapping
.
CopyArrays
=
1
# save data
SaveData
(
args
.
output
,
proxy
=
boundary_bulk_mapping
,
DataMode
=
'
Binary
'
,
EncodeAppendedData
=
1
,
CompressorType
=
'
ZLib
'
)
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