Tutorial 1g – Limit-state function evaluated with external application
In this tutorial we use an external application to evaluate the limit-state function.
The external application expects an input-file that contains the current realizations of the random variables,
and writes the result of the limit-state function to a text-file.
This tutorial is based on Tutorial 1b.
Please perform Tutorial 1b before you start with this tutorial.
The code given in this tutorial (Tutorial 1g) replaces the code given in Section 1.3 of Tutorial 1b.
The code given in Sections 1.1 and 1.2 of Tutorial 1b precedes all code given in this tutorial (Tutorial 1g);
and the code given in Section 1.4 of Tutorial 1b succeedes all code given in this tutorial (Tutorial 1g).
Table of Contents
1 Step by Step Instruction
1.1 Create the external application
In this tutorial we use an external application written in C++ that has source code:
C++-file main.cpp
#include <iostream>
#include <fstream>
int main(int argc, char **argv) {
std::ifstream ifile("tutorial_1g_input.dat");
double res(-60.);
double a;
while (ifile >> a)
{
res += a;
}
std::ofstream ofile("tutorial_1g_output.dat");
ofile << res;
return 0;
}
#include <fstream>
int main(int argc, char **argv) {
std::ifstream ifile("tutorial_1g_input.dat");
double res(-60.);
double a;
while (ifile >> a)
{
res += a;
}
std::ofstream ofile("tutorial_1g_output.dat");
ofile << res;
return 0;
}
If you want to compile the application by yourself, name the final executable tutorial_1g_extapp.
Alternatively, pre-build are available for download (see download-link at bottom of this page).
The application expects as input a file named tutorial_1g_input.dat and writes the result of the limit-state evaluation to a file named tutorial_1g_output.dat.
The application expects as input a file named tutorial_1g_input.dat and writes the result of the limit-state evaluation to a file named tutorial_1g_output.dat.
1.2 Fesslix parameter file
The limit-state function that employs the external application tutorial_1g_extapp can be stated as follows:
Fesslix parameter file
var lsf = objexec(:res,{
# assign current realizations to vector 'tmpx'
rbrv_vec_get x: tmpx = "RVS";
# write vector 'tmpx' to file
filestream fs ("tutorial_1g_input.dat");
sfor (i;N) {
funplot mtxcoeff(tmpx,i-1) { stream=fs; };
};
ostream_close fs;
# execute external application
if (is_win) {
run_external "tutorial_1g_extapp.exe";
} else {
run_external "./tutorial_1g_extapp";
};
# read result from file
ifstream is ( "tutorial_1g_output.dat" );
const res = isread(is);
});
# assign current realizations to vector 'tmpx'
rbrv_vec_get x: tmpx = "RVS";
# write vector 'tmpx' to file
filestream fs ("tutorial_1g_input.dat");
sfor (i;N) {
funplot mtxcoeff(tmpx,i-1) { stream=fs; };
};
ostream_close fs;
# execute external application
if (is_win) {
run_external "tutorial_1g_extapp.exe";
} else {
run_external "./tutorial_1g_extapp";
};
# read result from file
ifstream is ( "tutorial_1g_output.dat" );
const res = isread(is);
});