Skip to content
This repository has been archived by the owner on Feb 13, 2024. It is now read-only.

Commit

Permalink
Adds tests to show that part sides correctly set with small skews
Browse files Browse the repository at this point in the history
  • Loading branch information
spacether committed Dec 14, 2018
1 parent eeb4a09 commit 5833426
Show file tree
Hide file tree
Showing 10 changed files with 117 additions and 26 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
.PHONY: dist docs

dist:
# make dist version="X.X.X"
rm -rf dist
mkdir dist
make dist_source
make dist_docs
make dist_docs version=$(version)
make dist_examples

clean_examples:
Expand All @@ -31,14 +32,13 @@ clean:
rm -f ./*.sta
rm -f ./*.out


dist_examples:
make clean_examples
zip -r examples.zip examples
mv examples.zip dist/

docs:
# make docs version="0.9.5"
dist_docs:
# make dist_docs version="X.X.X"
rm -rf docs
rm -rf documentation
sphinx-apidoc -F -H "pycalculix" -V $(version) -A "Justin Black" -o docs pycalculix
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,11 @@ Initial Release: December 2014

## Change Log

#### 1.1.2
- Sets part.left/right/top/bottom using geometry.ACC constant, tests added
- Fixes issue https://github.com/spacether/pycalculix/issues/57 where part.left
was not being set if a line was slightly skewed

#### 1.1.1
- Omits test_pinned_plate from Mac OS X with Python >= 3.6 because it does not
converge in ccx
Expand Down
Binary file modified dist/documentation.zip
Binary file not shown.
Binary file modified dist/examples.zip
Binary file not shown.
Binary file not shown.
1 change: 0 additions & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SPHINXPROJ = pycalculix
SOURCEDIR = .
BUILDDIR = _build

Expand Down
18 changes: 6 additions & 12 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#
# import os
# import sys
# sys.path.insert(0, '/Users/justin/Documents/programming/pycalculix/pycalculix')
# sys.path.insert(0, '/Users/justin/programming/pycalculix/pycalculix')


# -- Project information -----------------------------------------------------
Expand All @@ -24,9 +24,9 @@
author = 'Justin Black'

# The short X.Y version
version = ''
version = '1.1.2'
# The full version, including alpha/beta/rc tags
release = ''
release = '1.1.2'


# -- General configuration ---------------------------------------------------
Expand Down Expand Up @@ -65,11 +65,11 @@

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path .
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = None


# -- Options for HTML output -------------------------------------------------
Expand Down Expand Up @@ -162,9 +162,6 @@

# Bibliographic Dublin Core info.
epub_title = project
epub_author = author
epub_publisher = author
epub_copyright = copyright

# The unique identifier of the text. This can be a ISBN number
# or the project homepage.
Expand All @@ -184,10 +181,7 @@
# -- Options for todo extension ----------------------------------------------

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True
from pycalculix.version import __version__
version = __version__
release = version
todo_include_todos = True
extensions = ['sphinx.ext.autodoc',
'sphinx.ext.napoleon',
'sphinx.ext.todo',
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.. pycalculix documentation master file, created by
sphinx-quickstart on Wed Jun 27 21:15:32 2018.
sphinx-quickstart on Fri Dec 14 10:41:52 2018.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Expand Down
1 change: 0 additions & 1 deletion docs/make.bat
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ if "%SPHINXBUILD%" == "" (
)
set SOURCEDIR=.
set BUILDDIR=_build
set SPHINXPROJ=pycalculix

if "%1" == "" goto help

Expand Down
108 changes: 101 additions & 7 deletions tests/test_part.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import pycalculix as pyc

class TestPart(unittest.TestCase):
"""Test meshing module"""
"""Test part module"""
def tearDown(self):
extenstion_to_del = ['fbd',
'inp',
Expand All @@ -24,14 +24,108 @@ def tearDown(self):
if extension in extenstion_to_del:
os.unlink(local_file)

def test_part_sides(self):
def test_part_sides_perfect(self):
# a hole with multiple lines for each side sets them correctly
pass
proj_name = 'test_part_sides'

def test_part_sides(self):
# a hole with multiple lines for each side sets them correctly
# even if one of them is skewed
pass
model = pyc.FeaModel(proj_name)
model.set_units('m') # this sets dist units to meters
part = pyc.Part(model)

divot_width = 1
corner_width = 2

part.goto(0, 0)
left_points = [
(corner_width, 0),
(corner_width + divot_width, divot_width),
(corner_width + divot_width*2, 0),
(corner_width*2 + divot_width*2, 0),
]
top_points = [
(corner_width*2 + divot_width*2, corner_width),
(corner_width*2 + divot_width, corner_width + divot_width),
(corner_width*2 + divot_width*2, corner_width + divot_width*2),
(corner_width*2 + divot_width*2, corner_width*2 + divot_width*2),
]
right_points = [
(corner_width + divot_width*2, corner_width*2 + divot_width*2),
(corner_width + divot_width, corner_width*2 + divot_width),
(corner_width, corner_width*2 + divot_width*2),
(0, corner_width*2 + divot_width*2),
]
bottom_points = [
(0, corner_width + divot_width*2),
(divot_width, corner_width + divot_width),
(0, corner_width),
(0, 0),
]
all_points = left_points + top_points + right_points + bottom_points
for x, y in all_points:
part.draw_line_to(x, y)

self.assertEqual([line.get_name() for line in part.left], ['L0', 'L3'])
self.assertEqual([line.get_name() for line in part.top], ['L4', 'L7'])
self.assertEqual([line.get_name() for line in part.right], ['L8', 'L11'])
self.assertEqual([line.get_name() for line in part.bottom], ['L12', 'L15'])

def test_part_sides_skewed(self):
# top right point in range, bottom right point out of range
# left side perfet (2 found)
# top in range but skewed on 2nd line (2 found)
# right in range but skewed on 1st line, 2nd out of range (1 found)
# bottom 1st out of range, in range but skewed on 2nd line, 2 (1 found)
initial_accuracy_val = pyc.geometry.ACC
pyc.geometry.ACC = 0.2
offset_in_range = 0.1
offset_too_big = 0.4

proj_name = 'test_part_sides_skewed'

model = pyc.FeaModel(proj_name)
model.set_units('m') # this sets dist units to meters
part = pyc.Part(model)

divot_width = 1
corner_width = 2

part.goto(0, 0)
left_points = [
(corner_width, 0),
(corner_width + divot_width, divot_width),
(corner_width + divot_width*2, 0),
(corner_width*2 + divot_width*2, 0),
]
top_points = [
(corner_width*2 + divot_width*2, corner_width),
(corner_width*2 + divot_width, corner_width + divot_width),
(corner_width*2 + divot_width*2, corner_width + divot_width*2),
(
corner_width*2 + divot_width*2 - offset_in_range,
corner_width*2 + divot_width*2 - offset_in_range
),
]
right_points = [
(corner_width + divot_width*2, corner_width*2 + divot_width*2),
(corner_width + divot_width, corner_width*2 + divot_width),
(corner_width, corner_width*2 + divot_width*2),
(0 + offset_too_big, corner_width*2 + divot_width*2 - offset_too_big),
]
bottom_points = [
(0, corner_width + divot_width*2),
(divot_width, corner_width + divot_width),
(0, corner_width),
(0, 0),
]
all_points = left_points + top_points + right_points + bottom_points
for x, y in all_points:
part.draw_line_to(x, y)

self.assertEqual([line.get_name() for line in part.left], ['L0', 'L3'])
self.assertEqual([line.get_name() for line in part.top], ['L4', 'L7'])
self.assertEqual([line.get_name() for line in part.right], ['L8'])
self.assertEqual([line.get_name() for line in part.bottom], ['L15'])
pyc.geometry.ACC = initial_accuracy_val

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

0 comments on commit 5833426

Please sign in to comment.