Exemplo n.º 1
0
    openfluid::base::SchedulingRequest runStep()
    {
      if (m_PartStr == "runstep")
        OPENFLUID_RaiseError(m_PartStr);

      return DefaultDeltaT();
    }
Exemplo n.º 2
0
    openfluid::base::SchedulingRequest initializeRun()
    {
      if (m_PartStr == "initializerun")
        OPENFLUID_RaiseError(m_PartStr);

      return DefaultDeltaT();
    }
Exemplo n.º 3
0
openfluid::base::SchedulingRequest ToolsSimulator::initializeRun()
{

  openfluid::tools::ColumnTextParser CTParser("#");
  std::string InputDir;
  double DoubleValue;
  std::string StrValue;

  OPENFLUID_GetRunEnvironment("dir.input",InputDir);
  std::string FileName = InputDir + "/" + "columnfile.txt";

  if (openfluid::tools::Filesystem::isFile(FileName))
  {
    CTParser.loadFromFile(FileName);

    if (CTParser.getColsCount() != 5)
      OPENFLUID_RaiseError("wrong columns number in " + FileName);

    if (!CTParser.getDoubleValue(2,1,&DoubleValue))
      OPENFLUID_RaiseError("error reading double value (3,2) in " + FileName);

    if (!openfluid::scientific::isVeryClose(DoubleValue,1.2))
      OPENFLUID_RaiseError("wrong double value for (3,2) in " + FileName);

    if (!CTParser.getStringValue(0,0,&StrValue))
      OPENFLUID_RaiseError("error reading string value (0,0) in " + FileName);

    if (StrValue != "5")
      OPENFLUID_RaiseError("wrong string value for (0,0) in " + FileName);


    if (CTParser.getStringValue(5,5,&StrValue))
      OPENFLUID_RaiseError("error : found value out of range (5,5) in " + FileName);
  }
  else OPENFLUID_RaiseError("file " + FileName + " not found!");

  return DefaultDeltaT();
}
Exemplo n.º 4
0
  openfluid::base::SchedulingRequest runStep()
  {

    return DefaultDeltaT();
  }
Exemplo n.º 5
0
  openfluid::base::SchedulingRequest initializeRun()
  {

    return DefaultDeltaT();
  }
Exemplo n.º 6
0
  openfluid::base::SchedulingRequest runStep()
  {

    openfluid::core::SpatialUnit* CurrentUnit;
    const openfluid::core::UnitsListByClassMap_t* UnitsByClass;
    const openfluid::core::UnitsList_t* UnitsList;
    const openfluid::core::UnitsPtrList_t* ToUnitsPtrList;
    const openfluid::core::UnitsPtrList_t* FromUnitsPtrList;
    std::vector<openfluid::core::UnitsClass_t> ClassVector;

    openfluid::core::UnitsListByClassMap_t::const_iterator itUnitsClass;
    openfluid::core::UnitsList_t::const_iterator itUnitsList;
    openfluid::core::UnitsPtrList_t::const_iterator itToUnitsPtrList;
    openfluid::core::UnitsPtrList_t::const_iterator itFromUnitsPtrList;


    UnitsByClass = const_cast<openfluid::core::UnitsListByClassMap_t*>(mp_SpatialData->allSpatialUnitsByClass());
/*
    std::cout << std::endl;
    std::cout.flush();
*/
    for (itUnitsClass=UnitsByClass->begin();itUnitsClass!=UnitsByClass->end();++itUnitsClass)
    {
      ClassVector.push_back((*itUnitsClass).first);
    }

    // To List
/*    std::cout << " -------  To  ------- " << std::endl;
    std::cout.flush();*/

    for (itUnitsClass=UnitsByClass->begin();itUnitsClass!=UnitsByClass->end();++itUnitsClass)
    {

      UnitsList = const_cast<openfluid::core::UnitsList_t*>(((*itUnitsClass).second).list());

      for (itUnitsList=UnitsList->begin();itUnitsList!=UnitsList->end();++itUnitsList)
      {
        CurrentUnit = const_cast<openfluid::core::SpatialUnit*>(&(*itUnitsList));

        // std::string SrcClassStr = CurrentUnit->getClass();
        std::string SrcIDStr = "";
        openfluid::tools::convertValue(CurrentUnit->getID(),&SrcIDStr);

        for (unsigned int i=0;i<ClassVector.size();i++)
        {
          ToUnitsPtrList = const_cast<openfluid::core::UnitsPtrList_t*>(CurrentUnit->toSpatialUnits(ClassVector[i]));

          if (ToUnitsPtrList != nullptr)
          {
            // std::string DestClassStr = ClassVector[i];

            for (itToUnitsPtrList=ToUnitsPtrList->begin();itToUnitsPtrList!=ToUnitsPtrList->end();++itToUnitsPtrList)
            {
              std::string DestIDStr = "";
              openfluid::tools::convertValue((*itToUnitsPtrList)->getID(),&DestIDStr);
/*              std::cout << SrcClassStr << "#" << SrcIDStr << " --> "<< DestClassStr << "#" << DestIDStr << std::endl;
              std::cout.flush();*/
            }
          }
        }
      }
    }

    // From List
/*    std::cout << " -------  From  ------- " << std::endl;
    std::cout.flush();*/

    for (itUnitsClass=UnitsByClass->begin();itUnitsClass!=UnitsByClass->end();++itUnitsClass)
    {

      UnitsList = const_cast<openfluid::core::UnitsList_t*>(((*itUnitsClass).second).list());

      for (itUnitsList=UnitsList->begin();itUnitsList!=UnitsList->end();++itUnitsList)
      {
        CurrentUnit = const_cast<openfluid::core::SpatialUnit*>(&(*itUnitsList));

        // std::string SrcClassStr = CurrentUnit->getClass();
        std::string SrcIDStr = "";
        openfluid::tools::convertValue(CurrentUnit->getID(),&SrcIDStr);

        for (unsigned int i=0;i<ClassVector.size();i++)
        {
          FromUnitsPtrList =
              const_cast<openfluid::core::UnitsPtrList_t*>(CurrentUnit->fromSpatialUnits(ClassVector[i]));

          if (FromUnitsPtrList != nullptr)
          {
            // std::string DestClassStr = ClassVector[i];

            for (itFromUnitsPtrList=FromUnitsPtrList->begin();
                 itFromUnitsPtrList!=FromUnitsPtrList->end();
                 ++itFromUnitsPtrList)
            {
              std::string DestIDStr = "";
              openfluid::tools::convertValue((*itFromUnitsPtrList)->getID(),&DestIDStr);
/*              std::cout << SrcClassStr << "#" << SrcIDStr << " <-- "<< DestClassStr << "#" << DestIDStr << std::endl;
              std::cout.flush();*/
            }
          }
        }
      }


    }


    return DefaultDeltaT();
  }
