Commit 33030734 authored by Amira Abdel-Rahman's avatar Amira Abdel-Rahman
Browse files

multithreading and top opt non concurrent and strain libraries

parent d81e1770
Pipeline #19655 passed with stage
in 39 seconds
......@@ -21,4 +21,5 @@ res3d
*.3mf
*bracket.3dm
*new_face_75.3dm
*.gcode
\ No newline at end of file
*.gcode
objs
<!DOCTYPE html>
<html lang="en">
<head>
<title>MetaVoxel</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<!-- <link type="text/css" rel="stylesheet" href="main.css"> -->
<style>
body {
background-color: #f0f0f0;
color: #444;
}
a {
color: #08f;
}
</style>
</head>
<body>
<div id="container"></div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script type="text/javascript" src="https://files.mcneel.com/rhino3dm/js/latest/rhino3dm.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@1.0.0/dist/tf.min.js"></script>
<!-- <script src="./lib/require.js"></script> -->
<script src="../lib/three.min.js"></script>
<script src="../lib/stats.js"></script>
<script src="../lib/dat.gui.js"></script>
<script src="../lib/SVGRenderer.js"></script>
<script src="../lib/DragControls.js"></script>
<script src="../lib/OrbitControls.js"></script>
<script src="../lib/TransformControls.js"></script>
<script src="../lib/js-colormaps.js"></script>
<script src="../lib/LineSegments2.js"></script>
<script src="../lib/LineSegmentsGeometry.js"></script>
<script src="../lib/Line2.js"></script>
<script src="../lib/LineMaterial.js"></script>
<script src="../lib/LineGeometry.js"></script>
<script src="../lib/GeometryUtils.js"></script>
<script src="../visualization/utils.js"></script>
<!-- <script src="./beamFea.js"></script>
<script src="./geometry.js"></script> -->
<script src="../visualization/main.js"></script>
<script>
$.getJSON("../json/bioVoxelFEA.json", function(json) {
setup=json;
setup.scale=1
setup.viz.colorMaps=[coolwarm,YlGnBu, winter ,jet];
console.log(setup)
three= new threejs(setup,"container","");
three.init();
// three.drawStructure();
// three.colorEdges();
// three.animate();
// init();
// drawStructure();
// colorEdges();
// animate();
});
</script>
</body>
</html>
This diff is collapsed.
This diff is collapsed.
{"setup":{"rhinoFileName":"../julia/examples/CAD_Rhino/chiral.3dm","poisson":false,"layerIndex":"1","materials":[[{"max":{"x":750,"z":750,"y":750},"min":{"x":-750,"z":-750,"y":-750}},{"cTE":0.0,"poissonRatio":0.0,"density":0.028,"area":277.55559999999997,"stiffness":2000.0}]],"rhino":true,"latticeSizeY":1,"scale":0.5,"supports":[[{"max":{"x":637.5,"z":637.5,"y":9.375},"min":{"x":-37.5,"z":-37.5,"y":-37.5}},[true,true,true,true,true,true]]],"thermal":false,"loads":[[{"max":{"x":637.5,"z":637.5,"y":112.5},"min":{"x":-37.5,"z":-37.5,"y":65.625}},{"x":0.0,"z":0.0,"y":-20000.0}]],"maxNumFiles":50,"voxelSize":75,"numTimeSteps":10000,"fixedDisplacements":[],"linear":true,"latticeSizeX":1,"gridSize":10,"latticeSizeZ":1,"useVoxelList":false,"hierarchical":false,"globalDamping":0.2,"useMaterialList":false}}
\ No newline at end of file
{"setup":{"materials":[[{"max":{"x":1125,"z":1125,"y":1125},"min":{"x":-1125,"z":-1125,"y":-1125}},{"cTE":0.0,"poissonRatio":0.35,"density":0.028,"area":5.6644,"stiffness":2000.0}]],"poisson":false,"rhino":false,"latticeSizeY":8,"scale":1.0,"supports":[[{"max":{"x":150,"z":600,"y":18.75},"min":{"x":0.0,"z":0.0,"y":0.0}},[true,true,true,true,true,true]]],"thermal":false,"loads":[[{"max":{"x":150,"z":600,"y":600},"min":{"x":0,"z":0,"y":581.25}},{"x":0.0,"z":0.0,"y":-0.5}]],"maxNumFiles":300,"voxelSize":75,"numTimeSteps":50000,"fixedDisplacements":[],"linear":true,"latticeSizeX":2,"gridSize":15,"latticeSizeZ":8,"useVoxelList":false,"hierarchical":false,"globalDamping":0.001}}
\ No newline at end of file
# Amira Abdel-Rahman
# (c) Massachusetts Institute of Technology 2020
######################### 1. Voxel Design ###########################
setup = Dict()
### 1.b Draw Lattice
rhino=false
loadsS=[-25,-33.3 ,-37.33,-40 ,-41.66 ,-42.85,-43.75]
voxelSize=75
latticeSizeX=2
latticeSizeY=8
latticeSizeZ=8
gridSize=15
setup["gridSize"]=gridSize
setup["rhino"]=false
setup["useVoxelList"]=false
setup["latticeSizeX"]=latticeSizeX
setup["latticeSizeY"]=latticeSizeY
setup["latticeSizeZ"]=latticeSizeZ
######################### 2. Boundary Conditions #########################
######################### 2.a. Global Settings #########################
#scaling params
setup["voxelSize"]=voxelSize; #voxel size
setup["scale"]=1.0; #scale for visualization
setup["hierarchical"]=false; #hierachical simualtion
#simulation params
setup["numTimeSteps"]=50000; #total num of timesteps for simulation
setup["poisson"]=false; # account for poisson ration (only for hierarchical)
setup["linear"]=true; # linear vs non-linear
setup["thermal"]=false; #if there is change in temperature
setup["globalDamping"]=0.01; # (usually from 0.1 to 0.4)
setup["globalDamping"]=0.001; # (usually from 0.1 to 0.4)
#visualization params
setup["maxNumFiles"]=300; #num of saved timesteps for visualization, make sure it's smaller than numTimeSteps
######################### 2.b. Materials #########################
#default material
material1= Dict()
material1["area"]=2.38*2.38
material1["density"]=0.028
material1["stiffness"]=2000.0
material1["poissonRatio"]=0.35
material1["cTE"]=0.0 #coefficient of thermal expansion
#large bounding box for default material
boundingBoxMaterial1=Dict()
boundingBoxMaterial1["min"]=Dict()
boundingBoxMaterial1["max"]=Dict()
boundingBoxMaterial1["min"]["x"]=-voxelSize*gridSize;
boundingBoxMaterial1["min"]["y"]=-voxelSize*gridSize;
boundingBoxMaterial1["min"]["z"]=-voxelSize*gridSize;
boundingBoxMaterial1["max"]["x"]= voxelSize*gridSize;
boundingBoxMaterial1["max"]["y"]= voxelSize*gridSize;
boundingBoxMaterial1["max"]["z"]= voxelSize*gridSize;
setup["materials"]=[
[boundingBoxMaterial1,material1]
];
######################### 2.c. Supports #########################
#x,y,z,rx,ry,rz (default is pinned joing i.e [false,false,false,true,true,true])
dof=[true,true,true,true,true,true]
boundingBoxSupport1=Dict()
boundingBoxSupport1["min"]=Dict()
boundingBoxSupport1["max"]=Dict()
boundingBoxSupport1["min"]["x"]=0.0;
boundingBoxSupport1["min"]["y"]=0.0;
boundingBoxSupport1["min"]["z"]=0.0;
boundingBoxSupport1["max"]["x"]= voxelSize*(latticeSizeX);
boundingBoxSupport1["max"]["y"]= voxelSize/4;
boundingBoxSupport1["max"]["z"]= voxelSize*(latticeSizeZ);
setup["supports"]=[
[boundingBoxSupport1,dof]
];
######################### 2.d. Loads #########################
#### 2.d.1 Static Loads
load1=Dict()
load1["x"]=0.0
load1["y"]= -33.333333 #-37.5 for 3*3*3 lattice
load1["y"]= -50/100
load1["z"]=0.0
boundingBoxLoad1=Dict()
boundingBoxLoad1["min"]=Dict()
boundingBoxLoad1["max"]=Dict()
boundingBoxLoad1["min"]["x"]=0;
boundingBoxLoad1["min"]["y"]=voxelSize*(latticeSizeY)-voxelSize/4;
boundingBoxLoad1["min"]["z"]=0;
boundingBoxLoad1["max"]["x"]=voxelSize*(latticeSizeX);
boundingBoxLoad1["max"]["y"]=voxelSize*(latticeSizeY);
boundingBoxLoad1["max"]["z"]=voxelSize*(latticeSizeZ);
setup["loads"]=[
[boundingBoxLoad1,load1]
];
setup["fixedDisplacements"]=[];
#### 2.d.2 Dynamic Loads
function floorEnabled()
return false
end
function gravityEnabled()
return false
end
function externalDisplacement(currentTimeStep,N_position,N_fixedDisplacement)
return N_fixedDisplacement
end
function externalForce(currentTimeStep,N_position,N_currentPosition,N_force)
return N_force
end
function updateTemperature(currentRestLength,currentTimeStep,mat)
return currentRestLength
end
###########################################################################
\ No newline at end of file
%% Cell type:code id:111e8d33 tags:
``` julia
# Amira Abdel-Rahman
# (c) Massachusetts Institute of Technology 2022
```
%% Cell type:code id:8102a0b4 tags:
``` julia
plotting=true
GPU=false
logging=true
include("../julia/MetaVoxels.jl") #load MetaVoxels!
```
%% Output
Loaded MetaVoxels Functions!
%% Cell type:code id:9f9c0b45 tags:
``` julia
simName= "tutorial" # set name for simulation
# get a saved setup from an external julia file
# include("../julia/examples/thermalTest.jl") #template for multimaterial hierarchical voxels with different thermal coefficient of thermal expansion
include("../julia/examples/latticeTest_bioVoxel.jl") #template for lattice voxel (big scale with real params)
## recompile these just for sanity check for dynamic loads
include("../julia/MetaVoxels.jl")
#export setup using nodejs and javascript from "./json/$(simName)Init.json" and save to "./json/$(simName).json"
exportJuliaSettingsUsingNode(setup,simName)
```
%% Output
Loaded MetaVoxels Functions!
Success! Created structure with 594 nodes and 1920 edges.
Process(`node ../node/app1.js tutorial`, ProcessExited(0))
%% Cell type:code id:11c5b1ea tags:
``` julia
setupSim=getSetup(simName); #get simulation from"./json/$(simName).json"
savedDataFolderPath="../json/$(simName)/" # make sure this folder exists, this is where the simulation result will be saved
setupSimFEA=getSetup(simName);
```
%% Cell type:code id:77db6741 tags:
``` julia
runMetaVoxels!(setupSim,savedDataFolderPath,"CPU")
```
%% Output
dt: 6.1640447419699046e-6, s: 0.001, mass: 1.5e-6, momentInertiaInverse: 4.0e12
first timestep took 0.8541083 seconds
ran 28 nodes and 52 edges for 5000 time steps took 1.863646 seconds
%% Cell type:code id:55169de1 tags:
``` julia
t=@timed setupSimFEA=solveFea(setupSimFEA);
time=t[2]
println("FEA took $time seconds")
```
%% Output
FEA took 356.4310816 seconds
%% Cell type:code id:29a583e1 tags:
``` julia
fileName=
# pass data as a json string (how it shall be displayed in a file)
stringdata = JSON.json(setupSimFEA)
fileName="../json/bioVoxelFEA.json"
# write the file with the stringdata variable information
open(fileName, "w") do f
write(f, stringdata)
end
```
%% Output
681605
%% Cell type:markdown id:f9c34850 tags:
# Visualize
%% Cell type:code id:dda14877 tags:
``` julia
#run node.js to serve the indexTutorial.html for visualizarion
mycommand = `node ../node/serve.js $(simName)`
run(mycommand)
```
%% Output
Server listening on port 8000
Open http://localhost:8000/demos/indexTutorialGraph.html in your browser
InterruptException:
Stacktrace:
[1] try_yieldto(undo::typeof(Base.ensure_rescheduled))
@ Base .\task.jl:710
[2] wait
@ .\task.jl:769 [inlined]
[3] wait(c::Base.GenericCondition{SpinLock})
@ Base .\condition.jl:106
[4] wait(x::Base.Process)
@ Base .\process.jl:621
[5] success
@ .\process.jl:483 [inlined]
[6] run(::Cmd; wait::Bool)
@ Base .\process.jl:440
[7] run(::Cmd)
@ Base .\process.jl:438
[8] top-level scope
@ In[15]:3
[9] eval