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

3D LBM with MADCAT

parent b492bfb0
Pipeline #12121 passed with stage
in 22 seconds
......@@ -29,7 +29,7 @@
var color7="#03dbfc"; //blue
var name="tutorial";
var name="newTendon";
// var name="newTendon";
var scale,nodeScale;
......@@ -39,13 +39,15 @@
}
var gui = new dat.GUI();
gui.add(interaction,'exaggeration',0.0,10.0).listen();
gui.add(interaction,'speed',0.0,200.0).listen();
gui.add(interaction,'exaggeration',0.0,100.0).listen();
gui.add(interaction,'speed',0.0,2000.0).listen();
$.getJSON("../json/"+name+"/0.json", function(json0) {
var maxNumFiles=json0.maxNumFiles-1;
var vizScale=json0.scale;
// var vizScale=1;
$.getJSON("../json/"+name+"/"+maxNumFiles+".json", function(json) {
var setup=json;
var static=false
......@@ -70,23 +72,19 @@
}
// scale=10000;
// nodeScale=scale/100;
var stress=0.0;
var gData =
{
nodes: setup.nodes.map(node => ({
// id: node.id,
id: (node.parent=="11")?node.id:(node.parent+node.id),
px:node.position.x*scale,
py:node.position.y*scale,
pz:node.position.z*scale,
dx:node.displacement.x*scale,
dy:node.displacement.y*scale,
dz:node.displacement.z*scale,
px:node.position.x*scale*vizScale,
py:node.position.y*scale*vizScale,
pz:node.position.z*scale*vizScale,
dx:node.displacement.x*scale*vizScale,
dy:node.displacement.y*scale*vizScale,
dz:node.displacement.z*scale*vizScale,
restrained:node.restrained_degrees_of_freedom[0],
loaded:!(node.force.x==0.0&&node.force.y==0.0&&node.force.z==0.0),
displaced:(node.fixedDisplacement===undefined ||(node.fixedDisplacement.x==0&&node.fixedDisplacement.y==0&&node.fixedDisplacement.z==0))?false:true,
......@@ -123,7 +121,7 @@
(document.getElementById('3d-graph'))
.d3Force('center', null)
.d3Force('charge', null)
// .linkWidth(1.0*scale)
.linkWidth(1.0*scale)
.linkOpacity(1.0)
// .linkColor(color3)
.nodeThreeObject(({ size,restrained,loaded,displaced,opacity }) => new THREE.Mesh(
......@@ -155,7 +153,7 @@
Graph.controls().target.set( 500, 100, 0 );
////////////////////////////////////
drawConstraintBoundingBoxes(json0,Graph.scene(),scale);
drawConstraintBoundingBoxes(json0,Graph.scene(),scale*vizScale);
///////////////////////////////////////
......@@ -194,9 +192,9 @@
$.getJSON("../json/"+name+"/"+i+".json", function(jsons) {
var setups=jsons;
for(let j=0;j<setups.nodes.length;j++){
gData.nodes[j].dxs[i]=setups.nodes[j].displacement.x*scale;
gData.nodes[j].dys[i]=setups.nodes[j].displacement.y*scale;
gData.nodes[j].dzs[i]=setups.nodes[j].displacement.z*scale;
gData.nodes[j].dxs[i]=setups.nodes[j].displacement.x*scale*vizScale;
gData.nodes[j].dys[i]=setups.nodes[j].displacement.y*scale*vizScale;
gData.nodes[j].dzs[i]=setups.nodes[j].displacement.z*scale*vizScale;
gData.nodes[j].axs[i]=setups.nodes[j].angle.x;
gData.nodes[j].ays[i]=setups.nodes[j].angle.y;
gData.nodes[j].azs[i]=setups.nodes[j].angle.z;
......
This diff is collapsed.
This diff is collapsed.
{"voxs":[[[0.0,11.0,0.0],[1.0]],[[0.0,12.0,0.0],[1.0]],[[1.0,12.0,0.0],[1.0]],[[0.0,13.0,0.0],[1.0]],[[1.0,13.0,0.0],[1.0]],[[2.0,13.0,0.0],[1.0]],[[0.0,14.0,0.0],[1.0]],[[1.0,14.0,0.0],[1.0]],[[2.0,14.0,0.0],[1.0]],[[0.0,15.0,0.0],[1.0]],[[1.0,15.0,0.0],[1.0]],[[0.0,16.0,0.0],[1.0]],[[0.0,7.0,1.0],[1.0]],[[0.0,8.0,1.0],[1.0]],[[1.0,8.0,1.0],[1.0]],[[0.0,9.0,1.0],[1.0]],[[1.0,9.0,1.0],[1.0]],[[2.0,9.0,1.0],[1.0]],[[0.0,10.0,1.0],[1.0]],[[1.0,10.0,1.0],[1.0]],[[2.0,10.0,1.0],[1.0]],[[3.0,10.0,1.0],[1.0]],[[0.0,11.0,1.0],[1.0]],[[1.0,11.0,1.0],[1.0]],[[2.0,11.0,1.0],[1.0]],[[3.0,11.0,1.0],[1.0]],[[4.0,11.0,1.0],[1.0]],[[0.0,12.0,1.0],[1.0]],[[1.0,12.0,1.0],[1.0]],[[2.0,12.0,1.0],[1.0]],[[3.0,12.0,1.0],[1.0]],[[4.0,12.0,1.0],[1.0]],[[5.0,12.0,1.0],[1.0]],[[0.0,13.0,1.0],[1.0]],[[1.0,13.0,1.0],[1.0]],[[2.0,13.0,1.0],[1.0]],[[3.0,13.0,1.0],[1.0]],[[4.0,13.0,1.0],[1.0]],[[5.0,13.0,1.0],[1.0]],[[6.0,13.0,1.0],[1.0]],[[0.0,14.0,1.0],[1.0]],[[1.0,14.0,1.0],[1.0]],[[2.0,14.0,1.0],[1.0]],[[3.0,14.0,1.0],[1.0]],[[4.0,14.0,1.0],[1.0]],[[5.0,14.0,1.0],[1.0]],[[6.0,14.0,1.0],[1.0]],[[0.0,15.0,1.0],[1.0]],[[1.0,15.0,1.0],[1.0]],[[2.0,15.0,1.0],[1.0]],[[3.0,15.0,1.0],[1.0]],[[4.0,15.0,1.0],[1.0]],[[5.0,15.0,1.0],[1.0]],[[0.0,16.0,1.0],[1.0]],[[1.0,16.0,1.0],[1.0]],[[2.0,16.0,1.0],[1.0]],[[3.0,16.0,1.0],[1.0]],[[4.0,16.0,1.0],[1.0]],[[0.0,17.0,1.0],[1.0]],[[1.0,17.0,1.0],[1.0]],[[2.0,17.0,1.0],[1.0]],[[3.0,17.0,1.0],[1.0]],[[0.0,18.0,1.0],[1.0]],[[1.0,18.0,1.0],[1.0]],[[2.0,18.0,1.0],[1.0]],[[0.0,19.0,1.0],[1.0]],[[1.0,19.0,1.0],[1.0]],[[0.0,20.0,1.0],[1.0]],[[2.0,4.0,2.0],[1.0]],[[1.0,5.0,2.0],[1.0]],[[2.0,5.0,2.0],[1.0]],[[3.0,5.0,2.0],[1.0]],[[13.0,5.0,2.0],[1.0]],[[0.0,6.0,2.0],[1.0]],[[1.0,6.0,2.0],[1.0]],[[2.0,6.0,2.0],[1.0]],[[3.0,6.0,2.0],[1.0]],[[4.0,6.0,2.0],[1.0]],[[12.0,6.0,2.0],[1.0]],[[13.0,6.0,2.0],[1.0]],[[0.0,7.0,2.0],[1.0]],[[1.0,7.0,2.0],[1.0]],[[2.0,7.0,2.0],[1.0]],[[3.0,7.0,2.0],[1.0]],[[4.0,7.0,2.0],[1.0]],[[5.0,7.0,2.0],[1.0]],[[11.0,7.0,2.0],[1.0]],[[12.0,7.0,2.0],[1.0]],[[13.0,7.0,2.0],[1.0]],[[0.0,8.0,2.0],[1.0]],[[1.0,8.0,2.0],[1.0]],[[2.0,8.0,2.0],[1.0]],[[3.0,8.0,2.0],[1.0]],[[4.0,8.0,2.0],[1.0]],[[5.0,8.0,2.0],[1.0]],[[6.0,8.0,2.0],[1.0]],[[10.0,8.0,2.0],[1.0]],[[11.0,8.0,2.0],[1.0]],[[12.0,8.0,2.0],[1.0]],[[13.0,8.0,2.0],[1.0]],[[0.0,9.0,2.0],[1.0]],[[1.0,9.0,2.0],[1.0]],[[2.0,9.0,2.0],[1.0]],[[3.0,9.0,2.0],[1.0]],[[4.0,9.0,2.0],[1.0]],[[5.0,9.0,2.0],[1.0]],[[6.0,9.0,2.0],[1.0]],[[7.0,9.0,2.0],[1.0]],[[9.0,9.0,2.0],[1.0]],[[10.0,9.0,2.0],[1.0]],[[11.0,9.0,2.0],[1.0]],[[12.0,9.0,2.0],[1.0]],[[13.0,9.0,2.0],[1.0]],[[0.0,10.0,2.0],[1.0]],[[1.0,10.0,2.0],[1.0]],[[2.0,10.0,2.0],[1.0]],[[3.0,10.0,2.0],[1.0]],[[4.0,10.0,2.0],[1.0]],[[5.0,10.0,2.0],[1.0]],[[6.0,10.0,2.0],[1.0]],[[7.0,10.0,2.0],[1.0]],[[8.0,10.0,2.0],[1.0]],[[9.0,10.0,2.0],[1.0]],[[10.0,10.0,2.0],[1.0]],[[11.0,10.0,2.0],[1.0]],[[12.0,10.0,2.0],[1.0]],[[13.0,10.0,2.0],[1.0]],[[0.0,11.0,2.0],[1.0]],[[1.0,11.0,2.0],[1.0]],[[2.0,11.0,2.0],[1.0]],[[3.0,11.0,2.0],[1.0]],[[4.0,11.0,2.0],[1.0]],[[5.0,11.0,2.0],[1.0]],[[6.0,11.0,2.0],[1.0]],[[7.0,11.0,2.0],[1.0]],[[8.0,11.0,2.0],[1.0]],[[9.0,11.0,2.0],[1.0]],[[10.0,11.0,2.0],[1.0]],[[11.0,11.0,2.0],[1.0]],[[12.0,11.0,2.0],[1.0]],[[0.0,12.0,2.0],[1.0]],[[1.0,12.0,2.0],[1.0]],[[2.0,12.0,2.0],[1.0]],[[3.0,12.0,2.0],[1.0]],[[4.0,12.0,2.0],[1.0]],[[5.0,12.0,2.0],[1.0]],[[6.0,12.0,2.0],[1.0]],[[7.0,12.0,2.0],[1.0]],[[8.0,12.0,2.0],[1.0]],[[9.0,12.0,2.0],[1.0]],[[10.0,12.0,2.0],[1.0]],[[11.0,12.0,2.0],[1.0]],[[0.0,13.0,2.0],[1.0]],[[1.0,13.0,2.0],[1.0]],[[2.0,13.0,2.0],[1.0]],[[3.0,13.0,2.0],[1.0]],[[4.0,13.0,2.0],[1.0]],[[5.0,13.0,2.0],[1.0]],[[6.0,13.0,2.0],[1.0]],[[7.0,13.0,2.0],[1.0]],[[8.0,13.0,2.0],[1.0]],[[9.0,13.0,2.0],[1.0]],[[10.0,13.0,2.0],[1.0]],[[0.0,14.0,2.0],[1.0]],[[1.0,14.0,2.0],[1.0]],[[2.0,14.0,2.0],[1.0]],[[3.0,14.0,2.0],[1.0]],[[4.0,14.0,2.0],[1.0]],[[5.0,14.0,2.0],[1.0]],[[6.0,14.0,2.0],[1.0]],[[7.0,14.0,2.0],[1.0]],[[8.0,14.0,2.0],[1.0]],[[9.0,14.0,2.0],[1.0]],[[0.0,15.0,2.0],[1.0]],[[1.0,15.0,2.0],[1.0]],[[2.0,15.0,2.0],[1.0]],[[3.0,15.0,2.0],[1.0]],[[4.0,15.0,2.0],[1.0]],[[5.0,15.0,2.0],[1.0]],[[6.0,15.0,2.0],[1.0]],[[7.0,15.0,2.0],[1.0]],[[8.0,15.0,2.0],[1.0]],[[0.0,16.0,2.0],[1.0]],[[1.0,16.0,2.0],[1.0]],[[2.0,16.0,2.0],[1.0]],[[3.0,16.0,2.0],[1.0]],[[4.0,16.0,2.0],[1.0]],[[5.0,16.0,2.0],[1.0]],[[6.0,16.0,2.0],[1.0]],[[7.0,16.0,2.0],[1.0]],[[0.0,17.0,2.0],[1.0]],[[1.0,17.0,2.0],[1.0]],[[2.0,17.0,2.0],[1.0]],[[3.0,17.0,2.0],[1.0]],[[4.0,17.0,2.0],[1.0]],[[5.0,17.0,2.0],[1.0]],[[6.0,17.0,2.0],[1.0]],[[0.0,18.0,2.0],[1.0]],[[1.0,18.0,2.0],[1.0]],[[2.0,18.0,2.0],[1.0]],[[3.0,18.0,2.0],[1.0]],[[4.0,18.0,2.0],[1.0]],[[5.0,18.0,2.0],[1.0]],[[0.0,19.0,2.0],[1.0]],[[1.0,19.0,2.0],[1.0]],[[2.0,19.0,2.0],[1.0]],[[3.0,19.0,2.0],[1.0]],[[4.0,19.0,2.0],[1.0]],[[0.0,20.0,2.0],[1.0]],[[1.0,20.0,2.0],[1.0]],[[2.0,20.0,2.0],[1.0]],[[3.0,20.0,2.0],[1.0]],[[0.0,21.0,2.0],[1.0]],[[1.0,21.0,2.0],[1.0]],[[2.0,21.0,2.0],[1.0]],[[0.0,22.0,2.0],[1.0]],[[1.0,22.0,2.0],[1.0]],[[0.0,23.0,2.0],[1.0]],[[13.0,0.0,3.0],[1.0]],[[12.0,1.0,3.0],[1.0]],[[13.0,1.0,3.0],[1.0]],[[11.0,2.0,3.0],[1.0]],[[12.0,2.0,3.0],[1.0]],[[13.0,2.0,3.0],[1.0]],[[10.0,3.0,3.0],[1.0]],[[11.0,3.0,3.0],[1.0]],[[12.0,3.0,3.0],[1.0]],[[13.0,3.0,3.0],[1.0]],[[9.0,4.0,3.0],[1.0]],[[10.0,4.0,3.0],[1.0]],[[11.0,4.0,3.0],[1.0]],[[12.0,4.0,3.0],[1.0]],[[13.0,4.0,3.0],[1.0]],[[6.0,5.0,3.0],[1.0]],[[7.0,5.0,3.0],[1.0]],[[8.0,5.0,3.0],[1.0]],[[9.0,5.0,3.0],[1.0]],[[10.0,5.0,3.0],[1.0]],[[11.0,5.0,3.0],[1.0]],[[12.0,5.0,3.0],[1.0]],[[13.0,5.0,3.0],[1.0]],[[5.0,6.0,3.0],[1.0]],[[6.0,6.0,3.0],[1.0]],[[7.0,6.0,3.0],[1.0]],[[8.0,6.0,3.0],[1.0]],[[9.0,6.0,3.0],[1.0]],[[10.0,6.0,3.0],[1.0]],[[11.0,6.0,3.0],[1.0]],[[12.0,6.0,3.0],[1.0]],[[13.0,6.0,3.0],[1.0]],[[4.0,7.0,3.0],[1.0]],[[5.0,7.0,3.0],[1.0]],[[6.0,7.0,3.0],[1.0]],[[7.0,7.0,3.0],[1.0]],[[8.0,7.0,3.0],[1.0]],[[9.0,7.0,3.0],[1.0]],[[10.0,7.0,3.0],[1.0]],[[11.0,7.0,3.0],[1.0]],[[12.0,7.0,3.0],[1.0]],[[13.0,7.0,3.0],[1.0]],[[3.0,8.0,3.0],[1.0]],[[4.0,8.0,3.0],[1.0]],[[5.0,8.0,3.0],[1.0]],[[6.0,8.0,3.0],[1.0]],[[7.0,8.0,3.0],[1.0]],[[8.0,8.0,3.0],[1.0]],[[9.0,8.0,3.0],[1.0]],[[10.0,8.0,3.0],[1.0]],[[11.0,8.0,3.0],[1.0]],[[12.0,8.0,3.0],[1.0]],[[2.0,9.0,3.0],[1.0]],[[3.0,9.0,3.0],[1.0]],[[4.0,9.0,3.0],[1.0]],[[5.0,9.0,3.0],[1.0]],[[6.0,9.0,3.0],[1.0]],[[7.0,9.0,3.0],[1.0]],[[8.0,9.0,3.0],[1.0]],[[9.0,9.0,3.0],[1.0]],[[10.0,9.0,3.0],[1.0]],[[11.0,9.0,3.0],[1.0]],[[1.0,10.0,3.0],[1.0]],[[2.0,10.0,3.0],[1.0]],[[3.0,10.0,3.0],[1.0]],[[4.0,10.0,3.0],[1.0]],[[5.0,10.0,3.0],[1.0]],[[6.0,10.0,3.0],[1.0]],[[7.0,10.0,3.0],[1.0]],[[8.0,10.0,3.0],[1.0]],[[9.0,10.0,3.0],[1.0]],[[10.0,10.0,3.0],[1.0]],[[0.0,11.0,3.0],[1.0]],[[1.0,11.0,3.0],[1.0]],[[2.0,11.0,3.0],[1.0]],[[3.0,11.0,3.0],[1.0]],[[4.0,11.0,3.0],[1.0]],[[5.0,11.0,3.0],[1.0]],[[6.0,11.0,3.0],[1.0]],[[7.0,11.0,3.0],[1.0]],[[8.0,11.0,3.0],[1.0]],[[9.0,11.0,3.0],[1.0]],[[0.0,12.0,3.0],[1.0]],[[1.0,12.0,3.0],[1.0]],[[2.0,12.0,3.0],[1.0]],[[3.0,12.0,3.0],[1.0]],[[4.0,12.0,3.0],[1.0]],[[5.0,12.0,3.0],[1.0]],[[6.0,12.0,3.0],[1.0]],[[7.0,12.0,3.0],[1.0]],[[8.0,12.0,3.0],[1.0]],[[0.0,13.0,3.0],[1.0]],[[1.0,13.0,3.0],[1.0]],[[2.0,13.0,3.0],[1.0]],[[3.0,13.0,3.0],[1.0]],[[4.0,13.0,3.0],[1.0]],[[5.0,13.0,3.0],[1.0]],[[6.0,13.0,3.0],[1.0]],[[7.0,13.0,3.0],[1.0]],[[0.0,14.0,3.0],[1.0]],[[1.0,14.0,3.0],[1.0]],[[2.0,14.0,3.0],[1.0]],[[3.0,14.0,3.0],[1.0]],[[4.0,14.0,3.0],[1.0]],[[5.0,14.0,3.0],[1.0]],[[6.0,14.0,3.0],[1.0]],[[0.0,15.0,3.0],[1.0]],[[1.0,15.0,3.0],[1.0]],[[2.0,15.0,3.0],[1.0]],[[3.0,15.0,3.0],[1.0]],[[4.0,15.0,3.0],[1.0]],[[5.0,15.0,3.0],[1.0]],[[0.0,16.0,3.0],[1.0]],[[1.0,16.0,3.0],[1.0]],[[2.0,16.0,3.0],[1.0]],[[3.0,16.0,3.0],[1.0]],[[4.0,16.0,3.0],[1.0]],[[0.0,17.0,3.0],[1.0]],[[1.0,17.0,3.0],[1.0]],[[2.0,17.0,3.0],[1.0]],[[3.0,17.0,3.0],[1.0]],[[0.0,18.0,3.0],[1.0]],[[1.0,18.0,3.0],[1.0]],[[2.0,18.0,3.0],[1.0]],[[0.0,19.0,3.0],[1.0]],[[1.0,19.0,3.0],[1.0]],[[0.0,20.0,3.0],[1.0]]]}
\ No newline at end of file
......@@ -24,6 +24,7 @@ if GPU
end
if plotting
# gr(size=(300,300), html_output_format=:png)
include("./include/plotViz.jl") #plotting and getting data out for analysis
end
......
# Amira Abdel-Rahman
# (c) Massachusetts Institute of Technology 2020
######################### 2D LBM Setup ###########################
######################### 1. Voxel Design ###########################
......@@ -84,9 +86,16 @@ setup["materials"]=[
#//allowed x, yand z are from -gridSize to +gridSize (floor is at 0)
setup["voxelList"]=[]
for o in ON2D
BOUND1=zeros(nx,ny);
BOUND1[Int((nx/2-2)/2):Int((nx/2+2)/2),2:ny-20].=1
BOUND1=Bool.(BOUND1.>0)
ON2D1 = findall(BOUND1);
for o in ON2D1
append!(setup["voxelList"],[ [[o[1],0,o[2]],material1] ])
end
......@@ -94,9 +103,9 @@ end
#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]
# dof=[false,true,false,true,true,true]
center = [nx/4, ny/4]
boundingBoxSupport=Dict()
boundingBoxSupport["min"]=Dict()
boundingBoxSupport["max"]=Dict()
......@@ -118,7 +127,7 @@ setup["supports"]=[
#get loads from LBM calculation
#TODO make sure later conversion is correct (friction..)
#CALLED ELSEWHERE
edgeList=findall(x->x!=0,presD)
setup["loads"]=[];
......@@ -138,13 +147,13 @@ for e in edgeList
boundingBoxLoad2["min"]=Dict()
boundingBoxLoad2["max"]=Dict()
boundingBoxLoad2["min"]["x"]=e[1]*voxelSize
boundingBoxLoad2["min"]["x"]=e[1]/voxelScaleToLBM*voxelSize
boundingBoxLoad2["min"]["y"]=-voxelSize;
boundingBoxLoad2["min"]["z"]=e[2]*voxelSize;
boundingBoxLoad2["min"]["z"]=e[2]/voxelScaleToLBM*voxelSize;
boundingBoxLoad2["max"]["x"]=e[1]*voxelSize+voxelSize;
boundingBoxLoad2["max"]["x"]=e[1]/voxelScaleToLBM*voxelSize+voxelSize;
boundingBoxLoad2["max"]["y"]=voxelSize;
boundingBoxLoad2["max"]["z"]=e[2]*voxelSize+voxelSize;
boundingBoxLoad2["max"]["z"]=e[2]/voxelScaleToLBM*voxelSize+voxelSize;
append!(setup["loads"],[[boundingBoxLoad2,load2]])
end
......@@ -167,7 +176,9 @@ function externalDisplacement(currentTimeStep,N_position,N_fixedDisplacement)
end
function externalForce(currentTimeStep,N_position,N_currentPosition,N_force)
if currentTimeStep==0
display(sum(velD))
end
edgeList=findall(x->x!=0,presD)
......@@ -177,13 +188,13 @@ function externalForce(currentTimeStep,N_position,N_currentPosition,N_force)
loadZ=0
for e in edgeList
minx=e[1]*voxelSize
minx=e[1]/voxelScaleToLBM*voxelSize
miny=-voxelSize;
minz=e[2]*voxelSize;
minz=e[2]/voxelScaleToLBM*voxelSize;
maxx=e[1]*voxelSize+voxelSize;
maxx=e[1]/voxelScaleToLBM*voxelSize+voxelSize;
maxy=voxelSize;
maxz=e[2]*voxelSize+voxelSize;
maxz=e[2]/voxelScaleToLBM*voxelSize+voxelSize;
if N_currentPosition.x>=minx && N_currentPosition.x<=maxx && N_currentPosition.z>=minz && N_currentPosition.z<=maxz
loadX+=velD[e][1]*sc;
......
# Amira Abdel-Rahman
# (c) Massachusetts Institute of Technology 2020
# (c) Massachusetts Institute of Technology 2021
######################### 1. Voxel Design ###########################
......@@ -18,9 +17,7 @@ gridSize=nx*2.0
setup["gridSize"]=gridSize
setup["rhino"]=false
setup["useVoxelList"]=true
setup["logging"]=logging
......@@ -60,6 +57,15 @@ material1["density"]=1e3
material1["stiffness"]=1e6
material1["poissonRatio"]=0.0
material1["cTE"]=0.0 #coefficient of thermal expansion
material1["scale"]=1.0 #for multiscale simulation
material2= Dict()
material2["area"]=voxelSize*voxelSize
material2["density"]=1e3
material2["stiffness"]=1e6*2.0
material2["poissonRatio"]=0.0
material2["cTE"]=0.0 #coefficient of thermal expansion
material2["scale"]=2.0 #for multiscale simulation
#large bounding box for default material
boundingBoxMaterial1=Dict()
......@@ -79,35 +85,81 @@ setup["materials"]=[
];
#
#//allowed x, yand z are from -gridSize to +gridSize (floor is at 0)
setup["voxelList"]=[]
for o in ON2D
append!(setup["voxelList"],[ [[o[1],o[3],o[2]],material1] ])
end
# initial design
# # voxelScaleToLBM=2;
# BOUND1=zeros(Int(nx/2),Int(ny/2),Int(nz/2))
# BOUND1[Int(floor((nx/2-2)/4)):Int(floor((nx/2+2)/2)),1:3,2:Int((nz-4*2))].=1
# BOUND1=Bool.(BOUND1.>0)
# ON2D1 = findall(BOUND1);
# # voxelScaleToLBM=1;
# # BOUND1=zeros(nx,ny,nz)
# # BOUND1[Int(nx/2-2):Int(nx/2+2),2:6,4:nz-4].=1
# # BOUND1=Bool.(BOUND1.>0)
# # ON2D1 = findall(BOUND1);
# setup["useVoxelList"]=true
# setup["voxelList"]=[]
# for o in ON2D1
# append!(setup["voxelList"],[ [[o[1],o[3],o[2]],material1] ])
# end
# latticeSizeX=7
# latticeSizeY=7
# latticeSizeZ=7
# setup["latticeSizeX"]=latticeSizeX
# setup["latticeSizeY"]=latticeSizeY
# setup["latticeSizeZ"]=latticeSizeZ
# setup["useVoxelList"]=false
setup["useVoxelList"]=true
setup["gridSize"]=50
setup["multiscale"]=true; #multiscale simualtion
setup["voxelList"]=[];
voxShift=[4,4,4]
for vox in voxs
if vox[2][1]==1
append!(setup["voxelList"], [[[vox[1][2]+voxShift[1],vox[1][3]+voxShift[2],vox[1][1]+voxShift[3]],material1]])
elseif vox[2][1]==2
append!(setup["voxelList"], [[[vox[1][2]+voxShift[1],vox[1][3]+voxShift[2],vox[1][1]+voxShift[3]],material]])
end
end
######################### 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]
# dof=[false,true,false,true,true,true]
boundingBoxSupport=Dict()
boundingBoxSupport["min"]=Dict()
boundingBoxSupport["max"]=Dict()
boundingBoxSupport["min"]["x"]=(center[1]-4)*voxelSize;
boundingBoxSupport["min"]["z"]=-0*voxelSize;
boundingBoxSupport["min"]["y"]=2*voxelSize;
# boundingBoxSupport["min"]["x"]=0*voxelSize;
# boundingBoxSupport["min"]["z"]=0*voxelSize;
# boundingBoxSupport["min"]["y"]=0*voxelSize;
# boundingBoxSupport["max"]["x"]=nx*voxelSize;
# boundingBoxSupport["max"]["z"]=nz*voxelSize;
# boundingBoxSupport["max"]["y"]=4*voxelSize;
# boundingBoxSupport["min"]["x"]= 0;
# boundingBoxSupport["min"]["y"]= 0;
# boundingBoxSupport["min"]["z"]= 0;
# boundingBoxSupport["max"]["x"]= voxelSize;
# boundingBoxSupport["max"]["y"]= voxelSize*(latticeSizeY);
# boundingBoxSupport["max"]["z"]= voxelSize*(latticeSizeZ);
boundingBoxSupport["min"]["x"]= 0;
boundingBoxSupport["min"]["y"]= 0;
boundingBoxSupport["min"]["z"]= 0;
boundingBoxSupport["max"]["z"]= voxelSize*(2+4);
boundingBoxSupport["max"]["y"]= voxelSize*(10+4);
boundingBoxSupport["max"]["x"]= voxelSize*gridSize;
boundingBoxSupport["max"]["x"]=(center[1]+4)*voxelSize;
boundingBoxSupport["max"]["z"]=nz*voxelSize;
boundingBoxSupport["max"]["y"]=3*voxelSize+voxelSize*2;
setup["supports"]=[
[boundingBoxSupport,dof]
......@@ -119,13 +171,14 @@ setup["supports"]=[
#get loads from LBM calculation
#TODO make sure later conversion is correct (friction..)
##CALLED ELSEWHERE
edgeList=findall(x->x!=0,presD)
setup["loads"]=[];
sc=0.0
if t==1
sc=0.1
sc=0.001
end
for e in edgeList
load2=Dict()
......@@ -135,25 +188,15 @@ for e in edgeList
boundingBoxLoad2=Dict()
boundingBoxLoad2["min"]=Dict()
boundingBoxLoad2["max"]=Dict()
# boundingBoxLoad2["min"]["x"]=e[1]*voxelSize
# boundingBoxLoad2["min"]["y"]=-voxelSize;
# boundingBoxLoad2["min"]["z"]=e[2]*voxelSize;
# boundingBoxLoad2["max"]["x"]=e[1]*voxelSize+voxelSize;
# boundingBoxLoad2["max"]["y"]=voxelSize;
# boundingBoxLoad2["max"]["z"]=e[2]*voxelSize+voxelSize;
boundingBoxLoad2["min"]=Dict();boundingBoxLoad2["max"]=Dict();
boundingBoxLoad2["min"]["x"]=e[1]*voxelSize;
boundingBoxLoad2["min"]["y"]=e[3]*voxelSize;
boundingBoxLoad2["min"]["z"]=e[2]*voxelSize;
boundingBoxLoad2["min"]["x"]=round(e[1]/voxelScaleToLBM)*voxelSize;
boundingBoxLoad2["min"]["y"]=round(e[3]/voxelScaleToLBM)*voxelSize;
boundingBoxLoad2["min"]["z"]=round(e[2]/voxelScaleToLBM)*voxelSize;
boundingBoxLoad2["max"]["x"]=e[1]*voxelSize+voxelSize;
boundingBoxLoad2["max"]["y"]=e[3]*voxelSize+voxelSize;
boundingBoxLoad2["max"]["z"]=e[2]*voxelSize+voxelSize;
boundingBoxLoad2["max"]["x"]=round(e[1]/voxelScaleToLBM)*voxelSize+voxelSize/voxelScaleToLBM;
boundingBoxLoad2["max"]["y"]=round(e[3]/voxelScaleToLBM)*voxelSize+voxelSize/voxelScaleToLBM;
boundingBoxLoad2["max"]["z"]=round(e[2]/voxelScaleToLBM)*voxelSize+voxelSize/voxelScaleToLBM;
append!(setup["loads"],[[boundingBoxLoad2,load2]])
end
......@@ -180,19 +223,19 @@ function externalForce(currentTimeStep,N_position,N_currentPosition,N_force)
edgeList=findall(x->x!=0,presD)
sc=0.2
sc=0.01
loadX=0
loadY=0
loadZ=0
for e in edgeList
minx=e[1]*voxelSize
miny=e[3]*voxelSize;
minz=e[2]*voxelSize;
minx=round(e[1]/voxelScaleToLBM)*voxelSize
miny=round(e[3]/voxelScaleToLBM)*voxelSize;
minz=round(e[2]/voxelScaleToLBM)*voxelSize;
maxx=e[1]*voxelSize+voxelSize;
maxy=e[3]*voxelSize+voxelSize;
maxz=e[2]*voxelSize+voxelSize;
maxx=round(e[1]/voxelScaleToLBM)+voxelSize/voxelScaleToLBM;
maxy=round(e[3]/voxelScaleToLBM)+voxelSize/voxelScaleToLBM;
maxz=round(e[2]/voxelScaleToLBM)+voxelSize/voxelScaleToLBM;
if N_currentPosition.x>=minx && N_currentPosition.x<=maxx && N_currentPosition.z>=minz && N_currentPosition.z<=maxz && N_currentPosition.y>=miny && N_currentPosition.y<=maxy
loadX+=velD[e][1]*sc;
......
# JULIA 1.2.0
using EnhancedGJK ,GeometryTypes,LinearAlgebra,BenchmarkTools;
# make sure MeshIO is old version (0.3.2) to use geometry types and not gemoetry basics
using MeshIO ,FileIO,CoordinateTransformations,MeshCat,RegionTrees;
# Pkg.add(Pkg.PackageSpec(;name="MeshIO", version="0.3.2"))
using MeshIO ,FileIO,CoordinateTransformations,RegionTrees;
using MeshCat;
# using GeometryBasics
import StaticArrays: SVector
......@@ -50,7 +51,7 @@ w=widths[1]
insideOnly=true
maxDivision=5 #how many divisions (biggest)
minDivision=6 #how many divisions (smallest)
minDivision=5 #how many divisions (smallest)
minSize=w/(2^minDivision) #min voxel size
maxSize=w/(2^maxDivision) #max voxel size
......@@ -114,4 +115,14 @@ end
voxx = Dict()
voxx["voxs"]=voxs
# pass data as a json string (how it shall be displayed in a file)
stringdata = JSON.json(voxx)
# write the file with the stringdata variable information
open("../json/voxs.json", "w") do f
write(f, stringdata)
end
......@@ -36,6 +36,7 @@ function updateDataAndSave!(metavoxel,setup,fileName,sys="GPU")
if haskey(setup,"scale")
scale1=setup["scale"]
end
scale1=1.0
scale2=1.0
scale=scale1/scale2
......
......@@ -13,7 +13,7 @@ using Plots
#3d
using GLMakie
using Makie
# using Makie
if GPU
using CUDA;
......@@ -22,6 +22,9 @@ end
using BenchmarkTools
using Test # do I need?
using FileIO, ImageIO, Colors, FixedPointNumbers, Images
using ConcaveHull
using Luxor
# Makie.AbstractPlotting.inline!(true)
......@@ -337,7 +340,7 @@ function lbm2D1(nx,ny,maxIter,setboundary2D,radius,dynamic=false,verbose=false,s
end
function concurrentlbm2D(nx,ny,UX,UY,F,FEQ,maxIter,setboundary2D,setup,t)
function concurrentlbm2D!(nx,ny,UX,UY,F,FEQ,maxIter,boundaryProblem,setup,t)
# configuration
omega = 1.0; density = 1.0;
......@@ -356,7 +359,7 @@ function concurrentlbm2D(nx,ny,UX,UY,F,FEQ,maxIter,setboundary2D,setup,t)
# FEQ = F;
# UX=zeros(nx,ny); UY=zeros(nx,ny);
BOUND,ON,numactivenodes,TO_REFLECT,REFLECTED=setboundary2D(nx,ny,setup,0);
BOUND,ON,numactivenodes,TO_REFLECT,REFLECTED=boundaryProblem(nx,ny,setup,0);
# constants
......@@ -512,7 +515,7 @@ function lbm3D(nx,ny,nz,maxIter,saveEvery=200)
while (ts<maxIter)
# while (ts<maxIter && 1e-10<abs((prevavu-avu)/avu)) || ts<maxIter2
# while (ts<maxIter && 1e-10<abs((prevavu-avu)/avu)) || ts<maxIter2
# Propagate
# boundary conditions: x direction open, rest closed
#nearest-neighbours
......@@ -630,7 +633,7 @@ function lbm3D(nx,ny,nz,maxIter,saveEvery=200)
ts=ts+1;
if ts%saveEvery==0
display3D(UX,UY,UZ,ts)
display3D(UX,UY,UZ,BOUND,ts)
print(ts)
print(",")
......@@ -665,17 +668,17 @@ function lbm3D(nx,ny,nz,maxIter,saveEvery=200)
######
return UX,UY,UZ,anim,anim2D
return UX,UY,UZ,BOUND,anim,anim2D
end
function concurrentlbm3D(nx,ny,nz,UX,UY,UZ,F,FEQ,maxIter,setboundary3D,setup,t)
function concurrentlbm3D!(nx,ny,nz,UX,UY,UZ,F,FEQ,maxIter,boundaryProblem,setup,t)
# configuration & setup of variables
omega=1.0; deltaU=0.1;
BOUND,ON,TO_REFLECT,REFLECTED=setboundary3D(nx,ny,nz,setup,0);
BOUND,ON,TO_REFLECT,REFLECTED=boundaryProblem(nx,ny,nz,setup,0);
# constants
t1=1/3; t2=1/18; t3=1/36;
......@@ -777,7 +780,7 @@ function concurrentlbm3D(nx,ny,nz,UX,UY,UZ,F,FEQ,maxIter,setboundary3D,setup,t)
end
display3D(UX,UY,UZ,t)
display3D(UX,UY,UZ,BOUND,t)
# frame(anim)
return UX,UY,UZ,F,FEQ,BOUND
end
......@@ -855,6 +858,7 @@ function setboundaryMetavoxels2D(nx,ny,setup,t) #circle in the middle #dynamic
# center = [nx/2, ny/2+y]
nodes=setup["nodes"]
scale=setup["scale"]*setup["voxelSize"] #later see scale
scale=1/voxelScaleToLBM*setup["voxelSize"] #make it part of setup
shift=-0.500001
disX=[];disY=[];disZ=[];
points=[]
......@@ -883,7 +887,7 @@ function setboundaryMetavoxels2D(nx,ny,setup,t) #circle in the middle #dynamic
pp[end]=Luxor.Point(hull.vertices[1][1], hull.vertices[1][2])
function getinside(xx,yy)
return isinside(Luxor.Point.(xx, yy), pp)
return Luxor.isinside(Luxor.Point.(xx, yy), pp)
end
BOUND = [getinside(i,j) for i=1:nx, j=1:ny]
......@@ -933,6 +937,7 @@ function setboundaryMetavoxels3D(nx,ny,nz,setup,t)
# center = [nx/2, ny/2+y]
nodes=setup["nodes"]
scale=setup["scale"]*setup["voxelSize"] #later see scale
scale=1/voxelScaleToLBM*setup["voxelSize"] #later see scale
shift=-0.500001
disX=[];disY=[];disZ=[];
......@@ -949,9 +954,16 @@ function setboundaryMetavoxels3D(nx,ny,nz,setup,t)
# append!(disZ,[node["position"]["z"]/scale+node["displacement"]["z"]/scale+shift])
k=Int(round((node["position"]["y"] + node["displacement"]["y"])/scale+shift))
append!(points[k],[ [(node["position"]["x"] + node["displacement"]["x"])/scale+shift,
if (k<nz&& k>0)
append!(points[k],[ [(node["position"]["x"] + node["displacement"]["x"])/scale+shift,
(node["position"]["z"] + node["displacement"]["z"])/scale+shift ]])
end
for kk