{"id":1395,"date":"2019-01-21T11:46:06","date_gmt":"2019-01-21T10:46:06","guid":{"rendered":"https:\/\/silentdynamics.de\/?p=1395"},"modified":"2019-03-26T14:17:52","modified_gmt":"2019-03-26T13:17:52","slug":"vector-calculus-in-bash-scripts","status":"publish","type":"post","link":"https:\/\/silentdynamics.de\/es\/2019\/01\/21\/vector-calculus-in-bash-scripts\/","title":{"rendered":"Vector Calculus in Bash Scripts"},"content":{"rendered":"<p>When performing preparatory operations for e.g. CFD or FEM analyses, it is often necessary to specify vector parameters. Vector constants are easy to handle:<\/p>\n<pre class=\"lang:default decode:true\">DIR=\"1 0 0\"\n\nmyMesh --direction \"$DIR\"<\/pre>\n<p>However, it quickly becomes complicated if the vectors have to be manipulated, e.g. multiplied by scalars or rotated.<\/p>\n<p>A powerful solution is to use the Matlab Octave clone to perform the operations. Two features of octave are useful in this context:<\/p>\n<ul>\n<li>the command line option &#8220;&#8211;eval&#8221; to specify the expression to handle<\/li>\n<li>the function &#8220;disp&#8221; to output the results in plain format in a single line<\/li>\n<\/ul>\n<p>An example:<\/p>\n<pre class=\"lang:default decode:true \">DIR=\"1 0 0\"\nVELOCITY=$(octave --eval \"disp( 11.*[$DIR] )\")\n\nmyMesh --direction \"$DIR\"\nmySolver --velocity \"$VELOCITY\"<\/pre>\n<p>More complicated operation are possible. Though one needs to take care to produce line vectors as results. Rotation as an example:<\/p>\n<pre class=\"lang:default decode:true \">DIR=\"1 0 0\"\nANG=45\n\nDIR_ROT=$(octave --eval \"pkg load linear-algebra; disp( (rotv([0 0 1], $ANG*pi\/180)*[$DIR]')' )\")\n\nmyMesh --direction \"$DIR_ROT\"<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When performing preparatory operations for e.g. CFD or FEM analyses, it is often necessary to specify vector parameters. Vector constants are easy to handle: DIR=&#8221;1 0 0&#8243; myMesh &#8211;direction &#8220;$DIR&#8221; However, it quickly becomes complicated if the vectors have to be manipulated, e.g. multiplied by scalars or rotated. A powerful solution is to use the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[191],"tags":[],"class_list":["post-1395","post","type-post","status-publish","format-standard","hentry","category-oss-cae-blog"],"_links":{"self":[{"href":"https:\/\/silentdynamics.de\/es\/wp-json\/wp\/v2\/posts\/1395","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/silentdynamics.de\/es\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/silentdynamics.de\/es\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/silentdynamics.de\/es\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/silentdynamics.de\/es\/wp-json\/wp\/v2\/comments?post=1395"}],"version-history":[{"count":0,"href":"https:\/\/silentdynamics.de\/es\/wp-json\/wp\/v2\/posts\/1395\/revisions"}],"wp:attachment":[{"href":"https:\/\/silentdynamics.de\/es\/wp-json\/wp\/v2\/media?parent=1395"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/silentdynamics.de\/es\/wp-json\/wp\/v2\/categories?post=1395"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/silentdynamics.de\/es\/wp-json\/wp\/v2\/tags?post=1395"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}