Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions src/Command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2003,6 +2003,44 @@ namespace libforefire
return normal;
}
}
if (tmpArgs[0] == "resolution")
{
double newPerimRes = getFloat("perimeterResolution", arg);
double newSpatialInc = getFloat("spatialIncrement", arg);

bool valid = true;

if (newPerimRes != FLOATERROR && newPerimRes <= 0.0) {
cout << "Error: perimeterResolution must be greater than 0." << endl;
valid = false;
}
if (newSpatialInc != FLOATERROR && newSpatialInc <= 0.0) {
cout << "Error: spatialIncrement must be greater than 0." << endl;
valid = false;
}
if (!valid) return error;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if arg is not a float?
Maybe we can add somehting like:

 bool valid = true;
    if (newPerimRes != FLOATERROR) {
        if (newPerimRes <= 0.0 || newPerimRes > 10000.0 || std::isnan(newPerimRes)) {
            cout << "Error: perimeterResolution must be between 0 and 10,000." << endl;
            valid = false;
        }
    }
    if (newSpatialInc != FLOATERROR) {
        if (newSpatialInc <= 0.0 || newSpatialInc > 10000.0 || std::isnan(newSpatialInc)) {
            cout << "Error: spatialIncrement must be between 0 and 10,000." << endl;
            valid = false;
        }
    }

    if (!valid) return error;

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!
if arg is not a float, the getFloat() will return FLOATERROR, so this should be covered!
I added a check to ensure >= 0.0, but would rather avoid to set an upper limit to keep it simple?

FireDomain* domain = getDomain();
if (domain != nullptr)
{
if (newPerimRes != FLOATERROR)
{
domain->setPerimeterResolution(newPerimRes);
cout << "Updated perimeterResolution to " << newPerimRes << endl;
}
if (newSpatialInc != FLOATERROR)
{
domain->setSpatialIncrement(newSpatialInc);
cout << "Updated spatialIncrement to " << newSpatialInc << endl;
}
return normal;
}
else
{
cout << "Error: No FireDomain available to update resolution parameters." << endl;
return error;
}
}
return error;
}
int Command::include(const string &arg, size_t &numTabs)
Expand Down
2 changes: 1 addition & 1 deletion src/DataBroker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1264,7 +1264,7 @@ namespace libforefire

if (varName == "altitude" && domain->getDomainID() == 0)
{
cout << "HHHHHHHHHHHHHHH read Altitude " << domain->getDomainID() << endl;
cout << "Reading Altitude " << domain->getDomainID() << endl;
auto altLayer = constructXYZTLayer(currentVar, SWCorner, spatialExtent, timeOrigin, Lt, -1);
registerLayer(varName, altLayer);
}
Expand Down
6 changes: 6 additions & 0 deletions src/FireDomain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,12 @@
}
return buffer.st_size;
}
void FireDomain::setPerimeterResolution(double res) {
this->perimeterResolution = res;
}
void FireDomain::setSpatialIncrement(double inc) {
this->spatialIncrement = inc;
}
void FireDomain::pushMultiDomainMetadataInList(size_t id, double lastTime, size_t atmoNX, size_t atmoNY, double nswx, double nswy, double nnex, double nney) {
distributedDomainInfo *currentInfo = new distributedDomainInfo;
currentInfo->ID = id;
Expand Down
3 changes: 3 additions & 0 deletions src/FireDomain.h
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,9 @@ class FireDomain: public ForeFireAtom, Visitable {

size_t getFreeFluxModelIndex();

void setPerimeterResolution(double res);
void setSpatialIncrement(double inc);

// Getter for the reference latitude.
double getRefLatitude() ;

Expand Down
1 change: 0 additions & 1 deletion src/SimulationParameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,6 @@ std::string landCoverIndexedCSV = R"(Index;Rhod;Rhol;Md;Ml;sd;sl;e;Sigmad;Sigmal
parameters.insert(make_pair("spatialCFLmax", "0.3"));
parameters.insert(make_pair("spatialIncrement", "2"));
parameters.insert(make_pair("spatialCFLmax", "0.3"));
parameters.insert(make_pair("spatialIncrement", "2"));
parameters.insert(make_pair("watchedProc", "-2"));
parameters.insert(make_pair("CommandOutputs", "0"));
parameters.insert(make_pair("FireDomainOutputs", "0"));
Expand Down