Skip to content

Commit

Permalink
Merge pull request #162 from abiyfantaye/master
Browse files Browse the repository at this point in the history
New example - improve GUI - wind load visualization - bug fixes [Updates for WE-UQ 4.1]
  • Loading branch information
fmckenna authored Oct 1, 2024
2 parents 41eebe5 + a43c3b8 commit caed98c
Show file tree
Hide file tree
Showing 14 changed files with 458 additions and 53 deletions.
47 changes: 43 additions & 4 deletions EVENTS/EmptyDomainCFD/EmptyDomainCFD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,37 @@ bool EmptyDomainCFD::inputFromJSON(QJsonObject &jsonObject)
{
this->clear();

caseDirectoryPathWidget->setText(jsonObject["caseDirectoryPath"].toString());
QString foamPath = jsonObject["caseDirectoryPath"].toString();

QDir foamDir(foamPath);

if (!foamDir.exists(foamPath))
{
QDir workingDir(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation));

QString workingDirPath = workingDir.filePath(QCoreApplication::applicationName() + QDir::separator()
+ "LocalWorkDir" + QDir::separator()
+ "EmptyDomainCFD");
workingDir.mkpath(workingDirPath);

caseDirectoryPathWidget->setText(workingDirPath);

if(!isCaseConfigured())
{
setupCase();
}

if (!isMeshed())
{
snappyHexMesh->onRunBlockMeshClicked();
}
}
else
{
caseDirectoryPathWidget->setText(jsonObject["caseDirectoryPath"].toString());
}


openFoamVersion->setCurrentText(jsonObject["OpenFoamVersion"].toString());

geometry->inputFromJSON(jsonObject);
Expand Down Expand Up @@ -621,21 +651,30 @@ bool EmptyDomainCFD::copyFiles(QString &destDir) {

QString caseName = "EmptyDomainCFD";

bool result = this->copyPath(caseDir(), destDir + QDir::separator() + caseName, false);
//Copy each directory in the OF case directory
QStringList foamDirs = {"constant", "system", "0"};

bool copyResults = true;

for(QString dir:foamDirs)
{
qDebug() << "Copying " << dir;
copyResults *= this->copyPath(caseDir() + QDir::separator() + dir, destDir + QDir::separator() + caseName + QDir::separator() + dir, false);
}

//Remove the 'constant/polyMesh' directory
// Makes it slow to transfer the mesh to DesignSafe
// The mesh will be run on the remote machine anyway
QDir polyMeshDir(destDir + QDir::separator() + caseName + QDir::separator() + "constant" + QDir::separator() + "polyMesh");
polyMeshDir.removeRecursively();

if (result == false) {
if (copyResults == false) {
QString errorMessage; errorMessage = "EmptyDomainCFD - failed to copy file: " + caseDir() + " to: " + destDir;
emit sendFatalMessage(errorMessage);
qDebug() << errorMessage;
}

return result;
return copyResults;
}

bool EmptyDomainCFD::cleanCase()
Expand Down
4 changes: 1 addition & 3 deletions EVENTS/EmptyDomainCFD/EmptyResultMonitoring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -615,13 +615,11 @@ void EmptyResultMonitoring::initializeVTKTable(int numRows)
{
vtkSampleTable->setColumnWidth(i, vtkSampleTable->size().width()/(vtkNumCols + 0.25));

for (int j=0; j < numRows; j++)
for(int j=0; j < numRows; j++)
{
vtkSampleTable->setItem(j, i, new QTableWidgetItem(""));
}
}


}


Expand Down
6 changes: 3 additions & 3 deletions EVENTS/EmptyDomainCFD/EmptyResultMonitoring.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ public slots:
void onAddProfileClicked();
void onRemoveProfileClicked();
void onShowProfilesClicked();
void onAddPlaneClicked();
void onRemovePlaneClicked();
void onMonitorProfileChecked(int);
void onMonitorPlaneChecked(int);

void onMonitorPlaneChecked(int);
void onAddPlaneClicked();
void onRemovePlaneClicked();

private:

Expand Down
27 changes: 16 additions & 11 deletions EVENTS/IsolatedBuildingCFD/GeometricInputWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ UPDATES, ENHANCEMENTS, OR MODIFICATIONS.

QLabel *windDirectionLabel = new QLabel("Wind Direction:");
windDirectionWidget = new QSpinBox;
windDirectionWidget->setRange(0, 90);
windDirectionWidget->setRange(0, 360);
windDirectionWidget->setSingleStep(10);
windDirectionWidget->setValue(0);

Expand Down Expand Up @@ -450,13 +450,11 @@ void GeometricInputWidget::buildingShapeChanged(const QString &arg)
{
importSTLButton->setEnabled(false);
importSTLLabel->setEnabled(false);
generateBuildingSTL->setEnabled(true);
}
else if(arg == "Complex")
{
importSTLButton->setEnabled(true);
importSTLLabel->setEnabled(true);
generateBuildingSTL->setEnabled(false);
}
}

Expand Down Expand Up @@ -741,9 +739,19 @@ void GeometricInputWidget::onSTLImportButtonClicked()
double depth = (yMax-yMin)*scale;
double height = (zMax-zMin)*scale;

theGI->setLengthUnit("m");
theGI->setNumStoriesAndHeight(mainModel->numberOfFloors(), height);
theGI->setBuildingDimensions(width, depth, width*depth);
if(mainModel->isLaunchedAsTool)
{
buildingWidthWidget->setText(QString::number(width));
buildingDepthWidget->setText(QString::number(depth));
buildingHeightWidget->setText(QString::number(height));
}

else
{
theGI->setLengthUnit("m");
theGI->setNumStoriesAndHeight(mainModel->numberOfFloors(), height);
theGI->setBuildingDimensions(width, depth, width*depth);
}

mainModel->writeOpenFoamFiles();
}
Expand All @@ -766,9 +774,6 @@ void GeometricInputWidget::onSTLCancelButtonClicked()

void GeometricInputWidget::onGenerateBuildingSTL()
{
if(buildingShape->currentText() == "Simple")
{
mainModel->writeOpenFoamFiles();
mainModel->reloadMesh();
}
mainModel->writeOpenFoamFiles();
mainModel->reloadMesh();
}
53 changes: 47 additions & 6 deletions EVENTS/IsolatedBuildingCFD/IsolatedBuildingCFD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ bool IsolatedBuildingCFD::initialize()
visWindowLayout = new QVBoxLayout();
visWindowGroup = new QGroupBox();

QTabWidget *inputTab = new QTabWidget(this);
inputTab = new QTabWidget(this);

QWidget *generalWidget = new QWidget();
QWidget *geometryWidget = new QWidget();
Expand Down Expand Up @@ -813,25 +813,36 @@ bool IsolatedBuildingCFD::inputAppDataFromJSON(QJsonObject &jsonObject) {

bool IsolatedBuildingCFD::copyFiles(QString &destDir) {

writeOpenFoamFiles();
writeOpenFoamFiles();

QString caseName = "IsolatedBuildingCFD";


//Copy each directory in the OF case directory
QStringList foamDirs = {"constant", "system", "0"};

QString caseName = "IsolatedBuildingCFD";
bool copyResults = true;

for(QString dir:foamDirs)
{
qDebug() << "Copying " << dir;
copyResults *= this->copyPath(caseDir() + QDir::separator() + dir, destDir + QDir::separator() + caseName + QDir::separator() + dir, false);
}

bool result = this->copyPath(caseDir(), destDir + QDir::separator() + caseName, false);

//Remove the 'constant/polyMesh' directory
// Makes it slow to transfer the mesh to DesignSafe
// The mesh will be run on the remote machine anyway
QDir polyMeshDir(destDir + QDir::separator() + caseName + QDir::separator() + "constant" + QDir::separator() + "polyMesh");
polyMeshDir.removeRecursively();

if (result == false) {
if (copyResults == false) {
QString errorMessage; errorMessage = "IsolatedBuildingCFD - failed to copy file: " + caseDir() + " to: " + destDir;
emit sendFatalMessage(errorMessage);
qDebug() << errorMessage;
}

return result;
return copyResults;
}

bool IsolatedBuildingCFD::cleanCase()
Expand Down Expand Up @@ -1024,6 +1035,23 @@ int IsolatedBuildingCFD::numberOfFloors()
}



double IsolatedBuildingCFD::buildingWidthModelScale()
{
return buildingWidth()/geometricScale();
}

double IsolatedBuildingCFD::buildingDepthModelScale()
{
return buildingDepth()/geometricScale();
}

double IsolatedBuildingCFD::buildingHeightModelScale()
{
return buildingHeight()/geometricScale();;
}


double IsolatedBuildingCFD::geometricScale()
{
return geometry->geometricScaleWidget->text().toDouble();
Expand Down Expand Up @@ -1147,6 +1175,19 @@ vtkPolyData* IsolatedBuildingCFD::getBldgBlock()
return visWidget->getBldgBlock();
}

double IsolatedBuildingCFD::getDuration()
{
return numericalSetup->duration->text().toDouble();
}


SC_ResultsWidget* IsolatedBuildingCFD::getResultsWidget(QWidget *parent)
{
inputTab->setCurrentIndex(6);
statusMessage("Isolated building CFD results downloaded! Now processing...");
return resultDisplay;
}

void IsolatedBuildingCFD::onSaveMeshClicked()
{
statusMessage("Writing OpenFOAM dictionary files ... ");
Expand Down
6 changes: 6 additions & 0 deletions EVENTS/IsolatedBuildingCFD/IsolatedBuildingCFD.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ class IsolatedBuildingCFD : public SimCenterAppWidget
double buildingWidth();
double buildingDepth();
double buildingHeight();
double buildingWidthModelScale();
double buildingDepthModelScale();
double buildingHeightModelScale();
int numberOfFloors();

double geometricScale();
Expand All @@ -132,6 +135,8 @@ class IsolatedBuildingCFD : public SimCenterAppWidget
double getTimeStep();

vtkPolyData* getBldgBlock();
SC_ResultsWidget* getResultsWidget(QWidget *parent);
double getDuration();

bool isLaunchedAsTool = false;

Expand Down Expand Up @@ -176,6 +181,7 @@ public slots:
QGridLayout *openFoamVersionLayout;
QComboBox *openFoamVersion;

QTabWidget *inputTab;
GeometricInputWidget *geometry;
SnappyHexMeshWidget *snappyHexMesh;
SimCenterVTKRenderingWidget *visWidget;
Expand Down
Loading

0 comments on commit caed98c

Please sign in to comment.