Skip to content

Commit

Permalink
clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
ecoon committed Jun 30, 2023
1 parent db1f772 commit acd37a4
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ VolumetricSnowPondedDepthEvaluator::EnsureCompatibility_ToDeps_(State& S)

// Loop over my dependencies, ensuring they meet the requirements.
for (const auto& key_tag : dependencies_) {
if (key_tag.first == delta_max_key_ || key_tag.first == delta_ex_key_ || key_tag.first == sd_key_) {
if (key_tag.first == delta_max_key_ || key_tag.first == delta_ex_key_ ||
key_tag.first == sd_key_) {
S.Require<CompositeVector, CompositeVectorSpace>(key_tag.first, key_tag.second)
.Update(*no_bf_dep_fac);
} else {
Expand Down
58 changes: 38 additions & 20 deletions src/pks/flow/constitutive_relations/wrm/rel_perm_frzBC_evaluator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ RelPermFrzBCEvaluator::RelPermFrzBCEvaluator(Teuchos::ParameterList& plist)


RelPermFrzBCEvaluator::RelPermFrzBCEvaluator(Teuchos::ParameterList& plist,
const Teuchos::RCP<WRMPartition>& wrms)
const Teuchos::RCP<WRMPartition>& wrms)
: EvaluatorSecondaryMonotypeCV(plist), wrms_(wrms), min_val_(0.)
{
InitializeFromPlist_();
Expand Down Expand Up @@ -156,8 +156,9 @@ RelPermFrzBCEvaluator::Evaluate_(const State& S, const std::vector<CompositeVect
for (unsigned int c = 0; c != ncells; ++c) {
int index = (*wrms_->first)[c];
double sat_res = wrms_->second[index]->residualSaturation();
double coef = 1 - std::exp(-omega_*(sat_c[0][c]+sat_gas_c[0][c])) + std::exp(-omega_);
res_c[0][c] = std::max(coef*std::pow((1-sat_gas_c[0][c]-sat_res)/(1-sat_res), 3+2*b_), min_val_);
double coef = 1 - std::exp(-omega_ * (sat_c[0][c] + sat_gas_c[0][c])) + std::exp(-omega_);
res_c[0][c] = std::max(
coef * std::pow((1 - sat_gas_c[0][c] - sat_res) / (1 - sat_res), 3 + 2 * b_), min_val_);
}

// -- Potentially evaluate the model on boundary faces as well.
Expand All @@ -180,26 +181,38 @@ RelPermFrzBCEvaluator::Evaluate_(const State& S, const std::vector<CompositeVect
AmanziMesh::Entity_ID f = face_map.LID(vandelay_map.GID(bf));
mesh->face_get_cells(f, AmanziMesh::Parallel_type::ALL, &cells);
AMANZI_ASSERT(cells.size() == 1);

int index = (*wrms_->first)[cells[0]];
double sat_res = wrms_->second[index]->residualSaturation();
double krel;
double coef_b = 1 - std::exp(-omega_*(sat_bf[0][bf]+sat_gas_bf[0][bf])) + std::exp(-omega_);
double coef_c = 1 - std::exp(-omega_*(sat_c[0][cells[0]]+sat_gas_c[0][cells[0]])) + std::exp(-omega_);
double coef_b =
1 - std::exp(-omega_ * (sat_bf[0][bf] + sat_gas_bf[0][bf])) + std::exp(-omega_);
double coef_c =
1 - std::exp(-omega_ * (sat_c[0][cells[0]] + sat_gas_c[0][cells[0]])) + std::exp(-omega_);
if (boundary_krel_ == BoundaryRelPerm::HARMONIC_MEAN) {
double krelb = std::max(coef_b*std::pow((1-sat_gas_bf[0][bf]-sat_res)/(1-sat_res), 3+2*b_), min_val_);
double kreli = std::max(coef_c*std::pow((1-sat_gas_c[0][cells[0]]-sat_res)/(1-sat_res), 3+2*b_), min_val_);
double krelb =
std::max(coef_b * std::pow((1 - sat_gas_bf[0][bf] - sat_res) / (1 - sat_res), 3 + 2 * b_),
min_val_);
double kreli = std::max(
coef_c * std::pow((1 - sat_gas_c[0][cells[0]] - sat_res) / (1 - sat_res), 3 + 2 * b_),
min_val_);
krel = 1.0 / (1.0 / krelb + 1.0 / kreli);
} else if (boundary_krel_ == BoundaryRelPerm::ARITHMETIC_MEAN) {
double krelb = std::max(coef_b*std::pow((1-sat_gas_bf[0][bf]-sat_res)/(1-sat_res), 3+2*b_), min_val_);
double kreli = std::max(coef_c*std::pow((1-sat_gas_c[0][cells[0]]-sat_res)/(1-sat_res), 3+2*b_), min_val_);
double krelb =
std::max(coef_b * std::pow((1 - sat_gas_bf[0][bf] - sat_res) / (1 - sat_res), 3 + 2 * b_),
min_val_);
double kreli = std::max(
coef_c * std::pow((1 - sat_gas_c[0][cells[0]] - sat_res) / (1 - sat_res), 3 + 2 * b_),
min_val_);
krel = (krelb + kreli) / 2.0;
} else if (boundary_krel_ == BoundaryRelPerm::INTERIOR_PRESSURE) {
krel = std::max(coef_c*std::pow((1-sat_gas_c[0][cells[0]]-sat_res)/(1-sat_res), 3+2*b_), min_val_);
krel = std::max(
coef_c * std::pow((1 - sat_gas_c[0][cells[0]] - sat_res) / (1 - sat_res), 3 + 2 * b_),
min_val_);
} else if (boundary_krel_ == BoundaryRelPerm::ONE) {
krel = 1.;
} else {
krel = coef_b*std::pow((1-sat_gas_bf[0][bf]-sat_res)/(1-sat_res), 3+2*b_);
krel = coef_b * std::pow((1 - sat_gas_bf[0][bf] - sat_res) / (1 - sat_res), 3 + 2 * b_);
}
res_bf[0][bf] = std::max(krel, min_val_);
}
Expand Down Expand Up @@ -260,9 +273,9 @@ RelPermFrzBCEvaluator::Evaluate_(const State& S, const std::vector<CompositeVect

void
RelPermFrzBCEvaluator::EvaluatePartialDerivative_(const State& S,
const Key& wrt_key,
const Tag& wrt_tag,
const std::vector<CompositeVector*>& result)
const Key& wrt_key,
const Tag& wrt_tag,
const std::vector<CompositeVector*>& result)
{
// Initialize the MeshPartition
if (!wrms_->first->initialized()) {
Expand All @@ -287,7 +300,9 @@ RelPermFrzBCEvaluator::EvaluatePartialDerivative_(const State& S,
for (unsigned int c = 0; c != ncells; ++c) {
int index = (*wrms_->first)[c];
double sat_res = wrms_->second[index]->residualSaturation();
res_c[0][c] = omega_*std::pow((1.-sat_gas_c[0][c]-sat_res)/(1-sat_res), 2*b_+3)*std::exp(-omega_*(sat_c[0][c]+sat_gas_c[0][c]));
res_c[0][c] = omega_ *
std::pow((1. - sat_gas_c[0][c] - sat_res) / (1 - sat_res), 2 * b_ + 3) *
std::exp(-omega_ * (sat_c[0][c] + sat_gas_c[0][c]));
AMANZI_ASSERT(res_c[0][c] >= 0.);
}

Expand Down Expand Up @@ -329,10 +344,13 @@ RelPermFrzBCEvaluator::EvaluatePartialDerivative_(const State& S,
for (unsigned int c = 0; c != ncells; ++c) {
int index = (*wrms_->first)[c];
double sat_res = wrms_->second[index]->residualSaturation();
double dbc_dsg = -(2*b_+3)/(1-sat_res)*std::pow((1-sat_gas_c[0][c]-sat_res)/(1-sat_res), 2*b_+2);
double coef = 1-std::exp(-omega_*(sat_c[0][c]+sat_gas_c[0][c]))+std::exp(-omega_);
double dcoef_dsg = omega_*std::exp(-omega_*(sat_c[0][c]+sat_gas_c[0][c]));
res_c[0][c] = dbc_dsg * coef + dcoef_dsg * std::pow((1.-sat_gas_c[0][c]-sat_res)/(1-sat_res), 2*b_+3);
double dbc_dsg = -(2 * b_ + 3) / (1 - sat_res) *
std::pow((1 - sat_gas_c[0][c] - sat_res) / (1 - sat_res), 2 * b_ + 2);
double coef = 1 - std::exp(-omega_ * (sat_c[0][c] + sat_gas_c[0][c])) + std::exp(-omega_);
double dcoef_dsg = omega_ * std::exp(-omega_ * (sat_c[0][c] + sat_gas_c[0][c]));
res_c[0][c] =
dbc_dsg * coef +
dcoef_dsg * std::pow((1. - sat_gas_c[0][c] - sat_res) / (1 - sat_res), 2 * b_ + 3);
}

// -- Potentially evaluate the model on boundary faces as well.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,14 @@ UpdateEnergyBalanceWithSnow_Inner(const GroundProperties& surf,

// latent heat
double vapor_pressure_skin = SaturatedVaporPressure(snow.temp);
double u_star = met.Us * c_von_Karman / std::log(met.Z_Us / CalcRoughnessFactor(snow.height, surf.roughness, snow.roughness));
double Re0 = params.density_air * u_star * CalcRoughnessFactor(snow.height, surf.roughness, snow.roughness) / params.dynamic_viscosity_air;
double KB = params.Da0_a * std::pow(Re0, params.Da0_b) - (params.Cd0_c * std::log(Re0) + params.Cd0_d);
double u_star =
met.Us * c_von_Karman /
std::log(met.Z_Us / CalcRoughnessFactor(snow.height, surf.roughness, snow.roughness));
double Re0 = params.density_air * u_star *
CalcRoughnessFactor(snow.height, surf.roughness, snow.roughness) /
params.dynamic_viscosity_air;
double KB =
params.Da0_a * std::pow(Re0, params.Da0_b) - (params.Cd0_c * std::log(Re0) + params.Cd0_d);
double Dhe_latent = WindFactor(
met.Us, met.Z_Us, CalcRoughnessFactor(snow.height, surf.roughness, snow.roughness), KB);
eb.fQe = LatentHeat(Dhe_latent * Sqig,
Expand Down Expand Up @@ -370,7 +375,8 @@ UpdateEnergyBalanceWithoutSnow(const GroundProperties& surf,
double vapor_pressure_skin = VaporPressureGround(surf, params);
double u_star = met.Us * c_von_Karman / std::log(met.Z_Us / surf.roughness);
double Re0 = params.density_air * u_star * surf.roughness / params.dynamic_viscosity_air;
double KB = params.Da0_a * std::pow(Re0, params.Da0_b) - (params.Cd0_c * std::log(Re0) + params.Cd0_d);
double KB =
params.Da0_a * std::pow(Re0, params.Da0_b) - (params.Cd0_c * std::log(Re0) + params.Cd0_d);
double Dhe_latent = WindFactor(met.Us, met.Z_Us, surf.roughness, KB);
double Rsoil = EvaporativeResistanceGround(surf, met, params, vapor_pressure_skin);
double coef = 1.0 / (Rsoil + 1.0 / (Dhe_latent * Sqig));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,8 +436,8 @@ SEBThreeComponentEvaluator::Evaluate_(const State& S, const std::vector<Composit
surf.rs_method = lc.second.rs_method; // does not matter
surf.emissivity = emissivity[2][c];
surf.albedo = sg_albedo[2][c];
surf.ponded_depth = 0; // does not matter
surf.saturation_gas = 0.; // does not matter
surf.ponded_depth = 0; // does not matter
surf.saturation_gas = 0.; // does not matter
surf.saturation_liq = sat_liq[0][cells[0]];
surf.porosity = 1.; // does not matter
surf.unfrozen_fraction = unfrozen_fraction[0][c]; // does not matter
Expand Down

0 comments on commit acd37a4

Please sign in to comment.