Created
November 27, 2019 00:56
-
-
Save jmansour/7973613d7a437dd5672d6c2858b9a592 to your computer and use it in GitHub Desktop.
pras_demo
This file contains hidden or 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
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 23, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import underworld as uw\n", | |
"import numpy as np" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 24, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"mesh = uw.mesh.FeMesh_Cartesian()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 25, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"swarm = uw.swarm.Swarm(mesh)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 26, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"var = swarm.add_variable('double',1)\n", | |
"material = swarm.add_variable('int',1)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 27, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"swarm.populate_using_layout(uw.swarm.layouts.PerCellSpaceFillerLayout(swarm,20))" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 29, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# get indices for column\n", | |
"inds = np.where( (swarm.data[:,0] > 0.5) & (swarm.data[:,0] < 0.8) )" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 31, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"material.data[:] = 0\n", | |
"# set material index to 1 in column\n", | |
"material.data[inds] = 1" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 48, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"array([[ 0.58203125, 0.01171875],\n", | |
" [ 0.70703125, 0.13671875],\n", | |
" [ 0.61328125, 0.10546875],\n", | |
" [ 0.73828125, 0.23046875],\n", | |
" [ 0.55078125, 0.16796875],\n", | |
" [ 0.67578125, 0.04296875],\n", | |
" [ 0.55859375, 0.06640625],\n", | |
" [ 0.68359375, 0.19140625],\n", | |
" [ 0.62109375, 0.12890625],\n", | |
" [ 0.74609375, 0.00390625],\n", | |
" [ 0.58984375, 0.22265625],\n", | |
" [ 0.71484375, 0.09765625],\n", | |
" [ 0.52734375, 0.03515625],\n", | |
" [ 0.65234375, 0.16015625],\n", | |
" [ 0.60546875, 0.01953125],\n", | |
" [ 0.73046875, 0.14453125],\n", | |
" [ 0.54296875, 0.20703125],\n", | |
" [ 0.66796875, 0.08203125],\n", | |
" [ 0.51171875, 0.17578125],\n", | |
" [ 0.63671875, 0.05078125],\n", | |
" [ 0.78710938, 0.17382812],\n", | |
" [ 0.75585938, 0.20507812],\n", | |
" [ 0.77148438, 0.06445312],\n", | |
" [ 0.77929688, 0.16601562],\n", | |
" [ 0.66601562, 0.38085938],\n", | |
" [ 0.58300781, 0.44628906],\n", | |
" [ 0.70800781, 0.32128906],\n", | |
" [ 0.64550781, 0.38378906],\n", | |
" [ 0.55175781, 0.35253906],\n", | |
" [ 0.67675781, 0.47753906],\n", | |
" [ 0.73925781, 0.29003906],\n", | |
" [ 0.50488281, 0.39941406],\n", | |
" [ 0.62988281, 0.27441406],\n", | |
" [ 0.56738281, 0.33691406],\n", | |
" [ 0.69238281, 0.46191406],\n", | |
" [ 0.59863281, 0.30566406],\n", | |
" [ 0.72363281, 0.43066406],\n", | |
" [ 0.53613281, 0.49316406],\n", | |
" [ 0.66113281, 0.36816406],\n", | |
" [ 0.66894531, 0.39160156],\n", | |
" [ 0.60644531, 0.45410156],\n", | |
" [ 0.73144531, 0.32910156],\n", | |
" [ 0.57519531, 0.42285156],\n", | |
" [ 0.70019531, 0.29785156],\n", | |
" [ 0.76269531, 0.36035156],\n", | |
" [ 0.77832031, 0.46972656],\n", | |
" [ 0.76660156, 0.33300781],\n", | |
" [ 0.79785156, 0.30175781],\n", | |
" [ 0.60449219, 0.50292969],\n", | |
" [ 0.72949219, 0.62792969],\n", | |
" [ 0.65136719, 0.67480469],\n", | |
" [ 0.58886719, 0.73730469],\n", | |
" [ 0.62011719, 0.64355469],\n", | |
" [ 0.74511719, 0.51855469],\n", | |
" [ 0.55761719, 0.58105469],\n", | |
" [ 0.68261719, 0.70605469],\n", | |
" [ 0.61621094, 0.53808594],\n", | |
" [ 0.74121094, 0.66308594],\n", | |
" [ 0.55371094, 0.72558594],\n", | |
" [ 0.67871094, 0.60058594],\n", | |
" [ 0.52246094, 0.63183594],\n", | |
" [ 0.64746094, 0.50683594],\n", | |
" [ 0.58496094, 0.56933594],\n", | |
" [ 0.70996094, 0.69433594],\n", | |
" [ 0.53808594, 0.61621094],\n", | |
" [ 0.66308594, 0.74121094],\n", | |
" [ 0.60058594, 0.67871094],\n", | |
" [ 0.56933594, 0.70996094],\n", | |
" [ 0.75683594, 0.52246094],\n", | |
" [ 0.76464844, 0.74902344],\n", | |
" [ 0.79589844, 0.65527344],\n", | |
" [ 0.78027344, 0.60839844],\n", | |
" [ 0.66748047, 0.79248047],\n", | |
" [ 0.51123047, 0.94873047],\n", | |
" [ 0.63623047, 0.82373047],\n", | |
" [ 0.57373047, 0.76123047],\n", | |
" [ 0.69873047, 0.88623047],\n", | |
" [ 0.69091797, 0.84716797],\n", | |
" [ 0.50341797, 0.78466797],\n", | |
" [ 0.62841797, 0.90966797],\n", | |
" [ 0.53466797, 0.81591797],\n", | |
" [ 0.65966797, 0.94091797],\n", | |
" [ 0.59716797, 0.87841797],\n", | |
" [ 0.72216797, 0.75341797],\n", | |
" [ 0.51904297, 0.92529297],\n", | |
" [ 0.64404297, 0.80029297],\n", | |
" [ 0.58154297, 0.86279297],\n", | |
" [ 0.70654297, 0.98779297],\n", | |
" [ 0.61279297, 0.76904297],\n", | |
" [ 0.73779297, 0.89404297],\n", | |
" [ 0.55029297, 0.95654297],\n", | |
" [ 0.67529297, 0.83154297],\n", | |
" [ 0.77490234, 0.95849609],\n", | |
" [ 0.75927734, 0.81787109],\n", | |
" [ 0.79052734, 0.78662109],\n", | |
" [ 0.78271484, 0.95068359]])" | |
] | |
}, | |
"execution_count": 48, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"# in reverse, we can get the locations for all particles with index 1\n", | |
"swarm.data[ np.where(material.data[:,0]==1) ]" | |
] | |
} | |
], | |
"metadata": { | |
"jupytext": { | |
"formats": "ipynb,py:percent" | |
}, | |
"kernelspec": { | |
"display_name": "Python 3", | |
"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.5.3" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
This file contains hidden or 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
FROM underworldcode/underworld2:2.7.1b | |
COPY demo.ipynb $NB_WORK |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment