Example #1
0
void
cmdloop(struct shinstance *psh, int top)
{
	union node *n;
	struct stackmark smark;
	int inter;
	int numeof = 0;

	TRACE((psh, "cmdloop(%d) called\n", top));
	setstackmark(psh, &smark);
	for (;;) {
		if (psh->pendingsigs)
			dotrap(psh);
		inter = 0;
		if (iflag(psh) && top) {
			inter = 1;
			showjobs(psh, psh->out2, SHOW_CHANGED);
			chkmail(psh, 0);
			flushout(&psh->errout);
		}
		n = parsecmd(psh, inter);
		/* showtree(n); DEBUG */
		if (n == NEOF) {
			if (!top || numeof >= 50)
				break;
			if (!stoppedjobs(psh)) {
				if (!Iflag(psh))
					break;
				out2str(psh, "\nUse \"exit\" to leave shell.\n");
			}
			numeof++;
		} else if (n != NULL && nflag(psh) == 0) {
			psh->job_warning = (psh->job_warning == 2) ? 1 : 0;
			numeof = 0;
			evaltree(psh, n, 0);
		}
		popstackmark(psh, &smark);
		setstackmark(psh, &smark);
		if (psh->evalskip == SKIPFILE) {
			psh->evalskip = 0;
			break;
		}
	}
	popstackmark(psh, &smark);
}
Example #2
0
//---------------------------------------------------------------------------
//一维存储周期边界节点编号及起始点信息
int Mesher::Record_periodic_boundary_nodes_number(const struct RVE_Geo &cell_geo)
{
	//用于记录那些节点已经被记录过(0:没有记录过,1:记录过)
	vector<int> nflag(nodes.size(),0);

	//生成各个方向点的最大编号
	int k_max = int(cell_geo.len_x/dx);
	int j_max = int(cell_geo.wid_y/dy);
	int i_max = int(cell_geo.hei_z/dz);

	//-----------------------------------------------------------------------------------------------------------------------------------------
	//周期边界节点编号及相关信息
	int count = 0;  //记录整体节点编号
	for( int i=0; i<=i_max; i++ )
		for( int j=0; j<=j_max; j++ )
			for( int k=0; k<=k_max; k++ )
			{
				if(nodes[count].type!=0&&nflag[count]==0)  //不是内点并且没有记录过
				{
					int key = 0;
					for(int m=i; m<=i_max; m+=i_max)
						for(int n=j; n<=j_max; n+=j_max)
							for(int p=k; p<=k_max; p+=k_max)
							{
								int num = m*(j_max+1)*(k_max+1) + n*(k_max+1) + p;
								peri_bnods[0].push_back(num);
								nflag[num]=1;	//此点已经记录过
								peri_bnods[1].push_back(key);  //标记位置
								key++;
							}
				}
				count++;  //整体节点编号加1
			}

	//-----------------------------------------------------------------------------------------------------------------------------------------
	//对一维存储按相关点从大到小重新排序
	int left = 0;
	int right = 0;
	for(int i=0; i<(int)peri_bnods[1].size(); i++)
	{
		if(i+1==(int)peri_bnods[1].size()||peri_bnods[1][i+1]==0) 
		{
			right = i;
			//---------------------------------------------------------------
			//将从小到大排序变为从大到小排序
			while(left<right)
			{
				int temp_peri = peri_bnods[0][right];
				peri_bnods[0][right] = peri_bnods[0][left];
				peri_bnods[0][left] = temp_peri;
				left++;
				right--;
			}
			//---------------------------------------------------------------
			left = i+1;
		}
	}

	//输出检查
	//hout << "peri_bnods:" << endl << endl;
	//for(int i=0; i<(int)peri_bnods[0].size(); i++)
	//{
	//	hout << peri_bnods[0][i] << "  " << peri_bnods[1][i] << endl;
	//}

	return 1;
}