Skip to content
  • 最新
  • 版块
  • 东岳流体
  • 随机看[请狂点我]
皮肤
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • 默认(不使用皮肤)
  • 不使用皮肤
折叠
CFD中文网

CFD中文网

  1. CFD中文网
  2. OpenFOAM
  3. 关于相邻cell

关于相邻cell

已定时 已固定 已锁定 已移动 OpenFOAM
8 帖子 3 发布者 5.4k 浏览
  • 从旧到新
  • 从新到旧
  • 最多赞同
回复
  • 在新帖中回复
登录后回复
此主题已被删除。只有拥有主题管理权限的用户可以查看。
  • 星 离线
    星 离线
    星星星星晴
    写于 最后由 编辑
    #1

    https://www.cfd-online.com/Forums/openfoam-meshing/61906-how-identify-cell-neighbours.html

    根据这个帖子,我可以得到一个cell周围的相邻cell id。
    进而可以得到这些cell中的相关信息。
    这个命令可以称之为目标cell外面的一层cell,假设是结构网格,那么就会有26个cell id。

    那假如想得到第2层相邻cell呢?应该第二层有25+25+15+15个,如何获得这些cell id 呢 跪求已有的轮子~

    游荡

    1 条回复 最后回复
  • 李东岳李 离线
    李东岳李 离线
    李东岳 管理员
    写于 最后由 编辑
    #2

    目前想到的只能是把第一层cell,再次进行抽取,取其中不是第一层cells的cells当做第二层cell

    http://dyfluid.com/index.html
    需要帮助debug算例的看这个 https://cfd-china.com/topic/8018

    星 1 条回复 最后回复
  • 星 离线
    星 离线
    星星星星晴
    在 中回复了 李东岳 最后由 编辑
    #3

    @李东岳 这样感觉好麻烦。。 能不能说以某个cell为圆心或者质心将方圆几公里的cell都选中呢,并给出cell id:143:

    游荡

    T 1 条回复 最后回复
  • T 离线
    T 离线
    Tens 神
    在 中回复了 星星星星晴 最后由 编辑
    #4

    @星星星星晴 看到之前师兄的程序,好像就是像东岳老师说的一层一层提取。我有个想法,是不是可以借鉴topoSet中的sphereToCell的思路,不过我看这个代码好像是遍历所有网格,感觉可能效率还不如上面的方法:143:

    星 1 条回复 最后回复
  • 星 离线
    星 离线
    星星星星晴
    在 中回复了 Tens 最后由 编辑
    #5

    @tens https://www.cfd-online.com/Forums/openfoam-meshing/61906-how-identify-cell-neighbours-3.html

    根据这个思路做出来了,我尝试了一层一层提取,感觉一层一层提取的id 有问题,不是我想要的那种结果,只能用这种方法跑了。
    看起来成功了

    //This gets all cell centres of all mesh cells
    const pointField& ctrs = mesh_.cellCentres();
    
        //This calculates the radius of your sphere
        const scalar radSquared = radius_*radius_;
    
        //Loop over all cells
        forAll(ctrs, cellI)
        {
            //calculates the distance between the cell centre and the current cell 
            //with the index cellI
            scalar offset = magSqr(centre_ - ctrs[cellI]);
            if (offset <= radSquared)
            {
                //Do something, e.g. store the current cell id in a list
            }
        }
    

    游荡

    李东岳李 星 2 条回复 最后回复
  • 李东岳李 离线
    李东岳李 离线
    李东岳 管理员
    在 中回复了 星星星星晴 最后由 编辑
    #6

    看起来是一个center_遍历一次网格

    http://dyfluid.com/index.html
    需要帮助debug算例的看这个 https://cfd-china.com/topic/8018

    星 1 条回复 最后回复
  • 星 离线
    星 离线
    星星星星晴
    在 中回复了 李东岳 最后由 编辑
    #7

    @李东岳 是的 因为我用那个相邻网格,导出id后 在paraview中看到的不是一团点,这个方法得到的是一团点

    游荡

    1 条回复 最后回复
  • 星 离线
    星 离线
    星星星星晴
    在 中回复了 星星星星晴 最后由 编辑
    #8

    @星星星星晴 本来没想到这么慢,结果发现假如我有1M parcel,1M cell 就要搞1M x 1M次, 实在有点笨。然后现在改为之前那个方法了。。 可能是当时不知道怎么回事有点脑残吧,搞错了,相邻cell一层一层搞出来快很多。。 下面是code, 编程能力有限,想搞成个function,总觉得麻烦。。不过改成function的话应该可以弄n层了吧。。

    还是python好写。。。

    	if (neighbor_) {
    		//Info << "cellI = " <<cellI<<nl;
    
    		//- first layer
    		List<int> first =  this->owner().mesh().cellCells()[cellI];
    		first.append(cellI);
    		sort(first);
    		all_neighbor.append(first);
    		int first_size = first.size();
    		//Info << "cellI = " << first <<nl;
    
    		//- second layer
    		List<int> second_all;
    		for (int i1 = 0; i1<first_size; i1++){
    			List<int> second =  this->owner().mesh().cellCells()[first[i1]];
    			//Info << "cellI second = " << second <<nl;
    			second_all.append(second);
    			
    		}
    		List<int> order,second_unique;
    		uniqueOrder(second_all, order);
    		forAll(order,kk)
    		{
    			second_unique.append(second_all[order[kk]]);
    		}
    		sort(second_unique);
    		all_neighbor.append(second_unique);
    
    
    		//- third layer
    		List<int> third_all;
    		for (int i1 = 0; i1<second_unique.size(); i1++){
    			List<int> third =  this->owner().mesh().cellCells()[second_unique[i1]];
    			//Info << "cellI third = " << third <<nl;
    			third_all.append(third);	
    		}
    		List<int> order3,third_unique;
    		uniqueOrder(third_all, order3);
    		forAll(order3,kk)
    		{
    			third_unique.append(third_all[order3[kk]]);
    		}
    		sort(third_unique);
    		all_neighbor.append(third_unique);
    
    		//- Fourth layer
    		List<int> fourth_all;
    		for (int i1 = 0; i1<third_unique.size(); i1++){
    			List<int> fourth =  this->owner().mesh().cellCells()[third_unique[i1]];
    			fourth_all.append(fourth);	
    		}
    		List<int> order4,fourth_unique;
    		uniqueOrder(fourth_all, order4);
    		forAll(order4,kk)
    		{
    			fourth_unique.append(fourth_all[order4[kk]]);
    		}
    		sort(fourth_unique);
    		all_neighbor.append(fourth_unique);
            
                    //- collect all
    		List<int> order_all;
    		uniqueOrder(all_neighbor, order_all);
    		forAll(order_all,kk)
    		{
    			all_neighbor_unique.append(all_neighbor[order_all[kk]]);
    		}
    		sort(all_neighbor_unique);
    

    游荡

    1 条回复 最后回复
  • I ir77 被引用 于这个主题
  • I ir77 被引用 于这个主题
  • I ir77 被引用 于这个主题

  • 登录

  • 登录或注册以进行搜索。
  • 第一个帖子
    最后一个帖子
0
  • 最新
  • 版块
  • 东岳流体
  • 随机看[请狂点我]