Skip to content

Commit

Permalink
Merge branch 'miscFixes'
Browse files Browse the repository at this point in the history
  • Loading branch information
nwagenbrenner committed Oct 11, 2024
2 parents d0da101 + 9f18e2d commit d6aeb2d
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 164 deletions.
52 changes: 36 additions & 16 deletions src/gui/mainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -560,11 +560,14 @@ void mainWindow::createConnections()
this, SLOT( selectNinjafoamSolver( bool ) ) );
#endif

//connect the speed and direction in the first row to the checkers
connect(tree->wind->windTable->speed[0], SIGNAL(valueChanged(double)), this,
SLOT(checkAllItems()));
connect(tree->wind->windTable->dir[0], SIGNAL(valueChanged(int)), this,
SLOT(checkAllItems()));
//connect the speed and direction in each row to the checkers
for(int i=0;i<tree->wind->windTable->nRuns;i++)
{
connect(tree->wind->windTable->speed[i], SIGNAL(valueChanged(double)), this,
SLOT(checkAllItems()));
connect(tree->wind->windTable->dir[i], SIGNAL(valueChanged(int)), this,
SLOT(checkAllItems()));
}

//connect the initialization check boxes to checkers
connect(tree->wind->windGroupBox, SIGNAL(toggled(bool)),
Expand Down Expand Up @@ -2615,9 +2618,13 @@ int mainWindow::countRuns()
{
int runs = 0;

while(tree->wind->windTable->speed[runs]->value() != 0 ||
tree->wind->windTable->dir[runs]->value() != 0)
runs++;
for(int i=0; i < tree->wind->windTable->nRuns; i++)
{
if(tree->wind->windTable->speed[i]->value() != 0 || tree->wind->windTable->dir[i]->value() != 0)
{
runs = i+1; // i goes from 0 to N-1, runs goes from 1 to N
}
}

return runs;
}
Expand Down Expand Up @@ -2870,13 +2877,30 @@ int mainWindow::checkSpdDirItem()
}
else if(runs == 0 && tree->diurnal->diurnalGroupBox->isChecked() == true) {
tree->spdDirItem->setIcon(0, tree->caution);
tree->spdDirItem->setToolTip(0, "No runs have been added, one run will be done at speed = 0, dir = 0");
tree->spdDirItem->setToolTip(0, "No runs have been added, one run will be done at speed = 0, dir = 0 while using diurnal");
status = amber;
}
else {
tree->spdDirItem->setIcon(0, tree->check);
tree->spdDirItem->setToolTip(0, QString::number(runs) + " runs");
status = green;
// override if any 0.0 wind speed runs are detected, warn and run if diurnal, stop if not diurnal
for(int i=0;i<runs;i++)
{
if(tree->wind->windTable->speed[i]->value() == 0.0)
{
if(tree->diurnal->diurnalGroupBox->isChecked() == false) {
tree->spdDirItem->setIcon(0, tree->cross);
tree->spdDirItem->setToolTip(0, QString::number(runs) + " runs have been added, but detecting at least one 0.0 wind speed run without diurnal being active");
status = red;
} else {
tree->spdDirItem->setIcon(0, tree->caution);
tree->spdDirItem->setToolTip(0, QString::number(runs) + " runs have been added, detecting at least one 0.0 wind speed run, diurnal is active so will continue the runs");
status = amber;
}
break;
}
}
}
}
else {
Expand Down Expand Up @@ -3567,12 +3591,10 @@ void mainWindow::enableNinjafoamOptions(bool enable)
tree->surface->foamCaseGroupBox->setHidden( false );
tree->surface->timeZoneGroupBox->setHidden( false );

tree->vtk->ninjafoamConflictLabel->setHidden( false );
tree->vtk->vtkLabel->setHidden( true );
tree->vtk->vtkGroupBox->setHidden( true );
tree->vtk->vtkLabel->setHidden( false );
tree->vtk->vtkGroupBox->setHidden( false );
tree->vtk->vtkGroupBox->setCheckable(true);
tree->vtk->vtkGroupBox->setChecked( false );
tree->vtk->vtkWarningLabel->setHidden( true );
tree->vtk->vtkGroupBox->setCheckable(false);
}
else{
tree->diurnal->diurnalGroupBox->setCheckable( true );
Expand All @@ -3593,9 +3615,7 @@ void mainWindow::enableNinjafoamOptions(bool enable)
tree->surface->timeZoneGroupBox->setHidden( false );
tree->surface->meshResComboBox->addItem("Custom", 4);

tree->vtk->ninjafoamConflictLabel->setHidden( true );
tree->vtk->vtkLabel->setHidden( false );
tree->vtk->vtkWarningLabel->setHidden( false );
tree->vtk->vtkGroupBox->setHidden( false );
tree->vtk->vtkGroupBox->setCheckable( true );
tree->vtk->vtkGroupBox->setChecked( false );
Expand Down
26 changes: 8 additions & 18 deletions src/gui/vtkOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,15 @@ vtkOutput::vtkOutput(QWidget *parent) : QWidget(parent)
vtkGroupBox->setCheckable(true);
vtkGroupBox->setChecked(false);

vtkLabel = new QLabel(tr("Write VTK surface and volume files"), this);
vtkWarningLabel = new QLabel(tr("*vtk files are for advanced users and are\n rarely used by fire managers/modelers."), this);
vtkWarningLabel->setDisabled(true);
//writeVolumeCheckBox = new QCheckBox(tr("Volume File"), this);
//writeSurfaceCheckBox = new QCheckBox(tr("Surface File"), this);

ninjafoamConflictLabel = new QLabel(tr("*.vtk files are not written for the"
" mometum solver output. Instead, the\n"
" OpenFOAM case directory is left behind in the same directory as your DEM.\n"
" This case directory (NINJAFOAM_*) contains the 3-D files which can be\n"
" viewed in a program called ParaView. See the OpenFOAM documentation for\n"
" more details.\n"
" \nNote that these files are for advanced users and are rarely used by fire\n"
"managers/modelers.\n"
vtkLabel = new QLabel(tr(" Write VTK surface and volume files\n"
" \n"
" Note that *vtk files are for advanced users and \n"
" are rarely used by fire managers/modelers.\n"
), this);
ninjafoamConflictLabel->setHidden(true);


//writeVolumeCheckBox = new QCheckBox(tr("Volume File"), this);
//writeSurfaceCheckBox = new QCheckBox(tr("Surface File"), this);

//vtkLayout = new QVBoxLayout;
//vtkLayout->addWidget(vtkLabel);
//vtkLayout->addWidget(writeVolumeCheckBox);
Expand All @@ -65,8 +57,6 @@ vtkOutput::vtkOutput(QWidget *parent) : QWidget(parent)

layout->addWidget(vtkGroupBox);
layout->addWidget(vtkLabel);
layout->addWidget(vtkWarningLabel);
layout->addWidget(ninjafoamConflictLabel);
layout->addStretch();
setLayout(layout);
//layout->addStretch();
Expand Down
2 changes: 0 additions & 2 deletions src/gui/vtkOutput.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,11 @@ class vtkOutput : public QWidget

QGroupBox *vtkGroupBox;
QLabel *vtkLabel;
QLabel *vtkWarningLabel;
QCheckBox *writeVolumeCheckBox;
QCheckBox *writeSurfaceCheckBox;

QVBoxLayout *vtkLayout;
QVBoxLayout *layout;
QLabel *ninjafoamConflictLabel;
};

#endif /* VTKOUTPUT_H */
3 changes: 1 addition & 2 deletions src/ninja/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ int windNinjaCLI(int argc, char* argv[])

("ascii_out_resolution", po::value<double>()->default_value(-1.0), "resolution of ascii fire behavior output files (-1 to use mesh resolution)")
("units_ascii_out_resolution", po::value<std::string>()->default_value("m"), "units of ascii fire behavior output file resolution (ft, m)")
("write_vtk_output", po::value<bool>()->default_value(false), "write VTK output file (true, false)")
("write_vtk_output", po::value<bool>()->default_value(false), "write VTK output file (true, false). For momentum solver runs, this is NOT of the full openfoam case but is actually of a corresponding mass solver mesh")
("write_farsite_atm", po::value<bool>()->default_value(false), "write a FARSITE atm file (true, false)")
("write_pdf_output", po::value<bool>()->default_value(false), "write PDF output file (true, false)")
("pdf_out_resolution", po::value<double>()->default_value(-1.0), "resolution of pdf output file (-1 to use mesh resolution)")
Expand Down Expand Up @@ -921,7 +921,6 @@ int windNinjaCLI(int argc, char* argv[])
return -1;
}
conflicting_options(vm, "momentum_flag", "input_points_file");
conflicting_options(vm, "momentum_flag", "write_vtk_output");
option_dependency(vm, "turbulence_output_flag", "momentum_flag");
option_dependency(vm, "turbulence_output_flag", "write_goog_output");
#ifdef FRICTION_VELOCITY
Expand Down
5 changes: 4 additions & 1 deletion src/ninja/gdal_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ int GDALFillBandNoData(GDALDataset *poDS, int nBand, int nSearchPixels)

poBand = poDS->GetRasterBand(1);

GDALFillNodata(poBand, NULL, 100, 0, 0, NULL, NULL, NULL);
GDALFillNodata(poBand, NULL, 120, 0, 0, NULL, NULL, NULL);

double dfNoData = poBand->GetNoDataValue(NULL);

Expand Down Expand Up @@ -920,6 +920,7 @@ bool GDALWarpToUtm (const char* filename, GDALDatasetH& hSrcDS, GDALDatasetH& hD
CPLPopErrorHandler();
if(eErr != CE_None)
{
CPLError( CE_Failure, CPLE_AppDefined, "GDALSuggestedWarpOutput failed." );
return false;
}
GDALDestroyGenImgProjTransformer(hTransformArg);
Expand All @@ -929,6 +930,7 @@ bool GDALWarpToUtm (const char* filename, GDALDatasetH& hSrcDS, GDALDatasetH& hD

if(hDstDS == NULL)
{
CPLError( CE_Failure, CPLE_AppDefined, "Failed to create gdal dataset." );
return false;
}

Expand Down Expand Up @@ -1018,6 +1020,7 @@ bool GDALWarpToUtm (const char* filename, GDALDatasetH& hSrcDS, GDALDatasetH& hD
}
if(nNoDataCount > 0)
{
CPLError( CE_Failure, CPLE_AppDefined, "Failed to fill all no data values." );
return false;
}

Expand Down
5 changes: 5 additions & 0 deletions src/ninja/ninja.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2838,6 +2838,11 @@ void ninja::writeOutputFiles()
}
// can pick between "ascii" and "binary" format for the vtk write format
std::string vtkWriteFormat = "binary";//"binary";//"ascii";
std::string found_vtkWriteFormat = CPLGetConfigOption("VTK_OUT_FORMAT", "binary");
if(found_vtkWriteFormat != "")
{
vtkWriteFormat = found_vtkWriteFormat;
}
volVTK VTK(u, v, w, mesh.XORD, mesh.YORD, mesh.ZORD, input.dem.get_xllCorner(), input.dem.get_yllCorner(), input.dem.get_nCols(), input.dem.get_nRows(), mesh.nlayers, input.volVTKFile, vtkWriteFormat, vtk_out_as_utm);
}catch (exception& e)
{
Expand Down
2 changes: 1 addition & 1 deletion src/ninja/ninja_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ char * NinjaQueryServerMessages(bool checkAbort)
{
CPLSetConfigOption( "GDAL_HTTP_TIMEOUT", "5" );
const char* url = "https://ninjastorm.firelab.org/sqlitetest/messages.txt";
CPLSetConfigOption( "GDAL_HTTP_TIMEOUT", NULL );
CPLHTTPResult *poResult = CPLHTTPFetch(url, NULL);
CPLSetConfigOption( "GDAL_HTTP_TIMEOUT", NULL );
if( !poResult || poResult->nStatus != 0 || poResult->nDataLen == 0 )
{
CPLDebug( "NINJA", "Failed to reach the ninjastorm server." );
Expand Down
Loading

0 comments on commit d6aeb2d

Please sign in to comment.