咨询,关于文件读写的问题
-
各位大神好,
我想咨询一下如何能让properties文件中的变量可以从别的文档中读取?
情况是这样的,如下,injectionmodel的设置中,因为我有31个injection model,而且每个injection都有些许不同,因此我就有很多参数需要设置, (Din和Dout是举例)。 这就导致了我的KinematicCloudProperties文件一共有3000....。
我的想法是每一个参数放到一个dictionary文件中,这样我就需要几个文件放到constant文件夹中就可以,这样会精简很多。
Din1 0 ; Din2 0.001 ; Din3 0.003 ; Din4 0.005 ; Din5 0.007 ; Din6 0.009 ; Din7 0.011 ; Din8 0.013 ; Din9 0.015 ; Din10 0.017 ; Din11 0.019 ; Din12 0.021 ; Din13 0.023 ; Din14 0.025 ; Din15 0.027 ; Din16 0.029 ; Din17 0.031 ; Din18 0.033 ; Din19 0.035 ; Din20 0.037 ; Din21 0.039 ; Din22 0.041 ; Din23 0.043 ; Din24 0.045 ; Din25 0.047 ; Din26 0.049 ; Din27 0.051 ; Din28 0.053 ; Din29 0.055 ; Din30 0.057 ; Din31 0.059 ; Dout1 0.001 ; Dout2 0.003 ; Dout3 0.005 ; Dout4 0.007 ; Dout5 0.009 ; Dout6 0.011 ; Dout7 0.013 ; Dout8 0.015 ; Dout9 0.017 ; Dout10 0.019 ; Dout11 0.021 ; Dout12 0.023 ; Dout13 0.025 ; Dout14 0.027 ; Dout15 0.029 ; Dout16 0.031 ; Dout17 0.033 ; Dout18 0.035 ; Dout19 0.037 ; Dout20 0.039 ; Dout21 0.041 ; Dout22 0.043 ; Dout23 0.045 ; Dout24 0.047 ; Dout25 0.049 ; Dout26 0.051 ; Dout27 0.053 ; Dout28 0.055 ; Dout29 0.057 ; Dout30 0.059 ; Dout31 0.061 ; model2 { type ConeNozzleInjection2; SOI $soi; massTotal $masstotal2; parcelBasisType fixed; nParticle $np2; injectionMethod disc; flowType constantVelocitywithdev; //PinJ 7e5; UMag $UMag2; outerDiameter $Dout2; innerDiameter $Din2; duration $duration1; position $position1; direction $direction1; parcelsPerSecond $PPS; flowRateProfile $flowrateprofile2; Cd $dragcoef; thetaInner constant $thetain2; thetaOuter constant $thetaout2; devPadU0 0.035; //velocity standard deviation devPadW0 1.6; //angular velocity (standard deviation) [1/s] injectiondevPadUx $injectiondevPadUx2; //velocity standard deviation injectiondevPadUy $injectiondevPadUy2; injectiondevPadUz $injectiondevPadUz2; /*sizeDistribution { type MPS_normal; MPS_normalDistribution //size distribution { expectation 0.00015; variance 0.000081; maxValue 0.000034200; minValue 0.000000220; } }*/ MPSVelocityDistribution { type MPS_normal; MPS_normalDistribution { expectation 0; variance 1; maxValue 4; minValue -4; } } sizeDistribution { type RosinRammler; RosinRammlerDistribution { minValue $rrmin; maxValue $rrmax; d $rrd2; n $rrn2; } } }
我的理想状态是
model24 { type ConeNozzleInjection2; SOI $soi; massTotal “$FOAM_CASE/injectionparameter/massTotal.masstotal24”; parcelBasisType fixed; nParticle “$FOAM_CASE/injectionparameter/nP.nP24”; UMag “$FOAM_CASE/injectionparameter/UMag.UMag24”; injectionMethod disc; flowType constantVelocitywithdev; //PinJ 7e5; massTotal $masstotal24; outerDiameter “$FOAM_CASE/injectionparameter/Dou.Dou24”; innerDiameter “$FOAM_CASE/injectionparameter/Din.Din24”; duration $duration1; position $position1; direction $direction1; parcelsPerSecond $PPS; flowRateProfile $flowrateprofile2; Cd $dragcoef; thetaInner “$FOAM_CASE/injectionparameter/thetaInner.theInner24”; thetaOuter constant $thetaout24; devPadU0 0.035; //velocity standard deviation devPadW0 1.6; //angular velocity (standard deviation) [1/s] injectiondevPadUx $injectiondevPadUx24; //velocity standard deviation injectiondevPadUy $injectiondevPadUy24; injectiondevPadUz $injectiondevPadUz24; /*sizeDistribution { type MPS_normal; MPS_normalDistribution //size distribution { expectation 0.00015; variance 0.000081; maxValue 0.000034200; minValue 0.000000220; } }*/ MPSVelocityDistribution { type MPS_normal; MPS_normalDistribution { expectation 0; variance 1; maxValue 4; minValue -4; } } sizeDistribution { type RosinRammler; RosinRammlerDistribution { minValue $rrmin; maxValue $rrmax; d $rrd24; n $rrn24; } } }
-
就在今天,Henry Weller 亲自帮你实现了这个功能
https://github.com/OpenFOAM/OpenFOAM-dev/commit/a7b842569064ede1574a77210b731904a206182a
我很好奇你的需求是如何上达天听的 -
@浪迹天大 测试例子:
https://github.com/OpenFOAM/OpenFOAM-dev/blob/master/applications/test/dictionary/testSlashDict
其中的 external 和 active2 都读取自另一个文件 testSlashDict2。