Skip to content

Commit

Permalink
Merge pull request #82 from yisangriB/master
Browse files Browse the repository at this point in the history
sy - fixing bugs related to FEM engines (openseespy and surrogateGP)
  • Loading branch information
fmckenna authored Jul 25, 2022
2 parents 8ed6172 + 1264701 commit 1748272
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 17 deletions.
40 changes: 25 additions & 15 deletions FEM/OpenSeesPyFEM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ OpenSeesPyFEM::outputAppDataToJSON(QJsonObject &jsonObject) {

if (fileInfo2.exists() && fileInfo2.isFile()) {
dataObj["parametersScript"]=fileInfo2.fileName();
dataObj["PS_Path"]=fileInfo1.path();
dataObj["PA_Path"]=fileInfo2.path();
} else {
if (fileName2.isEmpty())
dataObj["parametersScript"]=QString("");
Expand Down Expand Up @@ -253,6 +253,8 @@ OpenSeesPyFEM::inputAppDataFromJSON(QJsonObject &jsonObject) {
QString fileName;
QString filePath;

// Main ==

if (dataObject.contains("mainScript")) {
QJsonValue theName = dataObject["mainScript"];
fileName = theName.toString();
Expand All @@ -267,31 +269,39 @@ OpenSeesPyFEM::inputAppDataFromJSON(QJsonObject &jsonObject) {

inputScript->setText(QDir(filePath).filePath(fileName));

// Post ==

if (dataObject.contains("postprocessScript")) {
QJsonValue theName = dataObject["postprocessScript"];
fileName = theName.toString();

if (dataObject.contains("PS_Path")) {
QJsonValue theName = dataObject["PS_Path"];
filePath = theName.toString();
postprocessScript->setText(QDir(filePath).filePath(fileName));
} else
postprocessScript->setText(fileName);
} else
QJsonValue theName = dataObject["PS_Path"];
filePath = theName.toString();
postprocessScript->setText(QDir(filePath).filePath(fileName));
} else {
postprocessScript->setText(fileName);
}
} else {
postprocessScript->setText("");
}

// Params ==

if (dataObject.contains("parametersScript")) {
QJsonValue theName = dataObject["parametersScript"];
fileName = theName.toString();

if (dataObject.contains("PA_Path")) {
QJsonValue theName = dataObject["PA_Path"];
filePath = theName.toString();
parametersScript->setText(QDir(filePath).filePath(fileName));
} else
parametersScript->setText(fileName);
} else
parametersScript->setText("");
QJsonValue theName = dataObject["PA_Path"];
filePath = theName.toString();
parametersScript->setText(QDir(filePath).filePath(fileName));
} else {
parametersScript->setText(fileName);
}
} else {
parametersScript->setText("");
}

} else
return false;
Expand Down
6 changes: 5 additions & 1 deletion FEM/surrogateGpFEM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ surrogateGpFEM::surrogateGpFEM(QWidget *parent)

QLabel *label2 = new QLabel("SurrogateGP Model (.pkl)");
postprocessScript = new QLineEdit;
postprocessScript->setPlaceholderText("(Optional)");
postprocessScript->setPlaceholderText("");
QPushButton *choosePostprocessScript = new QPushButton();
choosePostprocessScript->setText(tr("Choose"));
connect(choosePostprocessScript, &QPushButton::clicked, this, [this](){
Expand Down Expand Up @@ -134,8 +134,10 @@ surrogateGpFEM::surrogateGpFEM(QWidget *parent)
QHBoxLayout * gpOutputLayout = new QHBoxLayout();
gpOutputComboBox= new QComboBox;
gpOutputComboBox->addItem("Median (representative) prediction");
//gpOutputComboBox->addItem("Random sample under prediction uncertainty");
gpOutputLayout->addWidget( new QLabel("GP output "));
gpOutputLayout->addWidget(gpOutputComboBox);
gpOutputComboBox->setMinimumWidth(400);
gpOutputLayout->addStretch(1);

connect(option3Button, &QRadioButton::toggled, this, [=](bool tog){
Expand Down Expand Up @@ -398,6 +400,8 @@ surrogateGpFEM::showGpOptions(QString name1) {
if (file.open(QFile::ReadOnly | QFile::Text)) {
QString val;
val=file.readAll();
val.replace(QString("NaN"),QString("null"));
val.replace(QString("Infinity"),QString("inf"));
QJsonDocument doc = QJsonDocument::fromJson(val.toUtf8());
QJsonObject jsonSur = doc.object();
file.close();
Expand Down
6 changes: 5 additions & 1 deletion FEM/surrogateGpParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,13 @@ surrogateGpParser::getVariables(QString inFilename)
if (file.open(QFile::ReadOnly | QFile::Text)) {
QString val;
val=file.readAll();
file.close();
val.replace(QString("NaN"),QString("null"));
val.replace(QString("Infinity"),QString("inf"));

QJsonDocument doc = QJsonDocument::fromJson(val.toUtf8());
QJsonObject jsonSur = doc.object();
file.close();


auto GPidentifier = jsonSur.find("kernName"); // should be the right .json file
if (!jsonSur.isEmpty() && GPidentifier != jsonSur.end()) {
Expand Down

0 comments on commit 1748272

Please sign in to comment.