Commit b89a1255 authored by Daniel Boeckenhoff's avatar Daniel Boeckenhoff
Browse files

not converting the coordinate systems of the fields in core

parent 51af578d
......@@ -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()
......@@ -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):
"""
......
......@@ -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 = []
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment