Scripting example I

Learning targets

  • Embedded scripting
  • Definition of a sinusoidal surface with surface roughness

This example describes a 2D computational domain with a sinusoidal surface with superimposed, smoothed surface roughness. The computational domain and the surface are specified as polygons. The x- and y-positions of the polygon points are computed in few lines of Matlab® code in a template file which is run from a script (please see also the documentation for the JCMsuite Matlab® Interface. In this case the roughness is defined using the built-in Matlab function rand() (see line 6 in the layout template file as shown below).

The resulting geometry and mesh correspond to the following figures:

_images/snapshot_190_1_2.png
_images/snapshot_190_2_2.png

Input Files

  • layout.jcm [ASCII]

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    Layout2D { 
      Name = "TutorialExample2D" 
      UnitOfLength = 1e-06 
      
      MeshOptions { 
        MinimumMeshAngle = 15 
        MaximumSideLength = 1 
      } 
      Objects {
        Polygon { 
          Name = "ComputationalDomain/Air" 
          DomainId = 1 
          Priority = -1 
          Points = [0 -2.21358387034975 30 -2.21358387034975 30 2.05274827751851 0 2.05274827751851 ] 
          Boundary { 
            Number = [1 3]
            Class = Transparent 
          }     
          Boundary { 
            Number = [2 4]
            Class = Periodic 
          }     
        } 
        
        Polygon {  
          Name = "Object"  
          DomainId = 2 
          Priority = 1 
          Points = [30 -2.21358387034975 30 0.62509403951649 29.9499165275459 0.601394683522343 29.8998330550918 0.575157038933245 29.8497495826377 0.546712051379572 29.7996661101836 0.51639066649169 29.7495826377295 0.484523829899972 29.6994991652755 0.45144248723479 29.6494156928214 0.417477584126515 29.5993322203673 0.382960066205522 29.5492487479132 0.348220879102177 29.4991652754591 0.313590968446853 29.449081803005 0.279401279869923 29.3989983305509 0.245982759001758 29.3489148580968 0.213666351472731 29.2988313856427 0.18278300291321 29.2487479131886 0.153663658953567 29.1986644407346 0.126639265224176 29.1485809682805 0.101930454945095 29.0984974958264 0.0789703001827249 29.0484140233723 0.0568494469392757 28.9983305509182 0.0346571398407863 28.9482470784641 0.0114826235132942 28.89816360601 -0.0135848574171631 28.8480801335559 -0.0414560583245483 28.7979966611018 -0.0730417345828215 28.7479131886477 -0.109109665669852 28.6978297161937 -0.149032344316443 28.6477462437396 -0.191394448078309 28.5976627712855 -0.234771760593547 28.5475792988314 -0.277740065500249 28.4974958263773 -0.318875146436516 28.4474123539232 -0.356752787040441 28.3973288814691 -0.389948770950119 28.347245409015 -0.417140570684034 28.2971619365609 -0.438404179655987 28.2470784641068 -0.454832521872483 28.1969949916528 -0.467541455036723 28.1469115191987 -0.477646836851913 28.0968280467446 -0.486264525021256 28.0467445742905 -0.494510377247958 27.9966611018364 -0.503500251235223 27.9465776293823 -0.514322140882626 27.8964941569282 -0.527497725977956 27.8464106844741 -0.543020933119819 27.79632721202 -0.560865549312752 27.7462437395659 -0.581005361561288 27.6961602671119 -0.603414156869965 27.6460767946578 -0.628065722243318 27.5959933222037 -0.654933844685883 27.5459098497496 -0.683980616981652 27.4958263772955 -0.714789859853601 27.4457429048414 -0.746494104461157 27.3956594323873 -0.778199441490991 27.3455759599332 -0.809011961629774 27.2954924874791 -0.838037755564178 27.245409015025 -0.864382913980873 27.195325542571 -0.887153527566533 27.1452420701169 -0.905463246852543 27.0951585976628 -0.918864942816463 27.0450751252087 -0.927584141339561 26.9949916527546 -0.931903290426032 26.9449081803005 -0.932104838080072 26.8948247078464 -0.928471232305874 26.8447412353923 -0.921284921107634 26.7946577629382 -0.910828352489547 26.7445742904841 -0.897387679093575 26.6944908180301 -0.881728877838796 26.644407345576 -0.865567293701666 26.5943238731219 -0.850729827499897 26.5442404006678 -0.839043380051201 26.4941569282137 -0.832334852173287 26.4440734557596 -0.832431144683868 26.3939899833055 -0.841159158400654 26.3439065108514 -0.860342846505258 26.2938230383973 -0.890457909884351 26.2437395659432 -0.928500543285511 26.1936560934891 -0.970913186712823 26.1435726210351 -1.01413828017038 26.093489148581 -1.05461826366227 26.0434056761269 -1.08879557719257 25.9933222036728 -1.11311266076537 25.9432387312187 -1.12401213040831 25.8931552587646 -1.11924109060591 25.8430717863105 -1.10098569550293 25.7929883138564 -1.07237547540735 25.7429048414023 -1.03653996062715 25.6928213689482 -0.996608681470317 25.6427378964942 -0.955711168244838 25.5926544240401 -0.916976951258696 25.542570951586 -0.883535560819878 25.4924874791319 -0.85773654685905 25.4424040066778 -0.838405640674593 25.3923205342237 -0.823373905773967 25.3422370617696 -0.810472346824667 25.2921535893155 -0.797531968494187 25.2420701168614 -0.782383775450023 25.1919866444073 -0.76285877235967 25.1419031719533 -0.736787963890623 25.0918196994992 -0.702535353214454 25.0417362270451 -0.661676418894888 24.991652754591 -0.616983608914538 24.9415692821369 -0.571231404483958 24.8914858096828 -0.52719428681369 24.8414023372287 -0.487646737114287 24.7913188647746 -0.455363236596299 24.7412353923205 -0.433118266470276 24.6911519198664 -0.423247333462421 24.6410684474124 -0.424513052338822 24.5909849749583 -0.433938384020245 24.5409015025042 -0.448534643838036 24.4908180300501 -0.46531314712354 24.440734557596 -0.481285209208102 24.3906510851419 -0.493462145423069 24.3405676126878 -0.498855271099786 24.2904841402337 -0.494699218777942 24.2404006677796 -0.480741607756187 24.1903171953255 -0.458312743905997 24.1402337228715 -0.428767630195555 24.0901502504174 -0.393461269593039 24.0400667779633 -0.353748665066633 23.9899833055092 -0.310984819584516 23.9398998330551 -0.266524736114875 23.889816360601 -0.221699302240279 23.8397328881469 -0.177450079481052 23.7896494156928 -0.134403652217757 23.7395659432387 -0.0931775688787446 23.6894824707846 -0.0543893778923645 23.6393989983305 -0.0186566276869675 23.5893155258765 0.013403133309094 23.5392320534224 0.0411723566674741 23.4891485809683 0.064088356761994 23.4390651085142 0.0829341199936628 23.3889816360601 0.0998865919586385 23.338898163606 0.117187242251729 23.2888146911519 0.137077540467738 23.2387312186978 0.161798956201472 23.1886477462437 0.193592959047737 23.1385642737896 0.234701018601337 23.0884808013356 0.287302477001605 23.0383973288815 0.351041621978576 22.9883138564274 0.422198553176876 22.9382303839733 0.496821242463045 22.8881469115192 0.570957661703616 22.8380634390651 0.640655782765139 22.787979966611 0.70196357751415 22.7378964941569 0.750929017817187 22.6878130217028 0.783636090273579 22.6377295492487 0.799017165322728 22.5876460767947 0.800868171717742 22.5375626043406 0.793460616681662 22.4874791318865 0.781066007437529 22.4373956594324 0.767955851208385 22.3873121869783 0.758401655217272 22.3372287145242 0.75667492668723 22.2871452420701 0.767035743829216 22.237061769616 0.791402612244397 22.1869782971619 0.826509089263128 22.1368948247078 0.868393242120002 22.0868113522538 0.913093138049614 22.0367278797997 0.956646844286553 21.9866444073456 0.99509242806542 21.9365609348915 1.02446795662081 21.8864774624374 1.04081307548762 21.8363939899833 1.04186077381901 21.7863105175292 1.03025778288734 21.7362270450751 1.00953707425636 21.686143572621 0.983231619489828 21.6360601001669 0.954874390151505 21.5859766277129 0.927998357805145 21.5358931552588 0.906136494014502 21.4858096828047 0.89282176764389 21.4357262103506 0.890448330540025 21.3856427378965 0.897036007491712 21.3355592654424 0.909554493793831 21.2854757929883 0.924973484741256 21.2353923205342 0.940262675628865 21.1853088480801 0.952391761751535 21.135225375626 0.958330438404141 21.085141903172 0.95504840088156 21.0350584307179 0.940352976030674 20.9849749582638 0.916328624433602 20.9348914858097 0.886421448111513 20.8848080133556 0.854078124499077 20.8347245409015 0.82274533103096 20.7846410684474 0.795869745141826 20.7345575959933 0.776898044266342 20.6844741235392 0.769276905839175 20.6343906510851 0.775787910880253 20.5843071786311 0.79466367113826 20.534223706177 0.822233012947677 20.4841402337229 0.854818325025632 20.4340567612688 0.888741996089263 20.3839732888147 0.920326414855701 20.3338898163606 0.945893970042075 20.2838063439065 0.961767050365522 20.2337228714524 0.964674192903666 20.1836393989983 0.955128544960962 20.1335559265442 0.935703048984351 20.0834724540901 0.908991281895218 20.0333889816361 0.877586820614947 19.983305509182 0.844083242064922 19.9332220367279 0.81107412316653 19.8831385642738 0.78115304084115 19.8330550918197 0.756685427922766 19.7829716193656 0.737056406974202 19.7328881469115 0.719560091426315 19.6828046744574 0.701447342636026 19.6327212020033 0.679969021960253 19.5826377295492 0.652375990755917 19.5325542570952 0.615919110379934 19.4824707846411 0.567849242189226 19.432387312187 0.505627132912848 19.3823038397329 0.430732650506454 19.3322203672788 0.348261253288735 19.2821368948247 0.263437295432539 19.2320534223706 0.1814851311107 19.1819699499165 0.107629114496069 19.1318864774624 0.0470935997614896 19.0818030050083 0.00510294107980693 19.0317195325543 -0.0132971399090061 18.9816360601002 -0.00843572927378824 18.9315525876461 0.0131685991397013 18.881469115192 0.0446546849370802 18.8313856427379 0.0791613677239621 18.7813021702838 0.109827487105959 18.7312186978297 0.129791882688691 18.6811352253756 0.13219339407777 18.6310517529215 0.110266626316566 18.5809682804674 0.0623117707263752 18.5308848080134 -0.00588737227670433 18.4808013355593 -0.0879444253937561 18.4307178631052 -0.177473011325864 18.3806343906511 -0.268086752774105 18.330550918197 -0.353399272439576 18.2804674457429 -0.42702419302335 18.2303839732888 -0.482607004935239 18.1803005008347 -0.517402863568964 18.1302170283806 -0.535548700030165 18.0801335559265 -0.541954442951516 18.0300500834725 -0.541530020965691 17.9799666110184 -0.539185362705365 17.9298831385643 -0.539830396803212 17.8797996661102 -0.548375051891905 17.8297161936561 -0.569722312841371 17.779632721202 -0.606247024087341 17.7295492487479 -0.654046739953228 17.6794657762938 -0.708261322003067 17.6293823038397 -0.764030631800896 17.5792988313856 -0.816494530910755 17.5292153589316 -0.860792880896681 17.4791318864775 -0.892065543322712 17.4290484140234 -0.905452908050829 17.3789649415693 -0.898177023661651 17.3288814691152 -0.874265138934462 17.2787979966611 -0.839132907676372 17.228714524207 -0.798195983694498 17.1786310517529 -0.756870020795944 17.1285475792988 -0.720570672787825 17.0784641068447 -0.694713593477254 17.0283806343907 -0.684714436671341 16.9782971619366 -0.69440817232955 16.9282136894825 -0.72077278854454 16.8781302170284 -0.758927370773664 16.8280467445743 -0.803990970594733 16.7779632721202 -0.851082639585566 16.7278797996661 -0.89532142932397 16.677796327212 -0.931826391387766 16.6277128547579 -0.955716577354762 16.5776293823038 -0.963164410029076 16.5275459098497 -0.956429978987043 16.4774624373957 -0.939955375963863 16.4273789649416 -0.918185488899105 16.3772954924875 -0.895565205732336 16.3272120200334 -0.876539414403124 16.2771285475793 -0.865553002851033 16.2270450751252 -0.867050859015633 16.1769616026711 -0.884704070193373 16.126878130217 -0.916157412878556 16.0767946577629 -0.956229477994656 16.0267111853088 -0.999722612013581 15.9766277128548 -1.04143916140724 15.9265442404007 -1.07618147264753 15.8764607679466 -1.09875189220638 15.8263772954925 -1.10395276655567 15.7762938230384 -1.0871719589844 15.7262103505843 -1.05007629010666 15.6761268781302 -0.998146268013687 15.6260434056761 -0.936916105503931 15.575959933222 -0.87192001537583 15.5258764607679 -0.808692210427818 15.4757929883139 -0.752766903458337 15.4257095158598 -0.709678307265825 15.3756260434057 -0.684632360769538 15.3255425709516 -0.677816340231885 15.2754590984975 -0.685498829556629 15.2253756260434 -0.703844362652955 15.1752921535893 -0.729017473430049 15.1252086811352 -0.7571826957971 15.0751252086811 -0.784504563663293 15.025041736227 -0.807147610937815 14.974958263773 -0.821375880129291 14.9248747913189 -0.825742111533409 14.8747913188648 -0.821087743232926 14.8247078464107 -0.808353721910032 14.7746243739566 -0.788480994246922 14.7245409015025 -0.762410506925787 14.6744574290484 -0.73108320662882 14.6243739565943 -0.695440040038212 14.5742904841402 -0.656415303439951 14.5242070116861 -0.614692828361259 14.4741235392321 -0.570635676537636 14.424040066778 -0.524585927950872 14.3739565943239 -0.476885662582756 14.3238731218698 -0.427876960415072 14.2737896494157 -0.377901901429611 14.2237061769616 -0.327302565608157 14.1736227045075 -0.276421774756149 14.1235392320534 -0.22565502918174 14.0734557595993 -0.175484560492502 14.0233722871452 -0.126400688045579 13.9732888146912 -0.0788937311981094 13.9232053422371 -0.0334540093072352 13.873121869783 0.00942815826990236 13.8230383973289 0.0492624521761595 13.7729549248748 0.0855607592692294 13.7228714524207 0.118218800387812 13.6727879799666 0.147950750363829 13.6227045075125 0.175575876555479 13.5726210350584 0.201913446320956 13.5225375626043 0.227782727018462 13.4724540901503 0.254002986006191 13.4223706176962 0.281393490642341 13.3722871452421 0.31077288783036 13.322203672788 0.342475656141729 13.2721202003339 0.375485470962563 13.2220367278798 0.408552273267903 13.1719532554257 0.440426004032783 13.1218697829716 0.46985660423224 13.0717863105175 0.495594014841311 13.0217028380634 0.516388176835029 12.9716193656093 0.530989042833043 12.9215358931553 0.538785481772746 12.8714524207012 0.541523149613086 12.8213689482471 0.541490993114955 12.771285475793 0.540977959039246 12.7212020033389 0.542272994146849 12.6711185308848 0.547665045198657 12.6210350584307 0.559443058955562 12.5709515859766 0.579895982178454 12.5208681135225 0.610578896273608 12.4707846410684 0.649449877049567 12.4207011686144 0.693366703799713 12.3706176961603 0.739186876576466 12.3205342237062 0.783767895432249 12.2704507512521 0.823967260419479 12.220367278798 0.856642471590584 12.1702838063439 0.878651028997981 12.1202003338898 0.887486767089373 12.0701168614357 0.884814435847266 12.0200333889816 0.873978596131551 11.9699499165275 0.858328422552216 11.9198664440735 0.841213089719254 11.8697829716194 0.825981772242659 11.8196994991653 0.815983644732421 11.7696160267112 0.814567881798533 11.7195325542571 0.824634877070361 11.669449081803 0.845089655570748 11.6193656093489 0.872741570687684 11.5692821368948 0.904381474299042 11.5191986644407 0.936800218282694 11.4691151919866 0.966788654516509 11.4190317195326 0.991137634878364 11.3689482470785 1.00663801124613 11.3188647746244 1.01037262660306 11.2687813021703 1.00305066167306 11.2186978297162 0.98783593189784 11.1686143572621 0.967938657844823 11.118530884808 0.946569060081457 11.0684474123539 0.926937359175186 11.0183639398998 0.912253775693453 10.9682804674457 0.905728530203701 10.9181969949917 0.910372412129665 10.8681135225376 0.925593102041965 10.8180300500835 0.947669424305769 10.7679465776294 0.972776215285319 10.7178631051753 0.99708831134486 10.6677796327212 1.01678054884864 10.6176961602671 1.0280277641609 10.567612687813 1.02700479364589 10.5175292153589 1.01001188776041 10.4674457429048 0.976867222246038 10.4173622704508 0.931299528733151 10.3672787979967 0.877241754756977 10.3171953255426 0.818626847852741 10.2671118530885 0.759387755555671 10.2170283806344 0.703457425400992 10.1669449081803 0.654768804923932 10.1168614357262 0.617197842388727 10.0667779632721 0.591864872622074 10.016694490818 0.575962661266168 9.96661101836394 0.566383316781297 9.91652754590985 0.560018947627752 9.86644407345576 0.55376166226582 9.81636060100167 0.544503569155793 9.76627712854758 0.529136776757959 9.71619365609349 0.504572569434643 9.6661101836394 0.469636427616928 9.61602671118531 0.426670922279782 9.56594323873122 0.37839606367792 9.51585976627713 0.327531862066053 9.46577629382304 0.276798327698893 9.41569282136895 0.228915470831155 9.36560934891486 0.186603301717544 9.31552587646077 0.15257774330519 9.26544240400668 0.128345986157019 9.21535893155259 0.112527034787335 9.1652754590985 0.103317617350347 9.11519198664441 0.0989144620002646 9.06510851419032 0.0975142968912974 9.01502504173623 0.0973138501776552 8.96494156928214 0.0965098500135479 8.91485809682805 0.0932991413533331 8.86477462437396 0.086154961560576 8.81469115191987 0.0744187408017899 8.76460767946578 0.0576019356513561 8.71452420701169 0.0352160026836558 8.66444073455759 0.00677239847307053 8.61435726210351 -0.0282174204060159 8.56427378964942 -0.070241997379227 8.51419031719533 -0.119789875872179 8.46410684474123 -0.176771107001561 8.41402337228714 -0.238686025202096 8.36393989983306 -0.302407616672153 8.31385642737897 -0.364808866123051 8.26377295492487 -0.422762758266096 8.21368948247078 -0.473142277812599 8.16360601001669 -0.512820409473871 8.11352253756261 -0.53867013796122 8.06343906510851 -0.548381199870929 8.01335559265442 -0.544171796795882 7.96327212020033 -0.5298207021124 7.91318864774624 -0.509108143745615 7.86310517529216 -0.485814349620661 7.81302170283806 -0.463719547662665 7.76293823038397 -0.446603965796762 7.71285475792988 -0.438247831948083 7.66277128547579 -0.441927080292875 7.6126878130217 -0.45715808463809 7.56260434056761 -0.481759365094601 7.51252086811352 -0.51354115469718 7.46243739565943 -0.550313686480596 7.41235392320534 -0.589887193479623 7.36227045075125 -0.630071908729027 7.31218697829716 -0.668678065263587 7.26210350584307 -0.703696409134544 7.21202003338898 -0.734963723666703 7.16193656093489 -0.763397939443527 7.1118530884808 -0.789930656986173 7.06176961602671 -0.815493476815803 7.01168614357262 -0.841017999453572 6.96160267111853 -0.86743582542064 6.91151919866444 -0.895678555238163 6.86143572621035 -0.926604651117358 6.81135225375626 -0.96001259428429 6.76126878130217 -0.994902126595545 6.71118530884808 -1.03025341492563 6.66110183639399 -1.06504662614906 6.6110183639399 -1.09826192714034 6.56093489148581 -1.12887948477397 6.51085141903172 -1.15587946592448 6.46076794657763 -1.178260685119 6.41068447412354 -1.19542481578039 6.36060100166945 -1.2071624350733 6.31051752921536 -1.21327997569675 6.26043405676127 -1.21358387034975 6.21035058430718 -1.20788055173128 6.16026711185309 -1.19597645254037 6.110183639399 -1.17767800547602 6.06010016694491 -1.15281754034713 6.01001669449082 -1.12213011391519 5.95993322203673 -1.0874665944892 5.90984974958264 -1.05074696526241 5.85976627712855 -1.01389120942807 5.80968280467446 -0.978819310179431 5.75959933222037 -0.947451250709744 5.70951585976628 -0.921707014212261 5.65943238731219 -0.903482918191534 5.6093489148581 -0.893158690239306 5.55926544240401 -0.888706019340618 5.50918196994992 -0.887882603516448 5.45909849749583 -0.888446140787774 5.40901502504174 -0.888154329175573 5.35893155258765 -0.884764866700824 5.30884808013355 -0.876035451384503 5.25876460767947 -0.859731394032401 5.20868113522538 -0.834755226581236 5.15859766277129 -0.80234509977287 5.10851419031719 -0.764026124344613 5.0584307178631 -0.721323411033779 5.00834724540902 -0.67576207057768 4.95826377295493 -0.628867213713622 4.90818030050083 -0.582163951178919 4.85809682804674 -0.537176962944006 4.80801335559265 -0.49517733479559 4.75792988313857 -0.456755757960773 4.70784641068447 -0.422390000714369 4.65776293823038 -0.392557831331202 4.60767946577629 -0.367737018086091 4.5575959933222 -0.348405329253857 4.50751252086812 -0.335040533109321 4.45742904841402 -0.328120361470769 4.40734557595993 -0.327506261996736 4.35726210350584 -0.330876366846114 4.30717863105175 -0.335425541748694 4.25709515859766 -0.338348652434268 4.20701168614357 -0.336840564632626 4.15692821368948 -0.328096144073561 4.10684474123539 -0.309310256486863 4.0567612687813 -0.277677767602324 4.00667779632721 -0.231322589591653 3.95659432387312 -0.172740255887506 3.90651085141903 -0.105710973424629 3.85642737896494 -0.0340151224875391 3.80634390651085 0.0385669166392452 3.75626043405676 0.108254763671207 3.70617696160267 0.171268038323824 3.65609348914858 0.223826360312588 3.60601001669449 0.262807756272312 3.5559265442404 0.289227338695345 3.50584307178631 0.305703273863515 3.45575959933222 0.314857232758206 3.40567612687813 0.319310886360804 3.35559265442404 0.321685905652691 3.30550918196995 0.324603961615253 3.25542570951586 0.330686725229873 3.20534223706177 0.342327140424296 3.15525876460768 0.359971626801411 3.10517529215359 0.383082802560839 3.0550918196995 0.411115690146821 3.00500834724541 0.443525312003601 2.95492487479132 0.479766690575417 2.90484140233723 0.519294848306517 2.85475792988314 0.561564807641141 2.80467445742905 0.605986231745007 2.75459098497496 0.651432768267217 2.70450751252087 0.696428065216539 2.65442404006678 0.739489746421969 2.60434056761269 0.779135435712494 2.5542570951586 0.813882756917104 2.50417362270451 0.842249333864789 2.45409015025042 0.862752790384538 2.40400667779633 0.874019999232815 2.35392320534224 0.876542508629608 2.30383973288815 0.872374842515409 2.25375626043406 0.863619843976263 2.20367278797996 0.852380356098211 2.15358931552588 0.840759221967298 2.10350584307179 0.830859284669564 2.0534223706177 0.824783387291052 2.00333889816361 0.824578987247552 1.95325542570951 0.830842173868216 1.90317195325543 0.842611622437717 1.85308848080134 0.858849380308979 1.80300500834725 0.878517494834925 1.75292153589315 0.90057801336848 1.70283806343906 0.923992983262566 1.65275459098498 0.947724451870105 1.60267111853089 0.970738063402815 1.55258764607679 0.992158954708519 1.5025041736227 1.01133160285929 1.45242070116861 1.02761643353539 1.40233722871453 1.04037387241711 1.35225375626043 1.04896434518473 1.30217028380634 1.05274827751851 1.25208681135225 1.05108609509874 1.20200333889816 1.04334516788447 1.15191986644408 1.02950798376556 1.10183639398998 1.01064645607566 1.05175292153589 0.987944132247547 1.0016694490818 0.962584559714002 0.951585976627712 0.935751285907807 0.901502504173624 0.908627858261748 0.851419031719534 0.882397824208603 0.801335559265443 0.858242983734488 0.751252086811352 0.836918148486925 0.701168614357261 0.81819608036982 0.65108514190317 0.801711987176187 0.601001669449083 0.787101076699042 0.550918196994992 0.773998556731396 0.500834724540901 0.762039635066266 0.45075125208681 0.750859519496665 0.40066777963272 0.740093417815609 0.350584307178632 0.729376537816112 0.300500834724541 0.718344087291188 0.250417362270451 0.706631274033852 0.20033388981636 0.693873305837117 0.150250417362269 0.679705390493999 0.100166944908182 0.663762735797513 0.0500834724540908 0.645680549540672 0 0.62509403951649 0 -2.21358387034975 ] 
          MeshOptions { 
            MaximumSideLength = 1 
          } 
        } 
      } 
    }
    
  • Matlab script run_geometry.m [ASCII]

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    % Interface for 1D periodic unit cell with sinusoidal surface layers
    
    keys.uol = 1e-6; % unit of length
    
    keys.sinus_period = 10.0; % sin period
    keys.sinus_n_periods = 3;
    keys.sinus_amplitude = 1.0; % sin amplitude
    keys.sinus_phase = 45; % sin phase
    keys.roughness_amplitude = 0.4; % roughness on sin
    keys.roughness_period = 0.4; % typical roughness length
    keys.offset_y = 1.0; % computational domain size offset in y direction
    keys.slc = 1.0; % maximum triangle sidelength
    
    jcmwave_geo('.', keys, 'jcmt_pattern', 'matlab', 'show', 4);
    
  • Layout template file layout.matlab.jcmt [ASCII]

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    <?
    % define a sinusoidal profile with roughness
    n_points = round(keys.sinus_n_periods*keys.sinus_period/keys.roughness_period);
    x = linspace(0, keys.sinus_n_periods*keys.sinus_period, n_points);
    y = keys.sinus_amplitude*sin(keys.sinus_phase*2*pi/360 + 2*pi*x/keys.sinus_period);
    y = y + (rand(size(y))-0.5)*keys.roughness_amplitude;
    y(1) = 0.5*(y(1) + y(end)); y(end) = y(1); % make sure to be periodic
    % smooth profile
    xx = linspace(keys.sinus_n_periods*keys.sinus_period, 0, n_points*8);
    yy = spline(x, y, xx);
    y_min = min(yy) - keys.offset_y;
    y_max = max(yy) + keys.offset_y;
    
    % computational domain
    keys.points_cd = [xx(end) y_min, xx(1) y_min, xx(1) y_max, xx(end) y_max];
    
    % surface
    keys.points_object(1:2:2*length(xx)) = xx;
    keys.points_object(2:2:2*length(xx)) = yy;
    keys.points_object = [xx(1) y_min,  keys.points_object, xx(end) y_min];
    ?>
    Layout2D {
      Name = "TutorialExample2D"
      UnitOfLength = %(uol)e
      
      MeshOptions {
        MinimumMeshAngle = 15
        MaximumSideLength = %(slc)e
      }
      Objects {  
        Polygon {
          Name = "ComputationalDomain/Air"
          DomainId = 1
          Priority = -1
          Points = %(points_cd)e
          Boundary {
            Number = [1 3]
            Class = Transparent
          }
          Boundary {
            Number = [2 4]
            Class = Periodic
          }
        }
        Polygon { 
          Name = "Object" 
          DomainId = 2
          Priority = 1
          Points = %(points_object)e
          MeshOptions { 
            MaximumSideLength = %(slc)e 
          } 
        }
      }
    }