comsol 几何选择

介绍 comsol 其中两种几何选择,球选择和框选择。

球选择

根据圆心和半径选择几何对象

    /**
     * geom_select
     */
    String SELECT_NAMED_FORMAT = "%s_%s";

	/**
     * 半径
     */
    private static final double R = 1E-8;


    public String createSelect(int entityDim, GeomSequence geom, String selectTag, double x, double y, double z) {
        // 创建球选择
        GeomFeature geomFeature = geom.create(selectTag, ComsolConstants.BallSelection);
        // 设置几何实体层
        geomFeature.set("entitydim", entityDim);
        // 设置球心坐标
        geomFeature.set("posx", x);
        geomFeature.set("posy", y);
        geomFeature.set("posz", z);
        // 设置半径
        geomFeature.set("r", R);
        return String.format(SELECT_NAMED_FORMAT, geom.tag(), selectTag);
    }


框选择

根据最大坐标和最小坐标框选对象

    /**
     * geom_select
     */
    String SELECT_NAMED_FORMAT = "%s_%s";

	/**
     * 最小差值
     */
    private static final double MIN = 0.00001;

	public GeomFeature createSelect(int entityDim, GeomSequence geom, String boxSelectTag, double x, double y, double z) {
        // 创建框选择
        GeomFeature geomFeature = geom.create(boxSelectTag, ComsolConstants.BoxSelection);
        // 设置几何实体层
        geomFeature.set("entitydim", entityDim);
        // 设置框区域
        geomFeature.set("xmin", x - MIN);
        geomFeature.set("xmax", x + MIN);
        geomFeature.set("ymin", y - MIN);
        geomFeature.set("ymax", y + MIN);
        geomFeature.set("zmin", z - MIN);
        geomFeature.set("zmax", z + MIN);
       return geomFeature;
    }


Demo

	// 创建材料 mat1
	Material material = model.material().create("mat1");
	// 创建球选择
	BallSelect ballSelect = new BallSelect();
	String selectTag = ballSelect.selectTag();
	String named = ballSelect.createSelect(3, geom, selectTag, 0.1, 0.1, 0.1);
	// 材料 mat1 使用球选择 选择对象
	material.selection().named(named);

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值