⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cogenelevation.cxx

📁 有限元学习研究用源代码(老外的),供科研人员参考
💻 CXX
字号:
#include "cogenelevation.hxx"

CogenElevation::CogenElevation(wzString s,cogeometry g)
  :Geom( new CogeometryElevation(s,g))
{geom = Geom;}

CogenElevation::CogenElevation(wzString s)
  :Geom( new CogeometryElevation(s, new Cogeometry1D()))
{geom = Geom;}

void CogenElevation::setBorder(wzFloat xmin,wzFloat xmax,
			       wzFloat ymin,wzFloat ymax,
			       wzFloat zmin,wzFloat zmax)
{
  CogenOctree::setBorder(xmin,xmax,ymin,ymax,0,1);
  Geom->setOrigin(xmin,ymin,zmin);
  Geom->setSize(xmax-xmin,ymax-ymin,zmax-zmin);
}

void CogenElevation::endInitialization()
{
  CogenOctree::endInitialization();
  //  Geom->setOrigin(min[0],min[1],0);
  //  Geom->setSize(max[0]-min[0],max[2]-min[1],1);
}

CogeometryElevation::CogeometryElevation(cogIndex lx, cogIndex ly
	     ,cogeometry geom)
:CogeometryByFunction(*(cogPointToFloat*)this,geom)
,map(lx,ly),x0(0),y0(0),f0(0),dx(1),dy(1),df(0x7fff)
{dx /= map.lx(); dy /= map.ly();}

CogeometryElevation::CogeometryElevation(wzString s
	     ,cogeometry geom)
:CogeometryByFunction(*(cogPointToFloat*)this,geom)
,map(s),x0(0),y0(0),f0(0),dx(1),dy(1),df(0x7fff)
{dx /= map.lx(); dy /= map.ly();}

wzFloat CogeometryElevation::call(const wzPoint& p) const
{
 cogFloat rx = (p.x()-x0)/dx; 
 cogFloat ry = (p.y()-y0)/dy; 
 cogInteger ix = (cogInteger) rx, jx = ix+1; rx -= ix;
 cogInteger iy = (cogInteger) ry, jy = iy+1; ry -= iy;
 if(ix<0){
        ix = jx = 0;
 }else if(jx>=map.lx()){
        ix = jx = map.lx()-1;
 }
 if(iy<0){
        iy = jy = 0;
 }else if(jy>=map.ly()){
        iy = jy = map.ly()-1;
 }
 cogFloat uii = map(ix,iy);
 cogFloat uij = map(ix,jy);
 cogFloat uji = map(jx,iy);
 cogFloat ujj = map(jx,jy);
 cogFloat u   = (1-rx)*((1-ry)*uii + ry * uij) + rx*((1-ry)*uji + ry * ujj);
 return p.z()-(u-f0)/df;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -