Hello Carlos,
here the code of the plugin. The code is placed in the callback section of the IFM structure.
#include "stdifm.h"
#include "IFM Plug-in1.h"
#include <ifm/document.h>
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
IfmModule g_pMod; /* Global handle related to this plugin */
#pragma region IFM_Definitions
/* --- IFMREG_BEGIN --- */
/* -- Do not edit! -- */
static void PreEnterSimulator (IfmDocument);
/*
* Enter a short description between the quotation marks in the following lines:
*/
static const char szDesc[] =
"Please, insert a plug-in description here!";
#ifdef __cplusplus
extern "C"
#endif /* __cplusplus */
IfmResult RegisterModule(IfmModule pMod)
{
if (IfmGetFeflowVersion (pMod) < IFM_REQUIRED_VERSION)
return False;
g_pMod = pMod;
IfmRegisterModule (pMod, "SIMULATION", "IFM_PLUG_IN1", "IFM Plug-in1", 0x1000);
IfmSetDescriptionString (pMod, szDesc);
IfmSetCopyrightPath (pMod, "IFM Plug-in1.txt");
IfmSetHtmlPage (pMod, "IFM Plug-in1.htm");
IfmSetPrimarySource (pMod, "IFM Plug-in1.cpp");
IfmRegisterProc (pMod, "PreEnterSimulator", 1, (IfmProc)PreEnterSimulator);
return True;
}
static void PreEnterSimulator (IfmDocument pDoc)
{
CIfmPlugIn1::FromHandle(pDoc)->PreEnterSimulator (pDoc);
}
/* --- IFMREG_END --- */
#pragma endregion
///////////////////////////////////////////////////////////////////////////
// Implementation of CIfmPlugIn1
// Constructor
CIfmPlugIn1::CIfmPlugIn1 (IfmDocument pDoc)
: m_pDoc(pDoc)
{
/*
* TODO: Add your own code here ...
*/
}
// Destructor
CIfmPlugIn1::~CIfmPlugIn1 ()
{
/*
* TODO: Add your own code here ...
*/
}
// Obtaining class instance from document handle
CIfmPlugIn1* CIfmPlugIn1::FromHandle (IfmDocument pDoc)
{
return reinterpret_cast<CIfmPlugIn1*>(IfmDocumentGetUserData(pDoc));
}
// Callbacks
void CIfmPlugIn1::PreEnterSimulator (IfmDocument pDoc)
// Reading number of Elements
{ int maxElement = IfmGetNumberOfElements(pDoc);
//Reading the values
double tab [5]={ 0.000, 0.000, 0.000, 0.000};
string colA;
double colB;
int i=0;
ifstream inputFile("C:\\PEST\\Basis_225_181_2L_simple_unsat_cal\\ifm.fpi");
if (inputFile.is_open())
{
while ((!inputFile.eof())&&(i<5))
{
inputFile>>colA;
inputFile>>colB;
tab[i]=colB;
i++;
}
inputFile.close();
}
double Value_s_s=tab [0];
double Value_s_r=tab [1];
double Value_alpha=tab [2];
double Value_n=tab [3];
//Writing values to file
ofstream myfile;
myfile.open ("C:\\PEST\\Basis_225_181_2L_simple_unsat_cal\\example.txt");
myfile << tab[0] << tab[1] << tab[2] << tab[3];
myfile.close();
//Assigning the values
for (int nElement=0;nElement < maxElement;nElement++)
{
IfmSetMatUnsatFittingCoefficient(pDoc,nElement,Value_alpha);
IfmSetMatUnsatFittingExponent(pDoc,nElement,Value_n);
IfmSetMatUnsatMaximumSaturation(pDoc,nElement,Value_s_s);
IfmSetMatUnsatResidualSaturation(pDoc,nElement,Value_s_r);
}
}
//Ludwig