khartmansjsu / MOC-Linux

repository for the re-design of Tharen Rice's Microsoft Visual C++ MOC package
Other
0 stars 0 forks source link

Implementing Standalone call to CreateMOCGrid() #3

Open khartmansjsu opened 2 years ago

khartmansjsu commented 2 years ago

MOC_GridDlg.cpp has a method called CMOC_GridDlg::OnCalcMOCBUTTOM(). This method is printed below for reference.

void CMOC_GridDlg::OnCalcMOCBUTTON()
{
        int flag = 0;
        m_STTRun_BUTTON.EnableWindow(0);
        //      This is the function that starts the whole calculation process
        MOC_GridCalc *moc = new MOC_GridCalc;
        UpdateData(TRUE);
        m_CalcMOC_BUTTON.EnableWindow(0);
        if(moc->SetInitialProperties( m_pres_i, m_temp_i,  m_molWt_i,
                 m_gamma_i,  m_pAmb,  m_nC,  m_RWTU,  m_RWTD,  m_dTLimit, m_nRRCAboveBD,
                 m_nSLi, m_nSLj, m_vel, m_throat_CHECK.GetCheck(), m_ispIdeal));

        else
        {
                AfxMessageBox("Could not set properties");
                exit(1);
        }

        //      Set the design variable, designValues[0] and [1] to the correct values depending on the
        //      designParamtype

        if ( designParam == EXITMACH) designValues[0] = m_mDesign;
        else if ( designParam == EPS) designValues[0] = m_eps;
        else if ( designParam == NOZZLELENGTH) designValues[0] = m_length;
        else if ( designParam == EXITPRESSURE) designValues[0] = m_pExit;

        if ( nozzleType == FIXEDEND)
        {
                designParam = ENDPOINT;
                designValues[0] = m_xE;
                designValues[1] = m_rE;
        }
        else if (nozzleType == CONE) designValues[1] = m_coneAngle;

        moc->SetSolutionParameters(  nozzleGeom,  nozzleType ,  designParam,  designValues[0],
                         designValues[1], m_thetaBi);
        moc->SetPrintMode(m_print_COMBO.GetCurSel());
        flag = moc->CreateMOCGrid();

        m_CalcMOC_BUTTON.EnableWindow(1);

        if (flag && m_print_COMBO.GetCurSel()) m_STTRun_BUTTON.EnableWindow(1);
        delete moc;
        return;
}

In this issue, I will document my progress on making a "main" function which will call the CreateMOCGrid method in linux, and produce the same output files which are generated in normal operation.

khartmansjsu commented 2 years ago

After some changes to the main file, excluding unnecessary logic and value updates, I have many calls to Chart.h from MOC_GridCalc_BDE.h, the latter being included in main so that a pointer to a MOC_GridCalc object class could be made. I want to remove the dependencies of MOC_GridCalc_BDE.h on Chart.h, because Chart.h does not have any functionality which is necessary for the calculation of the MOC grid.

How to do this?

Method:

First, comment out the include statement of Chart.h on line 34 of MOC_GridCalc_BDE.h and try to compile the main code again. This will generate complaints from within MOC_GridCalc_BDE.h that some things are being used which are not declared. These will be references to stuff in Chart.h. Currently, the only two compile time errors being thrown from MOC_GridCalc_BDE.h are missing declarations of "CString," which is because MFC header file afx.h is commented out.

Once we identify the calls to methods declared in Chart.h, comment those out and proceed.

Result: Commenting out Chart.h actually generated no extra compile-time errors.

Action: identify two uses of CString in MOC_GridCalc_BDE.h and characterize them as removable or not. If they can be removed, do so and recompile.

Result: CString type is used in two void type methods of MOC_GridCalc object class: OutputCenterlineData() and OutputJ. Both of these methods are declared in MOC_GridCalc_BDE.h, and though they are called in MOC_GridCalc_BDE.cpp, they are not defined there. Rather, they are defined in MOC_GridCalc_BDE_IO.cpp. It seems that the original developer likes to use CString types for strings. This will have to change, and I will use a standard type for declaring strings.

khartmansjsu commented 2 years ago

Fixing the following compile-time errors...

[khartm12@integrity MOC_Grid_BDE]$ g++ main_CreateMOCGrid.cpp -o main_CreateMOCGrid
main_CreateMOCGrid.cpp: In function ‘int main()’:
main_CreateMOCGrid.cpp:65:26: error: ‘m_throat_CHECK’ was not declared in this scope
   65 |   m_nSLi, m_nSLj, m_vel, m_throat_CHECK.GetCheck(), m_ispIdeal));
      |                          ^~~~~~~~~~~~~~
