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


C++ GridFunction::GetGridDimension方法代码示例

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


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

示例1: computeResidual

RealType Solver::computeResidual(GridFunction& sourcegridfunction,
    				     GridFunctionType& rhs,
    					 const PointType& h){
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    // The pre-value to be returned (return sqrt(doubleSum)):
    RealType doubleSum = 0.0;

    /* We need to compute the derivatives p_xx and p_yy, therefore the stencil has to be applied.
     */

    MultiIndexType dim = sourcegridfunction.GetGridDimension();
    MultiIndexType bread  (0,0);
    MultiIndexType eread  (dim[0]-1,dim[1]-1);
    MultiIndexType bwrite (1,1);
    MultiIndexType ewrite (dim[0]-2,dim[1]-2);

    //Compute the needed derivations for the whole (inner?) area
    Stencil stencil(3,h); 					// bzw. Kann man einfach const weitergeben? /Wie?
    //Get the values for derivative in x-direction:
    GridFunction Fxx(dim);
    stencil.ApplyFxxStencilOperator(bread, eread, bwrite, ewrite, sourcegridfunction.GetGridFunction(), Fxx);
    //Get the values for derivative in y-direction:
    GridFunction Fyy(dim);
    stencil.ApplyFyyStencilOperator(bread, eread, bwrite, ewrite, sourcegridfunction.GetGridFunction(), Fyy);

    // Compute the residual: res = sqrt(Sum_i^I(Sum_j^J((p_xx+p_yy-rightHandSide)²/(I*J))))
    RealType derivator;
    for (IndexType i = 1; i <= dim[0]-2; i++)
    {
    	for (IndexType j = 1; j <= dim[1]-2; j++)
    	{
    		derivator = Fxx.GetGridFunction()[i][j]+ Fyy.GetGridFunction()[i][j] - rhs[i][j];
            doubleSum +=  derivator*derivator / (dim[0]-2) / (dim[1]-2);
    	}
    }
    //std::cout<<doubleSum<<std::endl;
    return sqrt(doubleSum);
}
开发者ID:feelX46,项目名称:NumSim,代码行数:38,代码来源:solver.cpp


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