Exemplo n.º 7
0
 openfluid::base::SchedulingRequest runStep()
 { std::cout << "sim.a " << OPENFLUID_GetCurrentTimeIndex() << std::endl; return DefaultDeltaT(); }
Exemplo n.º 8
0
    openfluid::base::SchedulingRequest runStep()
    {
      int i,j;

      // ====== double ======

      double DValue, DMult, DResult;
      DValue = 1.5436;
      DMult = 2.5;
      DResult = 0.0;

      CALL_FMODSUBROUTINE(testmodule,multrealvalue)(&DValue,&DMult,&DResult);

      if (std::abs(DResult - (DValue*DMult)) > m_Precision)
        OPENFLUID_RaiseError("incorrect fortran call (multrealvalue)");


      // ====== int ======

      int IValue, IMult, IResult;
      IValue = 45;
      IMult = 18;
      IResult = 0;

      CALL_FMODSUBROUTINE(testmodule,multintvalue)(&IValue,&IMult,&IResult);

      if (IResult != (IValue*IMult))
        OPENFLUID_RaiseError("incorrect fortran call (multintvalue)");


      // ====== string ======

      // TODO finish this
      /*  std::string SStr1, SStr2, SResult;
  char* CResult;
  SStr1 = "Hello";
  SStr2 = "from fortran";

  CALL_FSUBROUTINE(catstrings)(STD2FSTRING(SStr1),STD2FSTRING(SStr2),CResult);

  SResult = std::string(CResult);

  if (SResult != (SStr1 + " " + SStr2))
    OPENFLUID_RaiseError("tests.fortran","incorrect fortran call (catstrings)");
       */


      // ====== matrix ======

      int MDim1,MDim2;
      double MMult;
      openfluid::core::MatrixValue MValue;
      openfluid::core::MatrixValue MResult;
      double* MTmpResult;

      MDim1 = 3;
      MDim2 = 5;

      MMult = 2.18;

      MValue = openfluid::core::MatrixValue(MDim1,MDim2);

      MTmpResult = new double[MDim1*MDim2];

      for (j=0; j < MDim2;j++)
        for (i=0; i < MDim1;i++)
          MValue.setElement(i,j,(j*MDim1)+i+1);

      std::cout << std::endl;



      std::cout << "MValue:"<< std::endl;
      for (j=0; j < MDim2;j++)
      {
        for (i=0; i < MDim1;i++)
        {
          std::cout << MValue.getElement(i,j) << " ";
        }
        std::cout << std::endl;
      }

      MResult.fill(0.0);

      CALL_FMODSUBROUTINE(testmodule,multrealmatrix)(MValue.data(),&MDim1,&MDim2,&MMult,MTmpResult);

      MResult = openfluid::core::MatrixValue(MDim1,MDim2);
      MResult.setData(MTmpResult,MDim1,MDim2);

      std::cout << "MTmpResult:"<< std::endl;
      for (j=0; j < MDim2;j++)
      {
        for (i=0; i < MDim1;i++)
        {
          std::cout << MTmpResult[i+(j*MDim1)] << " ";
        }
        std::cout << std::endl;
      }


      std::cout << "MResult:"<< std::endl;
      for (j=0; j < MDim2;j++)
      {
        for (i=0; i < MDim1;i++)
        {
          std::cout << MResult.getElement(i,j) << " ";
        }
        std::cout << std::endl;
      }


      std::cout << std::endl;


      for (j=0; j < MDim2;j++)
      {
        for (i=0; i < MDim1;i++)
        {
          //      std::cout << MResult.get(i,j) << "  " << (MValue.get(i,j) * MMult) << std::endl;
          if (std::abs(MResult.get(i,j) - (MValue.get(i,j) * MMult)) > m_Precision)
            OPENFLUID_RaiseError("incorrect fortran call (multrealmatrix)");
        }
      }

      delete[] MTmpResult;

      return DefaultDeltaT();
    }