-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
80191b7
commit 194d7cd
Showing
8 changed files
with
11,532 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
4,969 changes: 4,969 additions & 0 deletions
4,969
tutorials/23_beam_bridge/data/bridge_facet_region.xml
Large diffs are not rendered by default.
Oops, something went wrong.
1,661 changes: 1,661 additions & 0 deletions
1,661
tutorials/23_beam_bridge/data/bridge_physical_region.xml
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[{('0.05', '0.0'): ('mu[0]', '0.0'), ('0.25', '0.0'): ('mu[0]+0.2', '0.0'), ('0.15', '0.2'): ('mu[0]+0.1', '0.2')}, {('2.75', '0.0'): ('2.8-mu[0]', '0.0'), ('2.95', '0.0'): ('3.0-mu[0]', '0.0'), ('2.85', '0.2'): ('2.9-mu[0]', '0.2')}, {('0.0', '0.2'): ('0.0', '0.2'), ('0.15', '0.2'): ('mu[0]+0.1', '0.2'), ('0.0', '0.5'): ('0.0', '0.5')}, {('0.0', '0.5'): ('0.0', '0.5'), ('0.15', '0.2'): ('mu[0]+0.1', '0.2'), ('1.5', '0.2'): ('1.5', '0.2')}, {('0.0', '0.5'): ('0.0', '0.5'), ('1.5', '0.2'): ('1.5', '0.2'), ('3.0', '0.5'): ('3.0', '0.5')}, {('1.5', '0.2'): ('1.5', '0.2'), ('2.85', '0.2'): ('2.9-mu[0]', '0.2'), ('3.0', '0.5'): ('3.0', '0.5')}, {('2.85', '0.2'): ('2.9-mu[0]', '0.2'), ('3.0', '0.2'): ('3.0', '0.2'), ('3.0', '0.5'): ('3.0', '0.5')}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,238 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from dolfin import *\n", | ||
"from mshr import *\n", | ||
"from rbnics.backends.dolfin.wrapping import counterclockwise\n", | ||
"from rbnics.shape_parametrization.utils.symbolic import VerticesMappingIO" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# reference value\n", | ||
"m0 = 0.05" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Define domain\n", | ||
"beam = Rectangle(Point(0., 0.2),Point(3., 0.5))\n", | ||
"left_support = Polygon([Point(0.05, 0.), Point(0.25, 0.), Point(0.15, 0.2)])\n", | ||
"right_support = Polygon([Point(2.75, 0.), Point(2.95, 0.), Point(2.85, 0.2)])\n", | ||
"domain = beam + left_support + right_support" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Define vertices mappings of affine shape parametrization. These will be used\n", | ||
"# to partition the mesh in subdomains.\n", | ||
"vertices_mappings = [\n", | ||
" {\n", | ||
" (\"0.05\",\"0.0\"): (\"mu[0]\", \"0.0\"),\n", | ||
" (\"0.25\",\"0.0\"): (\"mu[0]+0.2\", \"0.0\"),\n", | ||
" (\"0.15\",\"0.2\"): (\"mu[0]+0.1\", \"0.2\")\n", | ||
" }, #subdomain 1\n", | ||
" {\n", | ||
" (\"2.75\",\"0.0\"): (\"2.8-mu[0]\", \"0.0\"),\n", | ||
" (\"2.95\",\"0.0\"): (\"3.0-mu[0]\", \"0.0\"),\n", | ||
" (\"2.85\",\"0.2\"): (\"2.9-mu[0]\", \"0.2\")\n", | ||
" }, #subdomain 2\n", | ||
" {\n", | ||
" (\"0.0\", \"0.2\"): (\"0.0\", \"0.2\"),\n", | ||
" (\"0.15\", \"0.2\"): (\"mu[0]+0.1\", \"0.2\"),\n", | ||
" (\"0.0\",\"0.5\"): (\"0.0\", \"0.5\")\n", | ||
" }, #subdomain 3\n", | ||
" {\n", | ||
" (\"0.0\",\"0.5\"): (\"0.0\",\"0.5\"),\n", | ||
" (\"0.15\", \"0.2\"): (\"mu[0]+0.1\",\"0.2\"),\n", | ||
" (\"1.5\",\"0.2\"): (\"1.5\",\"0.2\")\n", | ||
" }, #subdomain 4\n", | ||
" {\n", | ||
" (\"0.0\", \"0.5\"): (\"0.0\",\"0.5\"),\n", | ||
" (\"1.5\",\"0.2\"): (\"1.5\",\"0.2\"),\n", | ||
" (\"3.0\",\"0.5\"): (\"3.0\",\"0.5\")\n", | ||
" }, #subdomain 5\n", | ||
" {\n", | ||
" (\"1.5\",\"0.2\"): (\"1.5\",\"0.2\"),\n", | ||
" (\"2.85\", \"0.2\"): (\"2.9-mu[0]\",\"0.2\"),\n", | ||
" (\"3.0\",\"0.5\"): (\"3.0\",\"0.5\")\n", | ||
" }, #subdomain 6\n", | ||
" {\n", | ||
" (\"2.85\", \"0.2\"): (\"2.9-mu[0]\",\"0.2\"),\n", | ||
" (\"3.0\",\"0.2\"): (\"3.0\",\"0.2\"),\n", | ||
" (\"3.0\",\"0.5\"): (\"3.0\",\"0.5\")\n", | ||
" }, #subdomain 7\n", | ||
"]" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Create mesh\n", | ||
"for i, vertices_mapping in enumerate(vertices_mappings):\n", | ||
" subdomain_i = Polygon([Point(*[float(coord) for coord in vertex]) for vertex in counterclockwise(vertices_mapping.keys())])\n", | ||
" domain.set_subdomain(i + 1, subdomain_i)\n", | ||
"mesh = generate_mesh(domain, 50)\n", | ||
"plot(mesh)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Create subdomains\n", | ||
"subdomains = MeshFunction(\"size_t\", mesh, 2, mesh.domains())\n", | ||
"plot(subdomains)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Create boundaries\n", | ||
"\n", | ||
"#beam\n", | ||
"class BottomLeftOut(SubDomain):\n", | ||
" def inside(self,x,on_boundary):\n", | ||
" return on_boundary and abs(x[1]-0.2) < DOLFIN_EPS and x[0]<= m0+0.1\n", | ||
"class BottomLeftIn(SubDomain):\n", | ||
" def inside(self,x,on_boundary):\n", | ||
" return on_boundary and ((abs(x[1]-0.2) < DOLFIN_EPS and x[0]>= m0+0.1 and x[0]<=1.5) or ((x[0]-(m0+0.1))**2+(x[1]-0.2)**2<DOLFIN_EPS))\n", | ||
"class BottomRightIn(SubDomain):\n", | ||
" def inside(self,x,on_boundary):\n", | ||
" return on_boundary and abs(x[1]-0.2) < DOLFIN_EPS and x[0]>=1.5 and x[0]<=2.9-m0\n", | ||
"class BottomRightOut(SubDomain):\n", | ||
" def inside(self,x,on_boundary):\n", | ||
" return on_boundary and abs(x[1]-0.2) < DOLFIN_EPS and x[0]>=2.9-m0 and x[0]<=3\n", | ||
"class Top(SubDomain):\n", | ||
" def inside(self,x,on_boundary):\n", | ||
" return on_boundary and abs(x[1]-0.5) < DOLFIN_EPS\n", | ||
"class Left(SubDomain):\n", | ||
" def inside(self,x,on_boundary):\n", | ||
" return on_boundary and abs(x[0]) < DOLFIN_EPS\n", | ||
"class Right(SubDomain):\n", | ||
" def inside(self,x,on_boundary):\n", | ||
" return on_boundary and abs(x[0]-3) < DOLFIN_EPS\n", | ||
"\n", | ||
"#left support\n", | ||
"class LSBottom(SubDomain):\n", | ||
" def inside(self,x,on_boundary):\n", | ||
" return on_boundary and abs(x[1]) < DOLFIN_EPS and x[0]<1.5\n", | ||
"class LSLeft(SubDomain):\n", | ||
" def inside(self,x,on_boundary):\n", | ||
" return on_boundary and x[1]<=0.2 and abs(x[1]-2*x[0]+0.1) < DOLFIN_EPS\n", | ||
"class LSRight(SubDomain):\n", | ||
" def inside(self,x,on_boundary):\n", | ||
" return on_boundary and x[1]<=0.2 and abs(x[1]+2*x[0]-0.5) < DOLFIN_EPS\n", | ||
" \n", | ||
"#right support\n", | ||
"class RSBottom(SubDomain):\n", | ||
" def inside(self,x,on_boundary):\n", | ||
" return on_boundary and abs(x[1]) < DOLFIN_EPS and x[0]>1.5\n", | ||
"class RSLeft(SubDomain):\n", | ||
" def inside(self,x,on_boundary):\n", | ||
" return on_boundary and ((x[1]<0.2 and x[1] > 0 and x[0] >= 2.8-m0 and x[0]<= 2.9-m0) or ((x[0]-2.85)**2+(x[1]-0.2)**2)<DOLFIN_EPS or ((x[0]-2.75)**2+(x[1]-0)**2)<DOLFIN_EPS)\n", | ||
"class RSRight(SubDomain):\n", | ||
" def inside(self,x,on_boundary):\n", | ||
" return on_boundary and ((x[1]<0.2 and x[1] > 0 and x[0] >= 2.9-m0 and x[0]<= 3-m0) or ((x[0]-2.85)**2+(x[1]-0.2)**2)<DOLFIN_EPS or ((x[0]-2.95)**2+(x[1]-0)**2)<DOLFIN_EPS)\n", | ||
"\n", | ||
"boundaries = MeshFunction(\"size_t\", mesh, mesh.topology().dim() - 1)\n", | ||
"boundaries.set_all(0)\n", | ||
"\n", | ||
"lsBottom=LSBottom()\n", | ||
"lsBottom.mark(boundaries,1)\n", | ||
"rsBottom=RSBottom()\n", | ||
"rsBottom.mark(boundaries,2)\n", | ||
"bottomLeftOut=BottomLeftOut()\n", | ||
"bottomLeftOut.mark(boundaries, 3)\n", | ||
"bottomLeftIn=BottomLeftIn()\n", | ||
"bottomLeftIn.mark(boundaries, 4)\n", | ||
"bottomRightIn=BottomRightIn()\n", | ||
"bottomRightIn.mark(boundaries,5)\n", | ||
"bottomRightOut=BottomRightOut()\n", | ||
"bottomRightOut.mark(boundaries,6)\n", | ||
"\n", | ||
"top=Top()\n", | ||
"top.mark(boundaries,7)\n", | ||
"left=Left()\n", | ||
"left.mark(boundaries,8)\n", | ||
"right=Right()\n", | ||
"right.mark(boundaries,9)\n", | ||
"lsLeft=LSLeft()\n", | ||
"lsLeft.mark(boundaries,10)\n", | ||
"lsRight=LSRight()\n", | ||
"lsRight.mark(boundaries,11)\n", | ||
"rsRight=RSRight()\n", | ||
"rsRight.mark(boundaries,12)\n", | ||
"rsLeft=RSLeft()\n", | ||
"rsLeft.mark(boundaries,13)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Save to xml file\n", | ||
"VerticesMappingIO.save_file(vertices_mappings, \".\", \"bridge_vertices_mapping.vmp\")\n", | ||
"File(\"bridge.xml\") << mesh\n", | ||
"File(\"bridge_physical_region.xml\") << subdomains\n", | ||
"File(\"bridge_facet_region.xml\") << boundaries\n", | ||
"XDMFFile(\"bridge.xdmf\").write(mesh)\n", | ||
"XDMFFile(\"bridge_physical_region.xdmf\").write(subdomains)\n", | ||
"XDMFFile(\"bridge_facet_region.xdmf\").write(boundaries)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "fenicsproject", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.8" | ||
}, | ||
"vscode": { | ||
"interpreter": { | ||
"hash": "350886dd400890bdab5bb475c6063c29c7de30eb69ba1c0ec092516149a9f42d" | ||
} | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
Oops, something went wrong.