Skip to content

Commit

Permalink
cleans up a few names in writing checkpoint/vis files; stops use of p…
Browse files Browse the repository at this point in the history
…k name in tag
  • Loading branch information
ecoon committed Mar 4, 2024
1 parent 25b7b94 commit 5c504eb
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -358,17 +358,19 @@ WRMImplicitPermafrostModel::si_frozen_unsaturated_nospline_(double pc_liq,
int max_it(max_it_);

if (solver_ == "bisection") {
Errors::Message emsg("WRMImplicitPermafrostModel:: invalid solver method \"bisection\", use \"brent\"");
Errors::Message emsg(
"WRMImplicitPermafrostModel:: invalid solver method \"bisection\", use \"brent\"");
Exceptions::amanzi_throw(emsg);
} else if (solver_ == "toms") {
Errors::Message emsg("WRMImplicitPermafrostModel:: invalid solver method \"bisection\", use \"brent\"");
Errors::Message emsg(
"WRMImplicitPermafrostModel:: invalid solver method \"bisection\", use \"brent\"");
Exceptions::amanzi_throw(emsg);
} else if (solver_ == "brent") {
result = Utils::findRootBrent(func, left, right, eps_, &max_it);
} else {
Errors::Message emsg;
emsg << "WRMImplicitPermafrostModel: invalid solver method \""
<< solver_ << "\", use \"brent\"";
emsg << "WRMImplicitPermafrostModel: invalid solver method \"" << solver_
<< "\", use \"brent\"";
Exceptions::amanzi_throw(emsg);
}

Expand All @@ -378,8 +380,8 @@ WRMImplicitPermafrostModel::si_frozen_unsaturated_nospline_(double pc_liq,
if (max_it >= max_it_) {
// did not converge? May be ABS converged but not REL converged!
std::cerr << "WRMImplicitPermafrostModel did not converge, " << max_it
<< " iterations, error = " << func(si) << ", s_i = " << si
<< ", PC_{lg,il} = " << pc_liq << "," << pc_ice << std::endl;
<< " iterations, error = " << func(si) << ", s_i = " << si
<< ", PC_{lg,il} = " << pc_liq << "," << pc_ice << std::endl;
if (throw_ok) { Exceptions::amanzi_throw(Errors::CutTimeStep()); }
}
return si;
Expand Down
4 changes: 2 additions & 2 deletions src/pks/flow/predictor_delegate_bc_flux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ PredictorDelegateBCFlux::CreateFunctor_(int f, const Teuchos::Ptr<const Composit

int
PredictorDelegateBCFlux::CalculateLambda_(int f,
const Teuchos::Ptr<const CompositeVector>& pres,
double& lambda)
const Teuchos::Ptr<const CompositeVector>& pres,
double& lambda)
{
#if DEBUG_FLAG
std::cout << " Flux correcting face " << f << ": q = " << (*bc_values_)[f] << std::endl;
Expand Down
27 changes: 15 additions & 12 deletions src/pks/pk_bdf_default.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ PK_BDF_Default::Setup()
// check if continuation method and require continuation parameter
// -- ETC Note this needs fixed if more than one continuation method used
if (bdf_plist.isSublist("continuation parameters")) {
S_->Require<double>("continuation_parameter", Tag(name_), name_);
S_->Require<double>(Keys::cleanName(name_) + "_continuation_parameter", Tags::DEFAULT, name_);
}

// require data for checkpointing timestep size
S_->Require<double>("dt_internal", Tag(name_), name_);
S_->Require<double>(Keys::cleanName(name_) + "_dt_internal", Tags::DEFAULT, name_);
}
};

Expand All @@ -67,13 +67,15 @@ PK_BDF_Default::Initialize()
Teuchos::rcp(new BDF1_TI<TreeVector, TreeVectorSpace>(*this, bdf_plist, solution_, S_));

double dt_init = time_stepper_->initial_timestep();
S_->Assign("dt_internal", Tag(name_), name_, dt_init);
S_->GetRecordW("dt_internal", Tag(name_), name_).set_initialized();
S_->Assign(Keys::cleanName(name_) + "_dt_internal", Tags::DEFAULT, name_, dt_init);
S_->GetRecordW(Keys::cleanName(name_) + "_dt_internal", Tags::DEFAULT, name_).set_initialized();

// -- initialize continuation parameter if needed.
if (S_->HasRecord("continuation_parameter", Tag(name_))) {
S_->Assign("continuation_parameter", Tag(name_), name_, (double)1.);
S_->GetRecordW("continuation_parameter", Tag(name_), name_).set_initialized();
if (S_->HasRecord(Keys::cleanName(name_) + "_continuation_parameter", Tags::DEFAULT)) {
S_->Assign(
Keys::cleanName(name_) + "_continuation_parameter", Tags::DEFAULT, name_, (double)1.);
S_->GetRecordW(Keys::cleanName(name_) + "_continuation_parameter", Tags::DEFAULT, name_)
.set_initialized();
}

// -- initialize time derivative
Expand All @@ -93,15 +95,16 @@ double
PK_BDF_Default::get_dt()
{
if (!strongly_coupled_)
return S_->Get<double>("dt_internal", Tag(name_));
return S_->Get<double>(Keys::cleanName(name_) + "_dt_internal", Tags::DEFAULT);
else
return -1.;
}

void
PK_BDF_Default::set_dt(double dt)
{
if (!strongly_coupled_) S_->Assign("dt_internal", Tag(name_), name_, dt);
if (!strongly_coupled_)
S_->Assign(Keys::cleanName(name_) + "_dt_internal", Tags::DEFAULT, name_, dt);
}

// -- Commit any secondary (dependent) variables.
Expand Down Expand Up @@ -139,7 +142,7 @@ PK_BDF_Default::AdvanceStep(double t_old, double t_new, bool reinit)
// -- dt is the requested timestep size. It must be less than or equal to...
// -- dt_internal is the max valid dt, and is set by physics/solvers
// -- dt_solver is what the solver wants to do
double dt_internal = S_->Get<double>("dt_internal", Tag(name_));
double dt_internal = S_->Get<double>(Keys::cleanName(name_) + "_dt_internal", Tags::DEFAULT);

// NOTE, still a bug in amanzi#685, despite fixes in amanzi#694, so this assertion still fails --ETC
// AMANZI_ASSERT(dt <= dt_internal + 2.e-8); // roundoff
Expand Down Expand Up @@ -175,7 +178,7 @@ PK_BDF_Default::AdvanceStep(double t_old, double t_new, bool reinit)
dt_internal = dt_solver;
}

S_->Assign("dt_internal", Tag(name_), name_, dt_internal);
S_->Assign(Keys::cleanName(name_) + "_dt_internal", Tags::DEFAULT, name_, dt_internal);
} catch (Errors::TimeStepCrash& e) {
// inject more information into the crash message
std::stringstream msg_str;
Expand All @@ -196,7 +199,7 @@ PK_BDF_Default::AdvanceStep(double t_old, double t_new, bool reinit)
void
PK_BDF_Default::UpdateContinuationParameter(double lambda)
{
S_->Assign("continuation_parameter", Tag(name_), name_, lambda);
S_->Assign(Keys::cleanName(name_) + "_continuation_parameter", Tags::DEFAULT, name_, lambda);
ChangedSolution();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ AlbedoThreeComponentEvaluator::AlbedoThreeComponentEvaluator(Teuchos::ParameterL
a_ice_ = plist_.get<double>("albedo ice [-]", 0.44);
a_water_ = plist_.get<double>("albedo water [-]", 0.1168);
is_constant_snow_albedo_ = plist_.isParameter("albedo snow [-]");
if (is_constant_snow_albedo_) {
a_snow_ = plist_.get<double>("albedo snow [-]");
}
if (is_constant_snow_albedo_) { a_snow_ = plist_.get<double>("albedo snow [-]"); }

e_ice_ = plist_.get<double>("emissivity ice [-]", 0.98);
e_water_ = plist_.get<double>("emissivity water [-]", 0.995);
Expand Down Expand Up @@ -88,7 +86,8 @@ AlbedoThreeComponentEvaluator::Evaluate_(const State& S,

for (auto c : lc_ids) {
// albedo of the snow
albedo[2][c] = is_constant_snow_albedo_ ? a_snow_ : Relations::CalcAlbedoSnow((*snow_dens)[0][c]);
albedo[2][c] =
is_constant_snow_albedo_ ? a_snow_ : Relations::CalcAlbedoSnow((*snow_dens)[0][c]);

// a and e of water
albedo[1][c] = unfrozen_fraction[0][c] * a_water_ + (1 - unfrozen_fraction[0][c]) * a_ice_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ AlbedoTwoComponentEvaluator::AlbedoTwoComponentEvaluator(Teuchos::ParameterList&
a_ice_ = plist_.get<double>("albedo ice [-]", 0.44);
a_water_ = plist_.get<double>("albedo water [-]", 0.1168);
is_constant_snow_albedo_ = plist_.isParameter("albedo snow [-]");
if (is_constant_snow_albedo_) {
a_snow_ = plist_.get<double>("albedo snow [-]");
}
if (is_constant_snow_albedo_) { a_snow_ = plist_.get<double>("albedo snow [-]"); }

e_ice_ = plist_.get<double>("emissivity ice [-]", 0.98);
e_water_ = plist_.get<double>("emissivity water [-]", 0.995);
Expand Down Expand Up @@ -92,7 +90,8 @@ AlbedoTwoComponentEvaluator::Evaluate_(const State& S, const std::vector<Composi

for (auto c : lc_ids) {
// albedo of the snow
albedo[1][c] = is_constant_snow_albedo_ ? a_snow_ : Relations::CalcAlbedoSnow((*snow_dens)[0][c]);
albedo[1][c] =
is_constant_snow_albedo_ ? a_snow_ : Relations::CalcAlbedoSnow((*snow_dens)[0][c]);

double albedo_water =
unfrozen_fraction[0][c] * a_water_ + (1 - unfrozen_fraction[0][c]) * a_ice_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,17 +403,18 @@ DetermineSnowTemperature(const GroundProperties& surf,
int max_it(my_max_it);
double result(0.);
if (method == "bisection") {
Errors::Message msg("SurfaceEnergyBalance: root finding method \"bisection\" is not longer supported -- use \"brent\"");
Errors::Message msg("SurfaceEnergyBalance: root finding method \"bisection\" is not longer "
"supported -- use \"brent\"");
Exceptions::amanzi_throw(msg);
} else if (method == "toms") {
Errors::Message msg("SurfaceEnergyBalance: root finding method \"bisection\" is not longer supported -- use \"brent\"");
Errors::Message msg("SurfaceEnergyBalance: root finding method \"bisection\" is not longer "
"supported -- use \"brent\"");
Exceptions::amanzi_throw(msg);
} else if (method == "brent") {
result = Utils::findRootBrent(func, left, right, ENERGY_BALANCE_TOL, &max_it);
} else {
Errors::Message emsg;
emsg << "SurfaceEnergyBalance: invalid solver method \""
<< method << "\", use \"brent\"";
emsg << "SurfaceEnergyBalance: invalid solver method \"" << method << "\", use \"brent\"";
Exceptions::amanzi_throw(emsg);
}

Expand Down
2 changes: 1 addition & 1 deletion testing/ats-regression-tests

0 comments on commit 5c504eb

Please sign in to comment.