Skip to content

Commit

Permalink
Evaluating node range is failing on simple mesh.
Browse files Browse the repository at this point in the history
  • Loading branch information
hsorby committed Dec 6, 2024
1 parent 86f6b05 commit e787b9f
Show file tree
Hide file tree
Showing 2 changed files with 362 additions and 1 deletion.
342 changes: 342 additions & 0 deletions tests/resources/two_element_cube.exf
Original file line number Diff line number Diff line change
@@ -0,0 +1,342 @@
EX Version: 3
Region: /
!#nodeset nodes
Define node template: node1
Shape. Dimension=0
#Fields=1
1) fitted coordinates, coordinate, rectangular cartesian, real, #Components=3
x. #Values=4 (value,d/ds1,d/ds2,d/ds3)
y. #Values=4 (value,d/ds1,d/ds2,d/ds3)
z. #Values=4 (value,d/ds1,d/ds2,d/ds3)
Node template: node1
Node: 1
0.000000000000000e+00 1.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00
0.000000000000000e+00 0.000000000000000e+00 1.000000000000000e+00 0.000000000000000e+00
0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 5.000000000000000e-01
Node: 2
1.000000000000000e+00 9.999999999732445e-01 0.000000000000000e+00 0.000000000000000e+00
0.000000000000000e+00 0.000000000000000e+00 1.000000000000000e+00 0.000000000000000e+00
0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 5.000000000000000e-01
Node: 3
0.000000000000000e+00 1.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00
1.000000000000000e+00 0.000000000000000e+00 9.999999999732445e-01 0.000000000000000e+00
0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 5.000000000000000e-01
Node: 4
1.000000000000000e+00 9.999999999732445e-01 0.000000000000000e+00 0.000000000000000e+00
1.000000000000000e+00 0.000000000000000e+00 9.999999999732445e-01 0.000000000000000e+00
0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 5.000000000000000e-01
Node: 5
0.000000000000000e+00 1.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00
0.000000000000000e+00 0.000000000000000e+00 1.000000000000000e+00 0.000000000000000e+00
5.000000000000000e-01 0.000000000000000e+00 0.000000000000000e+00 5.000000000005000e-01
Node: 6
1.000000000000000e+00 9.999999999732445e-01 0.000000000000000e+00 0.000000000000000e+00
0.000000000000000e+00 0.000000000000000e+00 1.000000000000000e+00 0.000000000000000e+00
5.000000000000000e-01 0.000000000000000e+00 0.000000000000000e+00 5.000000000005000e-01
Node: 7
0.000000000000000e+00 1.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00
1.000000000000000e+00 0.000000000000000e+00 9.999999999732445e-01 0.000000000000000e+00
5.000000000000000e-01 0.000000000000000e+00 0.000000000000000e+00 5.000000000005000e-01
Node: 8
1.000000000000000e+00 9.999999999732445e-01 0.000000000000000e+00 0.000000000000000e+00
1.000000000000000e+00 0.000000000000000e+00 9.999999999732445e-01 0.000000000000000e+00
5.000000000000000e-01 0.000000000000000e+00 0.000000000000000e+00 5.000000000005000e-01
Node: 9
0.000000000000000e+00 1.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00
0.000000000000000e+00 0.000000000000000e+00 1.000000000000000e+00 0.000000000000000e+00
1.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 4.999999999866223e-01
Node: 10
1.000000000000000e+00 9.999999999732445e-01 0.000000000000000e+00 0.000000000000000e+00
0.000000000000000e+00 0.000000000000000e+00 1.000000000000000e+00 0.000000000000000e+00
1.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 4.999999999866223e-01
Node: 11
0.000000000000000e+00 1.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00
1.000000000000000e+00 0.000000000000000e+00 9.999999999732445e-01 0.000000000000000e+00
1.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 4.999999999866223e-01
Node: 12
1.000000000000000e+00 9.999999999732445e-01 0.000000000000000e+00 0.000000000000000e+00
1.000000000000000e+00 0.000000000000000e+00 9.999999999732445e-01 0.000000000000000e+00
1.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 4.999999999866223e-01
!#mesh mesh1d, dimension=1, nodeset=nodes
Define element template: element1
Shape. Dimension=1, line
#Scale factor sets=0
#Nodes=0
#Fields=0
Element template: element1
Element: 1
Element: 2
Element: 3
Element: 4
Element: 5
Element: 6
Element: 7
Element: 8
Element: 9
Element: 10
Element: 11
Element: 12
Element: 13
Element: 14
Element: 15
Element: 16
Element: 17
Element: 18
Element: 19
Element: 20
!#mesh mesh2d, dimension=2, face mesh=mesh1d, nodeset=nodes
Define element template: element2
Shape. Dimension=2, line*line
#Scale factor sets=0
#Nodes=0
#Fields=0
Element template: element2
Element: 1
Faces:
1 2 3 4
Element: 2
Faces:
5 6 7 8
Element: 3
Faces:
9 10 1 5
Element: 4
Faces:
11 12 2 6
Element: 5
Faces:
3 7 9 11
Element: 6
Faces:
4 8 10 12
Element: 7
Faces:
13 14 4 15
Element: 8
Faces:
16 17 8 18
Element: 9
Faces:
10 19 13 16
Element: 10
Faces:
12 20 14 17
Element: 11
Faces:
15 18 19 20
!#mesh mesh3d, dimension=3, face mesh=mesh2d, nodeset=nodes
Define element template: element3
Shape. Dimension=3, line*line*line
#Scale factor sets=0
#Nodes=8
#Fields=1
1) fitted coordinates, coordinate, rectangular cartesian, real, #Components=3
x. c.Hermite*c.Hermite*c.Hermite, no modify, standard node based.
#Nodes=8
1. #Values=3
Value labels: value d/ds1 d/ds2
0. #Values=1
Value labels: zero
1. #Values=1
Value labels: d/ds3
0. #Values=3
Value labels: zero zero zero
2. #Values=3
Value labels: value d/ds1 d/ds2
0. #Values=1
Value labels: zero
2. #Values=1
Value labels: d/ds3
0. #Values=3
Value labels: zero zero zero
3. #Values=3
Value labels: value d/ds1 d/ds2
0. #Values=1
Value labels: zero
3. #Values=1
Value labels: d/ds3
0. #Values=3
Value labels: zero zero zero
4. #Values=3
Value labels: value d/ds1 d/ds2
0. #Values=1
Value labels: zero
4. #Values=1
Value labels: d/ds3
0. #Values=3
Value labels: zero zero zero
5. #Values=3
Value labels: value d/ds1 d/ds2
0. #Values=1
Value labels: zero
5. #Values=1
Value labels: d/ds3
0. #Values=3
Value labels: zero zero zero
6. #Values=3
Value labels: value d/ds1 d/ds2
0. #Values=1
Value labels: zero
6. #Values=1
Value labels: d/ds3
0. #Values=3
Value labels: zero zero zero
7. #Values=3
Value labels: value d/ds1 d/ds2
0. #Values=1
Value labels: zero
7. #Values=1
Value labels: d/ds3
0. #Values=3
Value labels: zero zero zero
8. #Values=3
Value labels: value d/ds1 d/ds2
0. #Values=1
Value labels: zero
8. #Values=1
Value labels: d/ds3
0. #Values=3
Value labels: zero zero zero
y. c.Hermite*c.Hermite*c.Hermite, no modify, standard node based.
#Nodes=8
1. #Values=3
Value labels: value d/ds1 d/ds2
0. #Values=1
Value labels: zero
1. #Values=1
Value labels: d/ds3
0. #Values=3
Value labels: zero zero zero
2. #Values=3
Value labels: value d/ds1 d/ds2
0. #Values=1
Value labels: zero
2. #Values=1
Value labels: d/ds3
0. #Values=3
Value labels: zero zero zero
3. #Values=3
Value labels: value d/ds1 d/ds2
0. #Values=1
Value labels: zero
3. #Values=1
Value labels: d/ds3
0. #Values=3
Value labels: zero zero zero
4. #Values=3
Value labels: value d/ds1 d/ds2
0. #Values=1
Value labels: zero
4. #Values=1
Value labels: d/ds3
0. #Values=3
Value labels: zero zero zero
5. #Values=3
Value labels: value d/ds1 d/ds2
0. #Values=1
Value labels: zero
5. #Values=1
Value labels: d/ds3
0. #Values=3
Value labels: zero zero zero
6. #Values=3
Value labels: value d/ds1 d/ds2
0. #Values=1
Value labels: zero
6. #Values=1
Value labels: d/ds3
0. #Values=3
Value labels: zero zero zero
7. #Values=3
Value labels: value d/ds1 d/ds2
0. #Values=1
Value labels: zero
7. #Values=1
Value labels: d/ds3
0. #Values=3
Value labels: zero zero zero
8. #Values=3
Value labels: value d/ds1 d/ds2
0. #Values=1
Value labels: zero
8. #Values=1
Value labels: d/ds3
0. #Values=3
Value labels: zero zero zero
z. c.Hermite*c.Hermite*c.Hermite, no modify, standard node based.
#Nodes=8
1. #Values=3
Value labels: value d/ds1 d/ds2
0. #Values=1
Value labels: zero
1. #Values=1
Value labels: d/ds3
0. #Values=3
Value labels: zero zero zero
2. #Values=3
Value labels: value d/ds1 d/ds2
0. #Values=1
Value labels: zero
2. #Values=1
Value labels: d/ds3
0. #Values=3
Value labels: zero zero zero
3. #Values=3
Value labels: value d/ds1 d/ds2
0. #Values=1
Value labels: zero
3. #Values=1
Value labels: d/ds3
0. #Values=3
Value labels: zero zero zero
4. #Values=3
Value labels: value d/ds1 d/ds2
0. #Values=1
Value labels: zero
4. #Values=1
Value labels: d/ds3
0. #Values=3
Value labels: zero zero zero
5. #Values=3
Value labels: value d/ds1 d/ds2
0. #Values=1
Value labels: zero
5. #Values=1
Value labels: d/ds3
0. #Values=3
Value labels: zero zero zero
6. #Values=3
Value labels: value d/ds1 d/ds2
0. #Values=1
Value labels: zero
6. #Values=1
Value labels: d/ds3
0. #Values=3
Value labels: zero zero zero
7. #Values=3
Value labels: value d/ds1 d/ds2
0. #Values=1
Value labels: zero
7. #Values=1
Value labels: d/ds3
0. #Values=3
Value labels: zero zero zero
8. #Values=3
Value labels: value d/ds1 d/ds2
0. #Values=1
Value labels: zero
8. #Values=1
Value labels: d/ds3
0. #Values=3
Value labels: zero zero zero
Element template: element3
Element: 1
Faces:
1 2 3 4 5 6
Nodes:
1 2 3 4 5 6 7 8
Element: 2
Faces:
7 8 9 10 6 11
Nodes:
5 6 7 8 9 10 11 12
21 changes: 20 additions & 1 deletion tests/test_fitcube.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import os
import unittest
from cmlibs.utils.zinc.field import createFieldMeshIntegral
from cmlibs.utils.zinc.finiteelement import evaluate_field_nodeset_mean, find_node_with_name
from cmlibs.utils.zinc.finiteelement import evaluate_field_nodeset_mean, find_node_with_name, evaluate_field_nodeset_range
from cmlibs.zinc.context import Context
from cmlibs.zinc.field import Field
from cmlibs.zinc.node import Node, Nodeset
from cmlibs.zinc.result import RESULT_OK
Expand Down Expand Up @@ -765,6 +766,24 @@ def test_modelFitGroupMarkers(self):
self.assertAlmostEqual(expectedLocation[1][1], xi[1], delta=TOL)
self.assertAlmostEqual(expectedLocation[1][2], xi[2], delta=TOL)

def test_nodeset_max_and_min(self):
zinc_model_file = os.path.join(here, "resources", "two_element_cube.exf")

context = Context("max_min")
logger = context.getLogger()
region = context.getDefaultRegion()
region.readFile(zinc_model_file)

fm = region.getFieldmodule()

nodes = fm.findNodesetByFieldDomainType(Field.DOMAIN_TYPE_NODES)
coordinates = fm.findFieldByName("coordinates")
self.assertEqual(0, logger.getNumberOfMessages())
min_range, max_range = evaluate_field_nodeset_range(coordinates, nodes)
self.assertEqual(0, logger.getNumberOfMessages())
self.assertIsNotNone(min_range)
self.assertIsNotNone(max_range)


if __name__ == "__main__":
unittest.main()

0 comments on commit e787b9f

Please sign in to comment.