Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Daniel Boeckenhoff
tfields
Commits
b89a1255
Commit
b89a1255
authored
Aug 14, 2018
by
Daniel Boeckenhoff
Browse files
not converting the coordinate systems of the fields in core
parent
51af578d
Changes
4
Hide whitespace changes
Inline
Side-by-side
test/test_core.py
View file @
b89a1255
...
...
@@ -3,6 +3,7 @@ import numpy as np
from
sympy.abc
import
x
,
y
import
unittest
from
tempfile
import
NamedTemporaryFile
import
pickle
import
sympy
# NOQA: F401
...
...
@@ -28,6 +29,7 @@ class Base_Test(object):
"""
transformer
=
self
.
_inst
.
copy
()
transformer
.
transform
(
tfields
.
bases
.
CYLINDER
)
self
.
assertTrue
(
tfields
.
Tensors
(
self
.
_inst
).
equal
(
transformer
,
atol
=
ATOL
))
self
.
assertTrue
(
self
.
_inst
.
equal
(
transformer
,
atol
=
ATOL
))
if
len
(
self
.
_inst
)
>
0
:
self
.
assertFalse
(
np
.
array_equal
(
self
.
_inst
,
transformer
))
...
...
@@ -67,11 +69,19 @@ class Base_Test(object):
atol
=
ATOL
)
self
.
assertTrue
(
value
)
def
test_pickle
(
self
):
with
NamedTemporaryFile
(
suffix
=
'.pickle'
)
as
out_file
:
pickle
.
dump
(
self
.
_inst
,
out_file
)
out_file
.
flush
()
reloaded
=
pickle
.
load
(
open
(
out_file
.
name
,
'rb'
))
self
.
assertTrue
(
self
.
_inst
.
equal
(
reloaded
))
def
tearDown
(
self
):
del
self
.
_inst
class
Tensor_Fields_Test
(
object
):
def
test_fields
(
self
):
# field is of type list
...
...
@@ -83,6 +93,7 @@ class Tensor_Fields_Test(object):
# fields are copied not reffered by a pointer
self
.
assertFalse
(
field
is
target_field
)
"""
EMPTY TESTS
"""
...
...
@@ -97,6 +108,14 @@ class TensorFields_Empty_Test(Tensors_Empty_Test, Tensor_Fields_Test):
def
setUp
(
self
):
self
.
_fields
=
[]
self
.
_inst
=
tfields
.
TensorFields
([],
dim
=
3
)
class
TensorMaps_Empty_Test
(
TensorFields_Empty_Test
):
def
setUp
(
self
):
self
.
_fields
=
[]
self
.
_inst
=
tfields
.
TensorMaps
([],
dim
=
3
)
self
.
_maps
=
[]
self
.
_maps_fields
=
[]
class
TensorFields_Copy_Test
(
TensorFields_Empty_Test
):
...
...
@@ -111,13 +130,6 @@ class TensorFields_Copy_Test(TensorFields_Empty_Test):
self
.
assertTrue
(
self
.
_fields
[
1
].
coord_sys
,
'cartesian'
)
class
TensorMaps_Empty_Test
(
TensorFields_Empty_Test
):
def
setUp
(
self
):
self
.
_fields
=
[]
self
.
_inst
=
tfields
.
TensorMaps
([],
dim
=
3
)
self
.
_maps
=
[]
self
.
_maps_fields
=
[]
class
TensorMaps_Copy_Test
(
TensorMaps_Empty_Test
):
def
setUp
(
self
):
base
=
[(
-
1
,
1
,
3
)]
*
3
...
...
@@ -140,7 +152,5 @@ class TensorMaps_Copy_Test(TensorMaps_Empty_Test):
maps
=
self
.
_maps
)
if
__name__
==
'__main__'
:
unittest
.
main
()
tfields/core.py
View file @
b89a1255
...
...
@@ -1415,10 +1415,10 @@ class TensorFields(Tensors):
inst
=
cls
.
__new__
(
cls
,
inst
,
*
fields
)
return
inst
def
transform
(
self
,
coord_sys
):
super
(
TensorFields
,
self
).
transform
(
coord_sys
)
for
field
in
self
.
fields
:
field
.
transform
(
coord_sys
)
#
def transform(self, coord_sys):
#
super(TensorFields, self).transform(coord_sys)
#
#
for field in self.fields:
#
#
field.transform(coord_sys)
def
equal
(
self
,
other
,
**
kwargs
):
"""
...
...
tfields/mesh3D.py
View file @
b89a1255
...
...
@@ -523,6 +523,7 @@ class Mesh3D(tfields.TensorMaps):
def
in_faces
(
self
,
points
,
delta
,
assign_multiple
=
False
):
"""
Check whether points lie within triangles with Barycentric Technique
see Triangles3D.in_triangles
"""
masks
=
self
.
triangles
().
in_triangles
(
points
,
delta
,
assign_multiple
=
assign_multiple
)
...
...
@@ -536,7 +537,7 @@ class Mesh3D(tfields.TensorMaps):
self
.
faces
=
self
.
faces
[
~
face_delete_mask
]
self
.
faceScalars
=
self
.
faceScalars
[
~
face_delete_mask
]
def
template
(
self
,
sub_mesh
,
delta
=
1e-9
):
def
template
(
self
,
sub_mesh
):
"""
'Manual' way to build a template that can be used with self.cut
Returns:
...
...
@@ -557,7 +558,7 @@ class Mesh3D(tfields.TensorMaps):
"""
face_indices
=
np
.
arange
(
self
.
maps
[
0
].
shape
[
0
])
cents
=
tfields
.
Tensors
(
sub_mesh
.
centroids
())
mask
=
self
.
in_faces
(
cents
,
delta
)
mask
=
self
.
in_faces
(
cents
,
delta
=
None
)
inst
=
sub_mesh
.
copy
()
if
inst
.
maps
:
scalars
=
[]
...
...
tfields/triangles3D.py
View file @
b89a1255
...
...
@@ -557,8 +557,10 @@ class Triangles3D(tfields.TensorFields):
tensors (Points3D instance)
optional:
delta (float): normal distance to a triangle, that the points
is concidered to be contained in the triangle.
delta (float / None):
float: normal distance to a triangle, that the points are
concidered to be contained in the triangle.
None: find the minimum distance
assign_multiple (bool): if True, one point may belong to multiple
triangles at the same time. In the other case the first
occurence will be True the other False
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment