Skip to content

Commit

Permalink
Merge pull request #119 from JustinBonus/master
Browse files Browse the repository at this point in the history
Update HydroUQ EDPs, StochasticWave EVT, Local Workflow, and start Example for StochasticWave Local Workflow
  • Loading branch information
fmckenna authored May 29, 2024
2 parents d940324 + bd87ae4 commit e8756b9
Show file tree
Hide file tree
Showing 62 changed files with 2,085 additions and 283 deletions.
76 changes: 43 additions & 33 deletions EDP/HydroEDP_Selection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
// Written: fmckenna
// Modified: JustinBonus

#include "HydroEDP_Selection.h"
#include "EDP/HydroEDP_Selection.h"

#include <QHBoxLayout>
#include <QVBoxLayout>
Expand All @@ -59,13 +59,18 @@ UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#include <QPushButton>
#include <SectionTitle.h>


// In SimCenterCommon and
#include <StandardWindEDP.h>
#include "EDP/StandardHydroEDP.h"
#include "EDP/StandardTsunamiEDP.h"
#include "EDP/StandardStormSurgeEDP.h"
#include <StandardEDP.h>
#include <StandardHydroEDP.h>
#include <StandardTsunamiEDP.h>
#include <StandardStormSurgeEDP.h>
#include <StandardWindEDP.h>
#include <StandardEarthquakeEDP.h>
#include <UserDefinedEDP.h>



HydroEDP_Selection::HydroEDP_Selection(QWidget *parent)
: SimCenterAppWidget(parent), theCurrentEDP(0)
{
Expand All @@ -81,19 +86,19 @@ HydroEDP_Selection::HydroEDP_Selection(QWidget *parent)
label->setMinimumWidth(250);

edpSelection = new QComboBox();
edpSelection->addItem(tr("Standard"));
edpSelection->addItem(tr("Standard Hydro"));
edpSelection->addItem(tr("Standard Tsunami"));
edpSelection->addItem(tr("Standard Storm Surge"));
edpSelection->addItem(tr("User Defined"));
edpSelection->addItem(tr("Standard"));
edpSelection->setObjectName("EDPSelectionComboBox");

// edpSelection->setItemData(1, "A Seismic event using Seismic Hazard Analysis and Record Selection/Scaling", Qt::ToolTipRole);
edpSelection->setItemData(0, "A general hydrodynamic event with measurement of common engineering demand parameters (EDPs).", Qt::ToolTipRole);
edpSelection->setItemData(1, "A tsunami event with measurement of established tsunami demand parameters (EDPs) for coastal structures (e.g. residential, commercial).", Qt::ToolTipRole);
edpSelection->setItemData(2, "A hurricane storm surge event with measurement of established hydrodynamic storm surge demand parameters (EDPs) for affected structures (e.g. residential, commercial).", Qt::ToolTipRole);
edpSelection->setItemData(3, "User-defined selection of engineering demand parameters (EDPs) for custom workflows.", Qt::ToolTipRole);
edpSelection->setItemData(4, "A general event with measurement of common (earthquake) engineering demand parameters (EDPs).", Qt::ToolTipRole);
edpSelection->setItemData(0, "A general event with measurement of common (i.e. earthquake related) engineering demand parameters (EDPs).", Qt::ToolTipRole);
edpSelection->setItemData(1, "A general hydrodynamic event with measurement of common engineering demand parameters (EDPs).", Qt::ToolTipRole);
edpSelection->setItemData(2, "A tsunami event with measurement of established tsunami demand parameters (EDPs) for coastal structures (e.g. residential, commercial).", Qt::ToolTipRole);
edpSelection->setItemData(3, "A hurricane storm surge event with measurement of established hydrodynamic storm surge demand parameters (EDPs) for affected structures (e.g. residential, commercial).", Qt::ToolTipRole);
edpSelection->setItemData(4, "User-defined selection of engineering demand parameters (EDPs) for custom workflows.", Qt::ToolTipRole);
theSelectionLayout->addWidget(label);
theSelectionLayout->addWidget(edpSelection);
theSelectionLayout->addStretch();
Expand All @@ -109,17 +114,17 @@ HydroEDP_Selection::HydroEDP_Selection(QWidget *parent)
// create the individual widgets add to stacked widget
//

theStandardEDPs = new StandardEDP();
theStandardHydroEDPs = new StandardHydroEDP();
theStandardTsunamiEDPs = new StandardTsunamiEDP();
theStandardStormSurgeEDPs = new StandardStormSurgeEDP();
theUserDefinedEDPs = new UserDefinedEDP();
theStandardEDPs = new StandardEDP();

theStackedWidget->addWidget(theStandardEDPs);
theStackedWidget->addWidget(theStandardHydroEDPs);
theStackedWidget->addWidget(theStandardTsunamiEDPs);
theStackedWidget->addWidget(theStandardStormSurgeEDPs);
theStackedWidget->addWidget(theUserDefinedEDPs);
theStackedWidget->addWidget(theStandardEDPs);
theStackedWidget->setCurrentIndex(0);
layout->addWidget(theStackedWidget);
this->setLayout(layout);
Expand All @@ -146,6 +151,7 @@ HydroEDP_Selection::outputToJSON(QJsonObject &jsonObject)

bool
HydroEDP_Selection::inputFromJSON(QJsonObject &jsonObject) {
qDebug() << "EDP_SELECTION - " << jsonObject;

if (theCurrentEDP != 0) {
return theCurrentEDP->inputFromJSON(jsonObject);
Expand All @@ -160,28 +166,28 @@ void HydroEDP_Selection::edpSelectionChanged(const QString &arg1)
// switch stacked widgets depending on text
// note type output in json and name in pull down are not the same and hence the ||
//

if (arg1 == "Standard Hydro" || arg1 == "StandardHydroEDP") {
if (arg1 == "Standard" || arg1 == "StandardEDP") {
theStackedWidget->setCurrentIndex(0);
theCurrentEDP = theStandardEDPs;
}

else if (arg1 == "Standard Hydro" || arg1 == "StandardHydroEDP") {
theStackedWidget->setCurrentIndex(1);
theCurrentEDP = theStandardHydroEDPs;
}

else if(arg1 == "Standard Tsunami" || arg1 == "StandardTsunamiEDP") {
theStackedWidget->setCurrentIndex(1);
theStackedWidget->setCurrentIndex(2);
theCurrentEDP = theStandardTsunamiEDPs;
}

else if(arg1 == "Standard Storm Surge" || arg1 == "StandardStormSurgeEDP") {
theStackedWidget->setCurrentIndex(2);
theStackedWidget->setCurrentIndex(3);
theCurrentEDP = theStandardStormSurgeEDPs;
}
else if(arg1 == "User Defined" || arg1 == "UserDefinedEDP") {
theStackedWidget->setCurrentIndex(3);
theCurrentEDP = theUserDefinedEDPs;
}
else if (arg1 == "Standard" || arg1 == "StandardEDP") {
theStackedWidget->setCurrentIndex(4);
theCurrentEDP = theStandardEDPs;
theCurrentEDP = theUserDefinedEDPs;
}
else {
qDebug() << "ERROR .. HydroEDP_Selection selection .. type unknown: " << arg1;
Expand Down Expand Up @@ -216,22 +222,26 @@ HydroEDP_Selection::inputAppDataFromJSON(QJsonObject &jsonObject)

// based on application name value set edp type
int index = 0;
if ((type == QString("Standard Hydro EDPs")) ||
(type == QString("StandardHydroEDP"))) {
if ((type == QString("StandardEDP")) ||
(type == QString("Standard EDPs")) || (type == QString("Standard"))) {
index = 0;
} else if ((type == QString("StandardTsunamiEDP")) ||
(type == QString("Standard Tsunami EDPs"))) {
}
else if ((type == QString("Standard Hydro EDPs")) ||
(type == QString("StandardHydroEDP")) || (type == QString("Standard Hydro"))) {
index = 1;
} else if ((type == QString("StandardStormSurgeEDP")) ||
(type == QString("Standard Storm Surge EDPs"))) {
}
else if ((type == QString("StandardTsunamiEDP")) ||
(type == QString("Standard Tsunami EDPs")) || (type == QString("Standard Tsunami"))) {
index = 2;
} else if ((type == QString("UserDefinedEDP")) ||
(type == QString("User Defined EDPs"))) {
}
else if ((type == QString("StandardStormSurgeEDP")) ||
(type == QString("Standard Storm Surge EDPs") || (type == QString("Standard Storm Surge")))) {
index = 3;
} else if ((type == QString("StandardEDP")) ||
(type == QString("Standard EDPs"))) {
}
else if ((type == QString("UserDefinedEDP")) ||
(type == QString("User Defined EDPs")) || (type == QString("User Defined"))) {
index = 4;
}
}
else {
errorMessage("HydroEDP_Selection - no valid type found");
return false;
Expand Down
25 changes: 19 additions & 6 deletions EDP/HydroEDP_Selection.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,29 @@ UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#include <QVector>
class QComboBox;
class QStackedWidget;
class StandardEDP;
// class QJsonObject;

// class StandardHydroEDP;

// class StandardTsunamiEDP;
// class StandardStormSurgeEDP;
// class StandardWindEDP;
// class StandardEarthquakeEDP;
// class StandardEDP;
// class UserDefinedEDP;
class UserDefinedApplication;
class StandardHydroEDP;
class StandardTsunamiEDP;
class StandardStormSurgeEDP;
//class RandomVariablesContainer;

class HydroEDP_Selection : public SimCenterAppWidget
class HydroEDP_Selection : public SimCenterAppWidget
{
Q_OBJECT
public:
explicit HydroEDP_Selection(QWidget *parent = 0);
explicit HydroEDP_Selection( QWidget *parent = 0);
// explicit HydroEDP_Selection(RandomVariablesContainer *, QWidget *parent = 0);
// virtual ~HydroEDP_Selection();
~HydroEDP_Selection();


bool outputToJSON(QJsonObject &rvObject);
bool inputFromJSON(QJsonObject &rvObject);
bool outputAppDataToJSON(QJsonObject &rvObject);
Expand All @@ -80,7 +90,10 @@ public slots:
SimCenterAppWidget *theStandardHydroEDPs;
SimCenterAppWidget *theStandardTsunamiEDPs;
SimCenterAppWidget *theStandardStormSurgeEDPs;
SimCenterAppWidget *theStandardWindEDPs;
SimCenterAppWidget *theUserDefinedEDPs;

//RandomVariablesContainer *theRandomVariables;
};

#endif // HYDRO_EDP_SELECTION_H
54 changes: 34 additions & 20 deletions EDP/StandardHydroEDP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ UPDATES, ENHANCEMENTS, OR MODIFICATIONS.

// Written: fmckenna

#include "StandardHydroEDP.h"
#include "EDP/StandardHydroEDP.h"
// #include <QJsonObject>
// #include <QLabel>

#include <RandomVariablesContainer.h>
// #include <InputWidgetParameters.h>

#include <cstring>
#include <vector>
Expand All @@ -64,7 +66,6 @@ UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
using namespace std;
#include <QGridLayout>

#include <RandomVariablesContainer.h>
StandardHydroEDP::StandardHydroEDP(QWidget *parent)
: SimCenterAppWidget(parent)
{
Expand All @@ -87,6 +88,9 @@ StandardHydroEDP::StandardHydroEDP(QWidget *parent)
// add stuff to enter Additional Input
QLabel *labelAI = new QLabel("Additional Input");
additionalInputLE = new QLineEdit;
// Set the background text to (Optional)
additionalInputLE->setPlaceholderText("(Optional)");

QPushButton *chooseAdditionalInputButton = new QPushButton();
chooseAdditionalInputButton->setText(tr("Choose"));
connect(chooseAdditionalInputButton,SIGNAL(clicked()),this,SLOT(chooseAdditionalInput()));
Expand All @@ -97,6 +101,11 @@ StandardHydroEDP::StandardHydroEDP(QWidget *parent)
// add stuff to enter processing script
QLabel *labelPS = new QLabel("Processing Script");
processingScriptLE = new QLineEdit;
processingScriptLE->setText("StandardHydroEDP_PostProcess.py");
processingScriptLE->setReadOnly(true);
processingScriptLE->setToolTip("This script is used to process the output of the event simulation, EVT, to extract the Engineering Demand Parameters (EDPs) into a results.out file.");


QPushButton *chooseProcessingScriptButton = new QPushButton();
chooseProcessingScriptButton->setText(tr("Choose"));
connect(chooseProcessingScriptButton,SIGNAL(clicked()),this,SLOT(chooseProcessingScript()));
Expand Down Expand Up @@ -141,14 +150,14 @@ StandardHydroEDP::StandardHydroEDP(QWidget *parent)
titleLayout->addWidget(addEDP);
titleLayout->addItem(spacer2);

/*

QPushButton *removeEDP = new QPushButton();
removeEDP->setMinimumWidth(75);
removeEDP->setMaximumWidth(75);
removeEDP->setText(tr("Remove"));
connect(removeEDP,SIGNAL(clicked()),this,SLOT(removeEDP()));
titleLayout->addWidget(removeEDP);
*/
titleLayout->addWidget(removeEDP);


titleLayout->addStretch();

Expand Down Expand Up @@ -226,17 +235,17 @@ StandardHydroEDP::clear(void)
// from UserDefinedEDP.cpp, not needed for now
//

// additionalInputLE->setText("");
// processingScriptLE->setText("");

// int numEDPs = theEDPs.size();
// for (int i = numEDPs-1; i >= 0; i--) {
// EDP *theEDP = theEDPs.at(i);
// theEDP->close();
// edpLayout->removeWidget(theEDP);
// theEDPs.remove(i);
// delete theEDP;
// }
additionalInputLE->setText("");
processingScriptLE->setText("");

int numEDPs = theEDPs.size();
for (int i = numEDPs-1; i >= 0; i--) {
EDP *theEDP = theEDPs.at(i);
theEDP->close();
edpLayout->removeWidget(theEDP);
theEDPs.remove(i);
delete theEDP;
}
}


Expand All @@ -258,11 +267,11 @@ StandardHydroEDP::outputToJSON(QJsonObject &jsonObject)
QFileInfo fileInfoPS(fileName);
if (fileInfoPS.exists()) {

jsonObject["fileNamePS"]= fileInfoPS.fileName();
jsonObject["filePathPS"]=fileInfoPS.path();
jsonObject["fileNamePS"] = fileInfoPS.fileName();
jsonObject["filePathPS"] = fileInfoPS.path();

} else {
this->errorMessage("StandardHydroEDP :: Proceesing script does not exist");
this->errorMessage("StandardHydroEDP :: Processing script does not exist");
}
} else {
this->errorMessage("StandardHydroEDP :: no processing script");
Expand Down Expand Up @@ -420,6 +429,10 @@ StandardHydroEDP::copyFiles(QString &dirName) {
return false;
}
}
else {
this->errorMessage(QString("ERROR: copyFiles: no processing script"));
return false;
}

filename = additionalInputLE->text();
if (!filename.isEmpty()) {
Expand All @@ -429,7 +442,8 @@ StandardHydroEDP::copyFiles(QString &dirName) {
return false;
}
}
return 0;

return true;
}


Expand Down
2 changes: 1 addition & 1 deletion EDP/StandardHydroEDP.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#include <QComboBox>

class EDP;
class InputWidgetParameters;
// class InputWidgetParameters;

class StandardHydroEDP : public SimCenterAppWidget
{
Expand Down
3 changes: 2 additions & 1 deletion EDP/StandardStormSurgeEDP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ UPDATES, ENHANCEMENTS, OR MODIFICATIONS.

// Written: fmckenna

#include "StandardStormSurgeEDP.h"
#include "EDP/StandardStormSurgeEDP.h"
// #include <QJsonObject>
// #include <QLabel>

Expand All @@ -45,6 +45,7 @@ UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#include <vector>
// #include "UserDefinedEDP.h"
#include <EDP.h>
// #include <InputWidgetParameters.h>

#include <QPushButton>
#include <QScrollArea>
Expand Down
2 changes: 1 addition & 1 deletion EDP/StandardStormSurgeEDP.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#include <QComboBox>

class EDP;
class InputWidgetParameters;
// class InputWidgetParameters;

class StandardStormSurgeEDP : public SimCenterAppWidget
{
Expand Down
3 changes: 2 additions & 1 deletion EDP/StandardTsunamiEDP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ UPDATES, ENHANCEMENTS, OR MODIFICATIONS.

// Written: fmckenna

#include "StandardTsunamiEDP.h"
#include "EDP/StandardTsunamiEDP.h"
// #include <QJsonObject>
// #include <QLabel>

Expand All @@ -45,6 +45,7 @@ UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#include <vector>
// #include "UserDefinedEDP.h"
#include <EDP.h>
// #include <InputWidgetParameters.h>

#include <QPushButton>
#include <QScrollArea>
Expand Down
2 changes: 1 addition & 1 deletion EDP/StandardTsunamiEDP.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#include <QComboBox>

class EDP;
class InputWidgetParameters;
// class InputWidgetParameters;

class StandardTsunamiEDP : public SimCenterAppWidget
{
Expand Down
Loading

0 comments on commit e8756b9

Please sign in to comment.