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


C++ Model::GetNumNodes方法代码示例

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


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

示例1: SetOptimizationPdvsAndAdvs


//.........这里部分代码省略.........
//				if ( node )
//				{
//					// If found in no filter IDs.
//					if ( std::find( &noFilterNodeIds[0], &noFilterNodeIds[0] + ( UInt ) noFilterNodeIds.size(), glbNodeId ) - &noFilterNodeIds[0] != ( UInt ) noFilterNodeIds.size() ) {
//						UInt numEntries[] = {1,0};
//
//						neigbIdsVec[0] = glbNodeId - 1;
//						neigbWgtVec[0] = 1.0;
//
//						UInt paramIndex = 0;
//						UInt propTypeKey = node->GetIndexNum();
//						PhysicalDesignVar* pdv = aOptimizer->CreatePhysDesVar( aProblem, modelId, desDepObj, propId, propType, propTypeKey, paramIndex );
//
//						Function* PDVEvalFunc = new FunctionScalarProduct( numEntries, &neigbWgtVec[0] );
//						pdv->CreateEvaluationFunction( PDVEvalFunc, &neigbIdsVec[0] );
//					}
//					else {
//						Real neighborIds = 0;
//						Real neighborWgt = 0;
//						UInt position = 28;
//						for ( UInt ii = 0; ii < numNeigb; ii++ )
//						{
//							std::sscanf( lineChar + position,"%lf",&neighborIds );
//							neigbIdsVec[ii] = neighborIds - 1;
//							position += 14;
//						}
//						for ( UInt ii = 0; ii < numNeigb; ii++ )
//						{
//							std::sscanf( lineChar + position,"%lf",&neighborWgt );
//							neigbWgtVec[ii] = neighborWgt;
//							position += 14;
//						}
//
//						UInt numEntries[] = {numNeigb, 0};
//						UInt paramIndex = 0;
//						UInt propTypeKey = node->GetIndexNum();
//						PhysicalDesignVar* pdv = aOptimizer->CreatePhysDesVar( aProblem, modelId, desDepObj, propId, propType, propTypeKey, paramIndex );
//
//						Function* PDVEvalFunc = new FunctionScalarProduct( numEntries, &neigbWgtVec[0] );
//						pdv->CreateEvaluationFunction( PDVEvalFunc, &neigbIdsVec[0] );
//					}
//				}
//			}
//		}
//	}
//	else
//	{
//		std::fprintf( stdout, " Unable to open file!!!\n" );
//	}

	// Set number of abstract design variables (radius)
	UInt modelId = 1;
	UInt numAbsDesVar   = 1;
	UInt AbsDesVarInd[] = {0};
	// ------------------------------------------------------------------------
	// Set number of abstract design variables
    aOptimizer->SetNumDesVars(numAbsDesVar);

    // ------------------------------------------------------------------------
    // Create PDV's
    DesignDepObject desDepObj = NOD_PROP;
    UInt propId   = 11;
    Int  propType = NP_LS;
    PhysicalDesignVar* pdv = NULL;

    // Create optimizer sweep function
	UInt numParameters[] = { 1, 1 };					// number of coefficients and independent variables
	Real ParameterVals[] = { 0.0 };	// radius and center of circle

	Real CntrXGlbCoords = sCenterX;
	Real CntrYGlbCoords = sCenterY;
	Real CntrZGlbCoords = sCenterZ;

	Model* model = aProblem->GetModelById(modelId);
	UInt numNodes = model->GetNumNodes();

	model->BuildNodeToElementTable();

	Node* node = NULL;
	Real NodeXGlbCoords = 0.0;
	Real NodeYGlbCoords = 0.0;
	Real NodeZGlbCoords = 0.0;

	for ( UInt in = 0; in < numNodes; ++in )
	{
		node = model->GetNode(in);
		NodeXGlbCoords = node->GetGlobalXCoord();
		NodeYGlbCoords = node->GetGlobalYCoord();
		NodeZGlbCoords = node->GetGlobalZCoord();

		Real distance = std::sqrt( std::pow((NodeXGlbCoords-CntrXGlbCoords),2) + std::pow((NodeYGlbCoords-CntrYGlbCoords),2) + std::pow((NodeZGlbCoords-CntrZGlbCoords),2));
		ParameterVals[0] = distance;

		// Parameters for moving circle will be [distance, xcoords of node, ycoords of node, zcoords of node]

		pdv = aOptimizer->CreatePhysDesVar(aProblem,modelId,desDepObj,propId,propType,node->GetIndexNum());
		Function* SweepFunc = new FunctionUserDefined(numParameters,ParameterVals,mySweepFunc,mySweepFuncDeriv);
		pdv->CreateEvaluationFunction(SweepFunc,AbsDesVarInd);
	}
}
开发者ID:chvillanuevap,项目名称:thesis-defense,代码行数:101,代码来源:beam2D.C


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