From a4ab2b985eb03eff2297e68022668a6ea711b469 Mon Sep 17 00:00:00 2001 From: Javi G Date: Thu, 13 Jun 2019 17:00:00 +0200 Subject: [PATCH 01/23] Initial files for chimera app --- kratos.gid/apps/Chimera/images/logo.png | Bin 0 -> 7838 bytes kratos.gid/apps/Chimera/python/KratosFluid.py | 34 +++ kratos.gid/apps/Chimera/start.tcl | 79 +++++++ kratos.gid/apps/Chimera/write/write.tcl | 78 +++++++ .../Chimera/write/writeProjectParameters.tcl | 133 ++++++++++++ .../apps/Chimera/xml/AdaptivitySettings.spd | 10 + .../xml/BoundingBoxWindowController.tcl | 202 ++++++++++++++++++ .../apps/Chimera/xml/DistanceSettings.spd | 9 + kratos.gid/apps/Chimera/xml/EmbeddedDrag.spd | 7 + kratos.gid/apps/Chimera/xml/EmbeddedParts.spd | 4 + kratos.gid/apps/Chimera/xml/GetFromXML.tcl | 44 ++++ kratos.gid/apps/Chimera/xml/Main.spd | 12 ++ kratos.gid/apps/Chimera/xml/Materials.spd | 4 + kratos.gid/apps/Chimera/xml/Materials.xml | 15 ++ kratos.gid/apps/Chimera/xml/Procs.spd | 38 ++++ kratos.gid/apps/Chimera/xml/Strategies.xml | 49 +++++ kratos.gid/apps/FluidLauncher/start.tcl | 2 +- kratos.gid/kratos_default.spd | 1 + 18 files changed, 720 insertions(+), 1 deletion(-) create mode 100644 kratos.gid/apps/Chimera/images/logo.png create mode 100644 kratos.gid/apps/Chimera/python/KratosFluid.py create mode 100644 kratos.gid/apps/Chimera/start.tcl create mode 100644 kratos.gid/apps/Chimera/write/write.tcl create mode 100644 kratos.gid/apps/Chimera/write/writeProjectParameters.tcl create mode 100644 kratos.gid/apps/Chimera/xml/AdaptivitySettings.spd create mode 100644 kratos.gid/apps/Chimera/xml/BoundingBoxWindowController.tcl create mode 100644 kratos.gid/apps/Chimera/xml/DistanceSettings.spd create mode 100644 kratos.gid/apps/Chimera/xml/EmbeddedDrag.spd create mode 100644 kratos.gid/apps/Chimera/xml/EmbeddedParts.spd create mode 100644 kratos.gid/apps/Chimera/xml/GetFromXML.tcl create mode 100644 kratos.gid/apps/Chimera/xml/Main.spd create mode 100644 kratos.gid/apps/Chimera/xml/Materials.spd create mode 100644 kratos.gid/apps/Chimera/xml/Materials.xml create mode 100644 kratos.gid/apps/Chimera/xml/Procs.spd create mode 100644 kratos.gid/apps/Chimera/xml/Strategies.xml diff --git a/kratos.gid/apps/Chimera/images/logo.png b/kratos.gid/apps/Chimera/images/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..ddfe57475107a433ac82dc1e4d51f270bce4e64c GIT binary patch literal 7838 zcma)><5wjNw8pbF*~Vnsom{7y?3(OmvTJIxZM&0evW=5%+jiae{ss4bc=oe?ANG3I z-rx4x;VMcps7QoJ5D*Zka}^DKR=TO)}`E zzm(G^2HmojmyPMJZoIv`GQPmLevWQ#ZWg#Ohn`l4<`V&)I-JIaizsQS+|d6wc2`&C zTUhNp_UvP1d?H^jC2+4oqY{s3hK?vx9K&w=@UIxn2OWOEdc4+SCr)FcW1>j12G_!h z`4gBdN$?XmxaGrs3J7uQ2nVZ3z|8PSJ-7Gx*vhM|qpO^Jw8RX_NM{^t0%oMGyfi&$ z>oZI#?kXwY6K`sjL;FNYO*?o=8#I5Mz?$+-Lp20^bUU7sCu*|x3;?+}6u{w?GkzGi zir)KJR)l%%NUE`rzB|SvS_a~vjI>B;4@SCVZrdUfX14Yye!qFE+t)BOs0AS|E+TL^ z6SU-u^}NK8u4J4aMA8D?eWc&wQDM{>wg6PCbh>`v+)?B;<6v5B&xbSDy@ya!<&8+0 zW%NE)$Q-wH@LTb^T1{=wt;R3$p3et4;=!uIZ_Llw_++Qt-ZQ%-vnLDry)7wNb^QKWdiG6ESFOrH zmVPh!PlN#Nyo`h}(J56Pz1x@;s;iJWGS2Z%&n>i3Oklo$e^OT9I87?EB>Q@R>zS$ilkijm|G#k%~fV9WM( z8)siOBdruTB56DfmA!n?nUx)@pK+XdKsp89$pO(;CN00m*>x~zynQI0p+owetq4*3 zGl7_KI3^V({rE8(e5nmgDYx{0oI|_}sTjj8-BTPfgs}o<#bsB~b@0e7Ce+C&j=;^2 zu3_B7n2V(HDGtbF@1?@zDc5K_0?oJ^XLHm_4gIf$K5tdg(pT8Vn@IP4n;qN{7Q)2c zi3{8)1iBdiWP3l4as4lftOOC7#m))C3^~lHPayVf#Op}rVI(3kydsQSaNshH>${uV zh&evNP#D$kKO$)1srUsqq1)&zfI;e4(~#$E0ssB2 zEki^1^Zi)`9*^o`sgYJ^Yz>Y22&9`x)>>p-WBJIMLaAI*PuNB2$FO+#-Rh?2p&N0o zR}3LZXi?{}ccG>))4dXAhf=@C<+^^LGOL)z!rrz>X*8(v^QPiej#(h8kS14%KTbK( zSmueKsZ+J){Y)k&|K8UGx)o^kn9D&|U&8OXZ297J-W!A_`gLxdryyLj^DlC@k#ovH zBW0(7dv*R1rExux#wDr(p7t9T13CEd0$JNA+nTOV%L$E<2qHA~~ZktD;*tmzL{{UW~(XCRMeb+OSv25}lE zuSseWuq!;ZqE|jijDJ8nGb)UZvl2NNnl`O0^h%zW=I%JgZ5QGmxuqQa`s>)48mzbL z@8=z3|F3|ESvVD6+MUX44_OwtNYWTlFg;Uj2-FlxS5r);s#*P`RWe+uulWu2IHmqfoi&g~jWQ6W|wr`af2NR~fg*`lObHtiQ^^ z9qyhlS2!sbU&3Ocwi|Q=qkf6q)RVm)PjK8$*IspxVk;lz5*awO>6dgB5}pI%bnINC4!Ix>;{q_ z(iKc+3dE(1F7Gti!rwr`ChpEyyo19I(L3k61D9dZ0{DYl<3|@qH*RXcuMz(xn8PM6Xlk%Mc2;RGV2kxUa55*(bRtIZ|RAl zGa?qJK0oirkG48EtV~Xtc)uxXsgfE}^?2M#WhS-_yW?ADQxI$2&FWX^-9VG5Q-yBT z+qYuq#v*Dh)-0l4nj)YH-wCEw=nPZFb_MuC&WQ8jWSt!AlPk1##d%(mlemZ2xLxkL zfeb`{chexpQqx{3pm89WoN^?_(hM6$00mQU3vsFV7{fkjQl5}m56w`X_)`6&Qh%vP zE*vJJU~YuXz*!qU(z^`5hxLrX7u&ZPvzbv9??k9Fn4F z?SvyJP-4Hl>->CSB;leD>I5*BH>zeh!Un!q+}L9VSrAPeDk(^2H)`hb_Tgm&i_wO?^}`*=WeOlM{^ zs>Cf1>@PMq;cU3C=WykmbDd3eNmQLzmCPvkdxuyM`MVD!*Ac1e?qK3!@8x3jbJ7EV z=wbm-V3;oj0EFg4#M$u}`ty^LsDFked3hcX;$JuZ187zCvFe(M7h4n_-O$0{MR%Dj z{2Od|NzH4jA;JEl$-h~9U$m$ytu(T$^T_|~<0aXY1T;*dJ}V#ZfE-0_KW9Tb45I2U zk_iL|OtSdq*c(*3*`|b)O{n6v6^gXW2jmhQGg<4B!>R_-TNLZ!pEHt+VCWcKZ1zjE z=$3d6C7dbeaU?SF39<50pmAnYC?Is0=GpR=4dNUuusi)lUm{tfG;7>2kw7z89|!=vU)N}_e9InbE1jP5&)lHx(pyS9 zaU0o+Wf`V+ro@CIoJkz+6mE`=%CXLhp>pXLgB{%;`-VxDsi~$p*@d(dGnJEwRlrF5 zh$;KYOe@AeXpr+^VkM0!C=WtX=0nCfKiMXmXlw*mZu*<=C$sNB)qe9bGZ8F<-PeGy z@TarJ!`JweYHLw%EMf?8firsw%h!y|#vUfeML=x{2y!P<7kc3vcO7zXX z`PdW#6$2ehXfR;-SE`nKq`N|cjA?^fBDkwsrJL4UPgqBoQj9s>G6PSN-uQ1S>|;>~ zk0t*CB1xp@U&Z0#49yX5U6^*R`#9&G&iW*mXcu3LhZWpRW*KlyN9n_+$kq6#N*`!0LMc$#MYTmuJU9Z;%zA+z25xZNz?lS)N( z`>3GoMYI64#;L(U2(!7Mx9L9xAAd~mtI^v|$~jJ(G>fzBSSOo(1;jqLbCVI^_P!%s!-ytDS1TkSYh6E zqm+cO`Y>1vWHde!?MS`1*3Y96siGoo^a*bad7#joNvLoZd648E+paW21KcIeT(()Y zqLv?!9|vsYp?`GCV!kt=%CVRZXx$bltei85bZ24d$d(?wa1<%JA!cr=@TCkpfZeO) zO0gr$Fmd@OKT#%J?cv_W5etIb**qUYwNgmK5nE-sO%u2Ut8TC=`OoPXUI04s1HfH8 zu#vX7{-?;{%T&ir=vfpeSz}D03?yZcW;2;-U*n+Me1U`}Na%O%Sw=w(!YiY(7~ICo zF94kIpxV~M?|-Tc-87(z?*TfaJL*oYvvK6%L{-z7xmVvj8%W@6^2*D2V>gmUnUrr+ zhvJ+*>~(lD`QAU0*(&XJ@;qJM0q;2QoLc;bj`K6X%N=%KLg#_pQB@~rlYN}`JJuuJ z>gYd?t=DkSArAREPtzhuS}*??F2nhhD1h@bn4*>Uv&Axum7opOuZygj?p%oSL0HF>1rnK{H~sTnk?4PLc^IapGAdJR1zx1UWGCx z#a;$iu@(pg{$Q$6aRnzJG@b_B&uBJ6F|aP@_>=)JCQP|XRK{RotizJ09X2|V!=d^f z)gy&gg%E>u&}V@Eon1^IzgjhoP7eTz-6Lq;`>Np%g!buJq_ocA6r%Q&=#NHIn!Z%F zP0#%gAWsz5M!}1=x|_#MvO1fbY+FkQC5TsV#oS?y6y8ZLh_PWxR7VJ?S)jzve|_spqmjzIwhLddKvCk`O+&mokLViKg2JFI z(b%+f>su2C;CgqJXKm%6fZT{d|7AQsc&@=TOX-#|{>Ya9* zCvcXq5KY3Cq7Dm_lNvSfyKKG$Ju+e6+aM|Fy?qNd6#vGY*7=$D1aAj*)(Qk(^wsS)?m zg{BT-MptH3NXWR)=Qs~fSkvSD(W%BjpM)N{6`9X+dB12P4G1{1B*mp@D0CU5x94r| zzYTQ%nQfkgGMu6#t$rG!dEr{4y~{nO)}&U|yt~hveGBi4>|Ldr!9^uMU$$<~lcoI7 zu*F^WC9mdpeeMwJ8v2B>wQB2pPIvkP#HaAa1?75rO4V-O9+LbwSiV0=1FW}u5x@JJ z`<{UZ!F%>$9-XB<2;nQG6?053{$F7DB-2RbpHsiE3Zh?QR@2d7qmwLk!Kj?7gi4Mx z)#?kCNdsk}^ZI(`KYtM5f{srMw)nCv?CcDtqO_L3(kmOy5^A3Pp`7jr1{oUu)PbUQk;BLS4%+n6?4LPP9pIX{S{F;;aX)6QVd zvdFWStseK_)@5*5wr~@w#)0cdP^->uboBRqUJqR7{ju`hXDxbo{#7TgmqNvcc?Vak{vYuhi861^DTXN!5py9cb z$(v5tam80ILDB`b;xQSmtrXDrNY<1c#LR?i*LO+$il1>H9u|Dm+|mHLpYA8K$ig~t zl6hm@oUT6Kl+10}mgh9iE#1%<{-QNmPI-bX&uvu;4AqE=_WXN-vwAT8nHnQN z=DBt~rwoqs8Kx<|6sW_d(>nR(^6|G8heME}#RnsI-D8Y(qRXV7msJf~T=5%BEID3B zIKmLd%tB^`%-C8&`3XCZU|ltuaKrF6qSFh%ybFQ$%erEHn0c zM;oy}x$$L2*ulCJ+ZE=|V^Qr(F(K&Lv|OKmYd@s@vcvAijtCzq)CX6O^M-r{?GZI+ z92}qsnK>!C7&7!oDZr>lh7GiJQ|;-OL*?0S)BNXoZMnbfS}$x|gDw=%gs%V|!IG#w z17ijaYe5ymeHmiQke?cbw70Bqq~KPQw!e zHJ0$gctqV;Kn4mt$;^8S2Ls0BZh!>!mT#z0`;e-}!rl4`gce?YjiVPicc%2j;~kjN z^X8t}*RAaAVrfAS)akgAivMMhQ6c)SklOMg)AsHoSxg>hbVB0Mzv7u@>^;7KHZPY* zCe_w;&+|>3g@VlY&`ij8KZiH5 zKAz70g;O)d(cQ0&DS@TWfD*{px8c3riuLtGlm{xbau~a{^EUhTjTx-Tic(<~gOcqk z0=!98kr#->44pMW7=~Pu2tKE{qivzn!*w!Tj*%l&OH1XjL9CUPz2A1z5r31@x5{-X zeFO&v!_rd1Nli69nRMi(X^o4~J1n>x|E#xfG#v2Xl|QiG_@;nk7=KR6&6$_fjmdIU zKF6MoaB%tJVHF#)Q9|pW40tuY2;kx8${D_4LKmhlb9l5LrKfLRNf6#XUF}Gs(oqLU zLczkSZJ=(=2LN_-rnC@EYOXSLekC+_jZC8dTm$sUq zhNfwC)4f7)G6YeD6RSBR;?^JYP6Y7@h%f~Kdf(JopZ?L0s90yV}%#xjvBH0;v%F^xoL zjyO!k#~EtB1VCZ%22Iimc(C%xcrMFccHQzk=a8Cn|K;q$7lgnprIL=4OnDs1e8OHF z5W14qz6X)WKX#;CQVP&rO`Rh)oW7j;>d}W2hG9L_EBtS`Hf~Z|n2E|Z$YG4yJ|&FG zVXM#PzH}rWqQ3q=O7MiJvedN=(2mN#o-|up0z!E)NQMluL7mZdS(}YbALxsZ1{!DP z(u-ep4X;{xTX5dPuFTQF$B-7`E2$cM-}YJ7aumf%V@vAdQM%}$g61aKoN5N>b?16| zAbzzOTf@L0lj{Z~((~anBEVcf!Hf7;kkSjv?-ll@p7&Etdd#_x>N+Q_{Yy>KOJfdK zp0Q|%h5ONsj=GAE-9n$?Ex-;SbGEtBo?=qGULQRlm(Of;PP}BjkxG<*&C^oIH)W|i z-Y1m=G@mpm9CPAD)gi3~uF6!-hu-Wfc`HGm=+@af*Pk$J6tzFOD-R4-BGs=PHYy^E zY#9qktXdJuwq&K5#l@AA`T_&u5zD`C9DSS(#?(`_#w1dy=j z^PWmL!V*HYBr~&qK&ZV0+0W3f`QWtglC3kOwBtA+j;!HlH*hl_i6s+Ic3zF|4?qv^ zVa^9xb$j9&OHH2rb~7SeW#O)0iK3~VX3E?8(s^Z1_tgnx7Zyzk+F$aHchR>|w=8l7 zzyrVJcOc=OsFv;>gKWAV&%Yw3y9e5S<8)cHtBwAAy6udq2l7O(Ro*>e&Z+Wd=wUP{?^eCFHIpF)qK2ENt{tLJfys@|xWyYOYNAYfSbvHXC?#_Rwk1-7-e?vmFNpC!gqDo*l&1^Jw*Jd9!Y& zU5G)@;}3AH@KgDe&!T&H%%qX!l%I`JK{*=3x&w zN3u~r3RzrK>lYXzD`R=~hv>5{-7jD}KqJE8n(<=E>mv4i|9Z;3ag+ObxEb13|BM4E zBMaHW2-ja-aG96s)-ADMtEPstf(riSBCCDG;Ih+-|K&KISWO>PZY>(We0)GttlA(f zd!R)%TN@W)jQ~FY*LP*_>%g^%GC%i(u5YB38WobXWE^b*b%Nty#g$H&lg?;iq)GjL zUe1U?8p?%{q0ig3#buJs9 z#Gb7#ixch0J7(0a{E=<&-$EL67#YHCx~hg6Hn8EJtgA}Gb)^^kOU#QP*^A^L!1^P% zimCDg+cuolqh&2HGi^(SC7a!m9qyVEh?m*UzuDn}rL2@~_S@q#SZ%O}+<}i^*ap@} z!6FiDY=Q^7sj4Zdv0;9$S3%lhdsjmC0&L?Wp1&h=iC(w92^Fe);&W}g_M@?caRqZ@ zAzBwRv+h`KlXP7BVmd1q%{6NIXA9LO&7`LXnZss}<~Ow51$^g>j!Os3xOw@aB_%dd z%pJXxR>()FoJE5t1aV3T_nbZ2%b8YjOyoPCroHpoIoRDA2_5BvTMxxcj9Qv#ts>$6 zAzW|u1(_&?>$9J&sfnh?VIiMMmn^|-xG;5b)Pa+ef;oq6U)TTSN^&9t?6Wi^pm@0a z=E{ self.flush_frequency: + sys.stdout.flush() + self.last_flush = now + +if __name__ == "__main__": + + with open("ProjectParameters.json",'r') as parameter_file: + parameters = KratosMultiphysics.Parameters(parameter_file.read()) + + model = KratosMultiphysics.Model() + simulation = FluidDynamicsAnalysisWithFlush(model,parameters) + simulation.Run() diff --git a/kratos.gid/apps/Chimera/start.tcl b/kratos.gid/apps/Chimera/start.tcl new file mode 100644 index 000000000..c96118389 --- /dev/null +++ b/kratos.gid/apps/Chimera/start.tcl @@ -0,0 +1,79 @@ +namespace eval ::Chimera { + # Variable declaration + variable dir + variable prefix + variable attributes + variable oldMeshType + variable kratos_name +} + +proc ::Chimera::Init { } { + # Variable initialization + variable dir + variable prefix + variable attributes + variable kratos_name + + apps::LoadAppById "Fluid" + set kratos_name $::Fluid::kratos_name + + set dir [apps::getMyDir "Chimera"] + set attributes [dict create] + + set prefix Chim + + set ::Model::ValidSpatialDimensions [list 3D] + spdAux::SetSpatialDimmension "3D" + + # Allow to open the tree + set ::spdAux::TreeVisibility 1 + + dict set attributes UseIntervals 1 + + LoadMyFiles + Kratos::AddRestoreVar "::GidPriv(DuplicateEntities)" + set ::GidPriv(DuplicateEntities) 1 + + #::spdAux::CreateDimensionWindow +} + +proc ::Chimera::LoadMyFiles { } { + variable dir + + uplevel #0 [list source [file join $dir xml GetFromXML.tcl]] + uplevel #0 [list source [file join $dir write write.tcl]] + uplevel #0 [list source [file join $dir write writeProjectParameters.tcl]] +} + +proc ::Chimera::GetAttribute {name} { + variable attributes + set value "" + if {[dict exists $attributes $name]} {set value [dict get $attributes $name]} + return $value +} + +proc ::Chimera::CustomMenus { } { + Chimera::examples::UpdateMenus +} + +proc ::Chimera::BeforeMeshGeneration {elementsize} { + variable oldMeshType + + set project_path [GiD_Info project modelname] + if {$project_path ne "UNNAMED"} { + catch {file delete -force [file join [write::GetConfigurationAttribute dir] "[Kratos::GetModelName].post.res"]} + # Set Octree + set oldMeshType [GiD_Set MeshType] + ::GiD_Set MeshType 2 + } else { + after 500 {WarnWin "You need to save the project before meshing"} + return "-cancel-" + } +} + +proc ::Chimera::AfterMeshGeneration {fail} { + variable oldMeshType + GiD_Set MeshType $oldMeshType +} + +::Chimera::Init diff --git a/kratos.gid/apps/Chimera/write/write.tcl b/kratos.gid/apps/Chimera/write/write.tcl new file mode 100644 index 000000000..ee09ad147 --- /dev/null +++ b/kratos.gid/apps/Chimera/write/write.tcl @@ -0,0 +1,78 @@ +namespace eval Chimera::write { + variable writeAttributes +} + +proc Chimera::write::Init { } { + # Namespace variables inicialization + SetAttribute parts_un FLParts + SetAttribute nodal_conditions_un FLNodalConditions + SetAttribute conditions_un FLBC + SetAttribute materials_un EMBFLMaterials + SetAttribute results_un FLResults + SetAttribute time_parameters_un FLTimeParameters + SetAttribute writeCoordinatesByGroups 0 + SetAttribute validApps [list "Fluid" "Chimera"] + SetAttribute main_script_file "KratosFluid.py" + SetAttribute model_part_name "FluidModelPart" + SetAttribute materials_file "FluidMaterials.json" +} + +# Events +proc Chimera::write::writeModelPartEvent { } { + # Fluid::write::AddValidApps "Chimera" + set err [Fluid::write::Validate] + if {$err ne ""} {error $err} + + Fluid::write::InitConditionsMap + write::initWriteConfiguration [GetAttributes] + write::writeModelPartData + Fluid::write::writeProperties + write::writeMaterials [GetAttribute validApps] + write::writeNodalCoordinatesOnParts + write::writeElementConnectivities + Fluid::write::writeConditions + Fluid::write::writeMeshes + writeDistances + Fluid::write::FreeConditionsMap +} +proc Chimera::write::writeCustomFilesEvent { } { + write::CopyFileIntoModel "python/KratosFluid.py" + write::RenameFileInModel "KratosFluid.py" "MainKratos.py" +} + +proc Chimera::write::writeDistances { } { + set must_write [write::getValue EMBFLDistanceSettings ReadingMode] + if {$must_write eq "from_mdpa"} { + set data [GiD_Info Mesh EmbeddedDistances] + lassign $data nodes_list distances_list + set length [objarray length $nodes_list] + if {$length eq "0"} {W "Warning: No distances detected! Check Preferences > Mesh type > Embedded"} + write::WriteString "Begin NodalData DISTANCE" + incr write::current_mdpa_indent_level + set s [write::mdpaIndent] + for {set i 0} {$i < $length} {incr i } { + set node_id [objarray get $nodes_list $i] + set distance [objarray get $distances_list $i] + write::WriteString "$s$node_id 0 $distance" + } + incr write::current_mdpa_indent_level -1 + write::WriteString "End NodalData" + } +} + +proc Chimera::write::GetAttribute {att} { + variable writeAttributes + return [dict get $writeAttributes $att] +} + +proc Chimera::write::GetAttributes {} { + variable writeAttributes + return $writeAttributes +} + +proc Chimera::write::SetAttribute {att val} { + variable writeAttributes + dict set writeAttributes $att $val +} + +Chimera::write::Init diff --git a/kratos.gid/apps/Chimera/write/writeProjectParameters.tcl b/kratos.gid/apps/Chimera/write/writeProjectParameters.tcl new file mode 100644 index 000000000..7e323010b --- /dev/null +++ b/kratos.gid/apps/Chimera/write/writeProjectParameters.tcl @@ -0,0 +1,133 @@ +# Project Parameters +proc ::Chimera::write::getParametersDict { } { + set param_dict [Fluid::write::getParametersDict] + + ## Set the meshing adaptivity settings + set mesh_adaptivity [write::getValue EMBFLAdaptivitySettings mesh_adaptivity] + # Meshing adaptivity switch on/off in problem data dict + set new_problem_data [dict get $param_dict problem_data] + dict set new_problem_data "mesh_adaptivity" $mesh_adaptivity + dict set param_dict problem_data $new_problem_data + # Set the meshing adaptivity process list + if {$mesh_adaptivity eq "Yes"} { + dict set param_dict processes mesh_adaptivity_process_list [list [getMeshAdaptivityProcessDict]] + } else { + dict set param_dict processes mesh_adaptivity_process_list [list] + } + + ## Set the auxiliar embedded fluid application processes dictionary list + dict set param_dict processes auxiliar_process_list [getAuxiliarProcessList] + + ## Set the solver settings dictionary + set solverSettingsDict [dict get $param_dict solver_settings] + # If drag has to be computed, ensure that "compute_reactions" is set to true + set compute_embedded_drag [write::getValue EMBFLEmbeddedDrag compute_embedded_drag] + if {$compute_embedded_drag eq "Yes"} { + dict set solverSettingsDict "compute_reactions" true + } + set solverSettingsDict [dict merge $solverSettingsDict [write::getSolversParametersDict Chimera] ] + + # Set the embedded monolithic formulation settings + set currentStrategyId [write::getValue FLSolStrat] + if {$currentStrategyId eq "Monolithic"} { + set formulationSettingsDict [dict get $solverSettingsDict formulation] + # Set element type + dict set formulationSettingsDict element_type "embedded_navier_stokes" + # Set the is_slip flag and remove it from the original dictionary + dict set formulationSettingsDict is_slip [dict get $solverSettingsDict is_slip] + dict unset solverSettingsDict is_slip + # Set the penalty_coefficient and remove it from the original dictionary + dict set formulationSettingsDict penalty_coefficient [dict get $solverSettingsDict penalty_coefficient] + dict unset solverSettingsDict penalty_coefficient + # If exists, set the slip_length and remove it from the original dictionary + if {[dict exists $solverSettingsDict slip_length]} { + dict set formulationSettingsDict slip_length [dict get $solverSettingsDict slip_length] + dict unset solverSettingsDict slip_length + } + # Include the formulation settings in the solver settings dict + dict set solverSettingsDict formulation $formulationSettingsDict + } + + ## Set the distance reading settings dictionary + set dist_settings_dict [dict create] + set dist_mode [write::getValue EMBFLDistanceSettings ReadingMode] + dict set dist_settings_dict import_mode $dist_mode + if {$dist_mode ne "from_mdpa"} { + set dist_file [write::getValue EMBFLDistanceSettings distance_file_name] + dict set dist_settings_dict distance_file_name $dist_file + } + dict set solverSettingsDict distance_reading_settings $dist_settings_dict + + dict set param_dict solver_settings $solverSettingsDict + return $param_dict +} + +proc Chimera::write::writeParametersEvent { } { + set projectParametersDict [getParametersDict] + write::SetParallelismConfiguration + write::WriteJSON $projectParametersDict +} + +proc Chimera::write::getAuxiliarProcessList {} { + set auxiliar_process_list [list] + + # Append the distance modification process + lappend auxiliar_process_list [getDistanceModificationDict] + + # If required, append the embedded drag process dictionary + set compute_embedded_drag [write::getValue EMBFLEmbeddedDrag compute_embedded_drag] + if {$compute_embedded_drag eq "Yes"} { + lappend auxiliar_process_list [getEmbeddedDragProcessDict] + } + + return $auxiliar_process_list +} + +proc Chimera::write::getDistanceModificationDict { } { + set distance_modif_dict [dict create ] + dict set distance_modif_dict "python_module" apply_distance_modification_process + dict set distance_modif_dict "kratos_module" KratosMultiphysics.FluidDynamicsApplication + dict set distance_modif_dict "process_name" ApplyDistanceModificationProcess + set parameters_dict [dict create ] + dict set parameters_dict "model_part_name" [lindex [write::getPartsSubModelPartId] 0] + dict set parameters_dict "check_at_each_time_step" [write::getValue EMBFLDistanceSettings correct_distance_at_each_step] + dict set distance_modif_dict "Parameters" $parameters_dict + return $distance_modif_dict +} + +proc Chimera::write::getEmbeddedDragProcessDict {} { + set pdict [dict create] + dict set pdict "python_module" "compute_embedded_drag_process" + dict set pdict "kratos_module" "KratosMultiphysics.FluidDynamicsApplication" + dict set pdict "process_name" "ComputeEmbeddedDragProcess" + set params [dict create] + dict set params "model_part_name" [lindex [write::getPartsSubModelPartId] 0] + dict set params "write_drag_output_file" [write::getValue EMBFLEmbeddedDrag write_drag_output_file] + dict set params "print_drag_to_screen" [write::getValue EMBFLEmbeddedDrag print_drag_to_screen] + dict set params "interval" [write::getInterval [write::getValue EMBFLEmbeddedDrag Interval] ] + dict set pdict "Parameters" $params + + return $pdict +} + +proc Chimera::write::getMeshAdaptivityProcessDict {} { + set pdict [dict create] + dict set pdict "python_module" "mmg_process" + dict set pdict "kratos_module" "KratosMultiphysics.MeshingApplication" + dict set pdict "process_name" "MmgProcess" + # MmgProcess settings dictionary + set params_dict [dict create] + dict set params_dict "model_part_name" "MainModelPart" + dict set params_dict "initial_step" [write::getValue EMBFLAdaptivitySettings initial_step] + dict set params_dict "step_frequency" [write::getValue EMBFLAdaptivitySettings step_frequency] + dict set params_dict "initial_remeshing" [write::getValue EMBFLAdaptivitySettings initial_remeshing] + # Set anisotropic parameters section + set anisotropy_parameters_dict [dict create] + dict set anisotropy_parameters_dict "hmin_over_hmax_anisotropic_ratio" [write::getValue EMBFLAdaptivitySettings hmin_over_hmax_anisotropic_ratio] + dict set anisotropy_parameters_dict "boundary_layer_min_size_ratio" [write::getValue EMBFLAdaptivitySettings boundary_layer_min_size_ratio] + dict set params_dict "anisotropy_parameters" $anisotropy_parameters_dict + dict set params_dict "echo_level" [write::getValue EMBFLAdaptivitySettings echo_level] + dict set pdict "Parameters" $params_dict + + return $pdict +} diff --git a/kratos.gid/apps/Chimera/xml/AdaptivitySettings.spd b/kratos.gid/apps/Chimera/xml/AdaptivitySettings.spd new file mode 100644 index 000000000..703c6aeef --- /dev/null +++ b/kratos.gid/apps/Chimera/xml/AdaptivitySettings.spd @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/kratos.gid/apps/Chimera/xml/BoundingBoxWindowController.tcl b/kratos.gid/apps/Chimera/xml/BoundingBoxWindowController.tcl new file mode 100644 index 000000000..6fb058ac2 --- /dev/null +++ b/kratos.gid/apps/Chimera/xml/BoundingBoxWindowController.tcl @@ -0,0 +1,202 @@ + + +namespace eval EmbeddedFluid::xml::BoundingBox { + variable winpath + variable box + variable boxname +} + +proc EmbeddedFluid::xml::BoundingBox::Init {} { + package require wcb + variable winpath + set winpath ".gid.bboxwindow" + variable box + set box(x1) 1.0 + set box(y1) 1.0 + set box(z1) 1.0 + set box(x2) 1.0 + set box(y2) 1.0 + set box(z2) 1.0 + variable boxname + set boxname "FluidBox" +} + +proc EmbeddedFluid::xml::BoundingBox::CreateWindow { } { + variable winpath + #Init + set w $winpath + + if {[winfo exists $w]} {destroy $w} + + toplevel $w -class Toplevel -relief groove + #wm maxsize $w 500 300 + wm minsize $w 250 250 + wm overrideredirect $w 0 + wm resizable $w 1 1 + wm deiconify $w + wm title $w [= "Bounding box window"] + wm attribute $w -topmost 1 + + EmbeddedFluid::xml::BoundingBox::RefreshWindow +} + +proc EmbeddedFluid::xml::BoundingBox::RefreshWindow { } { + variable winpath + set w $winpath + if {[winfo exists $w.fr1]} {destroy $w.fr1} + if {[winfo exists $w.fr2]} {destroy $w.fr2} + if {[winfo exists $w.buts]} {destroy $w.buts} + set fr1 [ttk::labelframe $w.fr1 -text [= "Model space"]] + set fr2 [ttk::labelframe $w.fr2 -text [= "Create a bounding box"]] + set buts [ttk::frame $w.buts -style BottomFrame.TFrame] + + ttk::button $buts.q -text Close -command [list destroy $w] -style BottomFrame.TButton + ttk::button $buts.ok -text "Create Box" -command [list EmbeddedFluid::xml::BoundingBox::BuildBox] -style BottomFrame.TButton + EmbeddedFluid::xml::BoundingBox::ModelInfoFrame $fr1 + EmbeddedFluid::xml::BoundingBox::BoxDataFrame $fr2 + + grid $buts.ok $buts.q -sticky sew + + grid $fr1 -sticky nsew -row 0 -column 0 + grid $fr2 -sticky nsew -row 1 -column 0 + grid $buts -sticky sew -columnspan 2 + grid columnconfigure $w 0 -weight 1 + grid rowconfigure $w 2 -weight 1 + if { $::tcl_version >= 8.5 } { grid anchor $buts center } +} + +proc EmbeddedFluid::xml::BoundingBox::ModelInfoFrame {w} { + lassign [GetCurrentBox] x2 y2 z2 x1 y1 z1 + set x1 [format %.3g $x1] + set x2 [format %.3g $x2] + set y1 [format %.3g $y1] + set y2 [format %.3g $y2] + set z1 [format %.3g $z1] + set z2 [format %.3g $z2] + + set mintxt [= "Min"] + set maxtxt [= "Max"] + + set tX [= "Model X"] + set lX [ttk::label $w.lX -text ${tX}:] + set lminX [ttk::label $w.lminX -text ${mintxt}:] + set eminX [ttk::label $w.eminX -text $x1] + set lmaxX [ttk::label $w.lmaxX -text ${maxtxt}:] + set emaxX [ttk::label $w.emaxX -text $x2] + + set tY [= "Model Y"] + set lY [ttk::label $w.lY -text ${tY}:] + set lminY [ttk::label $w.lminY -text ${mintxt}:] + set eminY [ttk::label $w.eminY -text $y1] + set lmaxY [ttk::label $w.lmaxY -text ${maxtxt}:] + set emaxY [ttk::label $w.emaxY -text $y2] + + set tZ [= "Model Z"] + set lZ [ttk::label $w.lZ -text ${tZ}:] + set lminZ [ttk::label $w.lminZ -text ${mintxt}:] + set eminZ [ttk::label $w.eminZ -text $z1] + set lmaxZ [ttk::label $w.lmaxZ -text ${maxtxt}:] + set emaxZ [ttk::label $w.emaxZ -text $z2] + + grid $lX $lminX $eminX $lmaxX $emaxX -sticky w + grid $lY $lminY $eminY $lmaxY $emaxY -sticky w + grid $lZ $lminZ $eminZ $lmaxZ $emaxZ -sticky w +} + +proc EmbeddedFluid::xml::BoundingBox::BoxDataFrame {w} { + set tDist [= "Distance"] + set size 8 + set lX [ttk::label $w.lX -text $tDist] + set lminX [ttk::label $w.lminX -text "-X:"] + set eminX [ttk::entry $w.eminX -textvariable EmbeddedFluid::xml::BoundingBox::box(x1)] + wcb::callback $eminX before insert wcb::checkEntryForReal + set lmaxX [ttk::label $w.lmaxX -text "+X:"] + set emaxX [ttk::entry $w.emaxX -textvariable EmbeddedFluid::xml::BoundingBox::box(x2)] + wcb::callback $emaxX before insert wcb::checkEntryForReal + + set lY [ttk::label $w.lY -text $tDist] + set lminY [ttk::label $w.lminY -text "-Y:"] + set eminY [ttk::entry $w.eminY -textvariable EmbeddedFluid::xml::BoundingBox::box(y1)] + wcb::callback $eminY before insert wcb::checkEntryForReal + set lmaxY [ttk::label $w.lmaxY -text "+Y:"] + set emaxY [ttk::entry $w.emaxY -textvariable EmbeddedFluid::xml::BoundingBox::box(y2)] + wcb::callback $emaxY before insert wcb::checkEntryForReal + + set lZ [ttk::label $w.lZ -text $tDist] + set lminZ [ttk::label $w.lminZ -text "-Z:"] + set eminZ [ttk::entry $w.eminZ -textvariable EmbeddedFluid::xml::BoundingBox::box(z1)] + wcb::callback $eminZ before insert wcb::checkEntryForReal + set lmaxZ [ttk::label $w.lmaxZ -text "+Z:"] + set emaxZ [ttk::entry $w.emaxZ -textvariable EmbeddedFluid::xml::BoundingBox::box(z2)] + wcb::callback $emaxZ before insert wcb::checkEntryForReal + + grid $lX $lminX $eminX $lmaxX $emaxX -sticky e + grid $lY $lminY $eminY $lmaxY $emaxY -sticky e + grid $lZ $lminZ $eminZ $lmaxZ $emaxZ -sticky e + + grid configure $eminX $eminY $eminZ $emaxX $emaxY $emaxZ -sticky ew + grid columnconfigure $w {2 4} -weight 1 +} + +proc EmbeddedFluid::xml::BoundingBox::DestroyBox { } { + variable boxname + + if {[GiD_Layers exists $boxname]} { + GiD_Layers delete $boxname + } +} + +proc EmbeddedFluid::xml::BoundingBox::BuildBox { } { + variable boxname + + GidUtils::DisableGraphics + + EmbeddedFluid::xml::BoundingBox::DestroyBox + + GiD_Layers create $boxname + GiD_Layers edit to_use $boxname + + EmbeddedFluid::xml::BoundingBox::CreateBoxGeom + if {![GiD_Groups exists $boxname]} {GiD_Groups create $boxname} + + GiD_EntitiesGroups assign $boxname volumes [GiD_EntitiesLayers get $boxname volumes] + GiD_EntitiesGroups assign $boxname surfaces [GiD_EntitiesLayers get $boxname surfaces] + GiD_EntitiesGroups assign $boxname lines [GiD_EntitiesLayers get $boxname lines] + GiD_EntitiesGroups assign $boxname points [GiD_EntitiesLayers get $boxname points] + + GidUtils::EnableGraphics + + + GiD_Process 'Zoom Frame + GidUtils::UpdateWindow GROUPS + GidUtils::UpdateWindow LAYER +} + +proc EmbeddedFluid::xml::BoundingBox::CreateBoxGeom { } { + variable boxname + variable box + lassign [GetCurrentBox] x2 y2 z2 x1 y1 z1 + + set Xo [expr $x1 - $box(x1)] + set Yo [expr $y1 - $box(y1)] + set Zo [expr $z1 - $box(z1)] + set Xf [expr $x2 + $box(x2)] + set Yf [expr $y2 + $box(y2)] + set Zf [expr $z2 + $box(z2)] + + set h [expr $Zf - $Zo] + + GiD_Process Mescape Geometry Create Object Rectangle $Xo $Yo $Zo $Xf $Yf $Zo Mescape + set surfid [GiD_EntitiesLayers get $boxname surfaces] + GiD_Process Mescape Utilities Copy Surfaces Duplicate DoExtrude Volumes MaintainLayers Translation FNoJoin 0.0 0.0 0.0 FNoJoin 0.0 0.0 $h $surfid Mescape + GidUtils::SetWarnLine [= "Bounding box created: Xo = %s Yo = %s Zo = %s Xf = %s Yf = %s Zf = %s" $Xo $Yo $Zo $Xf $Yf $Zf] +} + +proc EmbeddedFluid::xml::BoundingBox::GetCurrentBox { } { + variable boxname + set layers [lsearch -all -inline -not -exact [GiD_Layers list] $boxname] + set modelbox [GiD_Info Layers -bbox {*}$layers] + return {*}$modelbox +} + +EmbeddedFluid::xml::BoundingBox::Init \ No newline at end of file diff --git a/kratos.gid/apps/Chimera/xml/DistanceSettings.spd b/kratos.gid/apps/Chimera/xml/DistanceSettings.spd new file mode 100644 index 000000000..64bf3ff67 --- /dev/null +++ b/kratos.gid/apps/Chimera/xml/DistanceSettings.spd @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/kratos.gid/apps/Chimera/xml/EmbeddedDrag.spd b/kratos.gid/apps/Chimera/xml/EmbeddedDrag.spd new file mode 100644 index 000000000..283974cbc --- /dev/null +++ b/kratos.gid/apps/Chimera/xml/EmbeddedDrag.spd @@ -0,0 +1,7 @@ + + + + + + + diff --git a/kratos.gid/apps/Chimera/xml/EmbeddedParts.spd b/kratos.gid/apps/Chimera/xml/EmbeddedParts.spd new file mode 100644 index 000000000..e2b0ac489 --- /dev/null +++ b/kratos.gid/apps/Chimera/xml/EmbeddedParts.spd @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/kratos.gid/apps/Chimera/xml/GetFromXML.tcl b/kratos.gid/apps/Chimera/xml/GetFromXML.tcl new file mode 100644 index 000000000..1e525de60 --- /dev/null +++ b/kratos.gid/apps/Chimera/xml/GetFromXML.tcl @@ -0,0 +1,44 @@ +namespace eval Chimera::xml { + # Namespace variables declaration + variable dir + variable lastImportMeshSize + variable export_dir + +} + +proc Chimera::xml::Init { } { + # Namespace variables inicialization + variable dir + variable lastImportMeshSize + set lastImportMeshSize 0 + Model::DestroyEverything + Model::InitVariables dir $Chimera::dir + + Model::getSolutionStrategies Strategies.xml + Model::getElements "../../Fluid/xml/Elements.xml" + Model::getMaterials Materials.xml + Model::getNodalConditions "../../Fluid/xml/NodalConditions.xml" + Model::getConstitutiveLaws "../../Fluid/xml/ConstitutiveLaws.xml" + Model::getProcesses "../../Common/xml/Processes.xml" + Model::getProcesses "../../Fluid/xml/Processes.xml" + Model::getConditions "../../Fluid/xml/Conditions.xml" + Model::getSolvers "../../Common/xml/Solvers.xml" +} + + +proc Chimera::xml::MultiAppEvent {args} { + if {$args eq "init"} { + spdAux::parseRoutes + spdAux::ConvertAllUniqueNames FL ${::Chimera::prefix} + } +} + +proc Chimera::xml::getUniqueName {name} { + return ${::Chimera::prefix}${name} +} + +proc Chimera::xml::CustomTree { args } { + +} + +Chimera::xml::Init diff --git a/kratos.gid/apps/Chimera/xml/Main.spd b/kratos.gid/apps/Chimera/xml/Main.spd new file mode 100644 index 000000000..3ece65dfc --- /dev/null +++ b/kratos.gid/apps/Chimera/xml/Main.spd @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/kratos.gid/apps/Chimera/xml/Materials.spd b/kratos.gid/apps/Chimera/xml/Materials.spd new file mode 100644 index 000000000..2b6cebca4 --- /dev/null +++ b/kratos.gid/apps/Chimera/xml/Materials.spd @@ -0,0 +1,4 @@ + + + + diff --git a/kratos.gid/apps/Chimera/xml/Materials.xml b/kratos.gid/apps/Chimera/xml/Materials.xml new file mode 100644 index 000000000..9d7b67da7 --- /dev/null +++ b/kratos.gid/apps/Chimera/xml/Materials.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/kratos.gid/apps/Chimera/xml/Procs.spd b/kratos.gid/apps/Chimera/xml/Procs.spd new file mode 100644 index 000000000..cf2089264 --- /dev/null +++ b/kratos.gid/apps/Chimera/xml/Procs.spd @@ -0,0 +1,38 @@ + + + + + + + 1} { + foreach group [lrange $childs 1 end] {$group delete} + gid_groups_conds::actualize_conditions_window + error "You can only set one part" + } + ]]> + + + + + \ No newline at end of file diff --git a/kratos.gid/apps/Chimera/xml/Strategies.xml b/kratos.gid/apps/Chimera/xml/Strategies.xml new file mode 100644 index 000000000..5a21bbaf1 --- /dev/null +++ b/kratos.gid/apps/Chimera/xml/Strategies.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/kratos.gid/apps/FluidLauncher/start.tcl b/kratos.gid/apps/FluidLauncher/start.tcl index baa7f8c7e..2d4a5f1bc 100644 --- a/kratos.gid/apps/FluidLauncher/start.tcl +++ b/kratos.gid/apps/FluidLauncher/start.tcl @@ -5,7 +5,7 @@ namespace eval ::FluidLauncher { proc ::FluidLauncher::Init { } { variable available_apps - set available_apps [list Fluid EmbeddedFluid PotentialFluid Buoyancy ConjugateHeatTransfer FluidDEM] + set available_apps [list Fluid EmbeddedFluid PotentialFluid Buoyancy ConjugateHeatTransfer FluidDEM Chimera] # Allow to open the tree set ::spdAux::TreeVisibility 0 diff --git a/kratos.gid/kratos_default.spd b/kratos.gid/kratos_default.spd index 60299ccd7..b1d3b9b3c 100644 --- a/kratos.gid/kratos_default.spd +++ b/kratos.gid/kratos_default.spd @@ -29,6 +29,7 @@ + From 69d32de0f551656e76f328de59dc25eec7689e2d Mon Sep 17 00:00:00 2001 From: Javi G Date: Thu, 13 Jun 2019 17:20:38 +0200 Subject: [PATCH 02/23] Load the tree --- kratos.gid/apps/Chimera/start.tcl | 51 ++--- .../apps/Chimera/xml/AdaptivitySettings.spd | 10 - .../xml/BoundingBoxWindowController.tcl | 202 ------------------ .../apps/Chimera/xml/DistanceSettings.spd | 9 - kratos.gid/apps/Chimera/xml/EmbeddedDrag.spd | 7 - kratos.gid/apps/Chimera/xml/EmbeddedParts.spd | 4 - kratos.gid/apps/Chimera/xml/GetFromXML.tcl | 37 +--- kratos.gid/apps/Chimera/xml/Main.spd | 12 +- kratos.gid/apps/Chimera/xml/Materials.spd | 4 - kratos.gid/apps/Chimera/xml/Materials.xml | 15 -- kratos.gid/apps/Chimera/xml/Strategies.xml | 49 ----- 11 files changed, 34 insertions(+), 366 deletions(-) delete mode 100644 kratos.gid/apps/Chimera/xml/AdaptivitySettings.spd delete mode 100644 kratos.gid/apps/Chimera/xml/BoundingBoxWindowController.tcl delete mode 100644 kratos.gid/apps/Chimera/xml/DistanceSettings.spd delete mode 100644 kratos.gid/apps/Chimera/xml/EmbeddedDrag.spd delete mode 100644 kratos.gid/apps/Chimera/xml/EmbeddedParts.spd delete mode 100644 kratos.gid/apps/Chimera/xml/Materials.spd delete mode 100644 kratos.gid/apps/Chimera/xml/Materials.xml delete mode 100644 kratos.gid/apps/Chimera/xml/Strategies.xml diff --git a/kratos.gid/apps/Chimera/start.tcl b/kratos.gid/apps/Chimera/start.tcl index c96118389..32f89f793 100644 --- a/kratos.gid/apps/Chimera/start.tcl +++ b/kratos.gid/apps/Chimera/start.tcl @@ -16,25 +16,22 @@ proc ::Chimera::Init { } { apps::LoadAppById "Fluid" set kratos_name $::Fluid::kratos_name + + set ::Model::ValidSpatialDimensions [list 2D] + spdAux::SetSpatialDimmension "2D" + spdAux::processIncludes set dir [apps::getMyDir "Chimera"] set attributes [dict create] set prefix Chim - set ::Model::ValidSpatialDimensions [list 3D] - spdAux::SetSpatialDimmension "3D" - # Allow to open the tree set ::spdAux::TreeVisibility 1 dict set attributes UseIntervals 1 LoadMyFiles - Kratos::AddRestoreVar "::GidPriv(DuplicateEntities)" - set ::GidPriv(DuplicateEntities) 1 - - #::spdAux::CreateDimensionWindow } proc ::Chimera::LoadMyFiles { } { @@ -52,28 +49,24 @@ proc ::Chimera::GetAttribute {name} { return $value } -proc ::Chimera::CustomMenus { } { - Chimera::examples::UpdateMenus -} - -proc ::Chimera::BeforeMeshGeneration {elementsize} { - variable oldMeshType +# proc ::Chimera::BeforeMeshGeneration {elementsize} { +# variable oldMeshType - set project_path [GiD_Info project modelname] - if {$project_path ne "UNNAMED"} { - catch {file delete -force [file join [write::GetConfigurationAttribute dir] "[Kratos::GetModelName].post.res"]} - # Set Octree - set oldMeshType [GiD_Set MeshType] - ::GiD_Set MeshType 2 - } else { - after 500 {WarnWin "You need to save the project before meshing"} - return "-cancel-" - } -} - -proc ::Chimera::AfterMeshGeneration {fail} { - variable oldMeshType - GiD_Set MeshType $oldMeshType -} +# set project_path [GiD_Info project modelname] +# if {$project_path ne "UNNAMED"} { +# catch {file delete -force [file join [write::GetConfigurationAttribute dir] "[Kratos::GetModelName].post.res"]} +# # Set Octree +# set oldMeshType [GiD_Set MeshType] +# ::GiD_Set MeshType 2 +# } else { +# after 500 {WarnWin "You need to save the project before meshing"} +# return "-cancel-" +# } +# } + +# proc ::Chimera::AfterMeshGeneration {fail} { +# variable oldMeshType +# GiD_Set MeshType $oldMeshType +# } ::Chimera::Init diff --git a/kratos.gid/apps/Chimera/xml/AdaptivitySettings.spd b/kratos.gid/apps/Chimera/xml/AdaptivitySettings.spd deleted file mode 100644 index 703c6aeef..000000000 --- a/kratos.gid/apps/Chimera/xml/AdaptivitySettings.spd +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/kratos.gid/apps/Chimera/xml/BoundingBoxWindowController.tcl b/kratos.gid/apps/Chimera/xml/BoundingBoxWindowController.tcl deleted file mode 100644 index 6fb058ac2..000000000 --- a/kratos.gid/apps/Chimera/xml/BoundingBoxWindowController.tcl +++ /dev/null @@ -1,202 +0,0 @@ - - -namespace eval EmbeddedFluid::xml::BoundingBox { - variable winpath - variable box - variable boxname -} - -proc EmbeddedFluid::xml::BoundingBox::Init {} { - package require wcb - variable winpath - set winpath ".gid.bboxwindow" - variable box - set box(x1) 1.0 - set box(y1) 1.0 - set box(z1) 1.0 - set box(x2) 1.0 - set box(y2) 1.0 - set box(z2) 1.0 - variable boxname - set boxname "FluidBox" -} - -proc EmbeddedFluid::xml::BoundingBox::CreateWindow { } { - variable winpath - #Init - set w $winpath - - if {[winfo exists $w]} {destroy $w} - - toplevel $w -class Toplevel -relief groove - #wm maxsize $w 500 300 - wm minsize $w 250 250 - wm overrideredirect $w 0 - wm resizable $w 1 1 - wm deiconify $w - wm title $w [= "Bounding box window"] - wm attribute $w -topmost 1 - - EmbeddedFluid::xml::BoundingBox::RefreshWindow -} - -proc EmbeddedFluid::xml::BoundingBox::RefreshWindow { } { - variable winpath - set w $winpath - if {[winfo exists $w.fr1]} {destroy $w.fr1} - if {[winfo exists $w.fr2]} {destroy $w.fr2} - if {[winfo exists $w.buts]} {destroy $w.buts} - set fr1 [ttk::labelframe $w.fr1 -text [= "Model space"]] - set fr2 [ttk::labelframe $w.fr2 -text [= "Create a bounding box"]] - set buts [ttk::frame $w.buts -style BottomFrame.TFrame] - - ttk::button $buts.q -text Close -command [list destroy $w] -style BottomFrame.TButton - ttk::button $buts.ok -text "Create Box" -command [list EmbeddedFluid::xml::BoundingBox::BuildBox] -style BottomFrame.TButton - EmbeddedFluid::xml::BoundingBox::ModelInfoFrame $fr1 - EmbeddedFluid::xml::BoundingBox::BoxDataFrame $fr2 - - grid $buts.ok $buts.q -sticky sew - - grid $fr1 -sticky nsew -row 0 -column 0 - grid $fr2 -sticky nsew -row 1 -column 0 - grid $buts -sticky sew -columnspan 2 - grid columnconfigure $w 0 -weight 1 - grid rowconfigure $w 2 -weight 1 - if { $::tcl_version >= 8.5 } { grid anchor $buts center } -} - -proc EmbeddedFluid::xml::BoundingBox::ModelInfoFrame {w} { - lassign [GetCurrentBox] x2 y2 z2 x1 y1 z1 - set x1 [format %.3g $x1] - set x2 [format %.3g $x2] - set y1 [format %.3g $y1] - set y2 [format %.3g $y2] - set z1 [format %.3g $z1] - set z2 [format %.3g $z2] - - set mintxt [= "Min"] - set maxtxt [= "Max"] - - set tX [= "Model X"] - set lX [ttk::label $w.lX -text ${tX}:] - set lminX [ttk::label $w.lminX -text ${mintxt}:] - set eminX [ttk::label $w.eminX -text $x1] - set lmaxX [ttk::label $w.lmaxX -text ${maxtxt}:] - set emaxX [ttk::label $w.emaxX -text $x2] - - set tY [= "Model Y"] - set lY [ttk::label $w.lY -text ${tY}:] - set lminY [ttk::label $w.lminY -text ${mintxt}:] - set eminY [ttk::label $w.eminY -text $y1] - set lmaxY [ttk::label $w.lmaxY -text ${maxtxt}:] - set emaxY [ttk::label $w.emaxY -text $y2] - - set tZ [= "Model Z"] - set lZ [ttk::label $w.lZ -text ${tZ}:] - set lminZ [ttk::label $w.lminZ -text ${mintxt}:] - set eminZ [ttk::label $w.eminZ -text $z1] - set lmaxZ [ttk::label $w.lmaxZ -text ${maxtxt}:] - set emaxZ [ttk::label $w.emaxZ -text $z2] - - grid $lX $lminX $eminX $lmaxX $emaxX -sticky w - grid $lY $lminY $eminY $lmaxY $emaxY -sticky w - grid $lZ $lminZ $eminZ $lmaxZ $emaxZ -sticky w -} - -proc EmbeddedFluid::xml::BoundingBox::BoxDataFrame {w} { - set tDist [= "Distance"] - set size 8 - set lX [ttk::label $w.lX -text $tDist] - set lminX [ttk::label $w.lminX -text "-X:"] - set eminX [ttk::entry $w.eminX -textvariable EmbeddedFluid::xml::BoundingBox::box(x1)] - wcb::callback $eminX before insert wcb::checkEntryForReal - set lmaxX [ttk::label $w.lmaxX -text "+X:"] - set emaxX [ttk::entry $w.emaxX -textvariable EmbeddedFluid::xml::BoundingBox::box(x2)] - wcb::callback $emaxX before insert wcb::checkEntryForReal - - set lY [ttk::label $w.lY -text $tDist] - set lminY [ttk::label $w.lminY -text "-Y:"] - set eminY [ttk::entry $w.eminY -textvariable EmbeddedFluid::xml::BoundingBox::box(y1)] - wcb::callback $eminY before insert wcb::checkEntryForReal - set lmaxY [ttk::label $w.lmaxY -text "+Y:"] - set emaxY [ttk::entry $w.emaxY -textvariable EmbeddedFluid::xml::BoundingBox::box(y2)] - wcb::callback $emaxY before insert wcb::checkEntryForReal - - set lZ [ttk::label $w.lZ -text $tDist] - set lminZ [ttk::label $w.lminZ -text "-Z:"] - set eminZ [ttk::entry $w.eminZ -textvariable EmbeddedFluid::xml::BoundingBox::box(z1)] - wcb::callback $eminZ before insert wcb::checkEntryForReal - set lmaxZ [ttk::label $w.lmaxZ -text "+Z:"] - set emaxZ [ttk::entry $w.emaxZ -textvariable EmbeddedFluid::xml::BoundingBox::box(z2)] - wcb::callback $emaxZ before insert wcb::checkEntryForReal - - grid $lX $lminX $eminX $lmaxX $emaxX -sticky e - grid $lY $lminY $eminY $lmaxY $emaxY -sticky e - grid $lZ $lminZ $eminZ $lmaxZ $emaxZ -sticky e - - grid configure $eminX $eminY $eminZ $emaxX $emaxY $emaxZ -sticky ew - grid columnconfigure $w {2 4} -weight 1 -} - -proc EmbeddedFluid::xml::BoundingBox::DestroyBox { } { - variable boxname - - if {[GiD_Layers exists $boxname]} { - GiD_Layers delete $boxname - } -} - -proc EmbeddedFluid::xml::BoundingBox::BuildBox { } { - variable boxname - - GidUtils::DisableGraphics - - EmbeddedFluid::xml::BoundingBox::DestroyBox - - GiD_Layers create $boxname - GiD_Layers edit to_use $boxname - - EmbeddedFluid::xml::BoundingBox::CreateBoxGeom - if {![GiD_Groups exists $boxname]} {GiD_Groups create $boxname} - - GiD_EntitiesGroups assign $boxname volumes [GiD_EntitiesLayers get $boxname volumes] - GiD_EntitiesGroups assign $boxname surfaces [GiD_EntitiesLayers get $boxname surfaces] - GiD_EntitiesGroups assign $boxname lines [GiD_EntitiesLayers get $boxname lines] - GiD_EntitiesGroups assign $boxname points [GiD_EntitiesLayers get $boxname points] - - GidUtils::EnableGraphics - - - GiD_Process 'Zoom Frame - GidUtils::UpdateWindow GROUPS - GidUtils::UpdateWindow LAYER -} - -proc EmbeddedFluid::xml::BoundingBox::CreateBoxGeom { } { - variable boxname - variable box - lassign [GetCurrentBox] x2 y2 z2 x1 y1 z1 - - set Xo [expr $x1 - $box(x1)] - set Yo [expr $y1 - $box(y1)] - set Zo [expr $z1 - $box(z1)] - set Xf [expr $x2 + $box(x2)] - set Yf [expr $y2 + $box(y2)] - set Zf [expr $z2 + $box(z2)] - - set h [expr $Zf - $Zo] - - GiD_Process Mescape Geometry Create Object Rectangle $Xo $Yo $Zo $Xf $Yf $Zo Mescape - set surfid [GiD_EntitiesLayers get $boxname surfaces] - GiD_Process Mescape Utilities Copy Surfaces Duplicate DoExtrude Volumes MaintainLayers Translation FNoJoin 0.0 0.0 0.0 FNoJoin 0.0 0.0 $h $surfid Mescape - GidUtils::SetWarnLine [= "Bounding box created: Xo = %s Yo = %s Zo = %s Xf = %s Yf = %s Zf = %s" $Xo $Yo $Zo $Xf $Yf $Zf] -} - -proc EmbeddedFluid::xml::BoundingBox::GetCurrentBox { } { - variable boxname - set layers [lsearch -all -inline -not -exact [GiD_Layers list] $boxname] - set modelbox [GiD_Info Layers -bbox {*}$layers] - return {*}$modelbox -} - -EmbeddedFluid::xml::BoundingBox::Init \ No newline at end of file diff --git a/kratos.gid/apps/Chimera/xml/DistanceSettings.spd b/kratos.gid/apps/Chimera/xml/DistanceSettings.spd deleted file mode 100644 index 64bf3ff67..000000000 --- a/kratos.gid/apps/Chimera/xml/DistanceSettings.spd +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/kratos.gid/apps/Chimera/xml/EmbeddedDrag.spd b/kratos.gid/apps/Chimera/xml/EmbeddedDrag.spd deleted file mode 100644 index 283974cbc..000000000 --- a/kratos.gid/apps/Chimera/xml/EmbeddedDrag.spd +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/kratos.gid/apps/Chimera/xml/EmbeddedParts.spd b/kratos.gid/apps/Chimera/xml/EmbeddedParts.spd deleted file mode 100644 index e2b0ac489..000000000 --- a/kratos.gid/apps/Chimera/xml/EmbeddedParts.spd +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/kratos.gid/apps/Chimera/xml/GetFromXML.tcl b/kratos.gid/apps/Chimera/xml/GetFromXML.tcl index 1e525de60..2983192e3 100644 --- a/kratos.gid/apps/Chimera/xml/GetFromXML.tcl +++ b/kratos.gid/apps/Chimera/xml/GetFromXML.tcl @@ -1,44 +1,29 @@ namespace eval Chimera::xml { # Namespace variables declaration variable dir - variable lastImportMeshSize - variable export_dir - } proc Chimera::xml::Init { } { # Namespace variables inicialization - variable dir - variable lastImportMeshSize - set lastImportMeshSize 0 - Model::DestroyEverything Model::InitVariables dir $Chimera::dir - Model::getSolutionStrategies Strategies.xml - Model::getElements "../../Fluid/xml/Elements.xml" - Model::getMaterials Materials.xml - Model::getNodalConditions "../../Fluid/xml/NodalConditions.xml" - Model::getConstitutiveLaws "../../Fluid/xml/ConstitutiveLaws.xml" - Model::getProcesses "../../Common/xml/Processes.xml" - Model::getProcesses "../../Fluid/xml/Processes.xml" - Model::getConditions "../../Fluid/xml/Conditions.xml" - Model::getSolvers "../../Common/xml/Solvers.xml" -} - - -proc Chimera::xml::MultiAppEvent {args} { - if {$args eq "init"} { - spdAux::parseRoutes - spdAux::ConvertAllUniqueNames FL ${::Chimera::prefix} - } + spdAux::processIncludes } proc Chimera::xml::getUniqueName {name} { - return ${::Chimera::prefix}${name} + return [Fluid::xml::getUniqueName $name] } proc Chimera::xml::CustomTree { args } { - + spdAux::processIncludes + Fluid::xml::CustomTree {*}$args + + set root [customlib::GetBaseRoot] + # Change the app name + [$root selectNodes "container\[@n = 'Fluid'\]"] setAttribute pn "Chimera" +} +proc Chimera::xml::UpdateParts {domNode args} { + Fluid::xml::UpdateParts $domNode {*}$args } Chimera::xml::Init diff --git a/kratos.gid/apps/Chimera/xml/Main.spd b/kratos.gid/apps/Chimera/xml/Main.spd index 3ece65dfc..91a8d025d 100644 --- a/kratos.gid/apps/Chimera/xml/Main.spd +++ b/kratos.gid/apps/Chimera/xml/Main.spd @@ -1,12 +1,2 @@ - - - - - - - - - - - \ No newline at end of file + diff --git a/kratos.gid/apps/Chimera/xml/Materials.spd b/kratos.gid/apps/Chimera/xml/Materials.spd deleted file mode 100644 index 2b6cebca4..000000000 --- a/kratos.gid/apps/Chimera/xml/Materials.spd +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/kratos.gid/apps/Chimera/xml/Materials.xml b/kratos.gid/apps/Chimera/xml/Materials.xml deleted file mode 100644 index 9d7b67da7..000000000 --- a/kratos.gid/apps/Chimera/xml/Materials.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/kratos.gid/apps/Chimera/xml/Strategies.xml b/kratos.gid/apps/Chimera/xml/Strategies.xml deleted file mode 100644 index 5a21bbaf1..000000000 --- a/kratos.gid/apps/Chimera/xml/Strategies.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 87176bf6053716234c5d300258dc34014cb6aec3 Mon Sep 17 00:00:00 2001 From: Javi G Date: Thu, 13 Jun 2019 17:23:54 +0200 Subject: [PATCH 03/23] Write as fluid --- kratos.gid/apps/Chimera/write/write.tcl | 21 --- .../Chimera/write/writeProjectParameters.tcl | 121 ------------------ 2 files changed, 142 deletions(-) diff --git a/kratos.gid/apps/Chimera/write/write.tcl b/kratos.gid/apps/Chimera/write/write.tcl index ee09ad147..25489b435 100644 --- a/kratos.gid/apps/Chimera/write/write.tcl +++ b/kratos.gid/apps/Chimera/write/write.tcl @@ -32,7 +32,6 @@ proc Chimera::write::writeModelPartEvent { } { write::writeElementConnectivities Fluid::write::writeConditions Fluid::write::writeMeshes - writeDistances Fluid::write::FreeConditionsMap } proc Chimera::write::writeCustomFilesEvent { } { @@ -40,26 +39,6 @@ proc Chimera::write::writeCustomFilesEvent { } { write::RenameFileInModel "KratosFluid.py" "MainKratos.py" } -proc Chimera::write::writeDistances { } { - set must_write [write::getValue EMBFLDistanceSettings ReadingMode] - if {$must_write eq "from_mdpa"} { - set data [GiD_Info Mesh EmbeddedDistances] - lassign $data nodes_list distances_list - set length [objarray length $nodes_list] - if {$length eq "0"} {W "Warning: No distances detected! Check Preferences > Mesh type > Embedded"} - write::WriteString "Begin NodalData DISTANCE" - incr write::current_mdpa_indent_level - set s [write::mdpaIndent] - for {set i 0} {$i < $length} {incr i } { - set node_id [objarray get $nodes_list $i] - set distance [objarray get $distances_list $i] - write::WriteString "$s$node_id 0 $distance" - } - incr write::current_mdpa_indent_level -1 - write::WriteString "End NodalData" - } -} - proc Chimera::write::GetAttribute {att} { variable writeAttributes return [dict get $writeAttributes $att] diff --git a/kratos.gid/apps/Chimera/write/writeProjectParameters.tcl b/kratos.gid/apps/Chimera/write/writeProjectParameters.tcl index 7e323010b..7eb6637d2 100644 --- a/kratos.gid/apps/Chimera/write/writeProjectParameters.tcl +++ b/kratos.gid/apps/Chimera/write/writeProjectParameters.tcl @@ -2,63 +2,6 @@ proc ::Chimera::write::getParametersDict { } { set param_dict [Fluid::write::getParametersDict] - ## Set the meshing adaptivity settings - set mesh_adaptivity [write::getValue EMBFLAdaptivitySettings mesh_adaptivity] - # Meshing adaptivity switch on/off in problem data dict - set new_problem_data [dict get $param_dict problem_data] - dict set new_problem_data "mesh_adaptivity" $mesh_adaptivity - dict set param_dict problem_data $new_problem_data - # Set the meshing adaptivity process list - if {$mesh_adaptivity eq "Yes"} { - dict set param_dict processes mesh_adaptivity_process_list [list [getMeshAdaptivityProcessDict]] - } else { - dict set param_dict processes mesh_adaptivity_process_list [list] - } - - ## Set the auxiliar embedded fluid application processes dictionary list - dict set param_dict processes auxiliar_process_list [getAuxiliarProcessList] - - ## Set the solver settings dictionary - set solverSettingsDict [dict get $param_dict solver_settings] - # If drag has to be computed, ensure that "compute_reactions" is set to true - set compute_embedded_drag [write::getValue EMBFLEmbeddedDrag compute_embedded_drag] - if {$compute_embedded_drag eq "Yes"} { - dict set solverSettingsDict "compute_reactions" true - } - set solverSettingsDict [dict merge $solverSettingsDict [write::getSolversParametersDict Chimera] ] - - # Set the embedded monolithic formulation settings - set currentStrategyId [write::getValue FLSolStrat] - if {$currentStrategyId eq "Monolithic"} { - set formulationSettingsDict [dict get $solverSettingsDict formulation] - # Set element type - dict set formulationSettingsDict element_type "embedded_navier_stokes" - # Set the is_slip flag and remove it from the original dictionary - dict set formulationSettingsDict is_slip [dict get $solverSettingsDict is_slip] - dict unset solverSettingsDict is_slip - # Set the penalty_coefficient and remove it from the original dictionary - dict set formulationSettingsDict penalty_coefficient [dict get $solverSettingsDict penalty_coefficient] - dict unset solverSettingsDict penalty_coefficient - # If exists, set the slip_length and remove it from the original dictionary - if {[dict exists $solverSettingsDict slip_length]} { - dict set formulationSettingsDict slip_length [dict get $solverSettingsDict slip_length] - dict unset solverSettingsDict slip_length - } - # Include the formulation settings in the solver settings dict - dict set solverSettingsDict formulation $formulationSettingsDict - } - - ## Set the distance reading settings dictionary - set dist_settings_dict [dict create] - set dist_mode [write::getValue EMBFLDistanceSettings ReadingMode] - dict set dist_settings_dict import_mode $dist_mode - if {$dist_mode ne "from_mdpa"} { - set dist_file [write::getValue EMBFLDistanceSettings distance_file_name] - dict set dist_settings_dict distance_file_name $dist_file - } - dict set solverSettingsDict distance_reading_settings $dist_settings_dict - - dict set param_dict solver_settings $solverSettingsDict return $param_dict } @@ -67,67 +10,3 @@ proc Chimera::write::writeParametersEvent { } { write::SetParallelismConfiguration write::WriteJSON $projectParametersDict } - -proc Chimera::write::getAuxiliarProcessList {} { - set auxiliar_process_list [list] - - # Append the distance modification process - lappend auxiliar_process_list [getDistanceModificationDict] - - # If required, append the embedded drag process dictionary - set compute_embedded_drag [write::getValue EMBFLEmbeddedDrag compute_embedded_drag] - if {$compute_embedded_drag eq "Yes"} { - lappend auxiliar_process_list [getEmbeddedDragProcessDict] - } - - return $auxiliar_process_list -} - -proc Chimera::write::getDistanceModificationDict { } { - set distance_modif_dict [dict create ] - dict set distance_modif_dict "python_module" apply_distance_modification_process - dict set distance_modif_dict "kratos_module" KratosMultiphysics.FluidDynamicsApplication - dict set distance_modif_dict "process_name" ApplyDistanceModificationProcess - set parameters_dict [dict create ] - dict set parameters_dict "model_part_name" [lindex [write::getPartsSubModelPartId] 0] - dict set parameters_dict "check_at_each_time_step" [write::getValue EMBFLDistanceSettings correct_distance_at_each_step] - dict set distance_modif_dict "Parameters" $parameters_dict - return $distance_modif_dict -} - -proc Chimera::write::getEmbeddedDragProcessDict {} { - set pdict [dict create] - dict set pdict "python_module" "compute_embedded_drag_process" - dict set pdict "kratos_module" "KratosMultiphysics.FluidDynamicsApplication" - dict set pdict "process_name" "ComputeEmbeddedDragProcess" - set params [dict create] - dict set params "model_part_name" [lindex [write::getPartsSubModelPartId] 0] - dict set params "write_drag_output_file" [write::getValue EMBFLEmbeddedDrag write_drag_output_file] - dict set params "print_drag_to_screen" [write::getValue EMBFLEmbeddedDrag print_drag_to_screen] - dict set params "interval" [write::getInterval [write::getValue EMBFLEmbeddedDrag Interval] ] - dict set pdict "Parameters" $params - - return $pdict -} - -proc Chimera::write::getMeshAdaptivityProcessDict {} { - set pdict [dict create] - dict set pdict "python_module" "mmg_process" - dict set pdict "kratos_module" "KratosMultiphysics.MeshingApplication" - dict set pdict "process_name" "MmgProcess" - # MmgProcess settings dictionary - set params_dict [dict create] - dict set params_dict "model_part_name" "MainModelPart" - dict set params_dict "initial_step" [write::getValue EMBFLAdaptivitySettings initial_step] - dict set params_dict "step_frequency" [write::getValue EMBFLAdaptivitySettings step_frequency] - dict set params_dict "initial_remeshing" [write::getValue EMBFLAdaptivitySettings initial_remeshing] - # Set anisotropic parameters section - set anisotropy_parameters_dict [dict create] - dict set anisotropy_parameters_dict "hmin_over_hmax_anisotropic_ratio" [write::getValue EMBFLAdaptivitySettings hmin_over_hmax_anisotropic_ratio] - dict set anisotropy_parameters_dict "boundary_layer_min_size_ratio" [write::getValue EMBFLAdaptivitySettings boundary_layer_min_size_ratio] - dict set params_dict "anisotropy_parameters" $anisotropy_parameters_dict - dict set params_dict "echo_level" [write::getValue EMBFLAdaptivitySettings echo_level] - dict set pdict "Parameters" $params_dict - - return $pdict -} From b04e020d7d0e5d284b1eba5e99e3d01cbc2f896f Mon Sep 17 00:00:00 2001 From: Javi G Date: Thu, 13 Jun 2019 19:31:40 +0200 Subject: [PATCH 04/23] Chimera parts parameters --- kratos.gid/apps/Chimera/start.tcl | 3 +-- kratos.gid/apps/Chimera/write/write.tcl | 2 +- kratos.gid/apps/Chimera/xml/ChimeraParts.spd | 6 ++++++ kratos.gid/apps/Chimera/xml/GetFromXML.tcl | 19 +++++++++++++++++-- .../apps/EmbeddedFluid/xml/Parts.spd.bak | 17 ----------------- 5 files changed, 25 insertions(+), 22 deletions(-) create mode 100644 kratos.gid/apps/Chimera/xml/ChimeraParts.spd delete mode 100644 kratos.gid/apps/EmbeddedFluid/xml/Parts.spd.bak diff --git a/kratos.gid/apps/Chimera/start.tcl b/kratos.gid/apps/Chimera/start.tcl index 32f89f793..5af1f7752 100644 --- a/kratos.gid/apps/Chimera/start.tcl +++ b/kratos.gid/apps/Chimera/start.tcl @@ -3,7 +3,6 @@ namespace eval ::Chimera { variable dir variable prefix variable attributes - variable oldMeshType variable kratos_name } @@ -16,12 +15,12 @@ proc ::Chimera::Init { } { apps::LoadAppById "Fluid" set kratos_name $::Fluid::kratos_name + set dir [apps::getMyDir "Chimera"] set ::Model::ValidSpatialDimensions [list 2D] spdAux::SetSpatialDimmension "2D" spdAux::processIncludes - set dir [apps::getMyDir "Chimera"] set attributes [dict create] set prefix Chim diff --git a/kratos.gid/apps/Chimera/write/write.tcl b/kratos.gid/apps/Chimera/write/write.tcl index 25489b435..f3b4fc5aa 100644 --- a/kratos.gid/apps/Chimera/write/write.tcl +++ b/kratos.gid/apps/Chimera/write/write.tcl @@ -7,7 +7,7 @@ proc Chimera::write::Init { } { SetAttribute parts_un FLParts SetAttribute nodal_conditions_un FLNodalConditions SetAttribute conditions_un FLBC - SetAttribute materials_un EMBFLMaterials + SetAttribute materials_un FLMaterials SetAttribute results_un FLResults SetAttribute time_parameters_un FLTimeParameters SetAttribute writeCoordinatesByGroups 0 diff --git a/kratos.gid/apps/Chimera/xml/ChimeraParts.spd b/kratos.gid/apps/Chimera/xml/ChimeraParts.spd new file mode 100644 index 000000000..e8473bde1 --- /dev/null +++ b/kratos.gid/apps/Chimera/xml/ChimeraParts.spd @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/kratos.gid/apps/Chimera/xml/GetFromXML.tcl b/kratos.gid/apps/Chimera/xml/GetFromXML.tcl index 2983192e3..45f9ec65f 100644 --- a/kratos.gid/apps/Chimera/xml/GetFromXML.tcl +++ b/kratos.gid/apps/Chimera/xml/GetFromXML.tcl @@ -18,9 +18,24 @@ proc Chimera::xml::CustomTree { args } { spdAux::processIncludes Fluid::xml::CustomTree {*}$args - set root [customlib::GetBaseRoot] # Change the app name - [$root selectNodes "container\[@n = 'Fluid'\]"] setAttribute pn "Chimera" + [[customlib::GetBaseRoot] selectNodes "container\[@n = 'Fluid'\]"] setAttribute pn "Chimera" + + # Add ChimeraParts.spd + set xpath "container\[@n = 'Fluid'\]/condition\[@n='ChimeraParts'\]" + if {[[customlib::GetBaseRoot] selectNodes $xpath] eq ""} { + set chimera_parts [gid_groups_conds::addF "container\[@n = 'Fluid'\]" include [list n ChimeraParts active 1 path {apps/Chimera/xml/ChimeraParts.spd}]] + + customlib::UpdateDocument + set parts [[customlib::GetBaseRoot] selectNodes [spdAux::getRoute FLParts]] + set new [$chimera_parts cloneNode] + set parent [[$parts nextSibling] parent] + $chimera_parts delete + $parent insertBefore $new [$parts nextSibling] + } + + customlib::ProcessIncludes $::Kratos::kratos_private(Path) + spdAux::parseRoutes } proc Chimera::xml::UpdateParts {domNode args} { Fluid::xml::UpdateParts $domNode {*}$args diff --git a/kratos.gid/apps/EmbeddedFluid/xml/Parts.spd.bak b/kratos.gid/apps/EmbeddedFluid/xml/Parts.spd.bak deleted file mode 100644 index a2d1b0a2f..000000000 --- a/kratos.gid/apps/EmbeddedFluid/xml/Parts.spd.bak +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file From 087ccdbb824dff02bfd69f501a378396db680555 Mon Sep 17 00:00:00 2001 From: Javi G Date: Thu, 13 Jun 2019 20:03:21 +0200 Subject: [PATCH 05/23] Init write --- kratos.gid/apps/Chimera/write/write.tcl | 30 +++++-------------------- 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/kratos.gid/apps/Chimera/write/write.tcl b/kratos.gid/apps/Chimera/write/write.tcl index f3b4fc5aa..d45c40332 100644 --- a/kratos.gid/apps/Chimera/write/write.tcl +++ b/kratos.gid/apps/Chimera/write/write.tcl @@ -4,35 +4,17 @@ namespace eval Chimera::write { proc Chimera::write::Init { } { # Namespace variables inicialization - SetAttribute parts_un FLParts - SetAttribute nodal_conditions_un FLNodalConditions - SetAttribute conditions_un FLBC - SetAttribute materials_un FLMaterials - SetAttribute results_un FLResults - SetAttribute time_parameters_un FLTimeParameters - SetAttribute writeCoordinatesByGroups 0 + variable writeAttributes + set writeAttributes [Fluid::write::GetAttributes] + + SetAttribute writeCoordinatesByGroups 1 SetAttribute validApps [list "Fluid" "Chimera"] - SetAttribute main_script_file "KratosFluid.py" - SetAttribute model_part_name "FluidModelPart" - SetAttribute materials_file "FluidMaterials.json" } # Events proc Chimera::write::writeModelPartEvent { } { - # Fluid::write::AddValidApps "Chimera" - set err [Fluid::write::Validate] - if {$err ne ""} {error $err} - - Fluid::write::InitConditionsMap - write::initWriteConfiguration [GetAttributes] - write::writeModelPartData - Fluid::write::writeProperties - write::writeMaterials [GetAttribute validApps] - write::writeNodalCoordinatesOnParts - write::writeElementConnectivities - Fluid::write::writeConditions - Fluid::write::writeMeshes - Fluid::write::FreeConditionsMap + + Fluid::write::writeModelPartEvent } proc Chimera::write::writeCustomFilesEvent { } { write::CopyFileIntoModel "python/KratosFluid.py" From 9c9908465446c9655a96b1496b9c83b4a7a4c195 Mon Sep 17 00:00:00 2001 From: Javi G Date: Mon, 1 Jul 2019 22:07:03 +0200 Subject: [PATCH 06/23] Write a file foreach patch #597 --- kratos.gid/apps/Chimera/write/write.tcl | 21 ++++++++++++++++- kratos.gid/apps/Chimera/xml/ChimeraParts.spd | 4 +--- kratos.gid/apps/Chimera/xml/Conditions.xml | 23 +++++++++++++++++++ kratos.gid/apps/Chimera/xml/Elements.xml | 20 ++++++++++++++++ kratos.gid/apps/Chimera/xml/GetFromXML.tcl | 2 ++ kratos.gid/apps/DEM/write/writeMDPA_Inlet.tcl | 4 ---- 6 files changed, 66 insertions(+), 8 deletions(-) create mode 100644 kratos.gid/apps/Chimera/xml/Conditions.xml create mode 100644 kratos.gid/apps/Chimera/xml/Elements.xml diff --git a/kratos.gid/apps/Chimera/write/write.tcl b/kratos.gid/apps/Chimera/write/write.tcl index d45c40332..06fec11fd 100644 --- a/kratos.gid/apps/Chimera/write/write.tcl +++ b/kratos.gid/apps/Chimera/write/write.tcl @@ -7,15 +7,34 @@ proc Chimera::write::Init { } { variable writeAttributes set writeAttributes [Fluid::write::GetAttributes] + SetAttribute chim_parts_un ChimParts SetAttribute writeCoordinatesByGroups 1 SetAttribute validApps [list "Fluid" "Chimera"] } # Events proc Chimera::write::writeModelPartEvent { } { - + # Write the background mesh as the fluid Fluid::write::writeModelPartEvent + write::CloseFile + + # Write the patches as independent mdpa + Chimera::write::writePatches } + +proc Chimera::write::writePatches { } { + set root [customlib::GetBaseRoot] + set xp "[spdAux::getRoute [GetAttribute chim_parts_un]]/group" + foreach patch [$root selectNodes $xp] { + set group_id [$patch @n] + set patch_name [write::GetWriteGroupName $group_id] + write::OpenFile ${patch_name}.mdpa + write::writeNodalCoordinatesOnGroups $group_id + write::writeGroupElementConnectivities $patch ChimeraPatch$Model::SpatialDimension + write::CloseFile + } +} + proc Chimera::write::writeCustomFilesEvent { } { write::CopyFileIntoModel "python/KratosFluid.py" write::RenameFileInModel "KratosFluid.py" "MainKratos.py" diff --git a/kratos.gid/apps/Chimera/xml/ChimeraParts.spd b/kratos.gid/apps/Chimera/xml/ChimeraParts.spd index e8473bde1..fd52fc59b 100644 --- a/kratos.gid/apps/Chimera/xml/ChimeraParts.spd +++ b/kratos.gid/apps/Chimera/xml/ChimeraParts.spd @@ -1,6 +1,4 @@ - - + - \ No newline at end of file diff --git a/kratos.gid/apps/Chimera/xml/Conditions.xml b/kratos.gid/apps/Chimera/xml/Conditions.xml new file mode 100644 index 000000000..3aec5f156 --- /dev/null +++ b/kratos.gid/apps/Chimera/xml/Conditions.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + diff --git a/kratos.gid/apps/Chimera/xml/Elements.xml b/kratos.gid/apps/Chimera/xml/Elements.xml new file mode 100644 index 000000000..a26c4d5da --- /dev/null +++ b/kratos.gid/apps/Chimera/xml/Elements.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/kratos.gid/apps/Chimera/xml/GetFromXML.tcl b/kratos.gid/apps/Chimera/xml/GetFromXML.tcl index 45f9ec65f..0f801de8e 100644 --- a/kratos.gid/apps/Chimera/xml/GetFromXML.tcl +++ b/kratos.gid/apps/Chimera/xml/GetFromXML.tcl @@ -7,6 +7,8 @@ proc Chimera::xml::Init { } { # Namespace variables inicialization Model::InitVariables dir $Chimera::dir + Model::getConditions Conditions.xml + Model::getElements Elements.xml spdAux::processIncludes } diff --git a/kratos.gid/apps/DEM/write/writeMDPA_Inlet.tcl b/kratos.gid/apps/DEM/write/writeMDPA_Inlet.tcl index bb0f780df..18fefc490 100644 --- a/kratos.gid/apps/DEM/write/writeMDPA_Inlet.tcl +++ b/kratos.gid/apps/DEM/write/writeMDPA_Inlet.tcl @@ -21,10 +21,6 @@ proc DEM::write::GetInletGroups { } { return $groups } - - - - proc DEM::write::writeInletMeshes { } { variable inletProperties foreach groupid [dict keys $inletProperties ] { From 93ca2d8343e3b2650d684958161adfec3e4b9e37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Zorrilla?= Date: Thu, 4 Jul 2019 17:15:08 +0200 Subject: [PATCH 07/23] Chimera cross example geometry --- .../apps/Chimera/examples/ChimeraCross.tcl | 256 ++++++++++++++++++ kratos.gid/apps/Chimera/examples/examples.tcl | 15 + kratos.gid/apps/Chimera/start.tcl | 12 +- 3 files changed, 281 insertions(+), 2 deletions(-) create mode 100644 kratos.gid/apps/Chimera/examples/ChimeraCross.tcl create mode 100644 kratos.gid/apps/Chimera/examples/examples.tcl diff --git a/kratos.gid/apps/Chimera/examples/ChimeraCross.tcl b/kratos.gid/apps/Chimera/examples/ChimeraCross.tcl new file mode 100644 index 000000000..38313111d --- /dev/null +++ b/kratos.gid/apps/Chimera/examples/ChimeraCross.tcl @@ -0,0 +1,256 @@ + +proc ::Chimera::examples::ChimeraCross {args} { + if {![Kratos::IsModelEmpty]} { + set txt "We are going to draw the example geometry.\nDo you want to lose your previous work?" + set retval [tk_messageBox -default ok -icon question -message $txt -type okcancel] + if { $retval == "cancel" } { return } + } + Kratos::ResetModel + + DrawChimeraCrossGeometry$::Model::SpatialDimension + # AssignGroupsChimeraCross$::Model::SpatialDimension + # AssignChimeraCrossMeshSizes$::Model::SpatialDimension + # TreeAssignationChimeraCross$::Model::SpatialDimension + + GiD_Process 'Redraw + GidUtils::UpdateWindow GROUPS + GidUtils::UpdateWindow LAYER + GiD_Process 'Zoom Frame +} + + +# Draw Geometry +proc ::Chimera::examples::DrawChimeraCrossGeometry3D {args} { + DrawChimeraCrossGeometry2D + GiD_Process Mescape Utilities Copy Surfaces Duplicate DoExtrude Volumes MaintainLayers Translation FNoJoin 0.0,0.0,0.0 FNoJoin 0.0,0.0,1.0 1 escape escape escape + GiD_Layers edit opaque Background 0 + GiD_Layers edit opaque Patch 0 + + GiD_Process escape escape 'Render Flat escape 'Rotate Angle 270 90 escape escape escape escape 'Rotate obj x -150 y -30 escape escape +} + +proc ::Chimera::examples::DrawChimeraCrossGeometry2D {args} { + # Background mesh geometry creation + GiD_Layers create Background + GiD_Layers edit to_use Background + + ## Points ## + set back_coords [list 0.0 0.0 0.0 15.0 0.0 0.0 15.0 10.0 0.0 0.0 10.0 0.0] + set back_points [list ] + foreach {x y z} $back_coords { + lappend back_points [GiD_Geometry create point append Background $x $y $z] + } + + ## Lines ## + set back_lines [list ] + set initial [lindex $back_points 0] + foreach point [lrange $back_points 1 end] { + lappend back_lines [GiD_Geometry create line append stline Background $initial $point] + set initial $point + } + lappend back_lines [GiD_Geometry create line append stline Background $initial [lindex $back_points 0]] + + ## Surface ## + GiD_Process Mescape Geometry Create NurbsSurface {*}$back_lines escape escape + + # Patch mesh geometry creation + GiD_Layers create Patch + GiD_Layers edit to_use Patch + + ## Points ## + set patch_coords [list 3.849 2.7749 0.0 8.0104 2.7749 0.0 8.0104 6.8667 0.0 3.849 6.8667 0.0] + set patch_points [list ] + foreach {x y z} $patch_coords { + lappend patch_points [GiD_Geometry create point append Patch $x $y $z] + } + + ## Lines ## + set patch_lines [list ] + set initial [lindex $patch_points 0] + foreach point [lrange $patch_points 1 end] { + lappend patch_lines [GiD_Geometry create line append stline Patch $initial $point] + set initial $point + } + lappend patch_lines [GiD_Geometry create line append stline Patch $initial [lindex $patch_points 0]] + + # Cross mesh geometry creation + ## Points ## + set cross_coords [list 5.0737 4.7791 0.0 5.7557 4.7791 0.0 5.7557 4.2084 0.0 5.9366 4.2084 0.0 5.9366 4.7791 0.0 6.7995 4.7791 0.0 6.7995 4.96 0.0 5.9366 4.96 0.0 5.9366 5.461 0.0 5.7557 5.461 0.0 5.7557 4.96 0.0 5.0737 4.96 0.0] + set cross_points [list ] + foreach {x y z} $cross_coords { + lappend cross_points [GiD_Geometry create point append Patch $x $y $z] + } + + ## Lines ## + set initial [lindex $cross_points 0] + foreach point [lrange $cross_points 1 end] { + lappend patch_lines [GiD_Geometry create line append stline Patch $initial $point] + set initial $point + } + lappend patch_lines [GiD_Geometry create line append stline Patch $initial [lindex $cross_points 0]] + + + ## Surface ## + GiD_Process Mescape Geometry Create NurbsSurface {*}$patch_lines escape escape +} + +# Group assign +proc ::Chimera::examples::AssignGroupsChimeraCross2D {args} { + # Create the groups + GiD_Groups create Fluid + GiD_Groups edit color Fluid "#26d1a8ff" + GiD_EntitiesGroups assign Fluid surfaces 1 + + GiD_Groups create Inlet + GiD_Groups edit color Inlet "#e0210fff" + GiD_EntitiesGroups assign Inlet lines 4 + + GiD_Groups create Outlet + GiD_Groups edit color Outlet "#42eb71ff" + GiD_EntitiesGroups assign Outlet lines 2 + + GiD_Groups create No_Slip_Walls + GiD_Groups edit color No_Slip_Walls "#3b3b3bff" + GiD_EntitiesGroups assign No_Slip_Walls lines {1 3} + + GiD_Groups create No_Slip_Cylinder + GiD_Groups edit color No_Slip_Cylinder "#3b3b3bff" + GiD_EntitiesGroups assign No_Slip_Cylinder lines 5 +} +proc ::Chimera::examples::AssignGroupsChimeraCross3D {args} { + # Create the groups + GiD_Groups create Fluid + GiD_Groups edit color Fluid "#26d1a8ff" + GiD_EntitiesGroups assign Fluid volumes 1 + + GiD_Groups create Inlet + GiD_Groups edit color Inlet "#e0210fff" + GiD_EntitiesGroups assign Inlet surfaces 5 + + GiD_Groups create Outlet + GiD_Groups edit color Outlet "#42eb71ff" + GiD_EntitiesGroups assign Outlet surfaces 3 + + GiD_Groups create No_Slip_Walls + GiD_Groups edit color No_Slip_Walls "#3b3b3bff" + GiD_EntitiesGroups assign No_Slip_Walls surfaces {1 2 4 7} + + GiD_Groups create No_Slip_Cylinder + GiD_Groups edit color No_Slip_Cylinder "#3b3b3bff" + GiD_EntitiesGroups assign No_Slip_Cylinder surfaces 6 +} + + +# Mesh sizes +proc ::Chimera::examples::AssignChimeraCrossMeshSizes3D {args} { + set cylinder_mesh_size 0.005 + set walls_mesh_size 0.05 + set fluid_mesh_size 0.05 + GiD_Process Mescape Utilities Variables SizeTransitionsFactor 0.4 escape escape + GiD_Process Mescape Meshing AssignSizes Surfaces $cylinder_mesh_size {*}[GiD_EntitiesGroups get No_Slip_Cylinder surfaces] escape escape + GiD_Process Mescape Meshing AssignSizes Surfaces $walls_mesh_size {*}[GiD_EntitiesGroups get Inlet surfaces] escape escape + GiD_Process Mescape Meshing AssignSizes Surfaces $walls_mesh_size {*}[GiD_EntitiesGroups get Outlet surfaces] escape escape + GiD_Process Mescape Meshing AssignSizes Surfaces $walls_mesh_size {*}[GiD_EntitiesGroups get No_Slip_Walls surfaces] escape escape + GiD_Process Mescape Meshing AssignSizes Volumes $fluid_mesh_size [GiD_EntitiesGroups get Fluid volumes] escape escape + Kratos::Event_BeforeMeshGeneration $fluid_mesh_size +} +proc ::Chimera::examples::AssignChimeraCrossMeshSizes2D {args} { + set cylinder_mesh_size 0.005 + set fluid_mesh_size 0.05 + GiD_Process Mescape Utilities Variables SizeTransitionsFactor 0.4 escape escape + GiD_Process Mescape Meshing AssignSizes Lines $cylinder_mesh_size {*}[GiD_EntitiesGroups get No_Slip_Cylinder lines] escape escape + GiD_Process Mescape Meshing AssignSizes Surfaces $fluid_mesh_size [GiD_EntitiesGroups get Fluid surfaces] escape escape + Kratos::Event_BeforeMeshGeneration $fluid_mesh_size +} + + +# Tree assign +proc ::Chimera::examples::TreeAssignationChimeraCross3D {args} { + TreeAssignationChimeraCross2D + AddCuts +} +proc ::Chimera::examples::TreeAssignationChimeraCross2D {args} { + set nd $::Model::SpatialDimension + set root [customlib::GetBaseRoot] + + set condtype line + if {$nd eq "3D"} { set condtype surface } + + # Monolithic solution strategy set + spdAux::SetValueOnTreeItem v "Monolithic" FLSolStrat + + # Fluid Parts + set fluidParts [spdAux::getRoute "FLParts"] + set fluidNode [customlib::AddConditionGroupOnXPath $fluidParts Fluid] + # set props [list Element Monolithic$nd ConstitutiveLaw Newtonian DENSITY 1.0 DYNAMIC_VISCOSITY 0.002 YIELD_STRESS 0 POWER_LAW_K 1 POWER_LAW_N 1] + set props [list Element Monolithic$nd ConstitutiveLaw Newtonian DENSITY 1.0 DYNAMIC_VISCOSITY 0.002] + foreach {prop val} $props { + set propnode [$fluidNode selectNodes "./value\[@n = '$prop'\]"] + if {$propnode ne "" } { + $propnode setAttribute v $val + } else { + W "Warning - Couldn't find property Fluid $prop" + } + } + + set fluidConditions [spdAux::getRoute "FLBC"] + ErasePreviousIntervals + + # Fluid Inlet + ::Chimera::xml::CreateNewInlet Inlet {new true name inlet1 ini 0 end 1} true "6*y*(1-y)*sin(pi*t*0.5)" + ::Chimera::xml::CreateNewInlet Inlet {new true name inlet2 ini 1 end End} true "6*y*(1-y)" + + # Fluid Outlet + set fluidOutlet "$fluidConditions/condition\[@n='Outlet$nd'\]" + set outletNode [customlib::AddConditionGroupOnXPath $fluidOutlet Outlet] + $outletNode setAttribute ov $condtype + set props [list value 0.0] + foreach {prop val} $props { + set propnode [$outletNode selectNodes "./value\[@n = '$prop'\]"] + if {$propnode ne "" } { + $propnode setAttribute v $val + } else { + W "Warning - Couldn't find property Outlet $prop" + } + } + + # Fluid Conditions + [customlib::AddConditionGroupOnXPath "$fluidConditions/condition\[@n='NoSlip$nd'\]" No_Slip_Walls] setAttribute ov $condtype + [customlib::AddConditionGroupOnXPath "$fluidConditions/condition\[@n='NoSlip$nd'\]" No_Slip_Cylinder] setAttribute ov $condtype + + # Time parameters + set time_parameters [list EndTime 45 DeltaTime 0.1] + set time_params_path [spdAux::getRoute "FLTimeParameters"] + foreach {n v} $time_parameters { + [$root selectNodes "$time_params_path/value\[@n = '$n'\]"] setAttribute v $v + } + # Output + set time_parameters [list OutputControlType step OutputDeltaStep 1] + set xpath "[spdAux::getRoute FLResults]/container\[@n='GiDOutput'\]/container\[@n='GiDOptions'\]" + foreach {n v} $time_parameters { + [$root selectNodes "$xpath/value\[@n = '$n'\]"] setAttribute v $v + } + # Parallelism + set time_parameters [list ParallelSolutionType OpenMP OpenMPNumberOfThreads 4] + set time_params_path [spdAux::getRoute "Parallelization"] + foreach {n v} $time_parameters { + [$root selectNodes "$time_params_path/value\[@n = '$n'\]"] setAttribute v $v + } + + spdAux::RequestRefresh +} + +proc ::Chimera::examples::ErasePreviousIntervals { } { + set root [customlib::GetBaseRoot] + set interval_base [spdAux::getRoute "Intervals"] + foreach int [$root selectNodes "$interval_base/blockdata\[@n='Interval'\]"] { + if {[$int @name] ni [list Initial Total Custom1]} {$int delete} + } +} + +proc ::Chimera::examples::AddCuts { } { + # Cuts + set results "[spdAux::getRoute FLResults]/container\[@n='GiDOutput'\]" + set cp [[customlib::GetBaseRoot] selectNodes "$results/container\[@n = 'CutPlanes'\]/blockdata\[@name = 'CutPlane'\]"] + [$cp selectNodes "./value\[@n = 'point'\]"] setAttribute v "0.0,0.5,0.0" +} \ No newline at end of file diff --git a/kratos.gid/apps/Chimera/examples/examples.tcl b/kratos.gid/apps/Chimera/examples/examples.tcl new file mode 100644 index 000000000..00abfc6b3 --- /dev/null +++ b/kratos.gid/apps/Chimera/examples/examples.tcl @@ -0,0 +1,15 @@ +namespace eval Chimera::examples { + +} + +proc Chimera::examples::Init { } { + uplevel #0 [list source [file join $::Chimera::dir examples ChimeraCross.tcl]] +} + +proc Chimera::examples::UpdateMenus { } { + GiDMenu::InsertOption "Kratos" [list "---"] 7 PRE "" "" "" insertafter = + GiDMenu::InsertOption "Kratos" [list "Cross section flow" ] 7 PRE [list ::Chimera::examples::ChimeraCross] "" "" insertafter = + GiDMenu::UpdateMenus +} + +Chimera::examples::Init \ No newline at end of file diff --git a/kratos.gid/apps/Chimera/start.tcl b/kratos.gid/apps/Chimera/start.tcl index 5af1f7752..817adccdf 100644 --- a/kratos.gid/apps/Chimera/start.tcl +++ b/kratos.gid/apps/Chimera/start.tcl @@ -16,7 +16,7 @@ proc ::Chimera::Init { } { apps::LoadAppById "Fluid" set kratos_name $::Fluid::kratos_name set dir [apps::getMyDir "Chimera"] - + set ::Model::ValidSpatialDimensions [list 2D] spdAux::SetSpatialDimmension "2D" spdAux::processIncludes @@ -36,6 +36,7 @@ proc ::Chimera::Init { } { proc ::Chimera::LoadMyFiles { } { variable dir + uplevel #0 [list source [file join $dir examples examples.tcl]] uplevel #0 [list source [file join $dir xml GetFromXML.tcl]] uplevel #0 [list source [file join $dir write write.tcl]] uplevel #0 [list source [file join $dir write writeProjectParameters.tcl]] @@ -48,9 +49,16 @@ proc ::Chimera::GetAttribute {name} { return $value } +proc ::Chimera::CustomToolbarItems { } { + variable dir + if {$::Model::SpatialDimension eq "2D"} { + Kratos::ToolbarAddItem "Example" "example.png" [list -np- ::Chimera::examples::ChimeraCross] [= "Example\nCross section flow"] + } +} + # proc ::Chimera::BeforeMeshGeneration {elementsize} { # variable oldMeshType - + # set project_path [GiD_Info project modelname] # if {$project_path ne "UNNAMED"} { # catch {file delete -force [file join [write::GetConfigurationAttribute dir] "[Kratos::GetModelName].post.res"]} From 8ef10933713856bb47683bb6191439834e0cc9a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Zorrilla?= Date: Thu, 4 Jul 2019 18:31:42 +0200 Subject: [PATCH 08/23] Conditions in cross example --- .../apps/Chimera/examples/ChimeraCross.tcl | 106 +++++++++--------- kratos.gid/apps/Chimera/xml/Conditions.xml | 11 +- 2 files changed, 57 insertions(+), 60 deletions(-) diff --git a/kratos.gid/apps/Chimera/examples/ChimeraCross.tcl b/kratos.gid/apps/Chimera/examples/ChimeraCross.tcl index 38313111d..60f6d27d6 100644 --- a/kratos.gid/apps/Chimera/examples/ChimeraCross.tcl +++ b/kratos.gid/apps/Chimera/examples/ChimeraCross.tcl @@ -8,9 +8,9 @@ proc ::Chimera::examples::ChimeraCross {args} { Kratos::ResetModel DrawChimeraCrossGeometry$::Model::SpatialDimension - # AssignGroupsChimeraCross$::Model::SpatialDimension - # AssignChimeraCrossMeshSizes$::Model::SpatialDimension - # TreeAssignationChimeraCross$::Model::SpatialDimension + AssignGroupsChimeraCross$::Model::SpatialDimension + AssignChimeraCrossMeshSizes$::Model::SpatialDimension + TreeAssignationChimeraCross$::Model::SpatialDimension GiD_Process 'Redraw GidUtils::UpdateWindow GROUPS @@ -99,7 +99,15 @@ proc ::Chimera::examples::AssignGroupsChimeraCross2D {args} { # Create the groups GiD_Groups create Fluid GiD_Groups edit color Fluid "#26d1a8ff" - GiD_EntitiesGroups assign Fluid surfaces 1 + GiD_EntitiesGroups assign Fluid surfaces {1 2} + + GiD_Groups create Background + GiD_Groups edit color Background "#26d1a8ff" + GiD_EntitiesGroups assign Background surfaces 1 + + GiD_Groups create Patch + GiD_Groups edit color Patch "#26d1a8ff" + GiD_EntitiesGroups assign Patch surfaces 2 GiD_Groups create Inlet GiD_Groups edit color Inlet "#e0210fff" @@ -113,62 +121,30 @@ proc ::Chimera::examples::AssignGroupsChimeraCross2D {args} { GiD_Groups edit color No_Slip_Walls "#3b3b3bff" GiD_EntitiesGroups assign No_Slip_Walls lines {1 3} - GiD_Groups create No_Slip_Cylinder - GiD_Groups edit color No_Slip_Cylinder "#3b3b3bff" - GiD_EntitiesGroups assign No_Slip_Cylinder lines 5 + GiD_Groups create No_Slip_Cross + GiD_Groups edit color No_Slip_Cross "#3b3b3bff" + GiD_EntitiesGroups assign No_Slip_Cross lines {9 10 11 12 13 14 15 16 17 18 19 20} } -proc ::Chimera::examples::AssignGroupsChimeraCross3D {args} { - # Create the groups - GiD_Groups create Fluid - GiD_Groups edit color Fluid "#26d1a8ff" - GiD_EntitiesGroups assign Fluid volumes 1 - - GiD_Groups create Inlet - GiD_Groups edit color Inlet "#e0210fff" - GiD_EntitiesGroups assign Inlet surfaces 5 - GiD_Groups create Outlet - GiD_Groups edit color Outlet "#42eb71ff" - GiD_EntitiesGroups assign Outlet surfaces 3 - - GiD_Groups create No_Slip_Walls - GiD_Groups edit color No_Slip_Walls "#3b3b3bff" - GiD_EntitiesGroups assign No_Slip_Walls surfaces {1 2 4 7} - - GiD_Groups create No_Slip_Cylinder - GiD_Groups edit color No_Slip_Cylinder "#3b3b3bff" - GiD_EntitiesGroups assign No_Slip_Cylinder surfaces 6 +proc ::Chimera::examples::AssignGroupsChimeraCross3D {args} { + # TO BE IMPLEMENTED } - # Mesh sizes -proc ::Chimera::examples::AssignChimeraCrossMeshSizes3D {args} { - set cylinder_mesh_size 0.005 - set walls_mesh_size 0.05 - set fluid_mesh_size 0.05 - GiD_Process Mescape Utilities Variables SizeTransitionsFactor 0.4 escape escape - GiD_Process Mescape Meshing AssignSizes Surfaces $cylinder_mesh_size {*}[GiD_EntitiesGroups get No_Slip_Cylinder surfaces] escape escape - GiD_Process Mescape Meshing AssignSizes Surfaces $walls_mesh_size {*}[GiD_EntitiesGroups get Inlet surfaces] escape escape - GiD_Process Mescape Meshing AssignSizes Surfaces $walls_mesh_size {*}[GiD_EntitiesGroups get Outlet surfaces] escape escape - GiD_Process Mescape Meshing AssignSizes Surfaces $walls_mesh_size {*}[GiD_EntitiesGroups get No_Slip_Walls surfaces] escape escape - GiD_Process Mescape Meshing AssignSizes Volumes $fluid_mesh_size [GiD_EntitiesGroups get Fluid volumes] escape escape - Kratos::Event_BeforeMeshGeneration $fluid_mesh_size -} proc ::Chimera::examples::AssignChimeraCrossMeshSizes2D {args} { - set cylinder_mesh_size 0.005 - set fluid_mesh_size 0.05 - GiD_Process Mescape Utilities Variables SizeTransitionsFactor 0.4 escape escape - GiD_Process Mescape Meshing AssignSizes Lines $cylinder_mesh_size {*}[GiD_EntitiesGroups get No_Slip_Cylinder lines] escape escape - GiD_Process Mescape Meshing AssignSizes Surfaces $fluid_mesh_size [GiD_EntitiesGroups get Fluid surfaces] escape escape - Kratos::Event_BeforeMeshGeneration $fluid_mesh_size + set cross_mesh_size 0.05 + set surface_mesh_size 0.2 + GiD_Process Mescape Meshing AssignSizes Lines $cross_mesh_size {*}[GiD_EntitiesGroups get No_Slip_Cross lines] escape escape + GiD_Process Mescape Meshing AssignSizes Lines $surface_mesh_size 5 7 8 6 escape escape + GiD_Process Mescape Meshing AssignSizes Surfaces $surface_mesh_size [GiD_EntitiesGroups get Fluid surfaces] escape escape + Kratos::Event_BeforeMeshGeneration $surface_mesh_size } +proc ::Chimera::examples::AssignChimeraCrossMeshSizes3D {args} { + # TO BE IMPLEMENTED +} # Tree assign -proc ::Chimera::examples::TreeAssignationChimeraCross3D {args} { - TreeAssignationChimeraCross2D - AddCuts -} proc ::Chimera::examples::TreeAssignationChimeraCross2D {args} { set nd $::Model::SpatialDimension set root [customlib::GetBaseRoot] @@ -182,8 +158,7 @@ proc ::Chimera::examples::TreeAssignationChimeraCross2D {args} { # Fluid Parts set fluidParts [spdAux::getRoute "FLParts"] set fluidNode [customlib::AddConditionGroupOnXPath $fluidParts Fluid] - # set props [list Element Monolithic$nd ConstitutiveLaw Newtonian DENSITY 1.0 DYNAMIC_VISCOSITY 0.002 YIELD_STRESS 0 POWER_LAW_K 1 POWER_LAW_N 1] - set props [list Element Monolithic$nd ConstitutiveLaw Newtonian DENSITY 1.0 DYNAMIC_VISCOSITY 0.002] + set props [list Element Monolithic$nd ConstitutiveLaw Newtonian DENSITY 1000.0 DYNAMIC_VISCOSITY 0.001] foreach {prop val} $props { set propnode [$fluidNode selectNodes "./value\[@n = '$prop'\]"] if {$propnode ne "" } { @@ -193,12 +168,25 @@ proc ::Chimera::examples::TreeAssignationChimeraCross2D {args} { } } + # Chimera Patches + set chimeraPatches [spdAux::getRoute "ChimParts"] + set chimeraNode [customlib::AddConditionGroupOnXPath $chimeraPatches Patch] + set chimera_patch_props [list overlap_distance 0.7] + foreach {prop val} $chimera_patch_props { + set propnode [$chimeraNode selectNodes "./value\[@n = '$prop'\]"] + if {$propnode ne ""} { + $propnode setAttribute v $val + } else { + W "Warning - Couldn't find property Chimera patches $prop" + } + } + + # Set conditions set fluidConditions [spdAux::getRoute "FLBC"] ErasePreviousIntervals # Fluid Inlet - ::Chimera::xml::CreateNewInlet Inlet {new true name inlet1 ini 0 end 1} true "6*y*(1-y)*sin(pi*t*0.5)" - ::Chimera::xml::CreateNewInlet Inlet {new true name inlet2 ini 1 end End} true "6*y*(1-y)" + ::Fluid::xml::CreateNewInlet Inlet {new false name Total ini 0 end 1} true 1.0 # Fluid Outlet set fluidOutlet "$fluidConditions/condition\[@n='Outlet$nd'\]" @@ -216,10 +204,11 @@ proc ::Chimera::examples::TreeAssignationChimeraCross2D {args} { # Fluid Conditions [customlib::AddConditionGroupOnXPath "$fluidConditions/condition\[@n='NoSlip$nd'\]" No_Slip_Walls] setAttribute ov $condtype - [customlib::AddConditionGroupOnXPath "$fluidConditions/condition\[@n='NoSlip$nd'\]" No_Slip_Cylinder] setAttribute ov $condtype + [customlib::AddConditionGroupOnXPath "$fluidConditions/condition\[@n='NoSlip$nd'\]" No_Slip_Cross] setAttribute ov $condtype + [customlib::AddConditionGroupOnXPath "$fluidConditions/condition\[@n='ChimeraInterface$nd'\]" No_Slip_Cross] setAttribute ov $condtype # Time parameters - set time_parameters [list EndTime 45 DeltaTime 0.1] + set time_parameters [list EndTime 1.0 DeltaTime 0.01] set time_params_path [spdAux::getRoute "FLTimeParameters"] foreach {n v} $time_parameters { [$root selectNodes "$time_params_path/value\[@n = '$n'\]"] setAttribute v $v @@ -240,6 +229,11 @@ proc ::Chimera::examples::TreeAssignationChimeraCross2D {args} { spdAux::RequestRefresh } +proc ::Chimera::examples::TreeAssignationChimeraCross3D {args} { + TreeAssignationChimeraCross2D + AddCuts +} + proc ::Chimera::examples::ErasePreviousIntervals { } { set root [customlib::GetBaseRoot] set interval_base [spdAux::getRoute "Intervals"] diff --git a/kratos.gid/apps/Chimera/xml/Conditions.xml b/kratos.gid/apps/Chimera/xml/Conditions.xml index 3aec5f156..a83f38f50 100644 --- a/kratos.gid/apps/Chimera/xml/Conditions.xml +++ b/kratos.gid/apps/Chimera/xml/Conditions.xml @@ -1,7 +1,8 @@ - @@ -10,8 +11,9 @@ - @@ -20,4 +22,5 @@ + From 8dcece699bae349c1b8fa2af04230d1f51c90592 Mon Sep 17 00:00:00 2001 From: Javi G Date: Fri, 10 Jan 2020 20:18:27 +0100 Subject: [PATCH 09/23] Commit masivo y fuera --- .../apps/Chimera/examples/ChimeraCross.tcl | 2 +- kratos.gid/apps/Chimera/write/write.tcl | 70 +++++++++++++++++-- .../Chimera/write/writeProjectParameters.tcl | 34 +++++++++ kratos.gid/apps/Chimera/xml/Conditions.xml | 4 +- kratos.gid/apps/Fluid/write/write.tcl | 10 +++ kratos.gid/kratos_default.spd | 2 +- 6 files changed, 112 insertions(+), 10 deletions(-) diff --git a/kratos.gid/apps/Chimera/examples/ChimeraCross.tcl b/kratos.gid/apps/Chimera/examples/ChimeraCross.tcl index 60f6d27d6..2d3df93d4 100644 --- a/kratos.gid/apps/Chimera/examples/ChimeraCross.tcl +++ b/kratos.gid/apps/Chimera/examples/ChimeraCross.tcl @@ -205,7 +205,7 @@ proc ::Chimera::examples::TreeAssignationChimeraCross2D {args} { # Fluid Conditions [customlib::AddConditionGroupOnXPath "$fluidConditions/condition\[@n='NoSlip$nd'\]" No_Slip_Walls] setAttribute ov $condtype [customlib::AddConditionGroupOnXPath "$fluidConditions/condition\[@n='NoSlip$nd'\]" No_Slip_Cross] setAttribute ov $condtype - [customlib::AddConditionGroupOnXPath "$fluidConditions/condition\[@n='ChimeraInterface$nd'\]" No_Slip_Cross] setAttribute ov $condtype + [customlib::AddConditionGroupOnXPath "$fluidConditions/condition\[@n='ChimeraInternalBoundary$nd'\]" No_Slip_Cross] setAttribute ov $condtype # Time parameters set time_parameters [list EndTime 1.0 DeltaTime 0.01] diff --git a/kratos.gid/apps/Chimera/write/write.tcl b/kratos.gid/apps/Chimera/write/write.tcl index 06fec11fd..b80ab7303 100644 --- a/kratos.gid/apps/Chimera/write/write.tcl +++ b/kratos.gid/apps/Chimera/write/write.tcl @@ -1,12 +1,15 @@ namespace eval Chimera::write { variable writeAttributes + + variable patches + variable inner_boundaries } proc Chimera::write::Init { } { # Namespace variables inicialization variable writeAttributes set writeAttributes [Fluid::write::GetAttributes] - + SetAttribute chim_parts_un ChimParts SetAttribute writeCoordinatesByGroups 1 SetAttribute validApps [list "Fluid" "Chimera"] @@ -17,29 +20,84 @@ proc Chimera::write::writeModelPartEvent { } { # Write the background mesh as the fluid Fluid::write::writeModelPartEvent write::CloseFile - + # Write the patches as independent mdpa Chimera::write::writePatches } proc Chimera::write::writePatches { } { - set root [customlib::GetBaseRoot] - set xp "[spdAux::getRoute [GetAttribute chim_parts_un]]/group" - foreach patch [$root selectNodes $xp] { - set group_id [$patch @n] + foreach patch [Chimera::write::GetPatchParts] { + set group_id [get_domnode_attribute $patch name] set patch_name [write::GetWriteGroupName $group_id] write::OpenFile ${patch_name}.mdpa + # Nodes write::writeNodalCoordinatesOnGroups $group_id + # Elements write::writeGroupElementConnectivities $patch ChimeraPatch$Model::SpatialDimension + # Internal patch boundary conditions + Chimera::write::GetInternalBoundaries write::CloseFile } } +proc Chimera::write::GetPatchParts { {what "xml"} } { + set root [customlib::GetBaseRoot] + set xp "[spdAux::getRoute [GetAttribute chim_parts_un]]/group" + set xml_nodes [$root selectNodes $xp] + if {$what eq "xml"} { + return $xml_nodes + } else { + set names [list ] + foreach patch $nodes { + lappend names [get_domnode_attribute $patch name] + } + return $names + } +} + +proc Chimera::write::GetInternalBoundaries { {patch_group_id ""} } { + # Empty means all + set all 0 + if {$patch_group_id eq ""} { + set all 1 + } + set name ChimeraInternalBoundary${Model::SpatialDimension} + set un [GetAttribute conditions_un] + set xp "[spdAux::getRoute $un]/condition\[@n = '$name'\]/group" + + set internal_boundaries_list [list ] + set root [customlib::GetBaseRoot] + foreach cnd_group [$root selectNodes $xp] { + set cnd_group_name [get_domnode_attribute $cnd_group n] + if {$all} { + lappend internal_boundaries_list [write::GetWriteGroupName $cnd_group_name] + } else { + set first_node [objarray get [GiD_EntitiesGroups get $cnd_group_name node] 0] + set affected_groups [GiD_EntitiesGroups entity_groups nodes $first_node] + if {$patch_group_id in $affected_groups} { + lappend internal_boundaries_list [write::GetWriteGroupName $cnd_group_name] + } + # set part_names [Fluid::write::GetFluidPartGroups] + # set patch_names [Chimera::write::GetPatchParts names] + # foreach group $affected_groups { + # if {$group ni $part_names} { + # if {$group ni $patch_names} { + # if + # } + # } + # } + } + } + return $internal_boundaries_list +} + proc Chimera::write::writeCustomFilesEvent { } { write::CopyFileIntoModel "python/KratosFluid.py" write::RenameFileInModel "KratosFluid.py" "MainKratos.py" } + +# Mandatory - Attribute handler proc Chimera::write::GetAttribute {att} { variable writeAttributes return [dict get $writeAttributes $att] diff --git a/kratos.gid/apps/Chimera/write/writeProjectParameters.tcl b/kratos.gid/apps/Chimera/write/writeProjectParameters.tcl index 7eb6637d2..92a40afe4 100644 --- a/kratos.gid/apps/Chimera/write/writeProjectParameters.tcl +++ b/kratos.gid/apps/Chimera/write/writeProjectParameters.tcl @@ -2,6 +2,40 @@ proc ::Chimera::write::getParametersDict { } { set param_dict [Fluid::write::getParametersDict] + # Check https://github.com/KratosMultiphysics/Kratos/blob/ChimeraApplication-development_2.0/applications/ChimeraApplication/tests/flow_over_cross_monolithic/flow_over_cross_monolithic.json + # in branch ChimeraApplication-development_2.0 + + set chimera_settings_dict [dict create ] + + # General parameters + dict set chimera_settings_dict chimera_echo_level 1 + dict set chimera_settings_dict reformulate_chimera_every_step true + + # Internal boundaries + set internal_parts_for_chimera_list [list ] + dict set chimera_settings_dict internal_parts_for_chimera $internal_parts_for_chimera_list + + "chimera_settings":{ + "chimera_echo_level" : 1, + "reformulate_chimera_every_step":true, + "chimera_parts": [ + [ + { + "model_part_name": "FluidModelPart.GENERIC_background_surface", + "overlap_distance": 0.01 + } + ], + [ + { + "model_part_name": "FluidModelPart.GENERIC_patch_surface", + "overlap_distance": 0.7 + } + ] + ], + "internal_parts_for_chimera":["FluidModelPart.NoSlip2D_cross"] + } + + dict set param_dict solver_settings chimera_settings $chimera_settings_dict return $param_dict } diff --git a/kratos.gid/apps/Chimera/xml/Conditions.xml b/kratos.gid/apps/Chimera/xml/Conditions.xml index a83f38f50..4ccf8efec 100644 --- a/kratos.gid/apps/Chimera/xml/Conditions.xml +++ b/kratos.gid/apps/Chimera/xml/Conditions.xml @@ -1,7 +1,7 @@ - @@ -12,7 +12,7 @@ - diff --git a/kratos.gid/apps/Fluid/write/write.tcl b/kratos.gid/apps/Fluid/write/write.tcl index a2cdbbce2..8e75d9346 100644 --- a/kratos.gid/apps/Fluid/write/write.tcl +++ b/kratos.gid/apps/Fluid/write/write.tcl @@ -202,6 +202,16 @@ proc Fluid::write::writeConditionsMesh { } { } } +proc Fluid::write::GetFluidPartGroups { } { + set xp "[spdAux::getRoute [GetAttribute parts_un]]/group" + set root [customlib::GetBaseRoot] + set parts_name_list [list] + foreach group [$root selectNodes $xp] { + lappend parts_name_list [get_domnode_attribute $group n] + } + return $parts_name_list +} + proc Fluid::write::InitConditionsMap { {map "" } } { variable FluidConditionMap diff --git a/kratos.gid/kratos_default.spd b/kratos.gid/kratos_default.spd index 4dde7b80b..564cf28db 100644 --- a/kratos.gid/kratos_default.spd +++ b/kratos.gid/kratos_default.spd @@ -29,7 +29,7 @@ - + From 8581e113c4856d1dc9a7075f175d71d55aa15959 Mon Sep 17 00:00:00 2001 From: Javi G Date: Tue, 14 Jan 2020 10:36:12 +0100 Subject: [PATCH 10/23] Write nodes in patches --- kratos.gid/apps/Chimera/write/write.tcl | 6 +-- .../Chimera/write/writeProjectParameters.tcl | 38 +++++++++---------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/kratos.gid/apps/Chimera/write/write.tcl b/kratos.gid/apps/Chimera/write/write.tcl index b80ab7303..e4c5ed4f8 100644 --- a/kratos.gid/apps/Chimera/write/write.tcl +++ b/kratos.gid/apps/Chimera/write/write.tcl @@ -27,15 +27,15 @@ proc Chimera::write::writeModelPartEvent { } { proc Chimera::write::writePatches { } { foreach patch [Chimera::write::GetPatchParts] { - set group_id [get_domnode_attribute $patch name] + set group_id [get_domnode_attribute $patch n] set patch_name [write::GetWriteGroupName $group_id] write::OpenFile ${patch_name}.mdpa # Nodes - write::writeNodalCoordinatesOnGroups $group_id + write::writeNodalCoordinatesOnGroups [list $group_id] # Elements write::writeGroupElementConnectivities $patch ChimeraPatch$Model::SpatialDimension # Internal patch boundary conditions - Chimera::write::GetInternalBoundaries + set internal_boundaries_list [Chimera::write::GetInternalBoundaries $patch_name] write::CloseFile } } diff --git a/kratos.gid/apps/Chimera/write/writeProjectParameters.tcl b/kratos.gid/apps/Chimera/write/writeProjectParameters.tcl index 92a40afe4..4ed80e7f2 100644 --- a/kratos.gid/apps/Chimera/write/writeProjectParameters.tcl +++ b/kratos.gid/apps/Chimera/write/writeProjectParameters.tcl @@ -15,25 +15,25 @@ proc ::Chimera::write::getParametersDict { } { set internal_parts_for_chimera_list [list ] dict set chimera_settings_dict internal_parts_for_chimera $internal_parts_for_chimera_list - "chimera_settings":{ - "chimera_echo_level" : 1, - "reformulate_chimera_every_step":true, - "chimera_parts": [ - [ - { - "model_part_name": "FluidModelPart.GENERIC_background_surface", - "overlap_distance": 0.01 - } - ], - [ - { - "model_part_name": "FluidModelPart.GENERIC_patch_surface", - "overlap_distance": 0.7 - } - ] - ], - "internal_parts_for_chimera":["FluidModelPart.NoSlip2D_cross"] - } + # "chimera_settings":{ + # "chimera_echo_level" : 1, + # "reformulate_chimera_every_step":true, + # "chimera_parts": [ + # [ + # { + # "model_part_name": "FluidModelPart.GENERIC_background_surface", + # "overlap_distance": 0.01 + # } + # ], + # [ + # { + # "model_part_name": "FluidModelPart.GENERIC_patch_surface", + # "overlap_distance": 0.7 + # } + # ] + # ], + # "internal_parts_for_chimera":["FluidModelPart.NoSlip2D_cross"] + # } dict set param_dict solver_settings chimera_settings $chimera_settings_dict return $param_dict From 3f4a058d39b8d47515150e0add6f95c54d0c9990 Mon Sep 17 00:00:00 2001 From: Javi G Date: Tue, 14 Jan 2020 11:10:54 +0100 Subject: [PATCH 11/23] Skip submodelpart print for ChimeraInternalBoundar --- kratos.gid/apps/Chimera/xml/GetFromXML.tcl | 5 +++++ kratos.gid/apps/Fluid/write/write.tcl | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/kratos.gid/apps/Chimera/xml/GetFromXML.tcl b/kratos.gid/apps/Chimera/xml/GetFromXML.tcl index 0f801de8e..777990e9c 100644 --- a/kratos.gid/apps/Chimera/xml/GetFromXML.tcl +++ b/kratos.gid/apps/Chimera/xml/GetFromXML.tcl @@ -19,6 +19,10 @@ proc Chimera::xml::getUniqueName {name} { proc Chimera::xml::CustomTree { args } { spdAux::processIncludes Fluid::xml::CustomTree {*}$args + + # Protection of submodelparts + [[customlib::GetBaseRoot] selectNodes "[spdAux::getRoute FLBC]/condition\[@n = 'ChimeraInternalBoundary2D'\]"] setAttribute print_smp 0 + [[customlib::GetBaseRoot] selectNodes "[spdAux::getRoute FLBC]/condition\[@n = 'ChimeraInternalBoundary3D'\]"] setAttribute print_smp 0 # Change the app name [[customlib::GetBaseRoot] selectNodes "container\[@n = 'Fluid'\]"] setAttribute pn "Chimera" @@ -39,6 +43,7 @@ proc Chimera::xml::CustomTree { args } { customlib::ProcessIncludes $::Kratos::kratos_private(Path) spdAux::parseRoutes } + proc Chimera::xml::UpdateParts {domNode args} { Fluid::xml::UpdateParts $domNode {*}$args } diff --git a/kratos.gid/apps/Fluid/write/write.tcl b/kratos.gid/apps/Fluid/write/write.tcl index 8e75d9346..3220d6e6e 100644 --- a/kratos.gid/apps/Fluid/write/write.tcl +++ b/kratos.gid/apps/Fluid/write/write.tcl @@ -174,7 +174,10 @@ proc Fluid::write::writeConditionsMesh { } { foreach group [$root selectNodes $xp1] { set groupid [$group @n] set groupid [write::GetWriteGroupName $groupid] - set condid [[$group parent] @n] + set condnode [$group parent] + set condid [$condnode @n] + set print_smp [get_domnode_attribute $condnode print_smp 1] + if {[write::isBooleanFalse $print_smp]} {continue} set cond [::Model::getCondition $condid] if {[$cond getGroupBy] eq "Condition"} { # Grouped conditions will be written later From 4f34a4bc9071e261d1d27a35b70df739292828e2 Mon Sep 17 00:00:00 2001 From: Javi G Date: Tue, 14 Jan 2020 12:46:06 +0100 Subject: [PATCH 12/23] Move to proper files --- .../Writing/WriteConditionsByUniqueId.tcl | 87 ------------------- .../scripts/Writing/WriteSubModelPart.tcl | 87 ++++++++++++++++++- 2 files changed, 86 insertions(+), 88 deletions(-) diff --git a/kratos.gid/scripts/Writing/WriteConditionsByUniqueId.tcl b/kratos.gid/scripts/Writing/WriteConditionsByUniqueId.tcl index 89831fcd2..f38b3f8d2 100644 --- a/kratos.gid/scripts/Writing/WriteConditionsByUniqueId.tcl +++ b/kratos.gid/scripts/Writing/WriteConditionsByUniqueId.tcl @@ -126,90 +126,3 @@ proc write::writeGroupConditionByUniqueId {groupid kname nnodes iter ConditionMa return $iter } - -proc write::writeConditionGroupedSubmodelPartsByUniqueId {cid groups_dict conditions_map} { - set s [mdpaIndent] - WriteString "${s}Begin SubModelPart $cid // Condition $cid" - - incr ::write::current_mdpa_indent_level - set s1 [mdpaIndent] - WriteString "${s1}Begin SubModelPartNodes" - WriteString "${s1}End SubModelPartNodes" - WriteString "${s1}Begin SubModelPartElements" - WriteString "${s1}End SubModelPartElements" - WriteString "${s1}Begin SubModelPartConditions" - WriteString "${s1}End SubModelPartConditions" - - foreach group [dict keys $groups_dict] { - if {[dict exists $groups_dict $group what]} {set what [dict get $groups_dict $group what]} else {set what ""} - if {[dict exists $groups_dict $group tableid_list]} {set tableid_list [dict get $groups_dict $group tableid_list]} else {set tableid_list ""} - write::writeGroupSubModelPartByUniqueId $cid $group $conditions_map $what $tableid_list - } - - incr ::write::current_mdpa_indent_level -1 - WriteString "${s}End SubModelPart" -} - - -# what can be: nodal, Elements, Conditions or Elements&Conditions -proc write::writeGroupSubModelPartByUniqueId { cid group ConditionsMap {what "Elements"} {tableid_list ""} } { - variable submodelparts - variable formats_dict - - set id_f [dict get $formats_dict ID] - - set mid "" - set what [split $what "&"] - set group [GetWriteGroupName $group] - if {![dict exists $submodelparts [list $cid ${group}]]} { - # Add the submodelpart to the catalog - set good_name [write::transformGroupName $group] - set mid "${cid}_${good_name}" - dict set submodelparts [list $cid ${group}] $mid - - # Prepare the print formats - incr ::write::current_mdpa_indent_level - set s1 [mdpaIndent] - incr ::write::current_mdpa_indent_level -1 - incr ::write::current_mdpa_indent_level 2 - set s2 [mdpaIndent] - set gdict [dict create] - set f "${s2}$id_f\n" - set f [subst $f] - dict set gdict $group $f - incr ::write::current_mdpa_indent_level -2 - - # Print header - set s [mdpaIndent] - WriteString "${s}Begin SubModelPart $mid // Group $group // Subtree $cid" - # Print tables - if {$tableid_list ne ""} { - set s1 [mdpaIndent] - WriteString "${s1}Begin SubModelPartTables" - foreach tableid $tableid_list { - WriteString "${s2}$tableid" - } - WriteString "${s1}End SubModelPartTables" - } - WriteString "${s1}Begin SubModelPartNodes" - GiD_WriteCalculationFile nodes -sorted $gdict - WriteString "${s1}End SubModelPartNodes" - WriteString "${s1}Begin SubModelPartElements" - if {"Elements" in $what} { - GiD_WriteCalculationFile elements -sorted $gdict - } - WriteString "${s1}End SubModelPartElements" - WriteString "${s1}Begin SubModelPartConditions" - if {"Conditions" in $what} { - set elems [GiD_WriteCalculationFile elements -sorted -return $gdict] - for {set i 0} {$i <[llength $elems]} {incr i} { - set eid [objarray get $ConditionsMap [lindex $elems $i]] - WriteString "${s2}[format $id_f $eid]" - } - } - WriteString "${s1}End SubModelPartConditions" - WriteString "${s}End SubModelPart" - } - return $mid -} - diff --git a/kratos.gid/scripts/Writing/WriteSubModelPart.tcl b/kratos.gid/scripts/Writing/WriteSubModelPart.tcl index dee0d040f..ae6cb2dad 100644 --- a/kratos.gid/scripts/Writing/WriteSubModelPart.tcl +++ b/kratos.gid/scripts/Writing/WriteSubModelPart.tcl @@ -146,7 +146,6 @@ proc write::getSubModelPartNames { args } { return $listOfProcessedGroups } - proc write::GetSubModelPartFromCondition { base_UN condition_id } { set root [customlib::GetBaseRoot] @@ -163,3 +162,89 @@ proc write::GetSubModelPartFromCondition { base_UN condition_id } { } return $submodelpart_list } + +proc write::writeConditionGroupedSubmodelPartsByUniqueId {cid groups_dict conditions_map} { + set s [mdpaIndent] + WriteString "${s}Begin SubModelPart $cid // Condition $cid" + + incr ::write::current_mdpa_indent_level + set s1 [mdpaIndent] + WriteString "${s1}Begin SubModelPartNodes" + WriteString "${s1}End SubModelPartNodes" + WriteString "${s1}Begin SubModelPartElements" + WriteString "${s1}End SubModelPartElements" + WriteString "${s1}Begin SubModelPartConditions" + WriteString "${s1}End SubModelPartConditions" + + foreach group [dict keys $groups_dict] { + if {[dict exists $groups_dict $group what]} {set what [dict get $groups_dict $group what]} else {set what ""} + if {[dict exists $groups_dict $group tableid_list]} {set tableid_list [dict get $groups_dict $group tableid_list]} else {set tableid_list ""} + write::writeGroupSubModelPartByUniqueId $cid $group $conditions_map $what $tableid_list + } + + incr ::write::current_mdpa_indent_level -1 + WriteString "${s}End SubModelPart" +} + +# what can be: nodal, Elements, Conditions or Elements&Conditions +proc write::writeGroupSubModelPartByUniqueId { cid group ConditionsMap {what "Elements"} {tableid_list ""} } { + variable submodelparts + variable formats_dict + + set id_f [dict get $formats_dict ID] + + set mid "" + set what [split $what "&"] + set group [GetWriteGroupName $group] + if {![dict exists $submodelparts [list $cid ${group}]]} { + # Add the submodelpart to the catalog + set good_name [write::transformGroupName $group] + set mid "${cid}_${good_name}" + dict set submodelparts [list $cid ${group}] $mid + + # Prepare the print formats + incr ::write::current_mdpa_indent_level + set s1 [mdpaIndent] + incr ::write::current_mdpa_indent_level -1 + incr ::write::current_mdpa_indent_level 2 + set s2 [mdpaIndent] + set gdict [dict create] + set f "${s2}$id_f\n" + set f [subst $f] + dict set gdict $group $f + incr ::write::current_mdpa_indent_level -2 + + # Print header + set s [mdpaIndent] + WriteString "${s}Begin SubModelPart $mid // Group $group // Subtree $cid" + # Print tables + if {$tableid_list ne ""} { + set s1 [mdpaIndent] + WriteString "${s1}Begin SubModelPartTables" + foreach tableid $tableid_list { + WriteString "${s2}$tableid" + } + WriteString "${s1}End SubModelPartTables" + } + WriteString "${s1}Begin SubModelPartNodes" + GiD_WriteCalculationFile nodes -sorted $gdict + WriteString "${s1}End SubModelPartNodes" + WriteString "${s1}Begin SubModelPartElements" + if {"Elements" in $what} { + GiD_WriteCalculationFile elements -sorted $gdict + } + WriteString "${s1}End SubModelPartElements" + WriteString "${s1}Begin SubModelPartConditions" + if {"Conditions" in $what} { + set elems [GiD_WriteCalculationFile elements -sorted -return $gdict] + for {set i 0} {$i <[llength $elems]} {incr i} { + set eid [objarray get $ConditionsMap [lindex $elems $i]] + WriteString "${s2}[format $id_f $eid]" + } + } + WriteString "${s1}End SubModelPartConditions" + WriteString "${s}End SubModelPart" + } + return $mid +} + From 0680af8dca2ac84ae0d2781a070fb49f3b7cd450 Mon Sep 17 00:00:00 2001 From: Javi G Date: Tue, 14 Jan 2020 12:46:26 +0100 Subject: [PATCH 13/23] typo --- kratos.gid/apps/Fluid/write/write.tcl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kratos.gid/apps/Fluid/write/write.tcl b/kratos.gid/apps/Fluid/write/write.tcl index 3220d6e6e..ca86e0261 100644 --- a/kratos.gid/apps/Fluid/write/write.tcl +++ b/kratos.gid/apps/Fluid/write/write.tcl @@ -55,7 +55,7 @@ proc Fluid::write::writeModelPartEvent { } { # Custom SubmodelParts variable last_condition_iterator - write::writeBasicSubmodelPartsByUniqueId $Fluid::write::FluidConditionMap $last_condition_iterator + write::writeBasicSubmodelPartsByUniqueId $Fluid::write::FluidConditionMap $last_condition_iterator # SubmodelParts writeMeshes @@ -63,6 +63,7 @@ proc Fluid::write::writeModelPartEvent { } { # Clean unset Fluid::write::FluidConditionMap } + proc Fluid::write::writeCustomFilesEvent { } { # Write the fluid materials json file Fluid::write::WriteMaterialsFile From 6676106348697d768a4ab16d630da404dcaf5f38 Mon Sep 17 00:00:00 2001 From: Javi G Date: Tue, 14 Jan 2020 12:46:50 +0100 Subject: [PATCH 14/23] Write internal boundary conditions in each file --- kratos.gid/apps/Chimera/write/write.tcl | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/kratos.gid/apps/Chimera/write/write.tcl b/kratos.gid/apps/Chimera/write/write.tcl index e4c5ed4f8..9e16a6116 100644 --- a/kratos.gid/apps/Chimera/write/write.tcl +++ b/kratos.gid/apps/Chimera/write/write.tcl @@ -26,6 +26,8 @@ proc Chimera::write::writeModelPartEvent { } { } proc Chimera::write::writePatches { } { + set iter $Fluid::write::last_condition_iterator + set iterators [dict create ] foreach patch [Chimera::write::GetPatchParts] { set group_id [get_domnode_attribute $patch n] set patch_name [write::GetWriteGroupName $group_id] @@ -36,6 +38,13 @@ proc Chimera::write::writePatches { } { write::writeGroupElementConnectivities $patch ChimeraPatch$Model::SpatialDimension # Internal patch boundary conditions set internal_boundaries_list [Chimera::write::GetInternalBoundaries $patch_name] + foreach internal_boundary_group $internal_boundaries_list { + incr iter + set iterators [write::writeGroupNodeCondition $iterators $internal_boundary_group ChimeraInternalBoundary${Model::SpatialDimension} $iter] + set iter [lindex [lindex [dict values $iterators] end] end] + } + + #::write::writeGroupSubModelPartByUniqueId $condid $group_id $Fluid::write::FluidConditionMap "Conditions" write::CloseFile } } @@ -55,7 +64,7 @@ proc Chimera::write::GetPatchParts { {what "xml"} } { } } -proc Chimera::write::GetInternalBoundaries { {patch_group_id ""} } { +proc Chimera::write::GetInternalBoundaries { {patch_group_id ""} {what "xml"} } { # Empty means all set all 0 if {$patch_group_id eq ""} { @@ -69,13 +78,20 @@ proc Chimera::write::GetInternalBoundaries { {patch_group_id ""} } { set root [customlib::GetBaseRoot] foreach cnd_group [$root selectNodes $xp] { set cnd_group_name [get_domnode_attribute $cnd_group n] + + if {$what eq "xml"} { + set gr $cnd_group + } else { + set gr [write::GetWriteGroupName $cnd_group_name] + } + if {$all} { - lappend internal_boundaries_list [write::GetWriteGroupName $cnd_group_name] + lappend internal_boundaries_list $gr } else { set first_node [objarray get [GiD_EntitiesGroups get $cnd_group_name node] 0] set affected_groups [GiD_EntitiesGroups entity_groups nodes $first_node] if {$patch_group_id in $affected_groups} { - lappend internal_boundaries_list [write::GetWriteGroupName $cnd_group_name] + lappend internal_boundaries_list $gr } # set part_names [Fluid::write::GetFluidPartGroups] # set patch_names [Chimera::write::GetPatchParts names] From 64c8936fe32843efd7bd1afb333de7a6134c5d90 Mon Sep 17 00:00:00 2001 From: Javi G Date: Tue, 14 Jan 2020 12:59:43 +0100 Subject: [PATCH 15/23] write conditions by unique id --- kratos.gid/apps/Chimera/write/write.tcl | 33 +++++++++++++++++++++---- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/kratos.gid/apps/Chimera/write/write.tcl b/kratos.gid/apps/Chimera/write/write.tcl index 9e16a6116..42e4f7274 100644 --- a/kratos.gid/apps/Chimera/write/write.tcl +++ b/kratos.gid/apps/Chimera/write/write.tcl @@ -3,6 +3,7 @@ namespace eval Chimera::write { variable patches variable inner_boundaries + variable ConditionMap } proc Chimera::write::Init { } { @@ -20,14 +21,21 @@ proc Chimera::write::writeModelPartEvent { } { # Write the background mesh as the fluid Fluid::write::writeModelPartEvent write::CloseFile + + + InitConditionsMap # Write the patches as independent mdpa Chimera::write::writePatches + + # Clean + unset Chimera::write::ConditionMap } proc Chimera::write::writePatches { } { set iter $Fluid::write::last_condition_iterator - set iterators [dict create ] + set condid ChimeraInternalBoundary${Model::SpatialDimension} + set ConditionMap [objarray new intarray [expr [GiD_Info Mesh MaxNumElements] +1] 0] foreach patch [Chimera::write::GetPatchParts] { set group_id [get_domnode_attribute $patch n] set patch_name [write::GetWriteGroupName $group_id] @@ -39,11 +47,11 @@ proc Chimera::write::writePatches { } { # Internal patch boundary conditions set internal_boundaries_list [Chimera::write::GetInternalBoundaries $patch_name] foreach internal_boundary_group $internal_boundaries_list { - incr iter - set iterators [write::writeGroupNodeCondition $iterators $internal_boundary_group ChimeraInternalBoundary${Model::SpatialDimension} $iter] - set iter [lindex [lindex [dict values $iterators] end] end] + set iter [write::writeGroupNodeConditionByUniqueId $internal_boundary_group $condid $iter $Chimera::write::ConditionMap] } - + #foreach internal_boundary_group $internal_boundaries_list { + # ::write::writeGroupSubModelPartByUniqueId $condid $group_id $iterators "Conditions" + #} #::write::writeGroupSubModelPartByUniqueId $condid $group_id $Fluid::write::FluidConditionMap "Conditions" write::CloseFile } @@ -112,6 +120,21 @@ proc Chimera::write::writeCustomFilesEvent { } { write::RenameFileInModel "KratosFluid.py" "MainKratos.py" } +proc Chimera::write::InitConditionsMap { {map "" } } { + + variable ConditionMap + if {$map eq ""} { + set ConditionMap [objarray new intarray [expr [GiD_Info Mesh MaxNumElements] +1] 0] + } { + set ConditionMap $map + } +} +proc Chimera::write::FreeConditionsMap { } { + + variable ConditionMap + unset ConditionMap +} + # Mandatory - Attribute handler proc Chimera::write::GetAttribute {att} { From f6f4c49099e137f0448fbb06f86d393aab066254 Mon Sep 17 00:00:00 2001 From: Javi G Date: Tue, 14 Jan 2020 16:05:40 +0100 Subject: [PATCH 16/23] Write submodelparts --- kratos.gid/apps/Chimera/write/write.tcl | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/kratos.gid/apps/Chimera/write/write.tcl b/kratos.gid/apps/Chimera/write/write.tcl index 42e4f7274..2e36f0e40 100644 --- a/kratos.gid/apps/Chimera/write/write.tcl +++ b/kratos.gid/apps/Chimera/write/write.tcl @@ -39,20 +39,22 @@ proc Chimera::write::writePatches { } { foreach patch [Chimera::write::GetPatchParts] { set group_id [get_domnode_attribute $patch n] set patch_name [write::GetWriteGroupName $group_id] + # New file for each patch write::OpenFile ${patch_name}.mdpa # Nodes write::writeNodalCoordinatesOnGroups [list $group_id] # Elements write::writeGroupElementConnectivities $patch ChimeraPatch$Model::SpatialDimension - # Internal patch boundary conditions + # Internal patch boundary Conditions set internal_boundaries_list [Chimera::write::GetInternalBoundaries $patch_name] foreach internal_boundary_group $internal_boundaries_list { set iter [write::writeGroupNodeConditionByUniqueId $internal_boundary_group $condid $iter $Chimera::write::ConditionMap] } - #foreach internal_boundary_group $internal_boundaries_list { - # ::write::writeGroupSubModelPartByUniqueId $condid $group_id $iterators "Conditions" - #} - #::write::writeGroupSubModelPartByUniqueId $condid $group_id $Fluid::write::FluidConditionMap "Conditions" + # Internal patch boundary Submodelparts + foreach internal_boundary_group $internal_boundaries_list { + ::write::writeGroupSubModelPartByUniqueId $condid [$internal_boundary_group @n] $Chimera::write::ConditionMap "Conditions" + } + # End file write::CloseFile } } From 3fa0bfcd3f657d82ec54129a3e9abd9f396fda44 Mon Sep 17 00:00:00 2001 From: Javi G Date: Tue, 14 Jan 2020 16:08:55 +0100 Subject: [PATCH 17/23] Patch submodelpart --- kratos.gid/apps/Chimera/write/write.tcl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kratos.gid/apps/Chimera/write/write.tcl b/kratos.gid/apps/Chimera/write/write.tcl index 2e36f0e40..157ae3fa7 100644 --- a/kratos.gid/apps/Chimera/write/write.tcl +++ b/kratos.gid/apps/Chimera/write/write.tcl @@ -50,6 +50,8 @@ proc Chimera::write::writePatches { } { foreach internal_boundary_group $internal_boundaries_list { set iter [write::writeGroupNodeConditionByUniqueId $internal_boundary_group $condid $iter $Chimera::write::ConditionMap] } + # Patch Submodelpart + ::write::writeGroupSubModelPartByUniqueId "Patch" $group_id "" "Elements" # Internal patch boundary Submodelparts foreach internal_boundary_group $internal_boundaries_list { ::write::writeGroupSubModelPartByUniqueId $condid [$internal_boundary_group @n] $Chimera::write::ConditionMap "Conditions" From 2c3a28cc685158fa79dca346b092b0ccd962a315 Mon Sep 17 00:00:00 2001 From: Javi G Date: Tue, 14 Jan 2020 17:00:08 +0100 Subject: [PATCH 18/23] Also project parameters --- kratos.gid/apps/Chimera/write/write.tcl | 4 +- .../Chimera/write/writeProjectParameters.tcl | 48 ++++++++++--------- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/kratos.gid/apps/Chimera/write/write.tcl b/kratos.gid/apps/Chimera/write/write.tcl index 157ae3fa7..b7dbeff62 100644 --- a/kratos.gid/apps/Chimera/write/write.tcl +++ b/kratos.gid/apps/Chimera/write/write.tcl @@ -1,8 +1,6 @@ namespace eval Chimera::write { variable writeAttributes - variable patches - variable inner_boundaries variable ConditionMap } @@ -40,7 +38,7 @@ proc Chimera::write::writePatches { } { set group_id [get_domnode_attribute $patch n] set patch_name [write::GetWriteGroupName $group_id] # New file for each patch - write::OpenFile ${patch_name}.mdpa + write::OpenFile [write::transformGroupName ${patch_name}].mdpa # Nodes write::writeNodalCoordinatesOnGroups [list $group_id] # Elements diff --git a/kratos.gid/apps/Chimera/write/writeProjectParameters.tcl b/kratos.gid/apps/Chimera/write/writeProjectParameters.tcl index 4ed80e7f2..b556c33d8 100644 --- a/kratos.gid/apps/Chimera/write/writeProjectParameters.tcl +++ b/kratos.gid/apps/Chimera/write/writeProjectParameters.tcl @@ -5,35 +5,39 @@ proc ::Chimera::write::getParametersDict { } { # Check https://github.com/KratosMultiphysics/Kratos/blob/ChimeraApplication-development_2.0/applications/ChimeraApplication/tests/flow_over_cross_monolithic/flow_over_cross_monolithic.json # in branch ChimeraApplication-development_2.0 + set bound_condid ChimeraInternalBoundary${Model::SpatialDimension} set chimera_settings_dict [dict create ] # General parameters dict set chimera_settings_dict chimera_echo_level 1 dict set chimera_settings_dict reformulate_chimera_every_step true - # Internal boundaries - set internal_parts_for_chimera_list [list ] - dict set chimera_settings_dict internal_parts_for_chimera $internal_parts_for_chimera_list + # Chimera parts + #set chimera_parts_dict [dict create ] + set chimera_parts_list [list ] + foreach patch_xml [Chimera::write::GetPatchParts] { + set patch_name [write::GetWriteGroupName [$patch_xml @n]] + set patch_name_write [write::transformGroupName $patch_name] + set overlap_distance [write::getValueByXPath "[$patch_xml toXPath]/value\[@n = 'overlap_distance'\]"] + set patch_dict [dict create ] + dict set patch_dict model_part_name FluidModelPart.${patch_name_write} + dict set patch_dict overlap_distance $overlap_distance + dict set patch_dict model_import_settings input_type mdpa + dict set patch_dict model_import_settings input_filename ${patch_name_write} + + # Internal boundaries + set internal_parts_for_chimera_list [list ] + foreach internal_boundary [Chimera::write::GetInternalBoundaries $patch_name name] { + set internal_boundary_write_name "${bound_condid}_[write::transformGroupName ${internal_boundary}]" + lappend internal_parts_for_chimera_list FluidModelPart.$internal_boundary_write_name + } + dict set patch_dict internal_parts_for_chimera $internal_parts_for_chimera_list - # "chimera_settings":{ - # "chimera_echo_level" : 1, - # "reformulate_chimera_every_step":true, - # "chimera_parts": [ - # [ - # { - # "model_part_name": "FluidModelPart.GENERIC_background_surface", - # "overlap_distance": 0.01 - # } - # ], - # [ - # { - # "model_part_name": "FluidModelPart.GENERIC_patch_surface", - # "overlap_distance": 0.7 - # } - # ] - # ], - # "internal_parts_for_chimera":["FluidModelPart.NoSlip2D_cross"] - # } + set patch_list [list] + lappend patch_list $patch_dict + lappend chimera_parts_list $patch_list + } + dict set chimera_settings_dict chimera_parts $chimera_parts_list dict set param_dict solver_settings chimera_settings $chimera_settings_dict return $param_dict From 5de94af452f0dcdc919d8e431afe553241edf4f1 Mon Sep 17 00:00:00 2001 From: Javi G Date: Wed, 15 Jan 2020 18:15:49 +0100 Subject: [PATCH 19/23] Fluid materials write --- kratos.gid/apps/Chimera/write/write.tcl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kratos.gid/apps/Chimera/write/write.tcl b/kratos.gid/apps/Chimera/write/write.tcl index b7dbeff62..4acbe1fe3 100644 --- a/kratos.gid/apps/Chimera/write/write.tcl +++ b/kratos.gid/apps/Chimera/write/write.tcl @@ -118,6 +118,9 @@ proc Chimera::write::GetInternalBoundaries { {patch_group_id ""} {what "xml"} } } proc Chimera::write::writeCustomFilesEvent { } { + # Write the fluid materials json file + Fluid::write::WriteMaterialsFile + write::CopyFileIntoModel "python/KratosFluid.py" write::RenameFileInModel "KratosFluid.py" "MainKratos.py" } From 1e687ca874b544269da19d6b7e59968c65e4cc41 Mon Sep 17 00:00:00 2001 From: Javi G Date: Wed, 15 Jan 2020 18:34:53 +0100 Subject: [PATCH 20/23] update python --- .../python/{KratosFluid.py => KratosChimera.py} | 12 +++++------- kratos.gid/apps/Chimera/write/write.tcl | 6 +++--- 2 files changed, 8 insertions(+), 10 deletions(-) rename kratos.gid/apps/Chimera/python/{KratosFluid.py => KratosChimera.py} (67%) diff --git a/kratos.gid/apps/Chimera/python/KratosFluid.py b/kratos.gid/apps/Chimera/python/KratosChimera.py similarity index 67% rename from kratos.gid/apps/Chimera/python/KratosFluid.py rename to kratos.gid/apps/Chimera/python/KratosChimera.py index 0552382cf..19d84a8c7 100644 --- a/kratos.gid/apps/Chimera/python/KratosFluid.py +++ b/kratos.gid/apps/Chimera/python/KratosChimera.py @@ -1,22 +1,20 @@ from __future__ import print_function, absolute_import, division #makes KratosMultiphysics backward compatible with python 2.6 and 2.7 import KratosMultiphysics -import KratosMultiphysics.FluidDynamicsApplication - -from fluid_dynamics_analysis import FluidDynamicsAnalysis +from KratosMultiphysics.ChimeraApplication.fluid_chimera_analysis import FluidChimeraAnalysis import sys import time -class FluidDynamicsAnalysisWithFlush(FluidDynamicsAnalysis): +class FluidChimeraAnalysisWithFlush(FluidChimeraAnalysis): def __init__(self,model,project_parameters,flush_frequency=10.0): - super(FluidDynamicsAnalysisWithFlush,self).__init__(model,project_parameters) + super(FluidChimeraAnalysisWithFlush,self).__init__(model,project_parameters) self.flush_frequency = flush_frequency self.last_flush = time.time() def FinalizeSolutionStep(self): - super(FluidDynamicsAnalysisWithFlush,self).FinalizeSolutionStep() + super(FluidChimeraAnalysisWithFlush,self).FinalizeSolutionStep() if self.parallel_type == "OpenMP": now = time.time() @@ -30,5 +28,5 @@ def FinalizeSolutionStep(self): parameters = KratosMultiphysics.Parameters(parameter_file.read()) model = KratosMultiphysics.Model() - simulation = FluidDynamicsAnalysisWithFlush(model,parameters) + simulation = FluidChimeraAnalysisWithFlush(model,parameters) simulation.Run() diff --git a/kratos.gid/apps/Chimera/write/write.tcl b/kratos.gid/apps/Chimera/write/write.tcl index 4acbe1fe3..5f55d432d 100644 --- a/kratos.gid/apps/Chimera/write/write.tcl +++ b/kratos.gid/apps/Chimera/write/write.tcl @@ -120,9 +120,9 @@ proc Chimera::write::GetInternalBoundaries { {patch_group_id ""} {what "xml"} } proc Chimera::write::writeCustomFilesEvent { } { # Write the fluid materials json file Fluid::write::WriteMaterialsFile - - write::CopyFileIntoModel "python/KratosFluid.py" - write::RenameFileInModel "KratosFluid.py" "MainKratos.py" + + write::CopyFileIntoModel "python/KratosChimera.py" + write::RenameFileInModel "KratosChimera.py" "MainKratos.py" } proc Chimera::write::InitConditionsMap { {map "" } } { From a4933596221f77d70cdd4b4dc2dbb33fd8cf479e Mon Sep 17 00:00:00 2001 From: Javi Garate Date: Thu, 10 Feb 2022 17:24:30 +0100 Subject: [PATCH 21/23] bring chimera app to this century --- kratos.gid/apps/Chimera/app.json | 51 ++++++++++++ .../apps/Chimera/examples/ChimeraCross.tcl | 62 ++++----------- kratos.gid/apps/Chimera/examples/examples.tcl | 25 +++--- kratos.gid/apps/Chimera/examples/examples.xml | 11 +++ kratos.gid/apps/Chimera/start.tcl | 79 +++---------------- .../xml/{GetFromXML.tcl => XmlController.tcl} | 10 +-- kratos.gid/apps/Examples/xml/examples.xml | 1 + kratos.gid/apps/Fluid/xml/XmlController.tcl | 16 ++-- 8 files changed, 117 insertions(+), 138 deletions(-) create mode 100644 kratos.gid/apps/Chimera/app.json create mode 100644 kratos.gid/apps/Chimera/examples/examples.xml rename kratos.gid/apps/Chimera/xml/{GetFromXML.tcl => XmlController.tcl} (95%) diff --git a/kratos.gid/apps/Chimera/app.json b/kratos.gid/apps/Chimera/app.json new file mode 100644 index 000000000..6ea814efc --- /dev/null +++ b/kratos.gid/apps/Chimera/app.json @@ -0,0 +1,51 @@ +{ + "id": "Chimera", + "name": "Chimera", + "prefix": "Chim", + "themed": false, + "kratos_name": "FluidDynamicsApplication", + "python_packages": [ + "" + ], + "dimensions": [ + "2D" + ], + "script_files": [ + "start.tcl", + "examples/examples.tcl", + "examples/ChimeraCross.tcl", + "xml/XmlController.tcl", + "write/write.tcl", + "write/writeProjectParameters.tcl" + ], + "start_script": "::Chimera::Init", + "requeriments": { + "apps": ["Fluid"], + "minimum_gid_version": "15.1.3d" + }, + "permissions": { + "open_tree": true, + "show_toolbar": true, + "intervals": true, + "wizard": false + }, + "unique_names": { + "parts": "FLParts", + "nodal_conditions": "FLNodalConditions", + "conditions": "FLBC", + "materials": "FLMaterials", + "results": "FLResults", + "drag": "FLDrags", + "time_parameters": "FLTimeParameters" + }, + "write": { + "coordinates": "all", + "materials_file": "FluidMaterials.json", + "properties_location": "json", + "model_part_name": "FluidModelPart", + "output_model_part_name": "fluid_computational_model_part" + }, + "main_launch_file": "../../exec/MainKratos.py", + "examples": "examples/examples.xml", + "description": "" +} \ No newline at end of file diff --git a/kratos.gid/apps/Chimera/examples/ChimeraCross.tcl b/kratos.gid/apps/Chimera/examples/ChimeraCross.tcl index 2d3df93d4..54d9ee476 100644 --- a/kratos.gid/apps/Chimera/examples/ChimeraCross.tcl +++ b/kratos.gid/apps/Chimera/examples/ChimeraCross.tcl @@ -1,5 +1,10 @@ -proc ::Chimera::examples::ChimeraCross {args} { +namespace eval ::Chimera::examples::ChimeraCross { + namespace path ::Chimera::examples + Kratos::AddNamespace [namespace current] +} + +proc ::Chimera::examples::ChimeraCross::Init {args} { if {![Kratos::IsModelEmpty]} { set txt "We are going to draw the example geometry.\nDo you want to lose your previous work?" set retval [tk_messageBox -default ok -icon question -message $txt -type okcancel] @@ -7,10 +12,10 @@ proc ::Chimera::examples::ChimeraCross {args} { } Kratos::ResetModel - DrawChimeraCrossGeometry$::Model::SpatialDimension - AssignGroupsChimeraCross$::Model::SpatialDimension - AssignChimeraCrossMeshSizes$::Model::SpatialDimension - TreeAssignationChimeraCross$::Model::SpatialDimension + DrawGeometry + AssignGroups + AssignMeshSizes + TreeAssignation GiD_Process 'Redraw GidUtils::UpdateWindow GROUPS @@ -18,18 +23,7 @@ proc ::Chimera::examples::ChimeraCross {args} { GiD_Process 'Zoom Frame } - -# Draw Geometry -proc ::Chimera::examples::DrawChimeraCrossGeometry3D {args} { - DrawChimeraCrossGeometry2D - GiD_Process Mescape Utilities Copy Surfaces Duplicate DoExtrude Volumes MaintainLayers Translation FNoJoin 0.0,0.0,0.0 FNoJoin 0.0,0.0,1.0 1 escape escape escape - GiD_Layers edit opaque Background 0 - GiD_Layers edit opaque Patch 0 - - GiD_Process escape escape 'Render Flat escape 'Rotate Angle 270 90 escape escape escape escape 'Rotate obj x -150 y -30 escape escape -} - -proc ::Chimera::examples::DrawChimeraCrossGeometry2D {args} { +proc ::Chimera::examples::ChimeraCross::DrawGeometry {args} { # Background mesh geometry creation GiD_Layers create Background GiD_Layers edit to_use Background @@ -95,7 +89,7 @@ proc ::Chimera::examples::DrawChimeraCrossGeometry2D {args} { } # Group assign -proc ::Chimera::examples::AssignGroupsChimeraCross2D {args} { +proc ::Chimera::examples::ChimeraCross::AssignGroups {args} { # Create the groups GiD_Groups create Fluid GiD_Groups edit color Fluid "#26d1a8ff" @@ -126,12 +120,8 @@ proc ::Chimera::examples::AssignGroupsChimeraCross2D {args} { GiD_EntitiesGroups assign No_Slip_Cross lines {9 10 11 12 13 14 15 16 17 18 19 20} } -proc ::Chimera::examples::AssignGroupsChimeraCross3D {args} { - # TO BE IMPLEMENTED -} - # Mesh sizes -proc ::Chimera::examples::AssignChimeraCrossMeshSizes2D {args} { +proc ::Chimera::examples::ChimeraCross::AssignMeshSizes {args} { set cross_mesh_size 0.05 set surface_mesh_size 0.2 GiD_Process Mescape Meshing AssignSizes Lines $cross_mesh_size {*}[GiD_EntitiesGroups get No_Slip_Cross lines] escape escape @@ -140,12 +130,8 @@ proc ::Chimera::examples::AssignChimeraCrossMeshSizes2D {args} { Kratos::Event_BeforeMeshGeneration $surface_mesh_size } -proc ::Chimera::examples::AssignChimeraCrossMeshSizes3D {args} { - # TO BE IMPLEMENTED -} - # Tree assign -proc ::Chimera::examples::TreeAssignationChimeraCross2D {args} { +proc ::Chimera::examples::ChimeraCross::TreeAssignation {args} { set nd $::Model::SpatialDimension set root [customlib::GetBaseRoot] @@ -228,23 +214,3 @@ proc ::Chimera::examples::TreeAssignationChimeraCross2D {args} { spdAux::RequestRefresh } - -proc ::Chimera::examples::TreeAssignationChimeraCross3D {args} { - TreeAssignationChimeraCross2D - AddCuts -} - -proc ::Chimera::examples::ErasePreviousIntervals { } { - set root [customlib::GetBaseRoot] - set interval_base [spdAux::getRoute "Intervals"] - foreach int [$root selectNodes "$interval_base/blockdata\[@n='Interval'\]"] { - if {[$int @name] ni [list Initial Total Custom1]} {$int delete} - } -} - -proc ::Chimera::examples::AddCuts { } { - # Cuts - set results "[spdAux::getRoute FLResults]/container\[@n='GiDOutput'\]" - set cp [[customlib::GetBaseRoot] selectNodes "$results/container\[@n = 'CutPlanes'\]/blockdata\[@name = 'CutPlane'\]"] - [$cp selectNodes "./value\[@n = 'point'\]"] setAttribute v "0.0,0.5,0.0" -} \ No newline at end of file diff --git a/kratos.gid/apps/Chimera/examples/examples.tcl b/kratos.gid/apps/Chimera/examples/examples.tcl index 00abfc6b3..b44745c6c 100644 --- a/kratos.gid/apps/Chimera/examples/examples.tcl +++ b/kratos.gid/apps/Chimera/examples/examples.tcl @@ -1,15 +1,20 @@ -namespace eval Chimera::examples { +namespace eval ::Chimera::examples { + namespace path ::Chimera + Kratos::AddNamespace [namespace current] } -proc Chimera::examples::Init { } { - uplevel #0 [list source [file join $::Chimera::dir examples ChimeraCross.tcl]] +proc ::Chimera::examples::ErasePreviousIntervals { } { + set root [customlib::GetBaseRoot] + set interval_base [spdAux::getRoute "Intervals"] + foreach int [$root selectNodes "$interval_base/blockdata\[@n='Interval'\]"] { + if {[$int @name] ni [list Initial Total Custom1]} {$int delete} + } } -proc Chimera::examples::UpdateMenus { } { - GiDMenu::InsertOption "Kratos" [list "---"] 7 PRE "" "" "" insertafter = - GiDMenu::InsertOption "Kratos" [list "Cross section flow" ] 7 PRE [list ::Chimera::examples::ChimeraCross] "" "" insertafter = - GiDMenu::UpdateMenus -} - -Chimera::examples::Init \ No newline at end of file +proc ::Chimera::examples::AddCuts { } { + # Cuts + set results "[spdAux::getRoute FLResults]/container\[@n='GiDOutput'\]" + set cp [[customlib::GetBaseRoot] selectNodes "$results/container\[@n = 'CutPlanes'\]/blockdata\[@name = 'CutPlane'\]"] + [$cp selectNodes "./value\[@n = 'point'\]"] setAttribute v "0.0,0.5,0.0" +} \ No newline at end of file diff --git a/kratos.gid/apps/Chimera/examples/examples.xml b/kratos.gid/apps/Chimera/examples/examples.xml new file mode 100644 index 000000000..c6ecf19f6 --- /dev/null +++ b/kratos.gid/apps/Chimera/examples/examples.xml @@ -0,0 +1,11 @@ + + + + This example applies an inlet condition to the air surrounding a 2D building. + The default mesh is made of 4.000 trianglular elements, and the calculation generates results for 800 timesteps. + - Size of model: 0.4 MB + - Time: Avg calulation time: 2 minutes + - Size with results: 250 MB + + + \ No newline at end of file diff --git a/kratos.gid/apps/Chimera/start.tcl b/kratos.gid/apps/Chimera/start.tcl index 817adccdf..4c3fc4b0f 100644 --- a/kratos.gid/apps/Chimera/start.tcl +++ b/kratos.gid/apps/Chimera/start.tcl @@ -1,79 +1,24 @@ namespace eval ::Chimera { + Kratos::AddNamespace [namespace current] # Variable declaration variable dir - variable prefix - variable attributes - variable kratos_name + variable _app + + proc GetAttribute {name} {variable _app; return [$_app getProperty $name]} + proc GetUniqueName {name} {variable _app; return [$_app getUniqueName $name]} + proc GetWriteProperty {name} {variable _app; return [$_app getWriteProperty $name]} } +proc ::Chimera::Init { app } { -proc ::Chimera::Init { } { # Variable initialization + variable _app variable dir - variable prefix - variable attributes - variable kratos_name - apps::LoadAppById "Fluid" - set kratos_name $::Fluid::kratos_name + set _app $app set dir [apps::getMyDir "Chimera"] - set ::Model::ValidSpatialDimensions [list 2D] - spdAux::SetSpatialDimmension "2D" - spdAux::processIncludes - - set attributes [dict create] - - set prefix Chim - - # Allow to open the tree - set ::spdAux::TreeVisibility 1 - - dict set attributes UseIntervals 1 - - LoadMyFiles -} - -proc ::Chimera::LoadMyFiles { } { - variable dir - - uplevel #0 [list source [file join $dir examples examples.tcl]] - uplevel #0 [list source [file join $dir xml GetFromXML.tcl]] - uplevel #0 [list source [file join $dir write write.tcl]] - uplevel #0 [list source [file join $dir write writeProjectParameters.tcl]] -} - -proc ::Chimera::GetAttribute {name} { - variable attributes - set value "" - if {[dict exists $attributes $name]} {set value [dict get $attributes $name]} - return $value + # XML init event + ::Chimera::xml::Init + ::Chimera::write::Init } -proc ::Chimera::CustomToolbarItems { } { - variable dir - if {$::Model::SpatialDimension eq "2D"} { - Kratos::ToolbarAddItem "Example" "example.png" [list -np- ::Chimera::examples::ChimeraCross] [= "Example\nCross section flow"] - } -} - -# proc ::Chimera::BeforeMeshGeneration {elementsize} { -# variable oldMeshType - -# set project_path [GiD_Info project modelname] -# if {$project_path ne "UNNAMED"} { -# catch {file delete -force [file join [write::GetConfigurationAttribute dir] "[Kratos::GetModelName].post.res"]} -# # Set Octree -# set oldMeshType [GiD_Set MeshType] -# ::GiD_Set MeshType 2 -# } else { -# after 500 {WarnWin "You need to save the project before meshing"} -# return "-cancel-" -# } -# } - -# proc ::Chimera::AfterMeshGeneration {fail} { -# variable oldMeshType -# GiD_Set MeshType $oldMeshType -# } - -::Chimera::Init diff --git a/kratos.gid/apps/Chimera/xml/GetFromXML.tcl b/kratos.gid/apps/Chimera/xml/XmlController.tcl similarity index 95% rename from kratos.gid/apps/Chimera/xml/GetFromXML.tcl rename to kratos.gid/apps/Chimera/xml/XmlController.tcl index 777990e9c..887c1f4b3 100644 --- a/kratos.gid/apps/Chimera/xml/GetFromXML.tcl +++ b/kratos.gid/apps/Chimera/xml/XmlController.tcl @@ -1,4 +1,6 @@ namespace eval Chimera::xml { + namespace path ::Chimera + Kratos::AddNamespace [namespace current] # Namespace variables declaration variable dir } @@ -23,15 +25,15 @@ proc Chimera::xml::CustomTree { args } { # Protection of submodelparts [[customlib::GetBaseRoot] selectNodes "[spdAux::getRoute FLBC]/condition\[@n = 'ChimeraInternalBoundary2D'\]"] setAttribute print_smp 0 [[customlib::GetBaseRoot] selectNodes "[spdAux::getRoute FLBC]/condition\[@n = 'ChimeraInternalBoundary3D'\]"] setAttribute print_smp 0 - + # Change the app name [[customlib::GetBaseRoot] selectNodes "container\[@n = 'Fluid'\]"] setAttribute pn "Chimera" - + # Add ChimeraParts.spd set xpath "container\[@n = 'Fluid'\]/condition\[@n='ChimeraParts'\]" if {[[customlib::GetBaseRoot] selectNodes $xpath] eq ""} { set chimera_parts [gid_groups_conds::addF "container\[@n = 'Fluid'\]" include [list n ChimeraParts active 1 path {apps/Chimera/xml/ChimeraParts.spd}]] - + customlib::UpdateDocument set parts [[customlib::GetBaseRoot] selectNodes [spdAux::getRoute FLParts]] set new [$chimera_parts cloneNode] @@ -47,5 +49,3 @@ proc Chimera::xml::CustomTree { args } { proc Chimera::xml::UpdateParts {domNode args} { Fluid::xml::UpdateParts $domNode {*}$args } - -Chimera::xml::Init diff --git a/kratos.gid/apps/Examples/xml/examples.xml b/kratos.gid/apps/Examples/xml/examples.xml index 7ca5de691..f3a154d47 100644 --- a/kratos.gid/apps/Examples/xml/examples.xml +++ b/kratos.gid/apps/Examples/xml/examples.xml @@ -22,4 +22,5 @@ + diff --git a/kratos.gid/apps/Fluid/xml/XmlController.tcl b/kratos.gid/apps/Fluid/xml/XmlController.tcl index cb28e5bcf..67a05525c 100644 --- a/kratos.gid/apps/Fluid/xml/XmlController.tcl +++ b/kratos.gid/apps/Fluid/xml/XmlController.tcl @@ -1,7 +1,7 @@ namespace eval ::Fluid::xml { namespace path ::Fluid Kratos::AddNamespace [namespace current] - + # Namespace variables declaration variable dir } @@ -10,7 +10,7 @@ proc ::Fluid::xml::Init { } { # Namespace variables inicialization variable dir Model::InitVariables dir $::Fluid::dir - + Model::getSolutionStrategies Strategies.xml Model::getElements Elements.xml Model::getMaterials Materials.xml @@ -40,7 +40,7 @@ proc ::Fluid::xml::CustomTree { args } { if {[$root selectNodes "$xpath/condition\[@n='Drag'\]"] eq ""} { gid_groups_conds::addF $xpath include [list n Drag active 1 path {apps/Fluid/xml/Drag.spd}] } - + customlib::ProcessIncludes $::Kratos::kratos_private(Path) spdAux::parseRoutes @@ -48,7 +48,7 @@ proc ::Fluid::xml::CustomTree { args } { if {[$root selectNodes "$xpath/container\[@n='OnNodes'\]"] ne ""} { gid_groups_conds::addF "$xpath/container\[@n='OnNodes'\]" value [list n REACTION pn "Reaction" v No values "Yes,No"] } - + # TODO: remove when Non newtonian is implemented for 2d if {$::Model::SpatialDimension eq "2D"} { Model::ForgetConstitutiveLaw HerschelBulkley } @@ -56,7 +56,7 @@ proc ::Fluid::xml::CustomTree { args } { spdAux::SetValueOnTreeItem state "\[HideIfElement {DVMS2D DVMS3D}\]" FLStratParams dynamic_tau } -# Usage +# Usage # Fluid::xml::CreateNewInlet Inlet {new false name Total} true "6*y*(1-y)" proc ::Fluid::xml::CreateNewInlet { base_group_name {interval_data {new true name inlet1 ini 0 end "End"}} {uses_formula false} {value 10.0} {direction automatic_inwards_normal} {fluid_conditions_UN FLBC} {inlet_condition_name_base AutomaticInlet} } { # Fluid Inlet @@ -66,8 +66,8 @@ proc ::Fluid::xml::CreateNewInlet { base_group_name {interval_data {new true nam set fluidConditions [spdAux::getRoute $fluid_conditions_UN] set fluidInlet "$fluidConditions/condition\[@n='$inlet_condition_name_base$nd'\]" - - set interval_name [dict get $interval_data name] + + set interval_name [dict get $interval_data name] if {[write::isBooleanTrue [dict get $interval_data new]]} { spdAux::CreateInterval $interval_name [dict get $interval_data ini] [dict get $interval_data end] @@ -94,7 +94,7 @@ proc ::Fluid::xml::CreateNewInlet { base_group_name {interval_data {new true nam } proc ::Fluid::xml::ClearInlets { delete_groups {fluid_conditions_UN FLBC} {inlet_condition_name_base AutomaticInlet} } { - + set nd $::Model::SpatialDimension set fluidConditions [spdAux::getRoute $fluid_conditions_UN] set fluidInlets "$fluidConditions/condition\[@n='$inlet_condition_name_base$nd'\]/group" From 4a157d56bb4723af2714e277ce6705a64adda01d Mon Sep 17 00:00:00 2001 From: Javi Garate Date: Thu, 10 Feb 2022 19:08:17 +0100 Subject: [PATCH 22/23] required changes to execute --- kratos.gid/apps/Chimera/app.json | 2 +- kratos.gid/apps/Chimera/write/write.tcl | 31 +++++++++---------- .../Chimera/write/writeProjectParameters.tcl | 28 ++++++++++++++--- kratos.gid/apps/Chimera/xml/Conditions.xml | 4 +-- kratos.gid/apps/Fluid/start.tcl | 4 +-- 5 files changed, 44 insertions(+), 25 deletions(-) diff --git a/kratos.gid/apps/Chimera/app.json b/kratos.gid/apps/Chimera/app.json index 6ea814efc..1bff2d35a 100644 --- a/kratos.gid/apps/Chimera/app.json +++ b/kratos.gid/apps/Chimera/app.json @@ -45,7 +45,7 @@ "model_part_name": "FluidModelPart", "output_model_part_name": "fluid_computational_model_part" }, - "main_launch_file": "../../exec/MainKratos.py", + "main_launch_file": "python/KratosChimera.py", "examples": "examples/examples.xml", "description": "" } \ No newline at end of file diff --git a/kratos.gid/apps/Chimera/write/write.tcl b/kratos.gid/apps/Chimera/write/write.tcl index 5f55d432d..537bc3225 100644 --- a/kratos.gid/apps/Chimera/write/write.tcl +++ b/kratos.gid/apps/Chimera/write/write.tcl @@ -1,6 +1,6 @@ namespace eval Chimera::write { variable writeAttributes - + variable ConditionMap } @@ -8,10 +8,11 @@ proc Chimera::write::Init { } { # Namespace variables inicialization variable writeAttributes set writeAttributes [Fluid::write::GetAttributes] - + SetAttribute chim_parts_un ChimParts SetAttribute writeCoordinatesByGroups 1 SetAttribute validApps [list "Fluid" "Chimera"] + SetAttribute main_launch_file [::Chimera::GetAttribute main_launch_file] } # Events @@ -20,12 +21,12 @@ proc Chimera::write::writeModelPartEvent { } { Fluid::write::writeModelPartEvent write::CloseFile - + InitConditionsMap - + # Write the patches as independent mdpa Chimera::write::writePatches - + # Clean unset Chimera::write::ConditionMap } @@ -39,11 +40,13 @@ proc Chimera::write::writePatches { } { set patch_name [write::GetWriteGroupName $group_id] # New file for each patch write::OpenFile [write::transformGroupName ${patch_name}].mdpa + # Properties 0 + ::Fluid::write::writeProperties # Nodes write::writeNodalCoordinatesOnGroups [list $group_id] - # Elements + # Elements write::writeGroupElementConnectivities $patch ChimeraPatch$Model::SpatialDimension - # Internal patch boundary Conditions + # Internal patch boundary Conditions set internal_boundaries_list [Chimera::write::GetInternalBoundaries $patch_name] foreach internal_boundary_group $internal_boundaries_list { set iter [write::writeGroupNodeConditionByUniqueId $internal_boundary_group $condid $iter $Chimera::write::ConditionMap] @@ -82,13 +85,13 @@ proc Chimera::write::GetInternalBoundaries { {patch_group_id ""} {what "xml"} } } set name ChimeraInternalBoundary${Model::SpatialDimension} set un [GetAttribute conditions_un] - set xp "[spdAux::getRoute $un]/condition\[@n = '$name'\]/group" - + set xp "[spdAux::getRoute $un]/condition\[@n = '$name'\]/group" + set internal_boundaries_list [list ] set root [customlib::GetBaseRoot] foreach cnd_group [$root selectNodes $xp] { set cnd_group_name [get_domnode_attribute $cnd_group n] - + if {$what eq "xml"} { set gr $cnd_group } else { @@ -108,7 +111,7 @@ proc Chimera::write::GetInternalBoundaries { {patch_group_id ""} {what "xml"} } # foreach group $affected_groups { # if {$group ni $part_names} { # if {$group ni $patch_names} { - # if + # if # } # } # } @@ -120,9 +123,7 @@ proc Chimera::write::GetInternalBoundaries { {patch_group_id ""} {what "xml"} } proc Chimera::write::writeCustomFilesEvent { } { # Write the fluid materials json file Fluid::write::WriteMaterialsFile - - write::CopyFileIntoModel "python/KratosChimera.py" - write::RenameFileInModel "KratosChimera.py" "MainKratos.py" + write::SetConfigurationAttribute main_launch_file [GetAttribute main_launch_file] } proc Chimera::write::InitConditionsMap { {map "" } } { @@ -156,5 +157,3 @@ proc Chimera::write::SetAttribute {att val} { variable writeAttributes dict set writeAttributes $att $val } - -Chimera::write::Init diff --git a/kratos.gid/apps/Chimera/write/writeProjectParameters.tcl b/kratos.gid/apps/Chimera/write/writeProjectParameters.tcl index b556c33d8..8484c4f6f 100644 --- a/kratos.gid/apps/Chimera/write/writeProjectParameters.tcl +++ b/kratos.gid/apps/Chimera/write/writeProjectParameters.tcl @@ -2,7 +2,7 @@ proc ::Chimera::write::getParametersDict { } { set param_dict [Fluid::write::getParametersDict] - # Check https://github.com/KratosMultiphysics/Kratos/blob/ChimeraApplication-development_2.0/applications/ChimeraApplication/tests/flow_over_cross_monolithic/flow_over_cross_monolithic.json + # Check https://github.com/KratosMultiphysics/Kratos/blob/ChimeraApplication-development_2.0/applications/ChimeraApplication/tests/flow_over_cross_monolithic/flow_over_cross_monolithic.json # in branch ChimeraApplication-development_2.0 set bound_condid ChimeraInternalBoundary${Model::SpatialDimension} @@ -14,17 +14,17 @@ proc ::Chimera::write::getParametersDict { } { # Chimera parts #set chimera_parts_dict [dict create ] - set chimera_parts_list [list ] + set chimera_parts_list [GetBackgroundPatch] foreach patch_xml [Chimera::write::GetPatchParts] { set patch_name [write::GetWriteGroupName [$patch_xml @n]] set patch_name_write [write::transformGroupName $patch_name] set overlap_distance [write::getValueByXPath "[$patch_xml toXPath]/value\[@n = 'overlap_distance'\]"] set patch_dict [dict create ] - dict set patch_dict model_part_name FluidModelPart.${patch_name_write} + dict set patch_dict model_part_name FluidModelPart.Patch_${patch_name_write} dict set patch_dict overlap_distance $overlap_distance dict set patch_dict model_import_settings input_type mdpa dict set patch_dict model_import_settings input_filename ${patch_name_write} - + # Internal boundaries set internal_parts_for_chimera_list [list ] foreach internal_boundary [Chimera::write::GetInternalBoundaries $patch_name name] { @@ -40,9 +40,29 @@ proc ::Chimera::write::getParametersDict { } { dict set chimera_settings_dict chimera_parts $chimera_parts_list dict set param_dict solver_settings chimera_settings $chimera_settings_dict + + dict set param_dict solver_settings model_import_settings input_type chimera + dict set param_dict solver_settings model_import_settings input_filename "" + return $param_dict } +proc Chimera::write::GetBackgroundPatch { } { + set patch_dict [dict create ] + dict set patch_dict model_part_name FluidModelPart + # dict set patch_dict overlap_distance $overlap_distance + dict set patch_dict model_import_settings input_type mdpa + dict set patch_dict model_import_settings input_filename [file tail [GiD_Info Project ModelName]] + + # Internal boundaries + dict set patch_dict internal_parts_for_chimera [list FluidModelPart] + + set patch_list [list ] + lappend patch_list $patch_dict + lappend chimera_parts_list $patch_list + return $chimera_parts_list +} + proc Chimera::write::writeParametersEvent { } { set projectParametersDict [getParametersDict] write::SetParallelismConfiguration diff --git a/kratos.gid/apps/Chimera/xml/Conditions.xml b/kratos.gid/apps/Chimera/xml/Conditions.xml index 4ccf8efec..e02fa6e91 100644 --- a/kratos.gid/apps/Chimera/xml/Conditions.xml +++ b/kratos.gid/apps/Chimera/xml/Conditions.xml @@ -5,7 +5,7 @@ ImplementedInApplication="FluidApplication" MinimumKratosVersion="9000" ProductionReady="ProductionReady" WorkingSpaceDimension="3D" LocalSpaceDimension="2" SkinConditions="False" VariableName="Interface" App="Fluid" ElementType="Surface" ProcessName="PythonProcess" help="Fixes the pressure to a constant scalar value." > - + @@ -16,7 +16,7 @@ ImplementedInApplication="FluidApplication" MinimumKratosVersion="9000" ProductionReady="ProductionReady" WorkingSpaceDimension="2D" LocalSpaceDimension="1" SkinConditions="False" VariableName="Interface" App="Fluid" ElementType="Line" ProcessName="PythonProcess" help="Fixes the pressure to a constant scalar value." > - + diff --git a/kratos.gid/apps/Fluid/start.tcl b/kratos.gid/apps/Fluid/start.tcl index 4816d4682..7285efaca 100644 --- a/kratos.gid/apps/Fluid/start.tcl +++ b/kratos.gid/apps/Fluid/start.tcl @@ -1,6 +1,6 @@ namespace eval ::Fluid { Kratos::AddNamespace [namespace current] - + # Variable declaration variable _app variable dir @@ -17,7 +17,7 @@ proc ::Fluid::Init { app } { set _app $app set dir [apps::getMyDir "Fluid"] - + # XML init event ::Fluid::xml::Init ::Fluid::write::Init From c096abdf0df133753cafa441cedf6a0734e507fa Mon Sep 17 00:00:00 2001 From: Javier Garate Date: Sun, 20 Jul 2025 13:07:25 +0200 Subject: [PATCH 23/23] missing process and typo --- kratos.gid/apps/Chimera/app.json | 2 +- kratos.gid/apps/Chimera/xml/Conditions.xml | 4 ++-- kratos.gid/apps/Chimera/xml/Process.xml | 10 ++++++++++ kratos.gid/apps/Chimera/xml/XmlController.tcl | 1 + 4 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 kratos.gid/apps/Chimera/xml/Process.xml diff --git a/kratos.gid/apps/Chimera/app.json b/kratos.gid/apps/Chimera/app.json index 1bff2d35a..65b4121ce 100644 --- a/kratos.gid/apps/Chimera/app.json +++ b/kratos.gid/apps/Chimera/app.json @@ -19,7 +19,7 @@ "write/writeProjectParameters.tcl" ], "start_script": "::Chimera::Init", - "requeriments": { + "requirements": { "apps": ["Fluid"], "minimum_gid_version": "15.1.3d" }, diff --git a/kratos.gid/apps/Chimera/xml/Conditions.xml b/kratos.gid/apps/Chimera/xml/Conditions.xml index e02fa6e91..0df3764ae 100644 --- a/kratos.gid/apps/Chimera/xml/Conditions.xml +++ b/kratos.gid/apps/Chimera/xml/Conditions.xml @@ -3,7 +3,7 @@ + VariableName="Interface" App="Fluid" ElementType="Surface" ProcessName="ChimeraInternalBoundary" help="Fixes the pressure to a constant scalar value." > @@ -14,7 +14,7 @@ + VariableName="Interface" App="Fluid" ElementType="Line" ProcessName="ChimeraInternalBoundary" help="Fixes the pressure to a constant scalar value." > diff --git a/kratos.gid/apps/Chimera/xml/Process.xml b/kratos.gid/apps/Chimera/xml/Process.xml new file mode 100644 index 000000000..d899199bd --- /dev/null +++ b/kratos.gid/apps/Chimera/xml/Process.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/kratos.gid/apps/Chimera/xml/XmlController.tcl b/kratos.gid/apps/Chimera/xml/XmlController.tcl index 887c1f4b3..da75adbfa 100644 --- a/kratos.gid/apps/Chimera/xml/XmlController.tcl +++ b/kratos.gid/apps/Chimera/xml/XmlController.tcl @@ -9,6 +9,7 @@ proc Chimera::xml::Init { } { # Namespace variables inicialization Model::InitVariables dir $Chimera::dir + Model::getProcesses Process.xml Model::getConditions Conditions.xml Model::getElements Elements.xml spdAux::processIncludes