zoukankan      html  css  js  c++  java
  • 格子方法曲边处理

      应用格子玻尔兹曼方法做气固两相流时,对于颗粒相,借助相关作用力模型,可视为点源处理,也可以直接解析颗粒,精确刻画颗粒气体间相互作用力。全解析颗粒时,一般可将颗粒视为球体(三维)或者圆(二维),气体颗粒间相互作用体现在颗粒边界的的处理上,对于这样的曲边界,其处理方法的好坏直接影响计算的精度和稳定性,对于无滑移的曲边界,有将曲边近似为阶梯状的直接反弹法、在其基础上改进的插值反弹法,及基于构造虚拟固体点上分布函数的F-H、MLS、GZS方法等。上述方法中除直接反弹法外,其他几种方法无一例外的都需要求解曲边同其穿过的格点连线的交点及其交点在线段上的位置百分比,对于曲边附近的边界点,需要频繁求解该位置百分比及交点,故将此写成一个小函数,方便主函数调用。

      给出的代码中将曲边视为一个圆,可以通过圆心、半径来刻画,而格点连线可以通过连线两端点来描述,圆和直线都可以用解析式来表征,只需要联立圆和直线方程即可求解该交点及其百分比。

     1 /// To compute the q for interpolated bounce back
     2 /// Parameter cir_x, cir_y, cir_r: center point location and radius of the particle, is the curve boundary
     3 /// Parameter bpx, bpy: the location of the end point outside the circle, is the boundary point
     4 /// Parameter spx, spy: the location of the end point inside the circle, is the solid point
     5 double cal_q ( double cir_x, double cir_y, double cir_r, double bpx, double bpy, double spx, double spy ) {
     6     double k, b, A, B, C, x1, x2, y1, y2, q1, q2, q;
     7     if ( bpx != spx ) {  // ensure that k is exists
     8         // line parameter
     9         k = ( spy - bpy ) / ( spx - bpx );
    10         b = spy - k * spx;
    11         // equation parameter
    12         A = k * k + 1;
    13         B = 2 * k * ( b - cir_y ) - 2 * cir_x;
    14         C = ( b - cir_y ) * ( b - cir_y ) + cir_x * cir_x - cir_r * cir_r;
    15         // solve the equation
    16         x1 = ( -B + sqrt ( B * B - 4 * A * C ) ) / 2 / A;
    17         x2 = ( -B - sqrt ( B * B - 4 * A * C ) ) / 2 / A;
    18         q1 = ( bpx - x1 ) / ( bpx - spx );
    19         q2 = ( bpx - x2 ) / ( bpx - spx );
    20     } else {  // x1 = x2 = bpx = spx
    21         y1 = cir_y + sqrt ( cir_r * cir_r - ( bpx - cir_x ) * ( bpx - cir_x ) );
    22         y2 = cir_y - sqrt ( cir_r * cir_r - ( bpx - cir_x ) * ( bpx - cir_x ) );
    23         q1 = ( bpy - y1 ) / ( bpy - spy );
    24         q2 = ( bpy - y2 ) / ( bpy - spy );
    25     }
    26     // determine the final result
    27     if ( q1 >= 0 && q1 <= 1 ) {
    28         q = q1;
    29     } else {
    30         q = q2;
    31     }
    32     return q;
    33 }
  • 相关阅读:
    python初级入门篇
    ADO.NET中DbConnection.GetSchema方法的使用总结
    连接Git@OSC操作步骤
    win7 免安装MariaDB
    Java Web入门学习(二) Eclipse的配置
    PowerDesigner16 生成的备注脚本,在sql server 2008 中报“对象名 'sysproperties' 无效”的错误的解决办法
    Java Web入门学习(一) STS与Tomcat配置
    ECharts-入门学习
    xampp使用技巧及问题汇总
    Spring boot注解
  • 原文地址:https://www.cnblogs.com/kljfdsa/p/7441651.html
Copyright © 2011-2022 走看看