Пример #1
0
//######################################## ReadFiles Function #########################################################
void ReadFiles(string runPath)
{
    //Reads in all the input files

    FileReader fileIn;                  //Create file reading objects
    dictBodies dictBod;                 //Create dictionary object for bodies.in
    dictForces dictForce;               //Create dictionary object for forces.in
    dictControl dictCont;               //Create dictionary object for control.in
    dictSeaEnv dictSea;                 //Create dictionary object for seaenv.in
    dictData dictDat(&fileIn);           //Create dictionary object for data.in
    dictOutputs dictOut;                //Create dictionary object for outputs.in

    try {
        //Create pointer to System object for each of the filereader objects
        fileIn.setSystem( &sysofreq);
        dictBod.setSystem( &sysofreq);
        dictForce.setSystem( &sysofreq);
        dictCont.setSystem( &sysofreq);
        dictSea.setSystem( &sysofreq);
        dictDat.setSystem( &sysofreq);
        dictOut.setSystem( &sysofreq);

        //Set path for file reading
        fileIn.setPath(runPath);

        //Read input files
        //Sequence of file reading is important.
        //Read control file.
        fileIn.setDictionary(dictCont);
        fileIn.readControl();       //Must be first.
        //Read sea environment file.
        fileIn.setDictionary(dictSea);
        fileIn.readSeaEnv();
        //Read user forces
        fileIn.setDictionary(dictForce);
        fileIn.readForces();        //Must come before reading Bodies
        //Read Bodies
        fileIn.setDictionary(dictBod);
        fileIn.readBodies();        //Must come after reading forces.
        //Read hydrodynamic data
        fileIn.setDictionary(dictDat);
        fileIn.readData();
        //Read in output controls
        fileIn.setDictionary(dictOut);
        fileIn.readOutputs();

        //At the end, force system to check one last time for the active sea model.
        sysofreq.SearchActiveSeaModel();

        //Write output to screen.
        sysofreq.logStd.Write("Hydrodynamic Input Files",3);
        sysofreq.logStd.Write("-----------------------------",3);

        //So far, input files only specified the location of the hydrodynamic data.  Now need to actually  read it.
        HydroReader hydroIn;            //Create hydroreader.
        hydroIn.setSystem( &sysofreq);

        if (fileIn.listDataFiles().size() > 0)
        {
            for (unsigned int i = 0; i < fileIn.listDataFiles().size(); i++)
            {
                //Iterate through each of the items on the list of hydro files and read them.
                hydroIn.setPath(fileIn.listDataFiles(i));           //Set the path to the hydro system.
                hydroIn.readHydroSys();
            }
        }
    }
    catch(const std::exception &err)
    {
        sysofreq.logStd.Notify();
        sysofreq.logErr.Write(ID + std::string(err.what()));
    }
}