WSL/SLF GitLab Repository

Commit 9a9c045d authored by Nander Wever's avatar Nander Wever
Browse files

Removing some code duplication with better code structure.

parent c969af02
......@@ -538,8 +538,17 @@ void SnowpackInterface::setSnowDrift(SnowDriftA3D& mydrift)
if (drift) {
for (size_t i = 0; i < workers.size(); i++) workers[i]->setUseDrift(true);
setSnowDrift();
}
}
// Provide initial snow parameters to SnowDrift
/**
* @brief Send required fields to SnowDrift module
*/
void SnowpackInterface::setSnowDrift()
{
if (drift) {
// Provide snow parameters to SnowDrift
const Grid2DObject cH( getGrid(SnGrids::HS) );
const Grid2DObject sp( getGrid(SnGrids::SP) );
const Grid2DObject rg( getGrid(SnGrids::RG) );
......@@ -558,10 +567,18 @@ void SnowpackInterface::setEnergyBalance(EnergyBalance& myeb)
eb = &myeb;
if (eb) {
for (size_t i = 0; i < workers.size(); i++){
workers[i]->setUseEBalance(true);
}
// Provide initial albedo to EnergyBalance
for (size_t i = 0; i < workers.size(); i++) workers[i]->setUseEBalance(true);
setEnergyBalance();
}
}
/**
* @brief Send required fields to EnergyBalance module
*/
void SnowpackInterface::setEnergyBalance()
{
if (eb) {
// Provide albedo to EnergyBalance
const Grid2DObject alb( getGrid(SnGrids::TOP_ALB) );
eb->setAlbedo(alb);
}
......@@ -871,20 +888,10 @@ void SnowpackInterface::calcNextStep()
}
// Gather data if needed and make exchange for SnowDrift
if (drift) {
const Grid2DObject cH( getGrid(SnGrids::HS) );
const Grid2DObject sp( getGrid(SnGrids::SP) );
const Grid2DObject rg( getGrid(SnGrids::RG) );
const Grid2DObject N3( getGrid(SnGrids::N3) );
const Grid2DObject rb( getGrid(SnGrids::RB) );
drift->setSnowSurfaceData(cH, sp, rg, N3, rb);
}
if (drift) setSnowDrift();
// Gather data if needed and make exchange for EnergyBalance
if (eb) {
const Grid2DObject alb( getGrid(SnGrids::TOP_ALB) );
eb->setAlbedo(alb);
}
if (eb) setEnergyBalance();
//make output
writeOutput(nextStepTimestamp);
......
......@@ -143,7 +143,9 @@ class Runoff; // forward declaration, cyclic header include
// Methods to set other modules
void setSnowDrift(SnowDriftA3D& drift);
void setSnowDrift();
void setEnergyBalance(EnergyBalance& myeb);
void setEnergyBalance();
void setDataAssimilation(DataAssimilation& init_da);
void setRunoff(Runoff& init_runoff);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment