当前位置: 首页>>代码示例>>C++>>正文


C++ BlockInfo::pos方法代码示例

本文整理汇总了C++中BlockInfo::pos方法的典型用法代码示例。如果您正苦于以下问题:C++ BlockInfo::pos方法的具体用法?C++ BlockInfo::pos怎么用?C++ BlockInfo::pos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BlockInfo的用法示例。


在下文中一共展示了BlockInfo::pos方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: _is_intersecting

	bool _is_intersecting(tBox& box, const BlockInfo& info) const
	{			
		Real min_pos[2], max_pos[2];
		info.pos(min_pos, 0,0);
		info.pos(max_pos, B::sizeX-1, B::sizeY-1);
		
		const Real intersection[2] = {
			min(max_pos[0], (Real)(box.center[0] + box.h[0]*0.5)) - max(min_pos[0], (Real)(box.center[0] - box.h[0]*0.5)),
			min(max_pos[1], (Real)(box.center[1] + box.h[1]*0.5)) - max(min_pos[1], (Real)(box.center[1] - box.h[1]*0.5))
		};
		
		return intersection[0]>=0 && intersection[1]>=0;
	}
开发者ID:BijanZarif,项目名称:MRAG-I2D,代码行数:13,代码来源:I2D_CoreFMM_AggressiveVel.cpp

示例2: operator

	inline void operator()(const BlockInfo& info, FluidBlock2D& b) const
	{
		map< int, Diagnostic>::iterator it = diagnostics.find(info.blockID);
		assert(it != diagnostics.end());
		Diagnostic& diag = it->second;
		
		diag.force[0] = diag.force[1]  = 0.0;
		diag.torque[0] = diag.torque[1]  = 0.0;
		diag.area = 0.0;
		diag.gridpoints = 0.0;
		diag.circulation = 0.0;
		
		for(int iy=0; iy<FluidBlock2D::sizeY; iy++)
			for(int ix=0; ix<FluidBlock2D::sizeX; ix++)
			{
				Real p[2];
				info.pos(p,ix,iy);
				
				const Real Xs = b(ix,iy).tmp;
				diag.force[0] += b(ix,iy).u[0]*Xs;
				diag.force[1] += b(ix,iy).u[1]*Xs;
				
				diag.torque[0] +=  (p[0]-cor[0]) * (b(ix,iy).u[1]+Uinf[1]) * Xs;
				diag.torque[1] += -(p[1]-cor[1]) * (b(ix,iy).u[0]+Uinf[0]) * Xs;
				
				diag.area += Xs;
				diag.gridpoints += Xs;				
				diag.circulation += b(ix,iy).omega;
			}
		
		const Real dA = pow(info.h[0], 2);
		
		diag.force[0] *= dA*lambda;
		diag.force[1] *= dA*lambda;
		
		diag.torque[0] *= dA*lambda;
		diag.torque[1] *= dA*lambda;
		
		diag.area *= dA;		
		diag.circulation *= dA;
		
		diag.force[0] += diag.area*lambda*Uinf[0];
		diag.force[1] += diag.area*lambda*Uinf[1];
	}
开发者ID:BijanZarif,项目名称:MRAG-I2D,代码行数:44,代码来源:I2D_PenalizationOperator.cpp

示例3: operator

	//LOOPC-STYLE:
	void operator()(blocked_range<int> range) const
	{
		for(int iblock=range.begin(); iblock<range.end(); iblock++)
		{
			
			const BlockInfo info = destblocks[iblock];
			assert(destblocks[iblock].ptrBlock != NULL);
			VelocityBlock& my_b = *(VelocityBlock*)destblocks[iblock].ptrBlock;
			
			HCFMM::BoxIterator<tBox,tbb::scalable_allocator> it1(rootNode);
			
			tBox* current;
			bool canRemove;
			
			//clean velocity field:
			my_b.clear();
			
			while(it1!=NULL && (it1->nParticles>0))
			{
				canRemove=true;
				current=it1;
				
				const bool is_close = _isclose_box(current, info, _THETA);
				
				if(!is_close && current->parent!=NULL)
				{
					const bool parent_is_close = _isclose_box(current->parent, info, _THETA);
					
					if(parent_is_close) //if we were already well separated from parent, we should skipt this.

							for(int iy=0; iy<B::sizeY; iy++)
								for(int ix=0; ix<B::sizeX; ix++)
								{
									Real target_pos[2] = {0,0};
									info.pos(target_pos, ix, iy);
									
									if(current->parent==NULL || !(ws_barnes_hut(current->parent, target_pos, _THETA)))
									{
										VelocityRHS rhs;
										
										it1->expansions.evaluateExpansions(target_pos, &rhs);
										
										my_b.u[0][iy][ix] += rhs.x[0];
										my_b.u[1][iy][ix] += rhs.x[1];

										measurements.num_indirect_evals[iblock] += 1;
									}
								}
				}
				else  
				{
					//treat each point separately
						for(int iy=0; iy<B::sizeY; iy++)
							for(int ix=0; ix<B::sizeX; ix++)
							{
								Real target_pos[2] = {0,0};
								info.pos(target_pos,ix,iy);
								
								if(current->parent==NULL || !(ws_barnes_hut(current->parent, target_pos, _THETA))) 
								{	
									//when we were already well separated from the parent, we should not further interact.
									if (ws_barnes_hut(current, target_pos, _THETA))
									{
										measurements.num_indirect_evals[iblock] += 1;

										VelocityRHS rhs;
										
										it1->expansions.evaluateExpansions(target_pos, &rhs);
										
										my_b.u[0][iy][ix] += rhs.x[0];
										my_b.u[1][iy][ix] += rhs.x[1];
									}
									else
									{
										if(!it1->isleaf) 
											//Case 2: its not a leaf so we further traverse into the tree (summing up the children and bailing out)
											canRemove=false;
										else  //its close and a leaf ->interactDirectly with particles
										{
											Real u[2] = {0,0};
											
											const int nof_sources = current->nParticles;
											const VelocitySourceParticle * const p = current->vparticles;
											
											measurements.num_direct_evals[iblock] += nof_sources;

											if (_is_intersecting(*current, info)) //tBox current and this block are intersecting
												for (int i=0;i<nof_sources;++i)
												{
													Real r[2] = {
														target_pos[0] - p[i].x[0],
														target_pos[1] - p[i].x[1]
													};
													
													const Real distance_2 = r[0]*r[0] + r[1]*r[1];
													
													if (distance_2==0) continue;
													
													const Real factor = 1/distance_2;
//.........这里部分代码省略.........
开发者ID:BijanZarif,项目名称:MRAG-I2D,代码行数:101,代码来源:I2D_CoreFMM_AggressiveVel.cpp


注:本文中的BlockInfo::pos方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。