main_CreateMOCGrid.cpp:76:6: error: ‘designParam’ was not declared in this scope
   76 | if ( designParam == EXITMACH) designValues[0] = m_mDesign;
      |      ^~~~~~~~~~~
main_CreateMOCGrid.cpp:76:31: error: ‘designValues’ was not declared in this scope
   76 | if ( designParam == EXITMACH) designValues[0] = m_mDesign;
      |                               ^~~~~~~~~~~~
main_CreateMOCGrid.cpp:77:31: error: ‘designValues’ was not declared in this scope
   77 | else if ( designParam == EPS) designValues[0] = m_eps;
      |                               ^~~~~~~~~~~~
main_CreateMOCGrid.cpp:78:40: error: ‘designValues’ was not declared in this scope
   78 | else if ( designParam == NOZZLELENGTH) designValues[0] = m_length;
      |                                        ^~~~~~~~~~~~
main_CreateMOCGrid.cpp:79:40: error: ‘designValues’ was not declared in this scope
   79 | else if ( designParam == EXITPRESSURE) designValues[0] = m_pExit;
      |                                        ^~~~~~~~~~~~
main_CreateMOCGrid.cpp:81:17: error: expected unqualified-id before ‘==’ token
   81 | if ( nozzleType == FIXEDEND)
      |                 ^~
main_CreateMOCGrid.cpp:83:2: error: ‘designParam’ was not declared in this scope
   83 |  designParam = ENDPOINT;
      |  ^~~~~~~~~~~
main_CreateMOCGrid.cpp:84:2: error: ‘designValues’ was not declared in this scope
   84 |  designValues[0] = m_xE;
      |  ^~~~~~~~~~~~
main_CreateMOCGrid.cpp:87:21: error: expected unqualified-id before ‘==’ token
   87 | else if (nozzleType == CONE) designValues[1] = m_coneAngle;
      |                     ^~
main_CreateMOCGrid.cpp:87:30: error: ‘designValues’ was not declared in this scope
   87 | else if (nozzleType == CONE) designValues[1] = m_coneAngle;
      |                              ^~~~~~~~~~~~
main_CreateMOCGrid.cpp:89:40: error: expected primary-expression before ‘,’ token
   89 | moc->SetSolutionParameters(  nozzleGeom,  nozzleType ,  designParam,  designValues[0],
      |                                        ^
main_CreateMOCGrid.cpp:89:54: error: expected primary-expression before ‘,’ token
   89 | moc->SetSolutionParameters(  nozzleGeom,  nozzleType ,  designParam,  designValues[0],
      |                                                      ^
main_CreateMOCGrid.cpp:89:57: error: ‘designParam’ was not declared in this scope
   89 | moc->SetSolutionParameters(  nozzleGeom,  nozzleType ,  designParam,  designValues[0],
      |                                                         ^~~~~~~~~~~
main_CreateMOCGrid.cpp:89:71: error: ‘designValues’ was not declared in this scope
   89 | moc->SetSolutionParameters(  nozzleGeom,  nozzleType ,  designParam,  designValues[0],
      |                                                                       ^~~~~~~~~~~~
main_CreateMOCGrid.cpp:91:19: error: ‘m_print_COMBO’ was not declared in this scope
   91 | moc->SetPrintMode(m_print_COMBO.GetCurSel());
      |                   ^~~~~~~~~~~~~

m_threat_CHECK not declared

Results of search for this variable in other sections of the current directory

[khartm12@integrity MOC_Grid_BDE]$ grep -nrw './' -e 'm_throat_CHECK'
./MOC_GridDlg.h:35: CButton m_throat_CHECK;
./main_CreateMOCGrid.cpp:65:     m_nSLi, m_nSLj, m_vel, m_throat_CHECK.GetCheck(), m_ispIdeal));
./MOC_GridDlg.cpp:126:  DDX_Control(pDX, IDC_throat_CHECK, m_throat_CHECK);
./MOC_GridDlg.cpp:513:       m_nSLi, m_nSLj, m_vel, m_throat_CHECK.GetCheck(), m_ispIdeal));
./MOC_GridDlg.cpp:552:  if(m_throat_CHECK.GetCheck()) m_vel_EDIT.EnableWindow(1);
./MOC_GridDlg.cpp:599:      m_throat_CHECK.SetCheck(a);
./MOC_GridDlg.cpp:628:      ofile    << m_throat_CHECK.GetCheck()   << "\t" <<  m_perfect_RADIO.GetCheck()
./MOC_GridDlg.cpp:656:      ofile    << m_throat_CHECK.GetCheck()   << "\t" <<  m_perfect_RADIO.GetCheck()
[khartm12@integrity MOC_Grid_BDE]$ vi main_CreateMOCGrid.cpp