-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathPrismDomain.py
114 lines (94 loc) · 3.64 KB
/
PrismDomain.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# =============================================================================
# TexGen: Geometric textile modeller.
# Copyright (C) 2022 Louise Brown
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# =============================================================================
# Python 3 version used runpy module to execute scripts from TexGen GUI which requires import of library
from TexGen.Core import *
#Create a textile
textile = CTextile()
# Create vector for domain polygon points
points = XYVector()
# Add points to polygon and create prism domain using
# the vector of points and start and end point of prism
# # Diamond domain
# points.push_back(XY(1.0,0))
# points.push_back(XY(0,1))
# points.push_back(XY(-1,0))
# points.push_back(XY(0,-1))
# domain = CDomainPrism(points,XYZ(0,0,0), XYZ(0,2,0))
#Cube domain
# points.push_back(XY(1.0,0))
# points.push_back(XY(1.0,1))
# points.push_back(XY(-1,1))
# points.push_back(XY(-1,-1))
# points.push_back(XY(1,-1))
# domain = CDomainPrism(points,XYZ(0,0,0), XYZ(0,2,0))
# L domain
# points.push_back(XY(0,0))
# points.push_back(XY(2,0))
# points.push_back(XY(2,1))
# points.push_back(XY(1,1))
# points.push_back(XY(1,2))
# points.push_back(XY(0,2))
# domain = CDomainPrism(points,XYZ(0.5,0,0.5), XYZ(0.5,2,0.5))
# domain = CDomainPrism(points,XYZ(0,0,0), XYZ(0,2,0))
#L domain
# points.push_back(XY(0,0))
# points.push_back(XY(2,0))
# points.push_back(XY(2,1))
# points.push_back(XY(1,1))
# #points.push_back(XY(1.3,1))
# #points.push_back(XY(1,1.3))
# points.push_back(XY(1,2))
# points.push_back(XY(0,2))
# domain = CDomainPrism(points,XYZ(0.5,0,0.5), XYZ(0.5,2,0.5))
# domain = CDomainPrism(points,XYZ(0.5,0,0.5), XYZ(1,2,1))
#T domain
points.push_back(XY(1,0))
points.push_back(XY(0.4,0))
points.push_back(XY(0.3,0.05))
points.push_back(XY(0.15,0.2))
points.push_back(XY(0.1,0.3))
points.push_back(XY(0.1,1))
points.push_back(XY(-0.1,1))
points.push_back(XY(-0.1,0.3))
points.push_back(XY(-0.15,0.2))
points.push_back(XY(-0.3,0.05))
points.push_back(XY(-0.4,0))
points.push_back(XY(-1,0))
points.push_back(XY(-1,-0.1))
points.push_back(XY(1,-0.1))
domain = CDomainPrism(points,XYZ(0,0,0), XYZ(0,2,0))
# Add the domain to the textile
textile.AssignDomain(domain)
# Create a yarn passing through the domain
yarn = CYarn()
yarn.AddNode( CNode(XYZ(0,-0.2,0))) # x = 1.5 for L
yarn.AddNode( CNode(XYZ(0, 2.2,0)))
# #yarn.AddNode( CNode(XYZ(-1.5,1,-0.05)))
# #yarn.AddNode( CNode(XYZ(1.5,1,-0.05)))
# Add nodes to illustrate domain centreline (T)
#yarn.AddNode( CNode(XYZ(0,0,0))) )
#yarn.AddNode( CNode( XYZ(0,2,0)) )
# Add nodes to illustrate domain centreline (L)
#yarn.AddNode( CNode(XYZ(0.5,0,0.5)))
#yarn.AddNode( CNode(XYZ(0.5,2,0.5)))
section = CSectionEllipse(0.1,0.1)
yarn.AssignSection( CYarnSectionConstant(section))
yarn.SetResolution(10)
textile.AddYarn(yarn)
AddTextile('test', textile)
# Create a voxel mesh for the domain
Vox = CPrismVoxelMesh('CPrismPeriodicBoundaries')
Vox.SaveVoxelMesh( textile, 'PrismVoxels', 20, 20, 20, True, True, NO_BOUNDARY_CONDITIONS, 0, VTU_EXPORT)