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

📄 oilsanddesign.cpp

📁 这是本人两年前兼职为某个公司做的石油钻进设计软件
💻 CPP
字号:
// OilSandDesign.cpp : implementation file
//

#include "stdafx.h"
#include "CVenus.h"
#include "MainFrm.h"
#include "OilSandDesign.h"
#include	"ChildFrm.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// COilSandDesign

IMPLEMENT_DYNCREATE(COilSandDesign, CFormView)

COilSandDesign::COilSandDesign()
	: CFormView(COilSandDesign::IDD)
{
	//{{AFX_DATA_INIT(COilSandDesign)
	//}}AFX_DATA_INIT
}

COilSandDesign::~COilSandDesign()
{
}

void COilSandDesign::DoDataExchange(CDataExchange* pDX)
{
	CFormView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(COilSandDesign)
	DDX_Control(pDX, IDC_LIST_SHOTPARASELECT_LIST, m_ctrlList);
	DDX_Control(pDX, IDC_LIST_SHOTPARASELECT_SELECTED, m_ctrlSelected);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(COilSandDesign, CFormView)
	ON_WM_CONTEXTMENU()
	//{{AFX_MSG_MAP(COilSandDesign)
	ON_BN_CLICKED(IDC_BUTTON_SHOTPARASELECT_LOAD, OnButtonShotparaselectLoad)
	ON_NOTIFY(NM_CLICK, IDC_LIST_SHOTPARASELECT_LIST, OnClickListShotparaselectList)
	ON_COMMAND(ID_SPD_CACL, OnSpdCacl)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// COilSandDesign diagnostics

#ifdef _DEBUG
void COilSandDesign::AssertValid() const
{
	CFormView::AssertValid();
}

void COilSandDesign::Dump(CDumpContext& dc) const
{
	CFormView::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// COilSandDesign message handlers



void COilSandDesign::OnInitialUpdate() 
{
	CFormView::OnInitialUpdate();
	CMainFrame*	wnd = (CMainFrame*)AfxGetMainWnd();
	GetParentFrame()->SetWindowText(_T("油井防砂优化设计"));
	UpdateData();
	m_fQOil = wnd->m_structSandPressDesign.fQ;
	UpdateData(FALSE);

	m_ctrlList.InsertColumn (0,"序号",LVCFMT_LEFT ,40,0);
	m_ctrlList.InsertColumn (1,"相对流体压降",LVCFMT_LEFT ,100,1);
	m_ctrlList.InsertColumn (2,"型号",LVCFMT_LEFT ,200,2);
	m_ctrlList.InsertColumn (3,"相位角度",LVCFMT_LEFT ,100,3);
	m_ctrlList.InsertColumn (4,"孔密",LVCFMT_LEFT ,60,4);
	m_ctrlList.InsertColumn (5,"穿深",LVCFMT_LEFT ,60,5);
	m_ctrlList.InsertColumn (6,"孔径",LVCFMT_LEFT ,60,6);
	m_ctrlList.InsertColumn (7,"套管强度降低系数(%)",LVCFMT_LEFT ,150,7);
	m_ctrlSelected.InsertColumn (0,"序号",LVCFMT_LEFT ,40,0);
	m_ctrlSelected.InsertColumn (1,"相对流体压降",LVCFMT_LEFT ,100,1);
	m_ctrlSelected.InsertColumn (2,"型号",LVCFMT_LEFT ,200,2);
	m_ctrlSelected.InsertColumn (3,"相位角度",LVCFMT_LEFT ,100,3);
	m_ctrlSelected.InsertColumn (4,"孔密",LVCFMT_LEFT ,60,4);
	m_ctrlSelected.InsertColumn (5,"穿深",LVCFMT_LEFT ,60,5);
	m_ctrlSelected.InsertColumn (6,"孔径",LVCFMT_LEFT ,60,6);
	m_ctrlSelected.InsertColumn (7,"套管强度降低系数(%)",LVCFMT_LEFT ,150,7);
}

void COilSandDesign::OnButtonShotparaselectLoad() 
{
	CMainFrame*	wnd = (CMainFrame*)AfxGetMainWnd();

	if(wnd->m_structShotParaBase.bState == FALSE)
	{
		MessageBox("还未进行计算 !","工程信息");
		return;
	}

	UpdateData(TRUE);

	m_ctrlList.DeleteAllItems ();
	m_ctrlSelected.DeleteAllItems ();
	LVITEM pitem;
	pitem.mask=LVIF_TEXT;
	pitem.state=0;
	pitem.stateMask=0;
	pitem.iSubItem=0;
	pitem.pszText="";

	char strTemp[20];
	for(int i=0;i<wnd->m_structShotParaBase.iNum;i++)
	{
		pitem.iItem=i;
		m_ctrlList.InsertItem (&pitem);
		sprintf(strTemp,"%d",i+1);
		m_ctrlList.SetItemText (i,0,strTemp);
		sprintf(strTemp,"%2.4f",wnd->m_structShotParaSelect[i].fProPer );
		m_ctrlList.SetItemText (i,1,strTemp);
		m_ctrlList.SetItemText (i,2,wnd->m_structShotParaSelect[i].strModel );
		sprintf(strTemp,"%4.1f",wnd->m_structShotParaSelect[i].fAngle );
		m_ctrlList.SetItemText (i,3,strTemp);
		sprintf(strTemp,"%4.0f",wnd->m_structShotParaSelect[i].fShotDen );
		m_ctrlList.SetItemText (i,4,strTemp);
		sprintf(strTemp,"%5.2f",wnd->m_structShotParaSelect[i].fShotDepth );
		m_ctrlList.SetItemText (i,5,strTemp);
		sprintf(strTemp,"%3.2f",wnd->m_structShotParaSelect[i].fDiameter );
		m_ctrlList.SetItemText (i,6,strTemp);
		sprintf(strTemp,"%5.2f",wnd->m_structShotParaSelect[i].fPara );
		m_ctrlList.SetItemText (i,7,strTemp);
	}
	UpdateData(FALSE);	
	
}

void COilSandDesign::OnClickListShotparaselectList(NMHDR* pNMHDR, LRESULT* pResult) 
{
	CMainFrame*	wnd = (CMainFrame*)AfxGetMainWnd();
	UpdateData();

	m_ctrlSelected.DeleteAllItems ();
	LVITEM pitem;
	pitem.mask=LVIF_TEXT;
	pitem.state=0;
	pitem.stateMask=0;
	pitem.iSubItem=0;
	pitem.pszText="";
	pitem.iItem=0;
	m_ctrlSelected.InsertItem (&pitem);

	int m_iSelected = m_ctrlList.GetSelectionMark();

	char strTemp[20];
	sprintf(strTemp,"%d",m_iSelected+1);
	m_ctrlSelected.SetItemText (0,0,strTemp);
	sprintf(strTemp,"%2.4f",wnd->m_structShotParaSelect[m_iSelected].fProPer );
	m_ctrlSelected.SetItemText (0,1,strTemp);
	m_ctrlSelected.SetItemText (0,2,wnd->m_structShotParaSelect[m_iSelected].strModel );
	sprintf(strTemp,"%4.1f",wnd->m_structShotParaSelect[m_iSelected].fAngle );
	m_ctrlSelected.SetItemText (0,3,strTemp);
	sprintf(strTemp,"%4.0f",wnd->m_structShotParaSelect[m_iSelected].fShotDen );
	m_ctrlSelected.SetItemText (0,4,strTemp);
	sprintf(strTemp,"%5.2f",wnd->m_structShotParaSelect[m_iSelected].fShotDepth );
	m_ctrlSelected.SetItemText (0,5,strTemp);
	sprintf(strTemp,"%3.2f",wnd->m_structShotParaSelect[m_iSelected].fDiameter );
	m_ctrlSelected.SetItemText (0,6,strTemp);
	sprintf(strTemp,"%5.2f",wnd->m_structShotParaSelect[m_iSelected].fPara );
	m_ctrlSelected.SetItemText (0,7,strTemp);
	UpdateData(FALSE);

	*pResult = 0;
}

void COilSandDesign::OnSpdCacl() 
{
	// TODO: Add your command handler code here
	CMainFrame*	wnd = (CMainFrame*)AfxGetMainWnd();
	UpdateData();
	float u = wnd->m_structBDTTable.fStratumOilStiff;
	float k = (float)(wnd->m_structBDTTable.fStratumFilterPercent / 0.9869);
	float p = (float)(wnd->m_structBDTTable.fFloorOilPorportion / 0.016);
	float b = (float)(pow(10,6.5-0.95*log(k)));
	float d0 = wnd->m_structBDTTable.fOilResCannulaDiameter * 1000;
	float delta = wnd->m_structBDTTable.fOilResCannulaCliffDeep * 1000;
	m_fQOil = wnd->m_structOilShotForecast.fNPro*30;

	int i,j,nTemp1,nTemp2;
	STRUCTSHOTPARAPRESELECT structTemp;
	float l,q,d,a,fTemp,ks,kj,km,xw,xwt,yh,yc,f1,r;
	long lCount=0;
	for(i=0;i<wnd->m_structBDTTable.lCount;i++)
	{
//		l = (float)(wnd->m_structTTPShotPara[i].fShotDepth*wnd->m_structTTPResult.fPP[i] / 304.8);
//		d = (float)(wnd->m_structTTPShotPara[i].fDiameter*wnd->m_structTTPResult.fPP[i] / 304.8);
		l = (float)(wnd->m_structTTPResult.fPDepth[i] / 304.8);
		d = (float)(wnd->m_structTTPResult.fPDiameter[i] / 304.8);
		a = (float)(3.1415926 * pow(d/2,2));
		for(j=0;j<wnd->m_structBDTTable.iShotDenNum;j++)
		{
			q = (float)(m_fQOil / (0.1589873*wnd->m_structBDTTable.fShotDen[j]*
				wnd->m_structBDTTable.fShotLayerPly));
			for(nTemp1=0;nTemp1<wnd->m_structBDTTable.iShotPhasicNum;nTemp1++)
			{
				fTemp = (float)(0.888e-6*(l*u*q/(k*a))+9.1*pow(10,-18)*b*l*p*pow(q/a,2));
				fTemp = (float)(fTemp*0.00689);
				if(fTemp<0) fTemp = 0;
				if(lCount>=384)
				{
					structTemp.fAngle = wnd->m_structBDTTable.fShotPhasic[nTemp1];
					structTemp.fDiameter = wnd->m_structTTPShotPara[i].fDiameter;
					structTemp.fShotDen = wnd->m_structBDTTable.fShotDen[j];
					structTemp.fShotDepth = wnd->m_structTTPShotPara[i].fShotDepth;
					sprintf(structTemp.strModel,"%s",wnd->m_structTTPShotPara[i].strModel);
					if(structTemp.fProPer == 120)
						structTemp.fProPer = fTemp;
					else if(structTemp.fProPer == 90)
						structTemp.fProPer = (float)(fTemp/0.95);
					else if(structTemp.fProPer == 60)
						structTemp.fProPer = (float)(fTemp/0.93);
					else if(structTemp.fProPer == 180)
						structTemp.fProPer = (float)(fTemp/0.75);
					else if(structTemp.fProPer == 0)
						structTemp.fProPer = (float)(fTemp/0.62);
					else
						structTemp.fProPer = (float)(fTemp/0.91);

					 ks = wnd->m_structShotParaSelect[lCount].fShotDepth;
					 kj = wnd->m_structShotParaSelect[lCount].fDiameter;
					 km = wnd->m_structShotParaSelect[lCount].fShotDen;
					 xw = wnd->m_structShotParaSelect[lCount].fAngle;
					 yh = wnd->m_structSDT[j].fPressDeep ;
					 yc = wnd->m_structSDT[j].fPressLong ;
					 xwt = xw;
					if(xw==0) xwt = (float)360;
					 f1 = (float)(360*1000/(xwt*km));
					 r = (float)((d0-2*delta)/2);
					fTemp = (float)(1+(kj*1.48/(f1-kj*1.48))*(90/(3.141593*xwt))
						*(2*kj/r+sin(2*kj/r)));
					structTemp.fPara = (float)(1/fTemp);

					for(nTemp2=0;nTemp2<lCount;nTemp2++)
					{
						if(structTemp.fProPer<wnd->m_structShotParaSelect[nTemp2].fProPer)
							swap(structTemp,wnd->m_structShotParaSelect[nTemp2]);
					}
					continue;
				}
				wnd->m_structShotParaSelect[lCount].fAngle = wnd->m_structBDTTable.fShotPhasic[nTemp1];
				wnd->m_structShotParaSelect[lCount].fDiameter = wnd->m_structTTPShotPara[i].fDiameter;
				wnd->m_structShotParaSelect[lCount].fShotDen = wnd->m_structBDTTable.fShotDen[j];
				wnd->m_structShotParaSelect[lCount].fShotDepth = wnd->m_structTTPShotPara[i].fShotDepth;
				sprintf(wnd->m_structShotParaSelect[lCount].strModel,"%s",wnd->m_structTTPShotPara[i].strModel);
				if(wnd->m_structShotParaSelect[lCount].fAngle == 120)
					wnd->m_structShotParaSelect[lCount].fProPer = fTemp;
				else if(wnd->m_structShotParaSelect[lCount].fAngle == 90)
					wnd->m_structShotParaSelect[lCount].fProPer = (float)(fTemp/0.95);
				else if(wnd->m_structShotParaSelect[lCount].fAngle == 60)
					wnd->m_structShotParaSelect[lCount].fProPer = (float)(fTemp/0.93);
				else if(wnd->m_structShotParaSelect[lCount].fAngle == 180)
					wnd->m_structShotParaSelect[lCount].fProPer = (float)(fTemp/0.75);
				else if(wnd->m_structShotParaSelect[lCount].fAngle == 0)
					wnd->m_structShotParaSelect[lCount].fProPer = (float)(fTemp/0.62);
				else
					wnd->m_structShotParaSelect[lCount].fProPer = (float)(fTemp/0.91);

				 ks = wnd->m_structShotParaSelect[lCount].fShotDepth;
				 kj = wnd->m_structShotParaSelect[lCount].fDiameter;
				 km = wnd->m_structShotParaSelect[lCount].fShotDen;
				 xw = wnd->m_structShotParaSelect[lCount].fAngle;
				 yh = wnd->m_structSDT[j].fPressDeep ;
				 yc = wnd->m_structSDT[j].fPressLong ;
				 xwt = xw;
				if(xw==0) xwt = (float)360;
				 f1 = (float)(360*1000/(xwt*km));
				 r = (float)((d0-2*delta)/2);
				fTemp = (float)(1+(kj*1.48/(f1-kj*1.48))*(90/(3.141593*xwt))
					*(2*kj/r+sin(2*kj/r)));
				wnd->m_structShotParaSelect[lCount].fPara = (float)(1/fTemp);

				for(nTemp2=0;nTemp2<lCount;nTemp2++)
				{
					if(wnd->m_structShotParaSelect[lCount].fProPer<wnd->m_structShotParaSelect[nTemp2].fProPer)
					{
						swap(wnd->m_structShotParaSelect[lCount],wnd->m_structShotParaSelect[nTemp2]);
					}
				}
				lCount++;
			}
		}
	}	

	wnd->m_structSandPressDesign.fQ = m_fQOil;

	m_ctrlList.DeleteAllItems ();
	m_ctrlSelected.DeleteAllItems ();
	LVITEM pitem;
	pitem.mask=LVIF_TEXT;
	pitem.state=0;
	pitem.stateMask=0;
	pitem.iSubItem=0;
	pitem.pszText="";

	char strTemp[20];
	for(i=0;i<lCount;i++)
	{
		pitem.iItem=i;
		m_ctrlList.InsertItem (&pitem);
		sprintf(strTemp,"%d",i+1);
		m_ctrlList.SetItemText (i,0,strTemp);
		sprintf(strTemp,"%2.4f",wnd->m_structShotParaSelect[i].fProPer);
		m_ctrlList.SetItemText (i,1,strTemp);
		m_ctrlList.SetItemText (i,2,wnd->m_structShotParaSelect[i].strModel);
		sprintf(strTemp,"%4.1f",wnd->m_structShotParaSelect[i].fAngle);
		m_ctrlList.SetItemText (i,3,strTemp);
		sprintf(strTemp,"%4.0f",wnd->m_structShotParaSelect[i].fShotDen);
		m_ctrlList.SetItemText (i,4,strTemp);
		sprintf(strTemp,"%5.2f",wnd->m_structShotParaSelect[i].fShotDepth);
		m_ctrlList.SetItemText (i,5,strTemp);
		sprintf(strTemp,"%3.2f",wnd->m_structShotParaSelect[i].fDiameter);
		m_ctrlList.SetItemText (i,6,strTemp);
		fTemp = (float)((1-wnd->m_structShotParaSelect[i].fPara)*100);
		sprintf(strTemp,"%5.2f",fTemp);
		m_ctrlList.SetItemText (i,7,strTemp);
	}

	UpdateData(FALSE);

	wnd->m_bSelected = TRUE;
	wnd->m_structSelectedPara = wnd->m_structShotParaSelect[0];
	wnd->m_structShotParaBase.bState = TRUE;
	wnd->m_structShotParaBase.iNum = lCount;
	
}

#include "resource.h"
void COilSandDesign::OnContextMenu(CWnd*, CPoint point)
{
	// CG: This block was added by the Pop-up Menu component	{		if (point.x == -1 && point.y == -1){			//keystroke invocation			CRect rect;			GetClientRect(rect);			ClientToScreen(rect);			point = rect.TopLeft();			point.Offset(5, 5);		}		CMenu menu;		VERIFY(menu.LoadMenu(IDR_POPUP_SPD));		CMenu* pPopup = menu.GetSubMenu(4);		ASSERT(pPopup != NULL);		CWnd* pWndPopupOwner = this;		while (pWndPopupOwner->GetStyle() & WS_CHILD)			pWndPopupOwner = pWndPopupOwner->GetParent();		pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y,			pWndPopupOwner);	}
}

⌨️ 快捷键说明

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