Newer
Older
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# MetaVoxel Tutorial"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"# Amira Abdel-Rahman\n",
"# (c) Massachusetts Institute of Technology 2020\n",
"\n",
"# tested using julia 1.5.2 and windows Nvidia geforce gtx 1070 Ti"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Import Julia Libraries"
]
},
{
"cell_type": "code",
"source": [
"using LinearAlgebra\n",
"import JSON\n",
"using StaticArrays, BenchmarkTools\n",
"using Base.Threads\n",
"import Base: +, * , -, ^"
]
},
{
"cell_type": "code",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"axialStrain (generic function with 1 method)"
]
},
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"include(\"./julia/include/vector.jl\") #utils for vectors and quaternions\n",
"include(\"./julia/include/material.jl\") #utils for node and edge material\n",
"include(\"./julia/include/export.jl\") #export simulation data to json\n",
"include(\"./julia/include/run.jl\") #turn setup to cuda arrays and run simulation\n",
"include(\"./julia/include/updateEdges.jl\") #edges properties update\n",
"include(\"./julia/include/externalForces.jl\") #external forces applied to the system\n",
"include(\"./julia/include/forces.jl\") #force integration\n",
"include(\"./julia/include/updateNodes.jl\") #nodes properties update"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 1. Voxel Design"
]
},
{
"cell_type": "code",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"\"tutorial\""
]
},
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
115
116
117
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# set name for simulation\n",
"name= \"tutorial\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 1.a. Import lines from Rhino (.3dm)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"rhino=true\n",
"\n",
"setup = Dict()\n",
"\n",
"setup[\"rhino\"]=rhino\n",
"setup[\"rhinoFileName\"]=\"./julia/examples/trial.3dm\";\n",
"setup[\"layerIndex\"]=\"1\"; #layer index to import, only lines from these layer will get imported\n",
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
"\n",
"# make sure to divide curves into smaller lines, it will only add nodes at the start and end of each line/curve\n",
"\n",
"voxelSize=75 #in case you want to array the base rhino curve, what is the size of the voxel\n",
"latticeSizeX=2 # if you don't want to copy/array make this 1\n",
"latticeSizeY=2 # if you don't want to copy/array make this 1\n",
"latticeSizeZ=2 # if you don't want to copy/array make this 1\n",
"\n",
"setup[\"latticeSizeX\"]=latticeSizeX\n",
"setup[\"latticeSizeY\"]=latticeSizeY\n",
"setup[\"latticeSizeZ\"]=latticeSizeZ\n",
"\n",
"gridSize=10 #lattice size\n",
"setup[\"gridSize\"]=gridSize\n",
"\n",
"#scaling params\n",
"setup[\"voxelSize\"]=voxelSize; #voxel size\n",
"setup[\"scale\"]=1e4; #scale for visualization\n",
"setup[\"hierarchical\"]=false; #hierachical simualtion\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 1.b Draw Lattice"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"rhino=false\n",
"\n",
"voxelSize=0.001\n",
"latticeSizeX=7\n",
"latticeSizeY=2\n",
"latticeSizeZ=2\n",
"\n",
"gridSize=10\n",
"\n",
"setup = Dict()\n",
"setup[\"gridSize\"]=gridSize\n",
"\n",
"setup[\"rhino\"]=false\n",
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
"\n",
"setup[\"latticeSizeX\"]=latticeSizeX\n",
"setup[\"latticeSizeY\"]=latticeSizeY\n",
"setup[\"latticeSizeZ\"]=latticeSizeZ\n",
"\n",
"#scaling params\n",
"setup[\"voxelSize\"]=voxelSize; #voxel size\n",
"setup[\"scale\"]=1e4; #scale for visualization\n",
"setup[\"hierarchical\"]=true; #hierachical simualtion \n",
"# if setup[\"hierarchical\"] is true it will assume each voxel is one node, \n",
"# else it will assume each voxel is a detailed cuboct"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 1.c. Fill mesh with voxels (wip)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"# rhino=false\n",
"# rhinoFileName= \"./trial.stl\"\n",
"# voxelSize=5.0"
]
},
Loading
Loading full blame...